@n8n/n8n-nodes-langchain 1.100.1 → 1.101.0

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 (178) hide show
  1. package/dist/credentials/WeaviateApi.credentials.js +164 -0
  2. package/dist/credentials/WeaviateApi.credentials.js.map +1 -0
  3. package/dist/known/credentials.json +7 -0
  4. package/dist/known/nodes.json +4 -0
  5. package/dist/nodes/agents/Agent/Agent.node.js +5 -2
  6. package/dist/nodes/agents/Agent/Agent.node.js.map +1 -1
  7. package/dist/nodes/agents/Agent/V1/AgentV1.node.js +1 -4
  8. package/dist/nodes/agents/Agent/V1/AgentV1.node.js.map +1 -1
  9. package/dist/nodes/agents/Agent/V2/AgentV2.node.js +23 -6
  10. package/dist/nodes/agents/Agent/V2/AgentV2.node.js.map +1 -1
  11. package/dist/nodes/agents/Agent/agents/SqlAgent/description.js +0 -1
  12. package/dist/nodes/agents/Agent/agents/SqlAgent/description.js.map +1 -1
  13. package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/description.js +29 -1
  14. package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/description.js.map +1 -1
  15. package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js +83 -1
  16. package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js.map +1 -1
  17. package/dist/nodes/agents/Agent/agents/ToolsAgent/common.js.map +1 -1
  18. package/dist/nodes/agents/OpenAiAssistant/OpenAiAssistant.node.js +0 -1
  19. package/dist/nodes/agents/OpenAiAssistant/OpenAiAssistant.node.js.map +1 -1
  20. package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js +0 -1
  21. package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js.map +1 -1
  22. package/dist/nodes/chains/ChainSummarization/V1/ChainSummarizationV1.node.js +0 -1
  23. package/dist/nodes/chains/ChainSummarization/V1/ChainSummarizationV1.node.js.map +1 -1
  24. package/dist/nodes/chains/ChainSummarization/V2/ChainSummarizationV2.node.js +0 -1
  25. package/dist/nodes/chains/ChainSummarization/V2/ChainSummarizationV2.node.js.map +1 -1
  26. package/dist/nodes/code/Code.node.js.map +1 -1
  27. package/dist/nodes/document_loaders/DocumentBinaryInputLoader/DocumentBinaryInputLoader.node.js +0 -2
  28. package/dist/nodes/document_loaders/DocumentBinaryInputLoader/DocumentBinaryInputLoader.node.js.map +1 -1
  29. package/dist/nodes/document_loaders/DocumentDefaultDataLoader/DocumentDefaultDataLoader.node.js +0 -2
  30. package/dist/nodes/document_loaders/DocumentDefaultDataLoader/DocumentDefaultDataLoader.node.js.map +1 -1
  31. package/dist/nodes/document_loaders/DocumentGithubLoader/DocumentGithubLoader.node.js +0 -2
  32. package/dist/nodes/document_loaders/DocumentGithubLoader/DocumentGithubLoader.node.js.map +1 -1
  33. package/dist/nodes/document_loaders/DocumentJSONInputLoader/DocumentJsonInputLoader.node.js +0 -2
  34. package/dist/nodes/document_loaders/DocumentJSONInputLoader/DocumentJsonInputLoader.node.js.map +1 -1
  35. package/dist/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.js +0 -2
  36. package/dist/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.js.map +1 -1
  37. package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js +0 -2
  38. package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js.map +1 -1
  39. package/dist/nodes/embeddings/EmbeddingsCohere/EmbeddingsCohere.node.js +0 -2
  40. package/dist/nodes/embeddings/EmbeddingsCohere/EmbeddingsCohere.node.js.map +1 -1
  41. package/dist/nodes/embeddings/EmbeddingsGoogleGemini/EmbeddingsGoogleGemini.node.js +0 -2
  42. package/dist/nodes/embeddings/EmbeddingsGoogleGemini/EmbeddingsGoogleGemini.node.js.map +1 -1
  43. package/dist/nodes/embeddings/EmbeddingsGoogleVertex/EmbeddingsGoogleVertex.node.js +0 -2
  44. package/dist/nodes/embeddings/EmbeddingsGoogleVertex/EmbeddingsGoogleVertex.node.js.map +1 -1
  45. package/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.js +0 -2
  46. package/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.js.map +1 -1
  47. package/dist/nodes/embeddings/EmbeddingsMistralCloud/EmbeddingsMistralCloud.node.js +0 -2
  48. package/dist/nodes/embeddings/EmbeddingsMistralCloud/EmbeddingsMistralCloud.node.js.map +1 -1
  49. package/dist/nodes/embeddings/EmbeddingsOllama/EmbeddingsOllama.node.js +0 -2
  50. package/dist/nodes/embeddings/EmbeddingsOllama/EmbeddingsOllama.node.js.map +1 -1
  51. package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js +0 -2
  52. package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js.map +1 -1
  53. package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js +4 -5
  54. package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js.map +1 -1
  55. package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js +0 -3
  56. package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js.map +1 -1
  57. package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js +6 -6
  58. package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js.map +1 -1
  59. package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js +3 -1
  60. package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js.map +1 -1
  61. package/dist/nodes/llms/LMCohere/LmCohere.node.js +0 -3
  62. package/dist/nodes/llms/LMCohere/LmCohere.node.js.map +1 -1
  63. package/dist/nodes/llms/LMOllama/LmOllama.node.js +0 -3
  64. package/dist/nodes/llms/LMOllama/LmOllama.node.js.map +1 -1
  65. package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js +3 -4
  66. package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js.map +1 -1
  67. package/dist/nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.js +0 -3
  68. package/dist/nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.js.map +1 -1
  69. package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js +1 -5
  70. package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js.map +1 -1
  71. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +3 -4
  72. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -1
  73. package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js +3 -4
  74. package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js.map +1 -1
  75. package/dist/nodes/llms/LmChatGoogleGemini/LmChatGoogleGemini.node.js +0 -3
  76. package/dist/nodes/llms/LmChatGoogleGemini/LmChatGoogleGemini.node.js.map +1 -1
  77. package/dist/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.js +0 -3
  78. package/dist/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.js.map +1 -1
  79. package/dist/nodes/llms/LmChatGroq/LmChatGroq.node.js +1 -4
  80. package/dist/nodes/llms/LmChatGroq/LmChatGroq.node.js.map +1 -1
  81. package/dist/nodes/llms/LmChatMistralCloud/LmChatMistralCloud.node.js +0 -3
  82. package/dist/nodes/llms/LmChatMistralCloud/LmChatMistralCloud.node.js.map +1 -1
  83. package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js +3 -3
  84. package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js.map +1 -1
  85. package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js +3 -4
  86. package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js.map +1 -1
  87. package/dist/nodes/llms/N8nLlmTracing.js.map +1 -1
  88. package/dist/nodes/llms/N8nNonEstimatingTracing.js.map +1 -1
  89. package/dist/nodes/llms/n8nDefaultFailedAttemptHandler.js +1 -1
  90. package/dist/nodes/llms/n8nDefaultFailedAttemptHandler.js.map +1 -1
  91. package/dist/nodes/memory/MemoryBufferWindow/MemoryBufferWindow.node.js +0 -2
  92. package/dist/nodes/memory/MemoryBufferWindow/MemoryBufferWindow.node.js.map +1 -1
  93. package/dist/nodes/memory/MemoryChatRetriever/MemoryChatRetriever.node.js +0 -2
  94. package/dist/nodes/memory/MemoryChatRetriever/MemoryChatRetriever.node.js.map +1 -1
  95. package/dist/nodes/memory/MemoryManager/MemoryManager.node.js +0 -2
  96. package/dist/nodes/memory/MemoryManager/MemoryManager.node.js.map +1 -1
  97. package/dist/nodes/memory/MemoryMotorhead/MemoryMotorhead.node.js +0 -2
  98. package/dist/nodes/memory/MemoryMotorhead/MemoryMotorhead.node.js.map +1 -1
  99. package/dist/nodes/memory/MemoryPostgresChat/MemoryPostgresChat.node.js +0 -2
  100. package/dist/nodes/memory/MemoryPostgresChat/MemoryPostgresChat.node.js.map +1 -1
  101. package/dist/nodes/memory/MemoryRedisChat/MemoryRedisChat.node.js +0 -2
  102. package/dist/nodes/memory/MemoryRedisChat/MemoryRedisChat.node.js.map +1 -1
  103. package/dist/nodes/memory/MemoryXata/MemoryXata.node.js +0 -2
  104. package/dist/nodes/memory/MemoryXata/MemoryXata.node.js.map +1 -1
  105. package/dist/nodes/memory/MemoryZep/MemoryZep.node.js +0 -2
  106. package/dist/nodes/memory/MemoryZep/MemoryZep.node.js.map +1 -1
  107. package/dist/nodes/output_parser/OutputParserAutofixing/OutputParserAutofixing.node.js +0 -2
  108. package/dist/nodes/output_parser/OutputParserAutofixing/OutputParserAutofixing.node.js.map +1 -1
  109. package/dist/nodes/output_parser/OutputParserItemList/OutputParserItemList.node.js +0 -2
  110. package/dist/nodes/output_parser/OutputParserItemList/OutputParserItemList.node.js.map +1 -1
  111. package/dist/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.js +0 -1
  112. package/dist/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.js.map +1 -1
  113. package/dist/nodes/rerankers/RerankerCohere/RerankerCohere.node.js.map +1 -1
  114. package/dist/nodes/retrievers/RetrieverContextualCompression/RetrieverContextualCompression.node.js +0 -1
  115. package/dist/nodes/retrievers/RetrieverContextualCompression/RetrieverContextualCompression.node.js.map +1 -1
  116. package/dist/nodes/retrievers/RetrieverMultiQuery/RetrieverMultiQuery.node.js +0 -1
  117. package/dist/nodes/retrievers/RetrieverMultiQuery/RetrieverMultiQuery.node.js.map +1 -1
  118. package/dist/nodes/retrievers/RetrieverVectorStore/RetrieverVectorStore.node.js +0 -2
  119. package/dist/nodes/retrievers/RetrieverVectorStore/RetrieverVectorStore.node.js.map +1 -1
  120. package/dist/nodes/retrievers/RetrieverWorkflow/RetrieverWorkflow.node.js.map +1 -1
  121. package/dist/nodes/text_splitters/TextSplitterCharacterTextSplitter/TextSplitterCharacterTextSplitter.node.js +0 -2
  122. package/dist/nodes/text_splitters/TextSplitterCharacterTextSplitter/TextSplitterCharacterTextSplitter.node.js.map +1 -1
  123. package/dist/nodes/text_splitters/TextSplitterRecursiveCharacterTextSplitter/TextSplitterRecursiveCharacterTextSplitter.node.js +0 -2
  124. package/dist/nodes/text_splitters/TextSplitterRecursiveCharacterTextSplitter/TextSplitterRecursiveCharacterTextSplitter.node.js.map +1 -1
  125. package/dist/nodes/text_splitters/TextSplitterTokenSplitter/TextSplitterTokenSplitter.node.js +0 -2
  126. package/dist/nodes/text_splitters/TextSplitterTokenSplitter/TextSplitterTokenSplitter.node.js.map +1 -1
  127. package/dist/nodes/text_splitters/TextSplitterTokenSplitter/TokenTextSplitter.js.map +1 -1
  128. package/dist/nodes/tools/ToolCalculator/ToolCalculator.node.js +0 -2
  129. package/dist/nodes/tools/ToolCalculator/ToolCalculator.node.js.map +1 -1
  130. package/dist/nodes/tools/ToolCode/ToolCode.node.js +0 -2
  131. package/dist/nodes/tools/ToolCode/ToolCode.node.js.map +1 -1
  132. package/dist/nodes/tools/ToolHttpRequest/ToolHttpRequest.node.js +0 -2
  133. package/dist/nodes/tools/ToolHttpRequest/ToolHttpRequest.node.js.map +1 -1
  134. package/dist/nodes/tools/ToolHttpRequest/utils.js.map +1 -1
  135. package/dist/nodes/tools/ToolSerpApi/ToolSerpApi.node.js +0 -2
  136. package/dist/nodes/tools/ToolSerpApi/ToolSerpApi.node.js.map +1 -1
  137. package/dist/nodes/tools/ToolThink/ToolThink.node.js.map +1 -1
  138. package/dist/nodes/tools/ToolVectorStore/ToolVectorStore.node.js +0 -2
  139. package/dist/nodes/tools/ToolVectorStore/ToolVectorStore.node.js.map +1 -1
  140. package/dist/nodes/tools/ToolWikipedia/ToolWikipedia.node.js +0 -2
  141. package/dist/nodes/tools/ToolWikipedia/ToolWikipedia.node.js.map +1 -1
  142. package/dist/nodes/tools/ToolWolframAlpha/ToolWolframAlpha.node.js +0 -2
  143. package/dist/nodes/tools/ToolWolframAlpha/ToolWolframAlpha.node.js.map +1 -1
  144. package/dist/nodes/tools/ToolWorkflow/v1/versionDescription.js +0 -2
  145. package/dist/nodes/tools/ToolWorkflow/v1/versionDescription.js.map +1 -1
  146. package/dist/nodes/tools/ToolWorkflow/v2/versionDescription.js.map +1 -1
  147. package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +215 -153
  148. package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
  149. package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js +1 -1
  150. package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js.map +1 -1
  151. package/dist/nodes/vector_store/VectorStoreInMemoryInsert/VectorStoreInMemoryInsert.node.js +0 -1
  152. package/dist/nodes/vector_store/VectorStoreInMemoryInsert/VectorStoreInMemoryInsert.node.js.map +1 -1
  153. package/dist/nodes/vector_store/VectorStoreInMemoryLoad/VectorStoreInMemoryLoad.node.js +0 -1
  154. package/dist/nodes/vector_store/VectorStoreInMemoryLoad/VectorStoreInMemoryLoad.node.js.map +1 -1
  155. package/dist/nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.js +2 -2
  156. package/dist/nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.js.map +1 -1
  157. package/dist/nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.js.map +1 -1
  158. package/dist/nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.js.map +1 -1
  159. package/dist/nodes/vector_store/VectorStoreWeaviate/VectorStoreWeaviate.node.js +242 -0
  160. package/dist/nodes/vector_store/VectorStoreWeaviate/VectorStoreWeaviate.node.js.map +1 -0
  161. package/dist/nodes/vector_store/VectorStoreWeaviate/Weaviate.utils.js +127 -0
  162. package/dist/nodes/vector_store/VectorStoreWeaviate/Weaviate.utils.js.map +1 -0
  163. package/dist/nodes/vector_store/VectorStoreWeaviate/weaviate.svg +2 -0
  164. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js +0 -1
  165. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js.map +1 -1
  166. package/dist/nodes/vector_store/shared/createVectorStoreNode/methods/listSearch.js +15 -2
  167. package/dist/nodes/vector_store/shared/createVectorStoreNode/methods/listSearch.js.map +1 -1
  168. package/dist/nodes/vector_store/shared/descriptions.js +26 -2
  169. package/dist/nodes/vector_store/shared/descriptions.js.map +1 -1
  170. package/dist/nodes/vendors/OpenAi/actions/assistant/message.operation.js +0 -1
  171. package/dist/nodes/vendors/OpenAi/actions/assistant/message.operation.js.map +1 -1
  172. package/dist/nodes/vendors/OpenAi/actions/versionDescription.js.map +1 -1
  173. package/dist/types/credentials.json +1 -0
  174. package/dist/types/nodes.json +4 -3
  175. package/dist/utils/httpProxyAgent.js +20 -6
  176. package/dist/utils/httpProxyAgent.js.map +1 -1
  177. package/dist/utils/logWrapper.js.map +1 -1
  178. package/package.json +21 -15
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/tools/ToolCode/ToolCode.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { DynamicStructuredTool, DynamicTool } from '@langchain/core/tools';\nimport type { JSONSchema7 } from 'json-schema';\nimport { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox';\nimport { PythonSandbox } from 'n8n-nodes-base/dist/nodes/Code/PythonSandbox';\nimport type { Sandbox } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n\tExecutionError,\n\tIDataObject,\n} from 'n8n-workflow';\nimport { jsonParse, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\n\nimport {\n\tbuildInputSchemaField,\n\tbuildJsonSchemaExampleField,\n\tbuildJsonSchemaExampleNotice,\n\tschemaTypeField,\n} from '@utils/descriptions';\nimport { nodeNameToToolName } from '@utils/helpers';\nimport { convertJsonSchemaToZod, generateSchemaFromExample } from '@utils/schemaParsing';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport type { DynamicZodObject } from '../../../types/zod.types';\n\nconst jsonSchemaExampleField = buildJsonSchemaExampleField({\n\tshowExtraProps: { specifyInputSchema: [true] },\n});\n\nconst jsonSchemaExampleNotice = buildJsonSchemaExampleNotice({\n\tshowExtraProps: {\n\t\tspecifyInputSchema: [true],\n\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t},\n});\n\nconst jsonSchemaField = buildInputSchemaField({ showExtraProps: { specifyInputSchema: [true] } });\n\nexport class ToolCode implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Code Tool',\n\t\tname: 'toolCode',\n\t\ticon: 'fa:code',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\tdescription: 'Write a tool in JS or Python',\n\t\tdefaults: {\n\t\t\tname: 'Code Tool',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Recommended Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolcode/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'See an example of a conversational agent with custom tool written in JavaScript <a href=\"/templates/1963\" target=\"_blank\">here</a>.',\n\t\t\t\tname: 'noticeTemplateExample',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'My_Tool',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'e.g. My_Tool',\n\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\tdescription:\n\t\t\t\t\t'The name of the function to be called, could contain letters, numbers, and underscores only',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Description',\n\t\t\t\tname: 'description',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder:\n\t\t\t\t\t'Call this tool to get a random color. The input should be a string with comma separted names of colors to exclude.',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Language',\n\t\t\t\tname: 'language',\n\t\t\t\ttype: 'options',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'JavaScript',\n\t\t\t\t\t\tvalue: 'javaScript',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Python (Beta)',\n\t\t\t\t\t\tvalue: 'python',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'javaScript',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'JavaScript',\n\t\t\t\tname: 'jsCode',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tlanguage: ['javaScript'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\teditor: 'jsEditor',\n\t\t\t\t},\n\t\t\t\tdefault:\n\t\t\t\t\t'// Example: convert the incoming query to uppercase and return it\\nreturn query.toUpperCase()',\n\t\t\t\t// TODO: Add proper text here later\n\t\t\t\thint: 'You can access the input the tool receives via the input property \"query\". The returned value should be a single string.',\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-missing-final-period\n\t\t\t\tdescription: 'E.g. Converts any text to uppercase',\n\t\t\t\tnoDataExpression: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Python',\n\t\t\t\tname: 'pythonCode',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tlanguage: ['python'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\teditor: 'codeNodeEditor', // TODO: create a separate `pythonEditor` component\n\t\t\t\t\teditorLanguage: 'python',\n\t\t\t\t},\n\t\t\t\tdefault:\n\t\t\t\t\t'# Example: convert the incoming query to uppercase and return it\\nreturn query.upper()',\n\t\t\t\t// TODO: Add proper text here later\n\t\t\t\thint: 'You can access the input the tool receives via the input property \"query\". The returned value should be a single string.',\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-missing-final-period\n\t\t\t\tdescription: 'E.g. Converts any text to uppercase',\n\t\t\t\tnoDataExpression: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Specify Input Schema',\n\t\t\t\tname: 'specifyInputSchema',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to specify the schema for the function. This would require the LLM to provide the input in the correct format and would validate it against the schema.',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\t{ ...schemaTypeField, displayOptions: { show: { specifyInputSchema: [true] } } },\n\t\t\tjsonSchemaExampleField,\n\t\t\tjsonSchemaExampleNotice,\n\t\t\tjsonSchemaField,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst node = this.getNode();\n\t\tconst workflowMode = this.getMode();\n\n\t\tconst { typeVersion } = node;\n\t\tconst name =\n\t\t\ttypeVersion <= 1.1\n\t\t\t\t? (this.getNodeParameter('name', itemIndex) as string)\n\t\t\t\t: nodeNameToToolName(node);\n\n\t\tconst description = this.getNodeParameter('description', itemIndex) as string;\n\n\t\tconst useSchema = this.getNodeParameter('specifyInputSchema', itemIndex) as boolean;\n\n\t\tconst language = this.getNodeParameter('language', itemIndex) as string;\n\t\tlet code = '';\n\t\tif (language === 'javaScript') {\n\t\t\tcode = this.getNodeParameter('jsCode', itemIndex) as string;\n\t\t} else {\n\t\t\tcode = this.getNodeParameter('pythonCode', itemIndex) as string;\n\t\t}\n\n\t\tconst getSandbox = (query: string | IDataObject, index = 0) => {\n\t\t\tconst context = getSandboxContext.call(this, index);\n\t\t\tcontext.query = query;\n\n\t\t\tlet sandbox: Sandbox;\n\t\t\tif (language === 'javaScript') {\n\t\t\t\tsandbox = new JavaScriptSandbox(context, code, this.helpers);\n\t\t\t} else {\n\t\t\t\tsandbox = new PythonSandbox(context, code, this.helpers);\n\t\t\t}\n\n\t\t\tsandbox.on(\n\t\t\t\t'output',\n\t\t\t\tworkflowMode === 'manual'\n\t\t\t\t\t? this.sendMessageToUI.bind(this)\n\t\t\t\t\t: (...args: unknown[]) =>\n\t\t\t\t\t\t\tconsole.log(`[Workflow \"${this.getWorkflow().id}\"][Node \"${node.name}\"]`, ...args),\n\t\t\t);\n\t\t\treturn sandbox;\n\t\t};\n\n\t\tconst runFunction = async (query: string | IDataObject): Promise<string> => {\n\t\t\tconst sandbox = getSandbox(query, itemIndex);\n\t\t\treturn await sandbox.runCode<string>();\n\t\t};\n\n\t\tconst toolHandler = async (query: string | IDataObject): Promise<string> => {\n\t\t\tconst { index } = this.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]]);\n\n\t\t\tlet response: string = '';\n\t\t\tlet executionError: ExecutionError | undefined;\n\t\t\ttry {\n\t\t\t\tresponse = await runFunction(query);\n\t\t\t} catch (error: unknown) {\n\t\t\t\texecutionError = new NodeOperationError(this.getNode(), error as ExecutionError);\n\t\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t\t}\n\n\t\t\tif (typeof response === 'number') {\n\t\t\t\tresponse = (response as number).toString();\n\t\t\t}\n\n\t\t\tif (typeof response !== 'string') {\n\t\t\t\t// TODO: Do some more testing. Issues here should actually fail the workflow\n\t\t\t\texecutionError = new NodeOperationError(this.getNode(), 'Wrong output type returned', {\n\t\t\t\t\tdescription: `The response property should be a string, but it is an ${typeof response}`,\n\t\t\t\t});\n\t\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t\t}\n\n\t\t\tif (executionError) {\n\t\t\t\tvoid this.addOutputData(NodeConnectionTypes.AiTool, index, executionError);\n\t\t\t} else {\n\t\t\t\tvoid this.addOutputData(NodeConnectionTypes.AiTool, index, [[{ json: { response } }]]);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst commonToolOptions = {\n\t\t\tname,\n\t\t\tdescription,\n\t\t\tfunc: toolHandler,\n\t\t};\n\n\t\tlet tool: DynamicTool | DynamicStructuredTool | undefined = undefined;\n\n\t\tif (useSchema) {\n\t\t\ttry {\n\t\t\t\t// We initialize these even though one of them will always be empty\n\t\t\t\t// it makes it easier to navigate the ternary operator\n\t\t\t\tconst jsonExample = this.getNodeParameter('jsonSchemaExample', itemIndex, '') as string;\n\t\t\t\tconst inputSchema = this.getNodeParameter('inputSchema', itemIndex, '') as string;\n\n\t\t\t\tconst schemaType = this.getNodeParameter('schemaType', itemIndex) as 'fromJson' | 'manual';\n\n\t\t\t\tconst jsonSchema =\n\t\t\t\t\tschemaType === 'fromJson'\n\t\t\t\t\t\t? generateSchemaFromExample(jsonExample, this.getNode().typeVersion >= 1.3)\n\t\t\t\t\t\t: jsonParse<JSONSchema7>(inputSchema);\n\n\t\t\t\tconst zodSchema = convertJsonSchemaToZod<DynamicZodObject>(jsonSchema);\n\n\t\t\t\ttool = new DynamicStructuredTool({\n\t\t\t\t\tschema: zodSchema,\n\t\t\t\t\t...commonToolOptions,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t'Error during parsing of JSON Schema. \\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AAAA,MAC1E,OAAO;AACN,aAAK,KAAK,cAAc,wCAAoB,QAAQ,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AAAA,MACtF;AAEA,aAAO;AAAA,IACR;AAEA,UAAM,oBAAoB;AAAA,MACzB;AAAA,MACA;AAAA,MACA,MAAM;AAAA,IACP;AAEA,QAAI,OAAwD;AAE5D,QAAI,WAAW;AACd,UAAI;AAGH,cAAM,cAAc,KAAK,iBAAiB,qBAAqB,WAAW,EAAE;AAC5E,cAAM,cAAc,KAAK,iBAAiB,eAAe,WAAW,EAAE;AAEtE,cAAM,aAAa,KAAK,iBAAiB,cAAc,SAAS;AAEhE,cAAM,aACL,eAAe,iBACZ,gDAA0B,aAAa,KAAK,QAAQ,EAAE,eAAe,GAAG,QACxE,+BAAuB,WAAW;AAEtC,cAAM,gBAAY,6CAAyC,UAAU;AAErE,eAAO,IAAI,mCAAsB;AAAA,UAChC,QAAQ;AAAA,UACR,GAAG;AAAA,QACJ,CAAC;AAAA,MACF,SAAS,OAAO;AACf,cAAM,IAAI;AAAA,UACT,KAAK,QAAQ;AAAA,UACb,6CAA6C;AAAA,QAC9C;AAAA,MACD;AAAA,IACD,OAAO;AACN,aAAO,IAAI,yBAAY,iBAAiB;AAAA,IACzC;AAEA,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/tools/ToolCode/ToolCode.node.ts"],"sourcesContent":["import { DynamicStructuredTool, DynamicTool } from '@langchain/core/tools';\nimport type { JSONSchema7 } from 'json-schema';\nimport { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox';\nimport { PythonSandbox } from 'n8n-nodes-base/dist/nodes/Code/PythonSandbox';\nimport type { Sandbox } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n\tExecutionError,\n\tIDataObject,\n} from 'n8n-workflow';\nimport { jsonParse, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\n\nimport {\n\tbuildInputSchemaField,\n\tbuildJsonSchemaExampleField,\n\tbuildJsonSchemaExampleNotice,\n\tschemaTypeField,\n} from '@utils/descriptions';\nimport { nodeNameToToolName } from '@utils/helpers';\nimport { convertJsonSchemaToZod, generateSchemaFromExample } from '@utils/schemaParsing';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport type { DynamicZodObject } from '../../../types/zod.types';\n\nconst jsonSchemaExampleField = buildJsonSchemaExampleField({\n\tshowExtraProps: { specifyInputSchema: [true] },\n});\n\nconst jsonSchemaExampleNotice = buildJsonSchemaExampleNotice({\n\tshowExtraProps: {\n\t\tspecifyInputSchema: [true],\n\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t},\n});\n\nconst jsonSchemaField = buildInputSchemaField({ showExtraProps: { specifyInputSchema: [true] } });\n\nexport class ToolCode implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Code Tool',\n\t\tname: 'toolCode',\n\t\ticon: 'fa:code',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\tdescription: 'Write a tool in JS or Python',\n\t\tdefaults: {\n\t\t\tname: 'Code Tool',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Recommended Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolcode/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'See an example of a conversational agent with custom tool written in JavaScript <a href=\"/templates/1963\" target=\"_blank\">here</a>.',\n\t\t\t\tname: 'noticeTemplateExample',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'My_Tool',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'e.g. My_Tool',\n\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\tdescription:\n\t\t\t\t\t'The name of the function to be called, could contain letters, numbers, and underscores only',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Description',\n\t\t\t\tname: 'description',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder:\n\t\t\t\t\t'Call this tool to get a random color. The input should be a string with comma separted names of colors to exclude.',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Language',\n\t\t\t\tname: 'language',\n\t\t\t\ttype: 'options',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'JavaScript',\n\t\t\t\t\t\tvalue: 'javaScript',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Python (Beta)',\n\t\t\t\t\t\tvalue: 'python',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'javaScript',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'JavaScript',\n\t\t\t\tname: 'jsCode',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tlanguage: ['javaScript'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\teditor: 'jsEditor',\n\t\t\t\t},\n\t\t\t\tdefault:\n\t\t\t\t\t'// Example: convert the incoming query to uppercase and return it\\nreturn query.toUpperCase()',\n\t\t\t\t// TODO: Add proper text here later\n\t\t\t\thint: 'You can access the input the tool receives via the input property \"query\". The returned value should be a single string.',\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-missing-final-period\n\t\t\t\tdescription: 'E.g. Converts any text to uppercase',\n\t\t\t\tnoDataExpression: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Python',\n\t\t\t\tname: 'pythonCode',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tlanguage: ['python'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\teditor: 'codeNodeEditor', // TODO: create a separate `pythonEditor` component\n\t\t\t\t\teditorLanguage: 'python',\n\t\t\t\t},\n\t\t\t\tdefault:\n\t\t\t\t\t'# Example: convert the incoming query to uppercase and return it\\nreturn query.upper()',\n\t\t\t\t// TODO: Add proper text here later\n\t\t\t\thint: 'You can access the input the tool receives via the input property \"query\". The returned value should be a single string.',\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-missing-final-period\n\t\t\t\tdescription: 'E.g. Converts any text to uppercase',\n\t\t\t\tnoDataExpression: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Specify Input Schema',\n\t\t\t\tname: 'specifyInputSchema',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to specify the schema for the function. This would require the LLM to provide the input in the correct format and would validate it against the schema.',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\t{ ...schemaTypeField, displayOptions: { show: { specifyInputSchema: [true] } } },\n\t\t\tjsonSchemaExampleField,\n\t\t\tjsonSchemaExampleNotice,\n\t\t\tjsonSchemaField,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst node = this.getNode();\n\t\tconst workflowMode = this.getMode();\n\n\t\tconst { typeVersion } = node;\n\t\tconst name =\n\t\t\ttypeVersion <= 1.1\n\t\t\t\t? (this.getNodeParameter('name', itemIndex) as string)\n\t\t\t\t: nodeNameToToolName(node);\n\n\t\tconst description = this.getNodeParameter('description', itemIndex) as string;\n\n\t\tconst useSchema = this.getNodeParameter('specifyInputSchema', itemIndex) as boolean;\n\n\t\tconst language = this.getNodeParameter('language', itemIndex) as string;\n\t\tlet code = '';\n\t\tif (language === 'javaScript') {\n\t\t\tcode = this.getNodeParameter('jsCode', itemIndex) as string;\n\t\t} else {\n\t\t\tcode = this.getNodeParameter('pythonCode', itemIndex) as string;\n\t\t}\n\n\t\tconst getSandbox = (query: string | IDataObject, index = 0) => {\n\t\t\tconst context = getSandboxContext.call(this, index);\n\t\t\tcontext.query = query;\n\n\t\t\tlet sandbox: Sandbox;\n\t\t\tif (language === 'javaScript') {\n\t\t\t\tsandbox = new JavaScriptSandbox(context, code, this.helpers);\n\t\t\t} else {\n\t\t\t\tsandbox = new PythonSandbox(context, code, this.helpers);\n\t\t\t}\n\n\t\t\tsandbox.on(\n\t\t\t\t'output',\n\t\t\t\tworkflowMode === 'manual'\n\t\t\t\t\t? this.sendMessageToUI.bind(this)\n\t\t\t\t\t: (...args: unknown[]) =>\n\t\t\t\t\t\t\tconsole.log(`[Workflow \"${this.getWorkflow().id}\"][Node \"${node.name}\"]`, ...args),\n\t\t\t);\n\t\t\treturn sandbox;\n\t\t};\n\n\t\tconst runFunction = async (query: string | IDataObject): Promise<string> => {\n\t\t\tconst sandbox = getSandbox(query, itemIndex);\n\t\t\treturn await sandbox.runCode<string>();\n\t\t};\n\n\t\tconst toolHandler = async (query: string | IDataObject): Promise<string> => {\n\t\t\tconst { index } = this.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]]);\n\n\t\t\tlet response: string = '';\n\t\t\tlet executionError: ExecutionError | undefined;\n\t\t\ttry {\n\t\t\t\tresponse = await runFunction(query);\n\t\t\t} catch (error: unknown) {\n\t\t\t\texecutionError = new NodeOperationError(this.getNode(), error as ExecutionError);\n\t\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t\t}\n\n\t\t\tif (typeof response === 'number') {\n\t\t\t\tresponse = (response as number).toString();\n\t\t\t}\n\n\t\t\tif (typeof response !== 'string') {\n\t\t\t\t// TODO: Do some more testing. Issues here should actually fail the workflow\n\t\t\t\texecutionError = new NodeOperationError(this.getNode(), 'Wrong output type returned', {\n\t\t\t\t\tdescription: `The response property should be a string, but it is an ${typeof response}`,\n\t\t\t\t});\n\t\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t\t}\n\n\t\t\tif (executionError) {\n\t\t\t\tvoid this.addOutputData(NodeConnectionTypes.AiTool, index, executionError);\n\t\t\t} else {\n\t\t\t\tvoid this.addOutputData(NodeConnectionTypes.AiTool, index, [[{ json: { response } }]]);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst commonToolOptions = {\n\t\t\tname,\n\t\t\tdescription,\n\t\t\tfunc: toolHandler,\n\t\t};\n\n\t\tlet tool: DynamicTool | DynamicStructuredTool | undefined = undefined;\n\n\t\tif (useSchema) {\n\t\t\ttry {\n\t\t\t\t// We initialize these even though one of them will always be empty\n\t\t\t\t// it makes it easier to navigate the ternary operator\n\t\t\t\tconst jsonExample = this.getNodeParameter('jsonSchemaExample', itemIndex, '') as string;\n\t\t\t\tconst inputSchema = this.getNodeParameter('inputSchema', itemIndex, '') as string;\n\n\t\t\t\tconst schemaType = this.getNodeParameter('schemaType', itemIndex) as 'fromJson' | 'manual';\n\n\t\t\t\tconst jsonSchema =\n\t\t\t\t\tschemaType === 'fromJson'\n\t\t\t\t\t\t? generateSchemaFromExample(jsonExample, this.getNode().typeVersion >= 1.3)\n\t\t\t\t\t\t: jsonParse<JSONSchema7>(inputSchema);\n\n\t\t\t\tconst zodSchema = convertJsonSchemaToZod<DynamicZodObject>(jsonSchema);\n\n\t\t\t\ttool = new DynamicStructuredTool({\n\t\t\t\t\tschema: zodSchema,\n\t\t\t\t\t...commonToolOptions,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t'Error during parsing of JSON Schema. \\n ' + error,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\ttool = new DynamicTool(commonToolOptions);\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: tool,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmD;AAEnD,+BAAkC;AAClC,2BAA8B;AAE9B,qBAAkC;AASlC,0BAAmE;AAEnE,0BAKO;AACP,qBAAmC;AACnC,2BAAkE;AAClE,0BAA6C;AAI7C,MAAM,6BAAyB,iDAA4B;AAAA,EAC1D,gBAAgB,EAAE,oBAAoB,CAAC,IAAI,EAAE;AAC9C,CAAC;AAED,MAAM,8BAA0B,kDAA6B;AAAA,EAC5D,gBAAgB;AAAA,IACf,oBAAoB,CAAC,IAAI;AAAA,IACzB,YAAY,CAA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AM,gBAAY,6CAAyC,UAAU;AAErE,eAAO,IAAI,mCAAsB;AAAA,UAChC,QAAQ;AAAA,UACR,GAAG;AAAA,QACJ,CAAC;AAAA,MACF,SAAS,OAAO;AACf,cAAM,IAAI;AAAA,UACT,KAAK,QAAQ;AAAA,UACb,6CAA6C;AAAA,QAC9C;AAAA,MACD;AAAA,IACD,OAAO;AACN,aAAO,IAAI,yBAAY,iBAAiB;AAAA,IACzC;AAEA,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
@@ -57,9 +57,7 @@ class ToolHttpRequest {
57
57
  },
58
58
  // Replaced by a `usableAsTool` version of the standalone HttpRequest node
59
59
  hidden: true,
60
- // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
61
60
  inputs: [],
62
- // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
63
61
  outputs: [import_n8n_workflow.NodeConnectionTypes.AiTool],
64
62
  outputNames: ["Tool"],
65
63
  properties: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/tools/ToolHttpRequest/ToolHttpRequest.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { DynamicTool } from '@langchain/core/tools';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n\tIHttpRequestMethods,\n\tIHttpRequestOptions,\n} from 'n8n-workflow';\nimport {\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\ttryToParseAlphanumericString,\n} from 'n8n-workflow';\n\nimport { N8nTool } from '@utils/N8nTool';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport {\n\tauthenticationProperties,\n\tjsonInput,\n\toptimizeResponseProperties,\n\tparametersCollection,\n\tplaceholderDefinitionsCollection,\n\tspecifyBySelector,\n} from './descriptions';\nimport type { PlaceholderDefinition, ToolParameter } from './interfaces';\nimport {\n\tconfigureHttpRequestFunction,\n\tconfigureResponseOptimizer,\n\textractParametersFromText,\n\tprepareToolDescription,\n\tconfigureToolFunction,\n\tupdateParametersAndOptions,\n\tmakeToolInputSchema,\n} from './utils';\n\nexport class ToolHttpRequest implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'HTTP Request Tool',\n\t\tname: 'toolHttpRequest',\n\t\ticon: { light: 'file:httprequest.svg', dark: 'file:httprequest.dark.svg' },\n\t\tgroup: ['output'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Makes an HTTP request and returns the response data',\n\t\tsubtitle: '={{ $parameter.toolDescription }}',\n\t\tdefaults: {\n\t\t\tname: 'HTTP Request',\n\t\t},\n\t\tcredentials: [],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Recommended Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolhttprequest/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// Replaced by a `usableAsTool` version of the standalone HttpRequest node\n\t\thidden: true,\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Description',\n\t\t\t\tname: 'toolDescription',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription:\n\t\t\t\t\t'Explain to LLM what this tool does, better description would allow LLM to produce expected result',\n\t\t\t\tplaceholder: 'e.g. Get the current weather in the requested city',\n\t\t\t\tdefault: '',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Method',\n\t\t\t\tname: 'method',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'DELETE',\n\t\t\t\t\t\tvalue: 'DELETE',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'GET',\n\t\t\t\t\t\tvalue: 'GET',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'PATCH',\n\t\t\t\t\t\tvalue: 'PATCH',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'POST',\n\t\t\t\t\t\tvalue: 'POST',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'PUT',\n\t\t\t\t\t\tvalue: 'PUT',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'GET',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'Tip: You can use a {placeholder} for any part of the request to be filled by the model. Provide more context about them in the placeholders section',\n\t\t\t\tname: 'placeholderNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'URL',\n\t\t\t\tname: 'url',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\trequired: true,\n\t\t\t\tplaceholder: 'e.g. http://www.example.com/{path}',\n\t\t\t},\n\t\t\t...authenticationProperties,\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Query Parameters',\n\t\t\t\tname: 'sendQuery',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has query params or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Query Parameters',\n\t\t\t\tname: 'specifyQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Query Parameters',\n\t\t\t\tname: 'parametersQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t\tspecifyQuery: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t\tspecifyQuery: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Headers',\n\t\t\t\tname: 'sendHeaders',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has headers or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Headers',\n\t\t\t\tname: 'specifyHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Header Parameters',\n\t\t\t\tname: 'parametersHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t\tspecifyHeaders: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t\tspecifyHeaders: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Body',\n\t\t\t\tname: 'sendBody',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has body or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Body',\n\t\t\t\tname: 'specifyBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Body Parameters',\n\t\t\t\tname: 'parametersBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t\tspecifyBody: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t\tspecifyBody: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\tplaceholderDefinitionsCollection,\n\t\t\t...optimizeResponseProperties,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst name = this.getNode().name.replace(/ /g, '_');\n\t\ttry {\n\t\t\ttryToParseAlphanumericString(name);\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'The name of this tool is not a valid alphanumeric string',\n\t\t\t\t{\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Only alphanumeric characters and underscores are allowed in the tool's name, and the name cannot start with a number\",\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst toolDescription = this.getNodeParameter('toolDescription', itemIndex) as string;\n\t\tconst sendQuery = this.getNodeParameter('sendQuery', itemIndex, false) as boolean;\n\t\tconst sendHeaders = this.getNodeParameter('sendHeaders', itemIndex, false) as boolean;\n\t\tconst sendBody = this.getNodeParameter('sendBody', itemIndex, false) as boolean;\n\n\t\tconst requestOptions: IHttpRequestOptions = {\n\t\t\tmethod: this.getNodeParameter('method', itemIndex, 'GET') as IHttpRequestMethods,\n\t\t\turl: this.getNodeParameter('url', itemIndex) as string,\n\t\t\tqs: {},\n\t\t\theaders: {\n\t\t\t\t// FIXME: This is a workaround to prevent the node from sending a default User-Agent (`n8n`) when the header is not set.\n\t\t\t\t// Needs to be replaced with a proper fix after NODE-1777 is resolved\n\t\t\t\t'User-Agent': undefined,\n\t\t\t},\n\t\t\tbody: {},\n\t\t\t// We will need a full response object later to extract the headers and check the response's content type.\n\t\t\treturnFullResponse: true,\n\t\t};\n\n\t\tconst authentication = this.getNodeParameter('authentication', itemIndex, 'none') as\n\t\t\t| 'predefinedCredentialType'\n\t\t\t| 'genericCredentialType'\n\t\t\t| 'none';\n\n\t\tif (authentication !== 'none') {\n\t\t\tconst domain = new URL(requestOptions.url).hostname;\n\t\t\tif (domain.includes('{') && domain.includes('}')) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\"Can't use a placeholder for the domain when using authentication\",\n\t\t\t\t\t{\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'This is for security reasons, to prevent the model accidentally sending your credentials to an unauthorized domain',\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst httpRequest = await configureHttpRequestFunction(this, authentication, itemIndex);\n\t\tconst optimizeResponse = configureResponseOptimizer(this, itemIndex);\n\n\t\tconst rawRequestOptions: { [key: string]: string } = {\n\t\t\tqs: '',\n\t\t\theaders: '',\n\t\t\tbody: '',\n\t\t};\n\n\t\tconst placeholdersDefinitions = (\n\t\t\tthis.getNodeParameter(\n\t\t\t\t'placeholderDefinitions.values',\n\t\t\t\titemIndex,\n\t\t\t\t[],\n\t\t\t) as PlaceholderDefinition[]\n\t\t).map((p) => {\n\t\t\tif (p.name.startsWith('{') && p.name.endsWith('}')) {\n\t\t\t\tp.name = p.name.slice(1, -1);\n\t\t\t}\n\t\t\treturn p;\n\t\t});\n\n\t\tconst toolParameters: ToolParameter[] = [];\n\n\t\ttoolParameters.push(\n\t\t\t...extractParametersFromText(placeholdersDefinitions, requestOptions.url, 'path'),\n\t\t);\n\n\t\tif (sendQuery) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'qs',\n\t\t\t\tinputTypePropertyName: 'specifyQuery',\n\t\t\t\tjsonPropertyName: 'jsonQuery',\n\t\t\t\tparametersPropertyName: 'parametersQuery.values',\n\t\t\t});\n\t\t}\n\n\t\tif (sendHeaders) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'headers',\n\t\t\t\tinputTypePropertyName: 'specifyHeaders',\n\t\t\t\tjsonPropertyName: 'jsonHeaders',\n\t\t\t\tparametersPropertyName: 'parametersHeaders.values',\n\t\t\t});\n\t\t}\n\n\t\tif (sendBody) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'body',\n\t\t\t\tinputTypePropertyName: 'specifyBody',\n\t\t\t\tjsonPropertyName: 'jsonBody',\n\t\t\t\tparametersPropertyName: 'parametersBody.values',\n\t\t\t});\n\t\t}\n\n\t\tfor (const placeholder of placeholdersDefinitions) {\n\t\t\tif (!toolParameters.find((parameter) => parameter.name === placeholder.name)) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t`Misconfigured placeholder '${placeholder.name}'`,\n\t\t\t\t\t{\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"This placeholder is defined in the 'Placeholder Definitions' but isn't used anywhere. Either remove the definition, or add the placeholder to a part of the request.\",\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst func = configureToolFunction(\n\t\t\tthis,\n\t\t\titemIndex,\n\t\t\ttoolParameters,\n\t\t\trequestOptions,\n\t\t\trawRequestOptions,\n\t\t\thttpRequest,\n\t\t\toptimizeResponse,\n\t\t);\n\n\t\tlet tool: DynamicTool | N8nTool;\n\n\t\t// If the node version is 1.1 or higher, we use the N8nTool wrapper:\n\t\t// it allows to use tool as a DynamicStructuredTool and have a fallback to DynamicTool\n\t\tif (this.getNode().typeVersion >= 1.1) {\n\t\t\tconst schema = makeToolInputSchema(toolParameters);\n\n\t\t\ttool = new N8nTool(this, {\n\t\t\t\tname,\n\t\t\t\tdescription: toolDescription,\n\t\t\t\tfunc,\n\t\t\t\tschema,\n\t\t\t});\n\t\t} else {\n\t\t\t// Keep the old behavior for nodes with version 1.0\n\t\t\tconst description = prepareToolDescription(toolDescription, toolParameters);\n\t\t\ttool = new DynamicTool({ name, description, func });\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: tool,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA4B;AAS5B,0BAIO;AAEP,qBAAwB;AACxB,0BAA6C;AAE7C,0BAOO;AAEP,mBAQO;AAEA,MAAM,gBAAqC;AAAA,EAA3C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM,EAAE,OAAO,wBAAwB,MAAM,4BAA4B;AAAA,MACzE,OAAO,CAAC,QAAQ;AAAA,MAChB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,MACV,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,aAAa,CAAC;AAAA,MACd,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,mBAAmB;AAAA,QAC5B;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA;AAAA,MAEA,QAAQ;AAAA;AAAA,MAER,QAAQ,CAAC;AAAA;AAAA,MAET,SAAS,CAAC,wCAAoB,MAAM;AAAA,MACpC,aAAa,CAAC,MAAM;AAAA,MACpB,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,OAAO,CAAC;AAAA,QAC1D;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,aACC;AAAA,UACD,aAAa;AAAA,UACb,SAAS;AAAA,UACT,aAAa;AAAA,YACZ,MAAM;AAAA,UACP;AAAA,QACD;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,M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SAAS,YAAY,IAAI,GAAG;AAC7E,cAAM,IAAI;AAAA,UACT,KAAK,QAAQ;AAAA,UACb,8BAA8B,YAAY,IAAI;AAAA,UAC9C;AAAA,YACC;AAAA,YACA,aACC;AAAA,UACF;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,UAAM,WAAO;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAEA,QAAI;AAIJ,QAAI,KAAK,QAAQ,EAAE,eAAe,KAAK;AACtC,YAAM,aAAS,kCAAoB,cAAc;AAEjD,aAAO,IAAI,uBAAQ,MAAM;AAAA,QACxB;AAAA,QACA,aAAa;AAAA,QACb;AAAA,QACA;AAAA,MACD,CAAC;AAAA,IACF,OAAO;AAEN,YAAM,kBAAc,qCAAuB,iBAAiB,cAAc;AAC1E,aAAO,IAAI,yBAAY,EAAE,MAAM,aAAa,KAAK,CAAC;AAAA,IACnD;AAEA,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/tools/ToolHttpRequest/ToolHttpRequest.node.ts"],"sourcesContent":["import { DynamicTool } from '@langchain/core/tools';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n\tIHttpRequestMethods,\n\tIHttpRequestOptions,\n} from 'n8n-workflow';\nimport {\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\ttryToParseAlphanumericString,\n} from 'n8n-workflow';\n\nimport { N8nTool } from '@utils/N8nTool';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport {\n\tauthenticationProperties,\n\tjsonInput,\n\toptimizeResponseProperties,\n\tparametersCollection,\n\tplaceholderDefinitionsCollection,\n\tspecifyBySelector,\n} from './descriptions';\nimport type { PlaceholderDefinition, ToolParameter } from './interfaces';\nimport {\n\tconfigureHttpRequestFunction,\n\tconfigureResponseOptimizer,\n\textractParametersFromText,\n\tprepareToolDescription,\n\tconfigureToolFunction,\n\tupdateParametersAndOptions,\n\tmakeToolInputSchema,\n} from './utils';\n\nexport class ToolHttpRequest implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'HTTP Request Tool',\n\t\tname: 'toolHttpRequest',\n\t\ticon: { light: 'file:httprequest.svg', dark: 'file:httprequest.dark.svg' },\n\t\tgroup: ['output'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Makes an HTTP request and returns the response data',\n\t\tsubtitle: '={{ $parameter.toolDescription }}',\n\t\tdefaults: {\n\t\t\tname: 'HTTP Request',\n\t\t},\n\t\tcredentials: [],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Recommended Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolhttprequest/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// Replaced by a `usableAsTool` version of the standalone HttpRequest node\n\t\thidden: true,\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Description',\n\t\t\t\tname: 'toolDescription',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription:\n\t\t\t\t\t'Explain to LLM what this tool does, better description would allow LLM to produce expected result',\n\t\t\t\tplaceholder: 'e.g. Get the current weather in the requested city',\n\t\t\t\tdefault: '',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Method',\n\t\t\t\tname: 'method',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'DELETE',\n\t\t\t\t\t\tvalue: 'DELETE',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'GET',\n\t\t\t\t\t\tvalue: 'GET',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'PATCH',\n\t\t\t\t\t\tvalue: 'PATCH',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'POST',\n\t\t\t\t\t\tvalue: 'POST',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'PUT',\n\t\t\t\t\t\tvalue: 'PUT',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'GET',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'Tip: You can use a {placeholder} for any part of the request to be filled by the model. Provide more context about them in the placeholders section',\n\t\t\t\tname: 'placeholderNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'URL',\n\t\t\t\tname: 'url',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\trequired: true,\n\t\t\t\tplaceholder: 'e.g. http://www.example.com/{path}',\n\t\t\t},\n\t\t\t...authenticationProperties,\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Query Parameters',\n\t\t\t\tname: 'sendQuery',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has query params or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Query Parameters',\n\t\t\t\tname: 'specifyQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Query Parameters',\n\t\t\t\tname: 'parametersQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t\tspecifyQuery: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t\tspecifyQuery: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Headers',\n\t\t\t\tname: 'sendHeaders',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has headers or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Headers',\n\t\t\t\tname: 'specifyHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Header Parameters',\n\t\t\t\tname: 'parametersHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t\tspecifyHeaders: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t\tspecifyHeaders: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Body',\n\t\t\t\tname: 'sendBody',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has body or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Body',\n\t\t\t\tname: 'specifyBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Body Parameters',\n\t\t\t\tname: 'parametersBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t\tspecifyBody: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t\tspecifyBody: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\tplaceholderDefinitionsCollection,\n\t\t\t...optimizeResponseProperties,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst name = this.getNode().name.replace(/ /g, '_');\n\t\ttry {\n\t\t\ttryToParseAlphanumericString(name);\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'The name of this tool is not a valid alphanumeric string',\n\t\t\t\t{\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Only alphanumeric characters and underscores are allowed in the tool's name, and the name cannot start with a number\",\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst toolDescription = this.getNodeParameter('toolDescription', itemIndex) as string;\n\t\tconst sendQuery = this.getNodeParameter('sendQuery', itemIndex, false) as boolean;\n\t\tconst sendHeaders = this.getNodeParameter('sendHeaders', itemIndex, false) as boolean;\n\t\tconst sendBody = this.getNodeParameter('sendBody', itemIndex, false) as boolean;\n\n\t\tconst requestOptions: IHttpRequestOptions = {\n\t\t\tmethod: this.getNodeParameter('method', itemIndex, 'GET') as IHttpRequestMethods,\n\t\t\turl: this.getNodeParameter('url', itemIndex) as string,\n\t\t\tqs: {},\n\t\t\theaders: {\n\t\t\t\t// FIXME: This is a workaround to prevent the node from sending a default User-Agent (`n8n`) when the header is not set.\n\t\t\t\t// Needs to be replaced with a proper fix after NODE-1777 is resolved\n\t\t\t\t'User-Agent': undefined,\n\t\t\t},\n\t\t\tbody: {},\n\t\t\t// We will need a full response object later to extract the headers and check the response's content type.\n\t\t\treturnFullResponse: true,\n\t\t};\n\n\t\tconst authentication = this.getNodeParameter('authentication', itemIndex, 'none') as\n\t\t\t| 'predefinedCredentialType'\n\t\t\t| 'genericCredentialType'\n\t\t\t| 'none';\n\n\t\tif (authentication !== 'none') {\n\t\t\tconst domain = new URL(requestOptions.url).hostname;\n\t\t\tif (domain.includes('{') && domain.includes('}')) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\"Can't use a placeholder for the domain when using authentication\",\n\t\t\t\t\t{\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'This is for security reasons, to prevent the model accidentally sending your credentials to an unauthorized domain',\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst httpRequest = await configureHttpRequestFunction(this, authentication, itemIndex);\n\t\tconst optimizeResponse = configureResponseOptimizer(this, itemIndex);\n\n\t\tconst rawRequestOptions: { [key: string]: string } = {\n\t\t\tqs: '',\n\t\t\theaders: '',\n\t\t\tbody: '',\n\t\t};\n\n\t\tconst placeholdersDefinitions = (\n\t\t\tthis.getNodeParameter(\n\t\t\t\t'placeholderDefinitions.values',\n\t\t\t\titemIndex,\n\t\t\t\t[],\n\t\t\t) as PlaceholderDefinition[]\n\t\t).map((p) => {\n\t\t\tif (p.name.startsWith('{') && p.name.endsWith('}')) {\n\t\t\t\tp.name = p.name.slice(1, -1);\n\t\t\t}\n\t\t\treturn p;\n\t\t});\n\n\t\tconst toolParameters: ToolParameter[] = [];\n\n\t\ttoolParameters.push(\n\t\t\t...extractParametersFromText(placeholdersDefinitions, requestOptions.url, 'path'),\n\t\t);\n\n\t\tif (sendQuery) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'qs',\n\t\t\t\tinputTypePropertyName: 'specifyQuery',\n\t\t\t\tjsonPropertyName: 'jsonQuery',\n\t\t\t\tparametersPropertyName: 'parametersQuery.values',\n\t\t\t});\n\t\t}\n\n\t\tif (sendHeaders) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'headers',\n\t\t\t\tinputTypePropertyName: 'specifyHeaders',\n\t\t\t\tjsonPropertyName: 'jsonHeaders',\n\t\t\t\tparametersPropertyName: 'parametersHeaders.values',\n\t\t\t});\n\t\t}\n\n\t\tif (sendBody) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'body',\n\t\t\t\tinputTypePropertyName: 'specifyBody',\n\t\t\t\tjsonPropertyName: 'jsonBody',\n\t\t\t\tparametersPropertyName: 'parametersBody.values',\n\t\t\t});\n\t\t}\n\n\t\tfor (const placeholder of placeholdersDefinitions) {\n\t\t\tif (!toolParameters.find((parameter) => parameter.name === placeholder.name)) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t`Misconfigured placeholder '${placeholder.name}'`,\n\t\t\t\t\t{\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"This placeholder is defined in the 'Placeholder Definitions' but isn't used anywhere. Either remove the definition, or add the placeholder to a part of the request.\",\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst func = configureToolFunction(\n\t\t\tthis,\n\t\t\titemIndex,\n\t\t\ttoolParameters,\n\t\t\trequestOptions,\n\t\t\trawRequestOptions,\n\t\t\thttpRequest,\n\t\t\toptimizeResponse,\n\t\t);\n\n\t\tlet tool: DynamicTool | N8nTool;\n\n\t\t// If the node version is 1.1 or higher, we use the N8nTool wrapper:\n\t\t// it allows to use tool as a DynamicStructuredTool and have a fallback to DynamicTool\n\t\tif (this.getNode().typeVersion >= 1.1) {\n\t\t\tconst schema = makeToolInputSchema(toolParameters);\n\n\t\t\ttool = new N8nTool(this, {\n\t\t\t\tname,\n\t\t\t\tdescription: toolDescription,\n\t\t\t\tfunc,\n\t\t\t\tschema,\n\t\t\t});\n\t\t} else {\n\t\t\t// Keep the old behavior for nodes with version 1.0\n\t\t\tconst description = prepareToolDescription(toolDescription, toolParameters);\n\t\t\ttool = new DynamicTool({ name, description, func });\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: tool,\n\t\t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,YACC;AAAA,YACA,aACC;AAAA,UACF;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,UAAM,WAAO;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAEA,QAAI;AAIJ,QAAI,KAAK,QAAQ,EAAE,eAAe,KAAK;AACtC,YAAM,aAAS,kCAAoB,cAAc;AAEjD,aAAO,IAAI,uBAAQ,MAAM;AAAA,QACxB;AAAA,QACA,aAAa;AAAA,QACb;AAAA,QACA;AAAA,MACD,CAAC;AAAA,IACF,OAAO;AAEN,YAAM,kBAAc,qCAAuB,iBAAiB,cAAc;AAC1E,aAAO,IAAI,yBAAY,EAAE,MAAM,aAAa,KAAK,CAAC;AAAA,IACnD;AAEA,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/tools/ToolHttpRequest/utils.ts"],"sourcesContent":["import { Readability } from '@mozilla/readability';\nimport * as cheerio from 'cheerio';\nimport { convert } from 'html-to-text';\nimport { JSDOM } from 'jsdom';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\nimport unset from 'lodash/unset';\nimport { getOAuth2AdditionalParameters } from 'n8n-nodes-base/dist/nodes/HttpRequest/GenericFunctions';\nimport type {\n\tIDataObject,\n\tIHttpRequestOptions,\n\tIRequestOptionsSimplified,\n\tExecutionError,\n\tNodeApiError,\n\tISupplyDataFunctions,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes, NodeOperationError, jsonParse } from 'n8n-workflow';\nimport { z } from 'zod';\n\nimport type {\n\tParameterInputType,\n\tParametersValues,\n\tPlaceholderDefinition,\n\tParametersValues as RawParametersValues,\n\tSendIn,\n\tToolParameter,\n} from './interfaces';\nimport type { DynamicZodObject } from '../../../types/zod.types';\n\nconst genericCredentialRequest = async (ctx: ISupplyDataFunctions, itemIndex: number) => {\n\tconst genericType = ctx.getNodeParameter('genericAuthType', itemIndex) as string;\n\n\tif (genericType === 'httpBasicAuth' || genericType === 'httpDigestAuth') {\n\t\tconst basicAuth = await ctx.getCredentials('httpBasicAuth', itemIndex);\n\t\tconst sendImmediately = genericType === 'httpDigestAuth' ? false : undefined;\n\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\toptions.auth = {\n\t\t\t\tusername: basicAuth.user as string,\n\t\t\t\tpassword: basicAuth.password as string,\n\t\t\t\tsendImmediately,\n\t\t\t};\n\t\t\treturn await ctx.helpers.httpRequest(options);\n\t\t};\n\t}\n\n\tif (genericType === 'httpHeaderAuth') {\n\t\tconst headerAuth = await ctx.getCredentials('httpHeaderAuth', itemIndex);\n\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\tif (!options.headers) options.headers = {};\n\t\t\toptions.headers[headerAuth.name as string] = headerAuth.value;\n\t\t\treturn await ctx.helpers.httpRequest(options);\n\t\t};\n\t}\n\n\tif (genericType === 'httpQueryAuth') {\n\t\tconst queryAuth = await ctx.getCredentials('httpQueryAuth', itemIndex);\n\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\tif (!options.qs) options.qs = {};\n\t\t\toptions.qs[queryAuth.name as string] = queryAuth.value;\n\t\t\treturn await ctx.helpers.httpRequest(options);\n\t\t};\n\t}\n\n\tif (genericType === 'httpCustomAuth') {\n\t\tconst customAuth = await ctx.getCredentials('httpCustomAuth', itemIndex);\n\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\tconst auth = jsonParse<IRequestOptionsSimplified>((customAuth.json as string) || '{}', {\n\t\t\t\terrorMessage: 'Invalid Custom Auth JSON',\n\t\t\t});\n\t\t\tif (auth.headers) {\n\t\t\t\toptions.headers = { ...options.headers, ...auth.headers };\n\t\t\t}\n\t\t\tif (auth.body) {\n\t\t\t\toptions.body = { ...(options.body as IDataObject), ...auth.body };\n\t\t\t}\n\t\t\tif (auth.qs) {\n\t\t\t\toptions.qs = { ...options.qs, ...auth.qs };\n\t\t\t}\n\t\t\treturn await ctx.helpers.httpRequest(options);\n\t\t};\n\t}\n\n\tif (genericType === 'oAuth1Api') {\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\treturn await ctx.helpers.requestOAuth1.call(ctx, 'oAuth1Api', options);\n\t\t};\n\t}\n\n\tif (genericType === 'oAuth2Api') {\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\treturn await ctx.helpers.requestOAuth2.call(ctx, 'oAuth2Api', options, {\n\t\t\t\ttokenType: 'Bearer',\n\t\t\t});\n\t\t};\n\t}\n\n\tthrow new NodeOperationError(ctx.getNode(), `The type ${genericType} is not supported`, {\n\t\titemIndex,\n\t});\n};\n\nconst predefinedCredentialRequest = async (ctx: ISupplyDataFunctions, itemIndex: number) => {\n\tconst predefinedType = ctx.getNodeParameter('nodeCredentialType', itemIndex) as string;\n\tconst additionalOptions = getOAuth2AdditionalParameters(predefinedType);\n\n\treturn async (options: IHttpRequestOptions) => {\n\t\treturn await ctx.helpers.httpRequestWithAuthentication.call(\n\t\t\tctx,\n\t\t\tpredefinedType,\n\t\t\toptions,\n\t\t\tadditionalOptions && { oauth2: additionalOptions },\n\t\t);\n\t};\n};\n\nexport const configureHttpRequestFunction = async (\n\tctx: ISupplyDataFunctions,\n\tcredentialsType: 'predefinedCredentialType' | 'genericCredentialType' | 'none',\n\titemIndex: number,\n) => {\n\tswitch (credentialsType) {\n\t\tcase 'genericCredentialType':\n\t\t\treturn await genericCredentialRequest(ctx, itemIndex);\n\t\tcase 'predefinedCredentialType':\n\t\t\treturn await predefinedCredentialRequest(ctx, itemIndex);\n\t\tdefault:\n\t\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\t\treturn await ctx.helpers.httpRequest(options);\n\t\t\t};\n\t}\n};\n\nconst defaultOptimizer = <T>(response: T) => {\n\tif (typeof response === 'string') {\n\t\treturn response;\n\t}\n\tif (typeof response === 'object') {\n\t\treturn JSON.stringify(response, null, 2);\n\t}\n\n\treturn String(response);\n};\n\nfunction isBinary(data: unknown) {\n\t// Check if data is a Buffer\n\tif (Buffer.isBuffer(data)) {\n\t\treturn true;\n\t}\n\n\t// If data is a string, assume it's text unless it contains null characters.\n\tif (typeof data === 'string') {\n\t\t// If the string contains a null character, it's likely binary.\n\t\tif (data.includes('\\0')) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t// For any other type, assume it's not binary.\n\treturn false;\n}\n\nconst htmlOptimizer = (ctx: ISupplyDataFunctions, itemIndex: number, maxLength: number) => {\n\tconst cssSelector = ctx.getNodeParameter('cssSelector', itemIndex, '') as string;\n\tconst onlyContent = ctx.getNodeParameter('onlyContent', itemIndex, false) as boolean;\n\tlet elementsToOmit: string[] = [];\n\n\tif (onlyContent) {\n\t\tconst elementsToOmitUi = ctx.getNodeParameter('elementsToOmit', itemIndex, '') as\n\t\t\t| string\n\t\t\t| string[];\n\n\t\tif (typeof elementsToOmitUi === 'string') {\n\t\t\telementsToOmit = elementsToOmitUi\n\t\t\t\t.split(',')\n\t\t\t\t.filter((s) => s)\n\t\t\t\t.map((s) => s.trim());\n\t\t}\n\t}\n\n\treturn <T>(response: T) => {\n\t\tif (typeof response !== 'string') {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t`The response type must be a string. Received: ${typeof response}`,\n\t\t\t\t{ itemIndex },\n\t\t\t);\n\t\t}\n\t\tconst returnData: string[] = [];\n\n\t\tconst html = cheerio.load(response);\n\t\tconst htmlElements = html(cssSelector);\n\n\t\thtmlElements.each((_, el) => {\n\t\t\tlet value = html(el).html() || '';\n\n\t\t\tif (onlyContent) {\n\t\t\t\tlet htmlToTextOptions;\n\n\t\t\t\tif (elementsToOmit?.length) {\n\t\t\t\t\thtmlToTextOptions = {\n\t\t\t\t\t\tselectors: elementsToOmit.map((selector) => ({\n\t\t\t\t\t\t\tselector,\n\t\t\t\t\t\t\tformat: 'skip',\n\t\t\t\t\t\t})),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tvalue = convert(value, htmlToTextOptions);\n\t\t\t}\n\n\t\t\tvalue = value\n\t\t\t\t.trim()\n\t\t\t\t.replace(/^\\s+|\\s+$/g, '')\n\t\t\t\t.replace(/(\\r\\n|\\n|\\r)/gm, '')\n\t\t\t\t.replace(/\\s+/g, ' ');\n\n\t\t\treturnData.push(value);\n\t\t});\n\n\t\tconst text = JSON.stringify(returnData, null, 2);\n\n\t\tif (maxLength > 0 && text.length > maxLength) {\n\t\t\treturn text.substring(0, maxLength);\n\t\t}\n\n\t\treturn text;\n\t};\n};\n\nconst textOptimizer = (ctx: ISupplyDataFunctions, itemIndex: number, maxLength: number) => {\n\treturn (response: string | IDataObject) => {\n\t\tif (typeof response === 'object') {\n\t\t\ttry {\n\t\t\t\tresponse = JSON.stringify(response, null, 2);\n\t\t\t} catch (error) {}\n\t\t}\n\n\t\tif (typeof response !== 'string') {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t`The response type must be a string. Received: ${typeof response}`,\n\t\t\t\t{ itemIndex },\n\t\t\t);\n\t\t}\n\n\t\tconst dom = new JSDOM(response);\n\t\tconst article = new Readability(dom.window.document, {\n\t\t\tkeepClasses: true,\n\t\t}).parse();\n\n\t\tconst text = article?.textContent || '';\n\n\t\tif (maxLength > 0 && text.length > maxLength) {\n\t\t\treturn text.substring(0, maxLength);\n\t\t}\n\n\t\treturn text;\n\t};\n};\n\nconst jsonOptimizer = (ctx: ISupplyDataFunctions, itemIndex: number) => {\n\treturn (response: string): string => {\n\t\tlet responseData: IDataObject | IDataObject[] | string = response;\n\n\t\tif (typeof responseData === 'string') {\n\t\t\tresponseData = jsonParse(response);\n\t\t}\n\n\t\tif (typeof responseData !== 'object' || !responseData) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t'The response type must be an object or an array of objects',\n\t\t\t\t{ itemIndex },\n\t\t\t);\n\t\t}\n\n\t\tconst dataField = ctx.getNodeParameter('dataField', itemIndex, '') as string;\n\t\tlet returnData: IDataObject[] = [];\n\n\t\tif (!Array.isArray(responseData)) {\n\t\t\tif (dataField) {\n\t\t\t\tconst data = responseData[dataField] as IDataObject | IDataObject[];\n\t\t\t\tif (Array.isArray(data)) {\n\t\t\t\t\tresponseData = data;\n\t\t\t\t} else {\n\t\t\t\t\tresponseData = [data];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresponseData = [responseData];\n\t\t\t}\n\t\t} else {\n\t\t\tif (dataField) {\n\t\t\t\tresponseData = responseData.map((data) => data[dataField]) as IDataObject[];\n\t\t\t}\n\t\t}\n\n\t\tconst fieldsToInclude = ctx.getNodeParameter('fieldsToInclude', itemIndex, 'all') as\n\t\t\t| 'all'\n\t\t\t| 'selected'\n\t\t\t| 'except';\n\n\t\tlet fields: string | string[] = [];\n\n\t\tif (fieldsToInclude !== 'all') {\n\t\t\tfields = ctx.getNodeParameter('fields', itemIndex, []) as string[] | string;\n\n\t\t\tif (typeof fields === 'string') {\n\t\t\t\tfields = fields.split(',').map((field) => field.trim());\n\t\t\t}\n\t\t} else {\n\t\t\treturnData = responseData;\n\t\t}\n\n\t\tif (fieldsToInclude === 'selected') {\n\t\t\tfor (const item of responseData) {\n\t\t\t\tconst newItem: IDataObject = {};\n\n\t\t\t\tfor (const field of fields) {\n\t\t\t\t\tset(newItem, field, get(item, field));\n\t\t\t\t}\n\n\t\t\t\treturnData.push(newItem);\n\t\t\t}\n\t\t}\n\n\t\tif (fieldsToInclude === 'except') {\n\t\t\tfor (const item of responseData) {\n\t\t\t\tfor (const field of fields) {\n\t\t\t\t\tunset(item, field);\n\t\t\t\t}\n\n\t\t\t\treturnData.push(item);\n\t\t\t}\n\t\t}\n\n\t\treturn JSON.stringify(returnData, null, 2);\n\t};\n};\n\nexport const configureResponseOptimizer = (ctx: ISupplyDataFunctions, itemIndex: number) => {\n\tconst optimizeResponse = ctx.getNodeParameter('optimizeResponse', itemIndex, false) as boolean;\n\n\tif (optimizeResponse) {\n\t\tconst responseType = ctx.getNodeParameter('responseType', itemIndex) as\n\t\t\t| 'json'\n\t\t\t| 'text'\n\t\t\t| 'html';\n\n\t\tlet maxLength = 0;\n\t\tconst truncateResponse = ctx.getNodeParameter('truncateResponse', itemIndex, false) as boolean;\n\n\t\tif (truncateResponse) {\n\t\t\tmaxLength = ctx.getNodeParameter('maxLength', itemIndex, 0) as number;\n\t\t}\n\n\t\tswitch (responseType) {\n\t\t\tcase 'html':\n\t\t\t\treturn htmlOptimizer(ctx, itemIndex, maxLength);\n\t\t\tcase 'text':\n\t\t\t\treturn textOptimizer(ctx, itemIndex, maxLength);\n\t\t\tcase 'json':\n\t\t\t\treturn jsonOptimizer(ctx, itemIndex);\n\t\t}\n\t}\n\n\treturn defaultOptimizer;\n};\n\nconst extractPlaceholders = (text: string): string[] => {\n\tconst placeholder = /(\\{[a-zA-Z0-9_-]+\\})/g;\n\tconst returnData: string[] = [];\n\n\tconst matches = text.matchAll(placeholder);\n\n\tfor (const match of matches) {\n\t\treturnData.push(match[0].replace(/{|}/g, ''));\n\t}\n\n\treturn returnData;\n};\n\nexport const extractParametersFromText = (\n\tplaceholders: PlaceholderDefinition[],\n\ttext: string,\n\tsendIn: SendIn,\n\tkey?: string,\n): ToolParameter[] => {\n\tif (typeof text !== 'string') return [];\n\n\tconst parameters = extractPlaceholders(text);\n\n\tif (parameters.length) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-use-before-define\n\t\tconst inputParameters = prepareParameters(\n\t\t\tparameters.map((name) => ({\n\t\t\t\tname,\n\t\t\t\tvalueProvider: 'modelRequired',\n\t\t\t})),\n\t\t\tplaceholders,\n\t\t\t'keypair',\n\t\t\tsendIn,\n\t\t\t'',\n\t\t);\n\n\t\treturn key\n\t\t\t? inputParameters.parameters.map((p) => ({ ...p, key }))\n\t\t\t: inputParameters.parameters;\n\t}\n\n\treturn [];\n};\n\nfunction prepareParameters(\n\trawParameters: RawParametersValues,\n\tplaceholders: PlaceholderDefinition[],\n\tparametersInputType: 'model' | 'keypair' | 'json',\n\tsendIn: SendIn,\n\tmodelInputDescription: string,\n\tjsonWithPlaceholders?: string,\n): { parameters: ToolParameter[]; values: IDataObject } {\n\tconst parameters: ToolParameter[] = [];\n\tconst values: IDataObject = {};\n\n\tif (parametersInputType === 'model') {\n\t\treturn {\n\t\t\tparameters: [\n\t\t\t\t{\n\t\t\t\t\tname: sendIn,\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttype: 'json',\n\t\t\t\t\tdescription: modelInputDescription,\n\t\t\t\t\tsendIn,\n\t\t\t\t},\n\t\t\t],\n\t\t\tvalues: {},\n\t\t};\n\t}\n\n\tif (parametersInputType === 'keypair') {\n\t\tfor (const entry of rawParameters) {\n\t\t\tif (entry.valueProvider.includes('model')) {\n\t\t\t\tconst placeholder = placeholders.find((p) => p.name === entry.name);\n\n\t\t\t\tconst parameter: ToolParameter = {\n\t\t\t\t\tname: entry.name,\n\t\t\t\t\trequired: entry.valueProvider === 'modelRequired',\n\t\t\t\t\tsendIn,\n\t\t\t\t};\n\n\t\t\t\tif (placeholder) {\n\t\t\t\t\tparameter.type = placeholder.type;\n\t\t\t\t\tparameter.description = placeholder.description;\n\t\t\t\t}\n\n\t\t\t\tparameters.push(parameter);\n\t\t\t} else if (entry.value) {\n\t\t\t\t// if value has placeholders push them to parameters\n\t\t\t\tparameters.push(\n\t\t\t\t\t...extractParametersFromText(placeholders, entry.value, sendIn, entry.name),\n\t\t\t\t);\n\t\t\t\tvalues[entry.name] = entry.value; //push to user provided values\n\t\t\t}\n\t\t}\n\t}\n\n\tif (parametersInputType === 'json' && jsonWithPlaceholders) {\n\t\tparameters.push(\n\t\t\t...extractParametersFromText(placeholders, jsonWithPlaceholders, sendIn, `${sendIn + 'Raw'}`),\n\t\t);\n\t}\n\n\treturn {\n\t\tparameters,\n\t\tvalues,\n\t};\n}\n\nconst MODEL_INPUT_DESCRIPTION = {\n\tqs: 'Query parameters for request as key value pairs',\n\theaders: 'Headers parameters for request as key value pairs',\n\tbody: 'Body parameters for request as key value pairs',\n};\n\nexport const updateParametersAndOptions = (options: {\n\tctx: ISupplyDataFunctions;\n\titemIndex: number;\n\ttoolParameters: ToolParameter[];\n\tplaceholdersDefinitions: PlaceholderDefinition[];\n\trequestOptions: IHttpRequestOptions;\n\trawRequestOptions: { [key: string]: string };\n\trequestOptionsProperty: 'headers' | 'qs' | 'body';\n\tinputTypePropertyName: string;\n\tjsonPropertyName: string;\n\tparametersPropertyName: string;\n}) => {\n\tconst {\n\t\tctx,\n\t\titemIndex,\n\t\ttoolParameters,\n\t\tplaceholdersDefinitions,\n\t\trequestOptions,\n\t\trawRequestOptions,\n\t\trequestOptionsProperty,\n\t\tinputTypePropertyName,\n\t\tjsonPropertyName,\n\t\tparametersPropertyName,\n\t} = options;\n\n\tconst inputType = ctx.getNodeParameter(\n\t\tinputTypePropertyName,\n\t\titemIndex,\n\t\t'keypair',\n\t) as ParameterInputType;\n\n\tlet parametersValues: ParametersValues = [];\n\n\tif (inputType === 'json') {\n\t\trawRequestOptions[requestOptionsProperty] = ctx.getNodeParameter(\n\t\t\tjsonPropertyName,\n\t\t\titemIndex,\n\t\t\t'',\n\t\t) as string;\n\t} else {\n\t\tparametersValues = ctx.getNodeParameter(\n\t\t\tparametersPropertyName,\n\t\t\titemIndex,\n\t\t\t[],\n\t\t) as ParametersValues;\n\t}\n\n\tconst inputParameters = prepareParameters(\n\t\tparametersValues,\n\t\tplaceholdersDefinitions,\n\t\tinputType,\n\t\trequestOptionsProperty,\n\t\tMODEL_INPUT_DESCRIPTION[requestOptionsProperty],\n\t\trawRequestOptions[requestOptionsProperty],\n\t);\n\n\ttoolParameters.push(...inputParameters.parameters);\n\n\trequestOptions[requestOptionsProperty] = {\n\t\t...(requestOptions[requestOptionsProperty] as IDataObject),\n\t\t...inputParameters.values,\n\t};\n};\n\nconst getParametersDescription = (parameters: ToolParameter[]) =>\n\tparameters\n\t\t.map(\n\t\t\t(p) =>\n\t\t\t\t`${p.name}: (description: ${p.description ?? ''}, type: ${p.type ?? 'string'}, required: ${!!p.required})`,\n\t\t)\n\t\t.join(',\\n ');\n\nexport const prepareToolDescription = (\n\ttoolDescription: string,\n\ttoolParameters: ToolParameter[],\n) => {\n\tlet description = `${toolDescription}`;\n\n\tif (toolParameters.length) {\n\t\tdescription += `\n\tTool expects valid stringified JSON object with ${toolParameters.length} properties.\n\tProperty names with description, type and required status:\n\t${getParametersDescription(toolParameters)}\n\tALL parameters marked as required must be provided`;\n\t}\n\n\treturn description;\n};\n\nexport const configureToolFunction = (\n\tctx: ISupplyDataFunctions,\n\titemIndex: number,\n\ttoolParameters: ToolParameter[],\n\trequestOptions: IHttpRequestOptions,\n\trawRequestOptions: { [key: string]: string },\n\thttpRequest: (options: IHttpRequestOptions) => Promise<any>,\n\toptimizeResponse: (response: string) => string,\n) => {\n\treturn async (query: string | IDataObject): Promise<string> => {\n\t\tconst { index } = ctx.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]]);\n\n\t\t// Clone options and rawRequestOptions to avoid mutating the original objects\n\t\tconst options: IHttpRequestOptions | null = structuredClone(requestOptions);\n\t\tconst clonedRawRequestOptions: { [key: string]: string } = structuredClone(rawRequestOptions);\n\t\tlet fullResponse: any;\n\t\tlet response: string = '';\n\t\tlet executionError: Error | undefined = undefined;\n\n\t\tif (!toolParameters.length) {\n\t\t\tquery = '{}';\n\t\t}\n\n\t\ttry {\n\t\t\tif (query) {\n\t\t\t\tlet dataFromModel;\n\n\t\t\t\tif (typeof query === 'string') {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tdataFromModel = jsonParse<IDataObject>(query);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (toolParameters.length === 1) {\n\t\t\t\t\t\t\tdataFromModel = { [toolParameters[0].name]: query };\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\t\tctx.getNode(),\n\t\t\t\t\t\t\t\t`Input is not a valid JSON: ${error.message}`,\n\t\t\t\t\t\t\t\t{ itemIndex },\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} else {\n\t\t\t\t\tdataFromModel = query;\n\t\t\t\t}\n\n\t\t\t\tfor (const parameter of toolParameters) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tparameter.required &&\n\t\t\t\t\t\t(dataFromModel[parameter.name] === undefined || dataFromModel[parameter.name] === null)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\tctx.getNode(),\n\t\t\t\t\t\t\t`Model did not provide parameter '${parameter.name}' which is required and must be present in the input`,\n\t\t\t\t\t\t\t{ itemIndex },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const parameter of toolParameters) {\n\t\t\t\t\tlet argument = dataFromModel[parameter.name];\n\n\t\t\t\t\tif (\n\t\t\t\t\t\targument &&\n\t\t\t\t\t\tparameter.type === 'json' &&\n\t\t\t\t\t\t!['qsRaw', 'headersRaw', 'bodyRaw'].includes(parameter.key ?? '') &&\n\t\t\t\t\t\ttypeof argument !== 'object'\n\t\t\t\t\t) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\targument = jsonParse(String(argument));\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\t\tctx.getNode(),\n\t\t\t\t\t\t\t\t`Parameter ${parameter.name} is not a valid JSON: ${error.message}`,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\titemIndex,\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\n\t\t\t\t\tif (parameter.sendIn === 'path') {\n\t\t\t\t\t\targument = String(argument);\n\n\t\t\t\t\t\t//remove \" or ' from start or end\n\t\t\t\t\t\targument = argument.replace(/^['\"]+|['\"]+$/g, '');\n\n\t\t\t\t\t\toptions.url = options.url.replace(`{${parameter.name}}`, argument);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (parameter.sendIn === parameter.name) {\n\t\t\t\t\t\tset(options, [parameter.sendIn], argument);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (['qsRaw', 'headersRaw', 'bodyRaw'].includes(parameter.key ?? '')) {\n\t\t\t\t\t\t//enclose string in quotes as user and model could omit them\n\t\t\t\t\t\tif (parameter.type === 'string') {\n\t\t\t\t\t\t\targument = String(argument);\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!argument.startsWith('\"') &&\n\t\t\t\t\t\t\t\t!clonedRawRequestOptions[parameter.sendIn].includes(`\"{${parameter.name}}\"`)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\targument = `\"${argument}\"`;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (typeof argument === 'object') {\n\t\t\t\t\t\t\targument = JSON.stringify(argument);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tclonedRawRequestOptions[parameter.sendIn] = clonedRawRequestOptions[\n\t\t\t\t\t\t\tparameter.sendIn\n\t\t\t\t\t\t].replace(`{${parameter.name}}`, String(argument));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (parameter.key) {\n\t\t\t\t\t\tlet requestOptionsValue = get(options, [parameter.sendIn, parameter.key]);\n\n\t\t\t\t\t\tif (typeof requestOptionsValue === 'string') {\n\t\t\t\t\t\t\trequestOptionsValue = requestOptionsValue.replace(\n\t\t\t\t\t\t\t\t`{${parameter.name}}`,\n\t\t\t\t\t\t\t\tString(argument),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tset(options, [parameter.sendIn, parameter.key], requestOptionsValue);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tset(options, [parameter.sendIn, parameter.name], argument);\n\t\t\t\t}\n\n\t\t\t\tfor (const [key, value] of Object.entries(clonedRawRequestOptions)) {\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tlet parsedValue;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tparsedValue = jsonParse<IDataObject>(value);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tlet recoveredData = '';\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\trecoveredData = value\n\t\t\t\t\t\t\t\t\t.replace(/'/g, '\"') // Replace single quotes with double quotes\n\t\t\t\t\t\t\t\t\t.replace(/(['\"])?([a-zA-Z0-9_]+)(['\"])?:/g, '\"$2\":') // Wrap keys in double quotes\n\t\t\t\t\t\t\t\t\t.replace(/,\\s*([\\]}])/g, '$1') // Remove trailing commas from objects\n\t\t\t\t\t\t\t\t\t.replace(/,+$/, ''); // Remove trailing comma\n\t\t\t\t\t\t\t\tparsedValue = jsonParse<IDataObject>(recoveredData);\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\t\t\tctx.getNode(),\n\t\t\t\t\t\t\t\t\t`Could not replace placeholders in ${key}: ${error.message}`,\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\toptions[key as 'qs' | 'headers' | 'body'] = parsedValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (options) {\n\t\t\t\toptions.url = encodeURI(options.url);\n\n\t\t\t\tif (options.headers && !Object.keys(options.headers).length) {\n\t\t\t\t\tdelete options.headers;\n\t\t\t\t}\n\t\t\t\tif (options.qs && !Object.keys(options.qs).length) {\n\t\t\t\t\tdelete options.qs;\n\t\t\t\t}\n\t\t\t\tif (options.body && !Object.keys(options.body).length) {\n\t\t\t\t\tdelete options.body;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage = 'Input provided by model is not valid';\n\n\t\t\tif (error instanceof NodeOperationError) {\n\t\t\t\texecutionError = error;\n\t\t\t} else {\n\t\t\t\texecutionError = new NodeOperationError(ctx.getNode(), errorMessage, {\n\t\t\t\t\titemIndex,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tresponse = errorMessage;\n\t\t}\n\n\t\tif (options) {\n\t\t\ttry {\n\t\t\t\tfullResponse = await httpRequest(options);\n\t\t\t} catch (error) {\n\t\t\t\tconst httpCode = (error as NodeApiError).httpCode;\n\t\t\t\tresponse = `${httpCode ? `HTTP ${httpCode} ` : ''}There was an error: \"${error.message}\"`;\n\t\t\t}\n\n\t\t\tif (!response) {\n\t\t\t\ttry {\n\t\t\t\t\t// Check if the response is binary data\n\t\t\t\t\tif (fullResponse.body && isBinary(fullResponse.body)) {\n\t\t\t\t\t\tthrow new NodeOperationError(ctx.getNode(), 'Binary data is not supported');\n\t\t\t\t\t}\n\n\t\t\t\t\tresponse = optimizeResponse(fullResponse.body ?? fullResponse);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tresponse = `There was an error: \"${error.message}\"`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (typeof response !== 'string') {\n\t\t\texecutionError = new NodeOperationError(ctx.getNode(), 'Wrong output type returned', {\n\t\t\t\tdescription: `The response property should be a string, but it is an ${typeof response}`,\n\t\t\t});\n\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t}\n\n\t\tif (executionError) {\n\t\t\tvoid ctx.addOutputData(NodeConnectionTypes.AiTool, index, executionError as ExecutionError);\n\t\t} else {\n\t\t\tvoid ctx.addOutputData(NodeConnectionTypes.AiTool, index, [[{ json: { response } }]]);\n\t\t}\n\n\t\treturn response;\n\t};\n};\n\nfunction makeParameterZodSchema(parameter: ToolParameter) {\n\tlet schema: z.ZodTypeAny;\n\n\tif (parameter.type === 'string') {\n\t\tschema = z.string();\n\t} else if (parameter.type === 'number') {\n\t\tschema = z.number();\n\t} else if (parameter.type === 'boolean') {\n\t\tschema = z.boolean();\n\t} else if (parameter.type === 'json') {\n\t\tschema = z.record(z.any());\n\t} else {\n\t\tschema = z.string();\n\t}\n\n\tif (!parameter.required) {\n\t\tschema = schema.optional();\n\t}\n\n\tif (parameter.description) {\n\t\tschema = schema.describe(parameter.description);\n\t}\n\n\treturn schema;\n}\n\nexport function makeToolInputSchema(parameters: ToolParameter[]): DynamicZodObject {\n\tconst schemaEntries = parameters.map((parameter) => [\n\t\tparameter.name,\n\t\tmakeParameterZodSchema(parameter),\n\t]);\n\n\treturn z.object(Object.fromEntries(schemaEntries));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA4B;AAC5B,cAAyB;AACzB,0BAAwB;AACxB,mBAAsB;AACtB,iBAAgB;AAChB,iBAAgB;AAChB,mBAAkB;AAClB,8BAA8C;AAS9C,0BAAmE;AACnE,iBAAkB;AAYlB,MAAM,2BAA2B,OAAO,KAA2B,cAAsB;AACxF,QAAM,cAAc,IAAI,iBAAiB,mBAAmB,SAAS;AAErE,MAAI,gBAAgB,mBAAmB,gBAAgB,kBAAkB;AACxE,UAAM,YAAY,MAAM,IAAI,eAAe,iBAAiB,SAAS;AACrE,UAAM,kBAAkB,gBAAgB,mBAAmB,QAAQ;AAEnE,WAAO,OAAO,YAAiC;AAC9C,cAAQ,OAAO;AAAA,QACd,UAAU,UAAU;AAAA,QACpB,UAAU,UAAU;AAAA,QACpB;AAAA,MACD;AACA,aAAO,MAAM,IAAI,QAAQ,YAAY,OAAO;AAAA,IAC7C;AAAA,EACD;AAEA,MAAI,gBAAgB,kBAAkB;AACrC,UAAM,aAAa,MAAM,IAAI,eAAe,kBAAkB,SAAS;AAEvE,WAAO,OAAO,YAAiC;AAC9C,UAAI,CAAC,QAAQ,QAAS,SAAQ,UAAU,CAAC;AACzC,cAAQ,QAAQ,WAAW,IA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ttpRequest/utils.ts"],"sourcesContent":["import { Readability } from '@mozilla/readability';\nimport * as cheerio from 'cheerio';\nimport { convert } from 'html-to-text';\nimport { JSDOM } from 'jsdom';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\nimport unset from 'lodash/unset';\nimport { getOAuth2AdditionalParameters } from 'n8n-nodes-base/dist/nodes/HttpRequest/GenericFunctions';\nimport type {\n\tIDataObject,\n\tIHttpRequestOptions,\n\tIRequestOptionsSimplified,\n\tExecutionError,\n\tNodeApiError,\n\tISupplyDataFunctions,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes, NodeOperationError, jsonParse } from 'n8n-workflow';\nimport { z } from 'zod';\n\nimport type {\n\tParameterInputType,\n\tParametersValues,\n\tPlaceholderDefinition,\n\tParametersValues as RawParametersValues,\n\tSendIn,\n\tToolParameter,\n} from './interfaces';\nimport type { DynamicZodObject } from '../../../types/zod.types';\n\nconst genericCredentialRequest = async (ctx: ISupplyDataFunctions, itemIndex: number) => {\n\tconst genericType = ctx.getNodeParameter('genericAuthType', itemIndex) as string;\n\n\tif (genericType === 'httpBasicAuth' || genericType === 'httpDigestAuth') {\n\t\tconst basicAuth = await ctx.getCredentials('httpBasicAuth', itemIndex);\n\t\tconst sendImmediately = genericType === 'httpDigestAuth' ? false : undefined;\n\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\toptions.auth = {\n\t\t\t\tusername: basicAuth.user as string,\n\t\t\t\tpassword: basicAuth.password as string,\n\t\t\t\tsendImmediately,\n\t\t\t};\n\t\t\treturn await ctx.helpers.httpRequest(options);\n\t\t};\n\t}\n\n\tif (genericType === 'httpHeaderAuth') {\n\t\tconst headerAuth = await ctx.getCredentials('httpHeaderAuth', itemIndex);\n\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\tif (!options.headers) options.headers = {};\n\t\t\toptions.headers[headerAuth.name as string] = headerAuth.value;\n\t\t\treturn await ctx.helpers.httpRequest(options);\n\t\t};\n\t}\n\n\tif (genericType === 'httpQueryAuth') {\n\t\tconst queryAuth = await ctx.getCredentials('httpQueryAuth', itemIndex);\n\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\tif (!options.qs) options.qs = {};\n\t\t\toptions.qs[queryAuth.name as string] = queryAuth.value;\n\t\t\treturn await ctx.helpers.httpRequest(options);\n\t\t};\n\t}\n\n\tif (genericType === 'httpCustomAuth') {\n\t\tconst customAuth = await ctx.getCredentials('httpCustomAuth', itemIndex);\n\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\tconst auth = jsonParse<IRequestOptionsSimplified>((customAuth.json as string) || '{}', {\n\t\t\t\terrorMessage: 'Invalid Custom Auth JSON',\n\t\t\t});\n\t\t\tif (auth.headers) {\n\t\t\t\toptions.headers = { ...options.headers, ...auth.headers };\n\t\t\t}\n\t\t\tif (auth.body) {\n\t\t\t\toptions.body = { ...(options.body as IDataObject), ...auth.body };\n\t\t\t}\n\t\t\tif (auth.qs) {\n\t\t\t\toptions.qs = { ...options.qs, ...auth.qs };\n\t\t\t}\n\t\t\treturn await ctx.helpers.httpRequest(options);\n\t\t};\n\t}\n\n\tif (genericType === 'oAuth1Api') {\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\treturn await ctx.helpers.requestOAuth1.call(ctx, 'oAuth1Api', options);\n\t\t};\n\t}\n\n\tif (genericType === 'oAuth2Api') {\n\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\treturn await ctx.helpers.requestOAuth2.call(ctx, 'oAuth2Api', options, {\n\t\t\t\ttokenType: 'Bearer',\n\t\t\t});\n\t\t};\n\t}\n\n\tthrow new NodeOperationError(ctx.getNode(), `The type ${genericType} is not supported`, {\n\t\titemIndex,\n\t});\n};\n\nconst predefinedCredentialRequest = async (ctx: ISupplyDataFunctions, itemIndex: number) => {\n\tconst predefinedType = ctx.getNodeParameter('nodeCredentialType', itemIndex) as string;\n\tconst additionalOptions = getOAuth2AdditionalParameters(predefinedType);\n\n\treturn async (options: IHttpRequestOptions) => {\n\t\treturn await ctx.helpers.httpRequestWithAuthentication.call(\n\t\t\tctx,\n\t\t\tpredefinedType,\n\t\t\toptions,\n\t\t\tadditionalOptions && { oauth2: additionalOptions },\n\t\t);\n\t};\n};\n\nexport const configureHttpRequestFunction = async (\n\tctx: ISupplyDataFunctions,\n\tcredentialsType: 'predefinedCredentialType' | 'genericCredentialType' | 'none',\n\titemIndex: number,\n) => {\n\tswitch (credentialsType) {\n\t\tcase 'genericCredentialType':\n\t\t\treturn await genericCredentialRequest(ctx, itemIndex);\n\t\tcase 'predefinedCredentialType':\n\t\t\treturn await predefinedCredentialRequest(ctx, itemIndex);\n\t\tdefault:\n\t\t\treturn async (options: IHttpRequestOptions) => {\n\t\t\t\treturn await ctx.helpers.httpRequest(options);\n\t\t\t};\n\t}\n};\n\nconst defaultOptimizer = <T>(response: T) => {\n\tif (typeof response === 'string') {\n\t\treturn response;\n\t}\n\tif (typeof response === 'object') {\n\t\treturn JSON.stringify(response, null, 2);\n\t}\n\n\treturn String(response);\n};\n\nfunction isBinary(data: unknown) {\n\t// Check if data is a Buffer\n\tif (Buffer.isBuffer(data)) {\n\t\treturn true;\n\t}\n\n\t// If data is a string, assume it's text unless it contains null characters.\n\tif (typeof data === 'string') {\n\t\t// If the string contains a null character, it's likely binary.\n\t\tif (data.includes('\\0')) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t// For any other type, assume it's not binary.\n\treturn false;\n}\n\nconst htmlOptimizer = (ctx: ISupplyDataFunctions, itemIndex: number, maxLength: number) => {\n\tconst cssSelector = ctx.getNodeParameter('cssSelector', itemIndex, '') as string;\n\tconst onlyContent = ctx.getNodeParameter('onlyContent', itemIndex, false) as boolean;\n\tlet elementsToOmit: string[] = [];\n\n\tif (onlyContent) {\n\t\tconst elementsToOmitUi = ctx.getNodeParameter('elementsToOmit', itemIndex, '') as\n\t\t\t| string\n\t\t\t| string[];\n\n\t\tif (typeof elementsToOmitUi === 'string') {\n\t\t\telementsToOmit = elementsToOmitUi\n\t\t\t\t.split(',')\n\t\t\t\t.filter((s) => s)\n\t\t\t\t.map((s) => s.trim());\n\t\t}\n\t}\n\n\treturn <T>(response: T) => {\n\t\tif (typeof response !== 'string') {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t`The response type must be a string. Received: ${typeof response}`,\n\t\t\t\t{ itemIndex },\n\t\t\t);\n\t\t}\n\t\tconst returnData: string[] = [];\n\n\t\tconst html = cheerio.load(response);\n\t\tconst htmlElements = html(cssSelector);\n\n\t\thtmlElements.each((_, el) => {\n\t\t\tlet value = html(el).html() || '';\n\n\t\t\tif (onlyContent) {\n\t\t\t\tlet htmlToTextOptions;\n\n\t\t\t\tif (elementsToOmit?.length) {\n\t\t\t\t\thtmlToTextOptions = {\n\t\t\t\t\t\tselectors: elementsToOmit.map((selector) => ({\n\t\t\t\t\t\t\tselector,\n\t\t\t\t\t\t\tformat: 'skip',\n\t\t\t\t\t\t})),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tvalue = convert(value, htmlToTextOptions);\n\t\t\t}\n\n\t\t\tvalue = value\n\t\t\t\t.trim()\n\t\t\t\t.replace(/^\\s+|\\s+$/g, '')\n\t\t\t\t.replace(/(\\r\\n|\\n|\\r)/gm, '')\n\t\t\t\t.replace(/\\s+/g, ' ');\n\n\t\t\treturnData.push(value);\n\t\t});\n\n\t\tconst text = JSON.stringify(returnData, null, 2);\n\n\t\tif (maxLength > 0 && text.length > maxLength) {\n\t\t\treturn text.substring(0, maxLength);\n\t\t}\n\n\t\treturn text;\n\t};\n};\n\nconst textOptimizer = (ctx: ISupplyDataFunctions, itemIndex: number, maxLength: number) => {\n\treturn (response: string | IDataObject) => {\n\t\tif (typeof response === 'object') {\n\t\t\ttry {\n\t\t\t\tresponse = JSON.stringify(response, null, 2);\n\t\t\t} catch (error) {}\n\t\t}\n\n\t\tif (typeof response !== 'string') {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t`The response type must be a string. Received: ${typeof response}`,\n\t\t\t\t{ itemIndex },\n\t\t\t);\n\t\t}\n\n\t\tconst dom = new JSDOM(response);\n\t\tconst article = new Readability(dom.window.document, {\n\t\t\tkeepClasses: true,\n\t\t}).parse();\n\n\t\tconst text = article?.textContent || '';\n\n\t\tif (maxLength > 0 && text.length > maxLength) {\n\t\t\treturn text.substring(0, maxLength);\n\t\t}\n\n\t\treturn text;\n\t};\n};\n\nconst jsonOptimizer = (ctx: ISupplyDataFunctions, itemIndex: number) => {\n\treturn (response: string): string => {\n\t\tlet responseData: IDataObject | IDataObject[] | string = response;\n\n\t\tif (typeof responseData === 'string') {\n\t\t\tresponseData = jsonParse(response);\n\t\t}\n\n\t\tif (typeof responseData !== 'object' || !responseData) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t'The response type must be an object or an array of objects',\n\t\t\t\t{ itemIndex },\n\t\t\t);\n\t\t}\n\n\t\tconst dataField = ctx.getNodeParameter('dataField', itemIndex, '') as string;\n\t\tlet returnData: IDataObject[] = [];\n\n\t\tif (!Array.isArray(responseData)) {\n\t\t\tif (dataField) {\n\t\t\t\tconst data = responseData[dataField] as IDataObject | IDataObject[];\n\t\t\t\tif (Array.isArray(data)) {\n\t\t\t\t\tresponseData = data;\n\t\t\t\t} else {\n\t\t\t\t\tresponseData = [data];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresponseData = [responseData];\n\t\t\t}\n\t\t} else {\n\t\t\tif (dataField) {\n\t\t\t\tresponseData = responseData.map((data) => data[dataField]) as IDataObject[];\n\t\t\t}\n\t\t}\n\n\t\tconst fieldsToInclude = ctx.getNodeParameter('fieldsToInclude', itemIndex, 'all') as\n\t\t\t| 'all'\n\t\t\t| 'selected'\n\t\t\t| 'except';\n\n\t\tlet fields: string | string[] = [];\n\n\t\tif (fieldsToInclude !== 'all') {\n\t\t\tfields = ctx.getNodeParameter('fields', itemIndex, []) as string[] | string;\n\n\t\t\tif (typeof fields === 'string') {\n\t\t\t\tfields = fields.split(',').map((field) => field.trim());\n\t\t\t}\n\t\t} else {\n\t\t\treturnData = responseData;\n\t\t}\n\n\t\tif (fieldsToInclude === 'selected') {\n\t\t\tfor (const item of responseData) {\n\t\t\t\tconst newItem: IDataObject = {};\n\n\t\t\t\tfor (const field of fields) {\n\t\t\t\t\tset(newItem, field, get(item, field));\n\t\t\t\t}\n\n\t\t\t\treturnData.push(newItem);\n\t\t\t}\n\t\t}\n\n\t\tif (fieldsToInclude === 'except') {\n\t\t\tfor (const item of responseData) {\n\t\t\t\tfor (const field of fields) {\n\t\t\t\t\tunset(item, field);\n\t\t\t\t}\n\n\t\t\t\treturnData.push(item);\n\t\t\t}\n\t\t}\n\n\t\treturn JSON.stringify(returnData, null, 2);\n\t};\n};\n\nexport const configureResponseOptimizer = (ctx: ISupplyDataFunctions, itemIndex: number) => {\n\tconst optimizeResponse = ctx.getNodeParameter('optimizeResponse', itemIndex, false) as boolean;\n\n\tif (optimizeResponse) {\n\t\tconst responseType = ctx.getNodeParameter('responseType', itemIndex) as\n\t\t\t| 'json'\n\t\t\t| 'text'\n\t\t\t| 'html';\n\n\t\tlet maxLength = 0;\n\t\tconst truncateResponse = ctx.getNodeParameter('truncateResponse', itemIndex, false) as boolean;\n\n\t\tif (truncateResponse) {\n\t\t\tmaxLength = ctx.getNodeParameter('maxLength', itemIndex, 0) as number;\n\t\t}\n\n\t\tswitch (responseType) {\n\t\t\tcase 'html':\n\t\t\t\treturn htmlOptimizer(ctx, itemIndex, maxLength);\n\t\t\tcase 'text':\n\t\t\t\treturn textOptimizer(ctx, itemIndex, maxLength);\n\t\t\tcase 'json':\n\t\t\t\treturn jsonOptimizer(ctx, itemIndex);\n\t\t}\n\t}\n\n\treturn defaultOptimizer;\n};\n\nconst extractPlaceholders = (text: string): string[] => {\n\tconst placeholder = /(\\{[a-zA-Z0-9_-]+\\})/g;\n\tconst returnData: string[] = [];\n\n\tconst matches = text.matchAll(placeholder);\n\n\tfor (const match of matches) {\n\t\treturnData.push(match[0].replace(/{|}/g, ''));\n\t}\n\n\treturn returnData;\n};\n\nexport const extractParametersFromText = (\n\tplaceholders: PlaceholderDefinition[],\n\ttext: string,\n\tsendIn: SendIn,\n\tkey?: string,\n): ToolParameter[] => {\n\tif (typeof text !== 'string') return [];\n\n\tconst parameters = extractPlaceholders(text);\n\n\tif (parameters.length) {\n\t\tconst inputParameters = prepareParameters(\n\t\t\tparameters.map((name) => ({\n\t\t\t\tname,\n\t\t\t\tvalueProvider: 'modelRequired',\n\t\t\t})),\n\t\t\tplaceholders,\n\t\t\t'keypair',\n\t\t\tsendIn,\n\t\t\t'',\n\t\t);\n\n\t\treturn key\n\t\t\t? inputParameters.parameters.map((p) => ({ ...p, key }))\n\t\t\t: inputParameters.parameters;\n\t}\n\n\treturn [];\n};\n\nfunction prepareParameters(\n\trawParameters: RawParametersValues,\n\tplaceholders: PlaceholderDefinition[],\n\tparametersInputType: 'model' | 'keypair' | 'json',\n\tsendIn: SendIn,\n\tmodelInputDescription: string,\n\tjsonWithPlaceholders?: string,\n): { parameters: ToolParameter[]; values: IDataObject } {\n\tconst parameters: ToolParameter[] = [];\n\tconst values: IDataObject = {};\n\n\tif (parametersInputType === 'model') {\n\t\treturn {\n\t\t\tparameters: [\n\t\t\t\t{\n\t\t\t\t\tname: sendIn,\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttype: 'json',\n\t\t\t\t\tdescription: modelInputDescription,\n\t\t\t\t\tsendIn,\n\t\t\t\t},\n\t\t\t],\n\t\t\tvalues: {},\n\t\t};\n\t}\n\n\tif (parametersInputType === 'keypair') {\n\t\tfor (const entry of rawParameters) {\n\t\t\tif (entry.valueProvider.includes('model')) {\n\t\t\t\tconst placeholder = placeholders.find((p) => p.name === entry.name);\n\n\t\t\t\tconst parameter: ToolParameter = {\n\t\t\t\t\tname: entry.name,\n\t\t\t\t\trequired: entry.valueProvider === 'modelRequired',\n\t\t\t\t\tsendIn,\n\t\t\t\t};\n\n\t\t\t\tif (placeholder) {\n\t\t\t\t\tparameter.type = placeholder.type;\n\t\t\t\t\tparameter.description = placeholder.description;\n\t\t\t\t}\n\n\t\t\t\tparameters.push(parameter);\n\t\t\t} else if (entry.value) {\n\t\t\t\t// if value has placeholders push them to parameters\n\t\t\t\tparameters.push(\n\t\t\t\t\t...extractParametersFromText(placeholders, entry.value, sendIn, entry.name),\n\t\t\t\t);\n\t\t\t\tvalues[entry.name] = entry.value; //push to user provided values\n\t\t\t}\n\t\t}\n\t}\n\n\tif (parametersInputType === 'json' && jsonWithPlaceholders) {\n\t\tparameters.push(\n\t\t\t...extractParametersFromText(placeholders, jsonWithPlaceholders, sendIn, `${sendIn + 'Raw'}`),\n\t\t);\n\t}\n\n\treturn {\n\t\tparameters,\n\t\tvalues,\n\t};\n}\n\nconst MODEL_INPUT_DESCRIPTION = {\n\tqs: 'Query parameters for request as key value pairs',\n\theaders: 'Headers parameters for request as key value pairs',\n\tbody: 'Body parameters for request as key value pairs',\n};\n\nexport const updateParametersAndOptions = (options: {\n\tctx: ISupplyDataFunctions;\n\titemIndex: number;\n\ttoolParameters: ToolParameter[];\n\tplaceholdersDefinitions: PlaceholderDefinition[];\n\trequestOptions: IHttpRequestOptions;\n\trawRequestOptions: { [key: string]: string };\n\trequestOptionsProperty: 'headers' | 'qs' | 'body';\n\tinputTypePropertyName: string;\n\tjsonPropertyName: string;\n\tparametersPropertyName: string;\n}) => {\n\tconst {\n\t\tctx,\n\t\titemIndex,\n\t\ttoolParameters,\n\t\tplaceholdersDefinitions,\n\t\trequestOptions,\n\t\trawRequestOptions,\n\t\trequestOptionsProperty,\n\t\tinputTypePropertyName,\n\t\tjsonPropertyName,\n\t\tparametersPropertyName,\n\t} = options;\n\n\tconst inputType = ctx.getNodeParameter(\n\t\tinputTypePropertyName,\n\t\titemIndex,\n\t\t'keypair',\n\t) as ParameterInputType;\n\n\tlet parametersValues: ParametersValues = [];\n\n\tif (inputType === 'json') {\n\t\trawRequestOptions[requestOptionsProperty] = ctx.getNodeParameter(\n\t\t\tjsonPropertyName,\n\t\t\titemIndex,\n\t\t\t'',\n\t\t) as string;\n\t} else {\n\t\tparametersValues = ctx.getNodeParameter(\n\t\t\tparametersPropertyName,\n\t\t\titemIndex,\n\t\t\t[],\n\t\t) as ParametersValues;\n\t}\n\n\tconst inputParameters = prepareParameters(\n\t\tparametersValues,\n\t\tplaceholdersDefinitions,\n\t\tinputType,\n\t\trequestOptionsProperty,\n\t\tMODEL_INPUT_DESCRIPTION[requestOptionsProperty],\n\t\trawRequestOptions[requestOptionsProperty],\n\t);\n\n\ttoolParameters.push(...inputParameters.parameters);\n\n\trequestOptions[requestOptionsProperty] = {\n\t\t...(requestOptions[requestOptionsProperty] as IDataObject),\n\t\t...inputParameters.values,\n\t};\n};\n\nconst getParametersDescription = (parameters: ToolParameter[]) =>\n\tparameters\n\t\t.map(\n\t\t\t(p) =>\n\t\t\t\t`${p.name}: (description: ${p.description ?? ''}, type: ${p.type ?? 'string'}, required: ${!!p.required})`,\n\t\t)\n\t\t.join(',\\n ');\n\nexport const prepareToolDescription = (\n\ttoolDescription: string,\n\ttoolParameters: ToolParameter[],\n) => {\n\tlet description = `${toolDescription}`;\n\n\tif (toolParameters.length) {\n\t\tdescription += `\n\tTool expects valid stringified JSON object with ${toolParameters.length} properties.\n\tProperty names with description, type and required status:\n\t${getParametersDescription(toolParameters)}\n\tALL parameters marked as required must be provided`;\n\t}\n\n\treturn description;\n};\n\nexport const configureToolFunction = (\n\tctx: ISupplyDataFunctions,\n\titemIndex: number,\n\ttoolParameters: ToolParameter[],\n\trequestOptions: IHttpRequestOptions,\n\trawRequestOptions: { [key: string]: string },\n\thttpRequest: (options: IHttpRequestOptions) => Promise<any>,\n\toptimizeResponse: (response: string) => string,\n) => {\n\treturn async (query: string | IDataObject): Promise<string> => {\n\t\tconst { index } = ctx.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]]);\n\n\t\t// Clone options and rawRequestOptions to avoid mutating the original objects\n\t\tconst options: IHttpRequestOptions | null = structuredClone(requestOptions);\n\t\tconst clonedRawRequestOptions: { [key: string]: string } = structuredClone(rawRequestOptions);\n\t\tlet fullResponse: any;\n\t\tlet response: string = '';\n\t\tlet executionError: Error | undefined = undefined;\n\n\t\tif (!toolParameters.length) {\n\t\t\tquery = '{}';\n\t\t}\n\n\t\ttry {\n\t\t\tif (query) {\n\t\t\t\tlet dataFromModel;\n\n\t\t\t\tif (typeof query === 'string') {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tdataFromModel = jsonParse<IDataObject>(query);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (toolParameters.length === 1) {\n\t\t\t\t\t\t\tdataFromModel = { [toolParameters[0].name]: query };\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\t\tctx.getNode(),\n\t\t\t\t\t\t\t\t`Input is not a valid JSON: ${error.message}`,\n\t\t\t\t\t\t\t\t{ itemIndex },\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} else {\n\t\t\t\t\tdataFromModel = query;\n\t\t\t\t}\n\n\t\t\t\tfor (const parameter of toolParameters) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tparameter.required &&\n\t\t\t\t\t\t(dataFromModel[parameter.name] === undefined || dataFromModel[parameter.name] === null)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\tctx.getNode(),\n\t\t\t\t\t\t\t`Model did not provide parameter '${parameter.name}' which is required and must be present in the input`,\n\t\t\t\t\t\t\t{ itemIndex },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const parameter of toolParameters) {\n\t\t\t\t\tlet argument = dataFromModel[parameter.name];\n\n\t\t\t\t\tif (\n\t\t\t\t\t\targument &&\n\t\t\t\t\t\tparameter.type === 'json' &&\n\t\t\t\t\t\t!['qsRaw', 'headersRaw', 'bodyRaw'].includes(parameter.key ?? '') &&\n\t\t\t\t\t\ttypeof argument !== 'object'\n\t\t\t\t\t) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\targument = jsonParse(String(argument));\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\t\tctx.getNode(),\n\t\t\t\t\t\t\t\t`Parameter ${parameter.name} is not a valid JSON: ${error.message}`,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\titemIndex,\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\n\t\t\t\t\tif (parameter.sendIn === 'path') {\n\t\t\t\t\t\targument = String(argument);\n\n\t\t\t\t\t\t//remove \" or ' from start or end\n\t\t\t\t\t\targument = argument.replace(/^['\"]+|['\"]+$/g, '');\n\n\t\t\t\t\t\toptions.url = options.url.replace(`{${parameter.name}}`, argument);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (parameter.sendIn === parameter.name) {\n\t\t\t\t\t\tset(options, [parameter.sendIn], argument);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (['qsRaw', 'headersRaw', 'bodyRaw'].includes(parameter.key ?? '')) {\n\t\t\t\t\t\t//enclose string in quotes as user and model could omit them\n\t\t\t\t\t\tif (parameter.type === 'string') {\n\t\t\t\t\t\t\targument = String(argument);\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!argument.startsWith('\"') &&\n\t\t\t\t\t\t\t\t!clonedRawRequestOptions[parameter.sendIn].includes(`\"{${parameter.name}}\"`)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\targument = `\"${argument}\"`;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (typeof argument === 'object') {\n\t\t\t\t\t\t\targument = JSON.stringify(argument);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tclonedRawRequestOptions[parameter.sendIn] = clonedRawRequestOptions[\n\t\t\t\t\t\t\tparameter.sendIn\n\t\t\t\t\t\t].replace(`{${parameter.name}}`, String(argument));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (parameter.key) {\n\t\t\t\t\t\tlet requestOptionsValue = get(options, [parameter.sendIn, parameter.key]);\n\n\t\t\t\t\t\tif (typeof requestOptionsValue === 'string') {\n\t\t\t\t\t\t\trequestOptionsValue = requestOptionsValue.replace(\n\t\t\t\t\t\t\t\t`{${parameter.name}}`,\n\t\t\t\t\t\t\t\tString(argument),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tset(options, [parameter.sendIn, parameter.key], requestOptionsValue);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tset(options, [parameter.sendIn, parameter.name], argument);\n\t\t\t\t}\n\n\t\t\t\tfor (const [key, value] of Object.entries(clonedRawRequestOptions)) {\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tlet parsedValue;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tparsedValue = jsonParse<IDataObject>(value);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tlet recoveredData = '';\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\trecoveredData = value\n\t\t\t\t\t\t\t\t\t.replace(/'/g, '\"') // Replace single quotes with double quotes\n\t\t\t\t\t\t\t\t\t.replace(/(['\"])?([a-zA-Z0-9_]+)(['\"])?:/g, '\"$2\":') // Wrap keys in double quotes\n\t\t\t\t\t\t\t\t\t.replace(/,\\s*([\\]}])/g, '$1') // Remove trailing commas from objects\n\t\t\t\t\t\t\t\t\t.replace(/,+$/, ''); // Remove trailing comma\n\t\t\t\t\t\t\t\tparsedValue = jsonParse<IDataObject>(recoveredData);\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\t\t\tctx.getNode(),\n\t\t\t\t\t\t\t\t\t`Could not replace placeholders in ${key}: ${error.message}`,\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\toptions[key as 'qs' | 'headers' | 'body'] = parsedValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (options) {\n\t\t\t\toptions.url = encodeURI(options.url);\n\n\t\t\t\tif (options.headers && !Object.keys(options.headers).length) {\n\t\t\t\t\tdelete options.headers;\n\t\t\t\t}\n\t\t\t\tif (options.qs && !Object.keys(options.qs).length) {\n\t\t\t\t\tdelete options.qs;\n\t\t\t\t}\n\t\t\t\tif (options.body && !Object.keys(options.body).length) {\n\t\t\t\t\tdelete options.body;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage = 'Input provided by model is not valid';\n\n\t\t\tif (error instanceof NodeOperationError) {\n\t\t\t\texecutionError = error;\n\t\t\t} else {\n\t\t\t\texecutionError = new NodeOperationError(ctx.getNode(), errorMessage, {\n\t\t\t\t\titemIndex,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tresponse = errorMessage;\n\t\t}\n\n\t\tif (options) {\n\t\t\ttry {\n\t\t\t\tfullResponse = await httpRequest(options);\n\t\t\t} catch (error) {\n\t\t\t\tconst httpCode = (error as NodeApiError).httpCode;\n\t\t\t\tresponse = `${httpCode ? `HTTP ${httpCode} ` : ''}There was an error: \"${error.message}\"`;\n\t\t\t}\n\n\t\t\tif (!response) {\n\t\t\t\ttry {\n\t\t\t\t\t// Check if the response is binary data\n\t\t\t\t\tif (fullResponse.body && isBinary(fullResponse.body)) {\n\t\t\t\t\t\tthrow new NodeOperationError(ctx.getNode(), 'Binary data is not supported');\n\t\t\t\t\t}\n\n\t\t\t\t\tresponse = optimizeResponse(fullResponse.body ?? fullResponse);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tresponse = `There was an error: \"${error.message}\"`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (typeof response !== 'string') {\n\t\t\texecutionError = new NodeOperationError(ctx.getNode(), 'Wrong output type returned', {\n\t\t\t\tdescription: `The response property should be a string, but it is an ${typeof response}`,\n\t\t\t});\n\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t}\n\n\t\tif (executionError) {\n\t\t\tvoid ctx.addOutputData(NodeConnectionTypes.AiTool, index, executionError as ExecutionError);\n\t\t} else {\n\t\t\tvoid ctx.addOutputData(NodeConnectionTypes.AiTool, index, [[{ json: { response } }]]);\n\t\t}\n\n\t\treturn response;\n\t};\n};\n\nfunction makeParameterZodSchema(parameter: ToolParameter) {\n\tlet schema: z.ZodTypeAny;\n\n\tif (parameter.type === 'string') {\n\t\tschema = z.string();\n\t} else if (parameter.type === 'number') {\n\t\tschema = z.number();\n\t} else if (parameter.type === 'boolean') {\n\t\tschema = z.boolean();\n\t} else if (parameter.type === 'json') {\n\t\tschema = z.record(z.any());\n\t} else {\n\t\tschema = z.string();\n\t}\n\n\tif (!parameter.required) {\n\t\tschema = schema.optional();\n\t}\n\n\tif (parameter.description) {\n\t\tschema = schema.describe(parameter.description);\n\t}\n\n\treturn schema;\n}\n\nexport function makeToolInputSchema(parameters: ToolParameter[]): DynamicZodObject {\n\tconst schemaEntries = parameters.map((parameter) => [\n\t\tparameter.name,\n\t\tmakeParameterZodSchema(parameter),\n\t]);\n\n\treturn z.object(Object.fromEntries(schemaEntries));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA4B;AAC5B,cAAyB;AACzB,0BAAwB;AACxB,mBAAsB;AACtB,iBAAgB;AAChB,iBAAgB;AAChB,mBAAkB;AAClB,8BAA8C;AAS9C,0BAAmE;AACnE,iBAAkB;AAYlB,M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A,EACnB,WAAW,UAAU,SAAS,WAAW;AACxC,aAAS,aAAE,QAAQ;AAAA,EACpB,WAAW,UAAU,SAAS,QAAQ;AACrC,aAAS,aAAE,OAAO,aAAE,IAAI,CAAC;AAAA,EAC1B,OAAO;AACN,aAAS,aAAE,OAAO;AAAA,EACnB;AAEA,MAAI,CAAC,UAAU,UAAU;AACxB,aAAS,OAAO,SAAS;AAAA,EAC1B;AAEA,MAAI,UAAU,aAAa;AAC1B,aAAS,OAAO,SAAS,UAAU,WAAW;AAAA,EAC/C;AAEA,SAAO;AACR;AAEO,SAAS,oBAAoB,YAA+C;AAClF,QAAM,gBAAgB,WAAW,IAAI,CAAC,cAAc;AAAA,IACnD,UAAU;AAAA,IACV,uBAAuB,SAAS;AAAA,EACjC,CAAC;AAED,SAAO,aAAE,OAAO,OAAO,YAAY,aAAa,CAAC;AAClD;","names":["set","get","unset"]}
@@ -51,9 +51,7 @@ class ToolSerpApi {
51
51
  ]
52
52
  }
53
53
  },
54
- // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
55
54
  inputs: [],
56
- // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
57
55
  outputs: [import_n8n_workflow.NodeConnectionTypes.AiTool],
58
56
  outputNames: ["Tool"],
59
57
  credentials: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/tools/ToolSerpApi/ToolSerpApi.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { SerpAPI } from '@langchain/community/tools/serpapi';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class ToolSerpApi implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'SerpApi (Google Search)',\n\t\tname: 'toolSerpApi',\n\t\ticon: 'file:serpApi.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Search in Google using SerpAPI',\n\t\tdefaults: {\n\t\t\tname: 'SerpAPI',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolserpapi/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'serpApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Country',\n\t\t\t\t\t\tname: 'gl',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdefault: 'us',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Defines the country to use for search. Head to <a href=\"https://serpapi.com/google-countries\">Google countries page</a> for a full list of supported countries.',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Device',\n\t\t\t\t\t\tname: 'device',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Desktop',\n\t\t\t\t\t\t\t\tvalue: 'desktop',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Mobile',\n\t\t\t\t\t\t\t\tvalue: 'mobile',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Tablet',\n\t\t\t\t\t\t\t\tvalue: 'tablet',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdefault: 'desktop',\n\t\t\t\t\t\tdescription: 'Device to use to get the results',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Explicit Array',\n\t\t\t\t\t\tname: 'no_cache',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Whether to force SerpApi to fetch the Google results even if a cached version is already present. Cache expires after 1h. Cached searches are free, and are not counted towards your searches per month.',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Google Domain',\n\t\t\t\t\t\tname: 'google_domain',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdefault: 'google.com',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Defines the domain to use for search. Head to <a href=\"https://serpapi.com/google-domains\">Google domains page</a> for a full list of supported domains.',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Language',\n\t\t\t\t\t\tname: 'hl',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdefault: 'en',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Defines the language to use. It\\'s a two-letter language code. (e.g., `en` for English, `es` for Spanish, or `fr` for French). Head to <a href=\"https://serpapi.com/google-languages\">Google languages page</a> for a full list of supported languages.',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('serpApi');\n\n\t\tconst options = this.getNodeParameter('options', itemIndex) as object;\n\n\t\treturn {\n\t\t\tresponse: logWrapper(new SerpAPI(credentials.apiKey as string, options), this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAAwB;AACxB,0BAMO;AAEP,wBAA2B;AAC3B,0BAA6C;AAEtC,MAAM,YAAiC;AAAA,EAAvC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA;AAAA,MAEA,QAAQ,CAAC;AAAA;AAAA,MAET,SAAS,CAAC,wCAAoB,MAAM;AAAA,MACpC,aAAa,CAAC,MAAM;AAAA,MACpB,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,OAAO,CAAC;AAAA,QAC1D;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,aAAa;AAAA,UACb,SAAS,CAAC;AAAA,UACV,SAAS;AAAA,YACR;AAAA,cACC,aAAa;AAAA,cACb,MAAM;AAAA,cACN,MAAM;AAAA,cACN,SAAS;AAAA,cACT,aACC;AAAA,YACF;AAAA,YACA;AAAA,cACC,aAAa;AAAA,cACb,MAAM;AAAA,cACN,MAAM;AAAA,cACN,SAAS;AAAA,gBACR;AAAA,kBACC,MAAM;AAAA,kBACN,OAAO;AAAA,gBACR;AAAA,gBACA;AAAA,kBACC,MAAM;AAAA,kBACN,OAAO;AAAA,gBACR;AAAA,gBACA;AAAA,kBACC,MAAM;AAAA,kBACN,OAAO;AAAA,gBACR;AAAA,cACD;AAAA,cACA,SAAS;AAAA,cACT,aAAa;AAAA,YACd;AAAA,YACA;AAAA,cACC,aAAa;AAAA,cACb,MAAM;AAAA,cACN,MAAM;AAAA,cACN,SAAS;AAAA,cACT,aACC;AAAA,YACF;AAAA,YACA;AAAA,cACC,aAAa;AAAA,cACb,MAAM;AAAA,cACN,MAAM;AAAA,cACN,SAAS;AAAA,cACT,aACC;AAAA,YACF;AAAA,YACA;AAAA,cACC,aAAa;AAAA,cACb,MAAM;AAAA,cACN,MAAM;AAAA,cACN,SAAS;AAAA,cACT,aACC;AAAA,YACF;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,UAAM,cAAc,MAAM,KAAK,eAAe,SAAS;AAEvD,UAAM,UAAU,KAAK,iBAAiB,WAAW,SAAS;AAE1D,WAAO;AAAA,MACN,cAAU,8BAAW,IAAI,uBAAQ,YAAY,QAAkB,OAAO,GAAG,IAAI;AAAA,IAC9E;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/tools/ToolSerpApi/ToolSerpApi.node.ts"],"sourcesContent":["import { SerpAPI } from '@langchain/community/tools/serpapi';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class ToolSerpApi implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'SerpApi (Google Search)',\n\t\tname: 'toolSerpApi',\n\t\ticon: 'file:serpApi.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Search in Google using SerpAPI',\n\t\tdefaults: {\n\t\t\tname: 'SerpAPI',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolserpapi/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'serpApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Country',\n\t\t\t\t\t\tname: 'gl',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdefault: 'us',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Defines the country to use for search. Head to <a href=\"https://serpapi.com/google-countries\">Google countries page</a> for a full list of supported countries.',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Device',\n\t\t\t\t\t\tname: 'device',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Desktop',\n\t\t\t\t\t\t\t\tvalue: 'desktop',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Mobile',\n\t\t\t\t\t\t\t\tvalue: 'mobile',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Tablet',\n\t\t\t\t\t\t\t\tvalue: 'tablet',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdefault: 'desktop',\n\t\t\t\t\t\tdescription: 'Device to use to get the results',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Explicit Array',\n\t\t\t\t\t\tname: 'no_cache',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Whether to force SerpApi to fetch the Google results even if a cached version is already present. Cache expires after 1h. Cached searches are free, and are not counted towards your searches per month.',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Google Domain',\n\t\t\t\t\t\tname: 'google_domain',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdefault: 'google.com',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Defines the domain to use for search. Head to <a href=\"https://serpapi.com/google-domains\">Google domains page</a> for a full list of supported domains.',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Language',\n\t\t\t\t\t\tname: 'hl',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdefault: 'en',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Defines the language to use. It\\'s a two-letter language code. (e.g., `en` for English, `es` for Spanish, or `fr` for French). Head to <a href=\"https://serpapi.com/google-languages\">Google languages page</a> for a full list of supported languages.',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('serpApi');\n\n\t\tconst options = this.getNodeParameter('options', itemIndex) as object;\n\n\t\treturn {\n\t\t\tresponse: logWrapper(new SerpAPI(credentials.apiKey as string, options), this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AACxB,0BAMO;AAEP,wBAA2B;AAC3B,0BAA6C;AAEtC,MAAM,YAAiC;AAAA,EAAvC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ,CAAC;AAAA,MAET,SAAS,CAAC,wCAAoB,MAAM;AAAA,MACpC,aAAa,CAAC,MAAM;AAAA,MACpB,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,OAAO,CAAC;AAAA,QAC1D;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,aAAa;AAAA,UACb,SAAS,CAAC;AAAA,UACV,SAAS;AAAA,YACR;AAAA,cACC,aAAa;AAAA,cACb,MAAM;AAAA,cACN,MAAM;AAAA,cACN,SAAS;AAAA,cACT,aACC;AAAA,YACF;AAAA,YACA;AAAA,cACC,aAAa;AAAA,cACb,MAAM;AAAA,cACN,MAAM;AAAA,cACN,SAAS;AAAA,gBACR;AAAA,kBACC,MAAM;AAAA,kBACN,OAAO;AAAA,gBACR;AAAA,gBACA;AAAA,kBACC,MAAM;AAAA,kBACN,OAAO;AAAA,gBACR;AAAA,gBACA;AAAA,kBACC,MAAM;AAAA,kBACN,OAAO;AAAA,gBACR;AAAA,cACD;AAAA,cACA,SAAS;AAAA,cACT,aAAa;AAAA,YACd;AAAA,YACA;AAAA,cACC,aAAa;AAAA,cACb,MAAM;AAAA,cACN,MAAM;AAAA,cACN,SAAS;AAAA,cACT,aACC;AAAA,YACF;AAAA,YACA;AAAA,cACC,aAAa;AAAA,cACb,MAAM;AAAA,cACN,MAAM;AAAA,cACN,SAAS;AAAA,cACT,aACC;AAAA,YACF;AAAA,YACA;AAAA,cACC,aAAa;AAAA,cACb,MAAM;AAAA,cACN,MAAM;AAAA,cACN,SAAS;AAAA,cACT,aACC;AAAA,YACF;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,UAAM,cAAc,MAAM,KAAK,eAAe,SAAS;AAEvD,UAAM,UAAU,KAAK,iBAAiB,WAAW,SAAS;AAE1D,WAAO;AAAA,MACN,cAAU,8BAAW,IAAI,uBAAQ,YAAY,QAAkB,OAAO,GAAG,IAAI;AAAA,IAC9E;AAAA,EACD;AACD;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/tools/ToolThink/ToolThink.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { DynamicTool } from 'langchain/tools';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\n// A thinking tool, see https://www.anthropic.com/engineering/claude-think-tool\n\nconst defaultToolDescription =\n\t'Use the tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed.';\n\nexport class ToolThink implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Think Tool',\n\t\tname: 'toolThink',\n\t\ticon: 'fa:brain',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Invite the AI agent to do some thinking',\n\t\tdefaults: {\n\t\t\tname: 'Think',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolthink/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tinputs: [],\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Think Tool Description',\n\t\t\t\tname: 'description',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: defaultToolDescription,\n\t\t\t\tplaceholder: '[Describe your thinking tool here, explaining how it will help the AI think]',\n\t\t\t\tdescription: \"The thinking tool's description\",\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst description = this.getNodeParameter('description', itemIndex) as string;\n\t\tconst tool = new DynamicTool({\n\t\t\tname: 'thinking_tool',\n\t\t\tdescription,\n\t\t\tfunc: async (subject: string) => {\n\t\t\t\treturn subject;\n\t\t\t},\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(tool, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA4B;AAC5B,0BAMO;AAEP,wBAA2B;AAC3B,0BAA6C;AAI7C,MAAM,yBACL;AAEM,MAAM,UAA+B;AAAA,EAArC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,QAAQ,CAAC;AAAA,MACT,SAAS,CAAC,wCAAoB,MAAM;AAAA,MACpC,aAAa,CAAC,MAAM;AAAA,MACpB,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,OAAO,CAAC;AAAA,QAC1D;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aAAa;AAAA,UACb,aAAa;AAAA,UACb,aAAa;AAAA,YACZ,MAAM;AAAA,UACP;AAAA,UACA,UAAU;AAAA,QACX;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,UAAM,cAAc,KAAK,iBAAiB,eAAe,SAAS;AAClE,UAAM,OAAO,IAAI,yBAAY;AAAA,MAC5B,MAAM;AAAA,MACN;AAAA,MACA,MAAM,OAAO,YAAoB;AAChC,eAAO;AAAA,MACR;AAAA,IACD,CAAC;AAED,WAAO;AAAA,MACN,cAAU,8BAAW,MAAM,IAAI;AAAA,IAChC;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/tools/ToolThink/ToolThink.node.ts"],"sourcesContent":["import { DynamicTool } from 'langchain/tools';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\n// A thinking tool, see https://www.anthropic.com/engineering/claude-think-tool\n\nconst defaultToolDescription =\n\t'Use the tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed.';\n\nexport class ToolThink implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Think Tool',\n\t\tname: 'toolThink',\n\t\ticon: 'fa:brain',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Invite the AI agent to do some thinking',\n\t\tdefaults: {\n\t\t\tname: 'Think',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolthink/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tinputs: [],\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Think Tool Description',\n\t\t\t\tname: 'description',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: defaultToolDescription,\n\t\t\t\tplaceholder: '[Describe your thinking tool here, explaining how it will help the AI think]',\n\t\t\t\tdescription: \"The thinking tool's description\",\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst description = this.getNodeParameter('description', itemIndex) as string;\n\t\tconst tool = new DynamicTool({\n\t\t\tname: 'thinking_tool',\n\t\t\tdescription,\n\t\t\tfunc: async (subject: string) => {\n\t\t\t\treturn subject;\n\t\t\t},\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(tool, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4B;AAC5B,0BAMO;AAEP,wBAA2B;AAC3B,0BAA6C;AAI7C,MAAM,yBACL;AAEM,MAAM,UAA+B;AAAA,EAArC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,QAAQ,CAAC;AAAA,MACT,SAAS,CAAC,wCAAoB,MAAM;AAAA,MACpC,aAAa,CAAC,MAAM;AAAA,MACpB,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,OAAO,CAAC;AAAA,QAC1D;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aAAa;AAAA,UACb,aAAa;AAAA,UACb,aAAa;AAAA,YACZ,MAAM;AAAA,UACP;AAAA,UACA,UAAU;AAAA,QACX;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,UAAM,cAAc,KAAK,iBAAiB,eAAe,SAAS;AAClE,UAAM,OAAO,IAAI,yBAAY;AAAA,MAC5B,MAAM;AAAA,MACN;AAAA,MACA,MAAM,OAAO,YAAoB;AAChC,eAAO;AAAA,MACR;AAAA,IACD,CAAC;AAED,WAAO;AAAA,MACN,cAAU,8BAAW,MAAM,IAAI;AAAA,IAChC;AAAA,EACD;AACD;","names":[]}
@@ -54,7 +54,6 @@ class ToolVectorStore {
54
54
  ]
55
55
  }
56
56
  },
57
- // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
58
57
  inputs: [
59
58
  {
60
59
  displayName: "Vector Store",
@@ -69,7 +68,6 @@ class ToolVectorStore {
69
68
  required: true
70
69
  }
71
70
  ],
72
- // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
73
71
  outputs: [import_n8n_workflow.NodeConnectionTypes.AiTool],
74
72
  outputNames: ["Tool"],
75
73
  properties: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/tools/ToolVectorStore/ToolVectorStore.node.ts"],"sourcesContent":["import type { BaseLanguageModel } from '@langchain/core/language_models/base';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport { VectorDBQAChain } from 'langchain/chains';\nimport { VectorStoreQATool } from 'langchain/tools';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes } from 'n8n-workflow';\n\nimport { nodeNameToToolName } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class ToolVectorStore implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Vector Store Question Answer Tool',\n\t\tname: 'toolVectorStore',\n\t\ticon: 'fa:database',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Answer questions with a vector store',\n\t\tdefaults: {\n\t\t\tname: 'Answer questions with a vector store',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolvectorstore/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Vector Store',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiVectorStore,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiLanguageModel,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Data Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'e.g. users_info',\n\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\tdescription:\n\t\t\t\t\t'Name of the data in vector store. This will be used to fill this tool description: Useful for when you need to answer questions about [name]. Whenever you need information about [data description], you should ALWAYS use this. Input should be a fully formed question.',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Description of Data',\n\t\t\t\tname: 'description',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: \"[Describe your data here, e.g. a user's name, email, etc.]\",\n\t\t\t\tdescription:\n\t\t\t\t\t'Describe the data in vector store. This will be used to fill this tool description: Useful for when you need to answer questions about [name]. Whenever you need information about [data description], you should ALWAYS use this. Input should be a fully formed question.',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Limit',\n\t\t\t\tname: 'topK',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 4,\n\t\t\t\tdescription: 'The maximum number of results to return',\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst node = this.getNode();\n\t\tconst { typeVersion } = node;\n\t\tconst name =\n\t\t\ttypeVersion <= 1\n\t\t\t\t? (this.getNodeParameter('name', itemIndex) as string)\n\t\t\t\t: nodeNameToToolName(node);\n\t\tconst toolDescription = this.getNodeParameter('description', itemIndex) as string;\n\t\tconst topK = this.getNodeParameter('topK', itemIndex, 4) as number;\n\n\t\tconst vectorStore = (await this.getInputConnectionData(\n\t\t\tNodeConnectionTypes.AiVectorStore,\n\t\t\titemIndex,\n\t\t)) as VectorStore;\n\n\t\tconst llm = (await this.getInputConnectionData(\n\t\t\tNodeConnectionTypes.AiLanguageModel,\n\t\t\t0,\n\t\t)) as BaseLanguageModel;\n\n\t\tconst description = VectorStoreQATool.getDescription(name, toolDescription);\n\t\tconst vectorStoreTool = new VectorStoreQATool(name, description, {\n\t\t\tllm,\n\t\t\tvectorStore,\n\t\t});\n\n\t\tvectorStoreTool.chain = VectorDBQAChain.fromLLM(llm, vectorStore, {\n\t\t\tk: topK,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(vectorStoreTool, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAgC;AAChC,mBAAkC;AAOlC,0BAAoC;AAEpC,qBAAmC;AACnC,wBAA2B;AAC3B,0BAA6C;AAEtC,MAAM,gBAAqC;AAAA,EAA3C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA;AAAA,MAEA,QAAQ;AAAA,QACP;AAAA,UACC,aAAa;AAAA,UACb,gBAAgB;AAAA,UAChB,MAAM,wCAAoB;AAAA,UAC1B,UAAU;AAAA,Q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AAe,MAAM,eAAe;AAC1E,UAAM,kBAAkB,IAAI,+BAAkB,MAAM,aAAa;AAAA,MAChE;AAAA,MACA;AAAA,IACD,CAAC;AAED,oBAAgB,QAAQ,8BAAgB,QAAQ,KAAK,aAAa;AAAA,MACjE,GAAG;AAAA,IACJ,CAAC;AAED,WAAO;AAAA,MACN,cAAU,8BAAW,iBAAiB,IAAI;AAAA,IAC3C;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/tools/ToolVectorStore/ToolVectorStore.node.ts"],"sourcesContent":["import type { BaseLanguageModel } from '@langchain/core/language_models/base';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport { VectorDBQAChain } from 'langchain/chains';\nimport { VectorStoreQATool } from 'langchain/tools';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes } from 'n8n-workflow';\n\nimport { nodeNameToToolName } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class ToolVectorStore implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Vector Store Question Answer Tool',\n\t\tname: 'toolVectorStore',\n\t\ticon: 'fa:database',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Answer questions with a vector store',\n\t\tdefaults: {\n\t\t\tname: 'Answer questions with a vector store',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolvectorstore/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Vector Store',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiVectorStore,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiLanguageModel,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Data Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'e.g. users_info',\n\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\tdescription:\n\t\t\t\t\t'Name of the data in vector store. This will be used to fill this tool description: Useful for when you need to answer questions about [name]. Whenever you need information about [data description], you should ALWAYS use this. Input should be a fully formed question.',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Description of Data',\n\t\t\t\tname: 'description',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: \"[Describe your data here, e.g. a user's name, email, etc.]\",\n\t\t\t\tdescription:\n\t\t\t\t\t'Describe the data in vector store. This will be used to fill this tool description: Useful for when you need to answer questions about [name]. Whenever you need information about [data description], you should ALWAYS use this. Input should be a fully formed question.',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Limit',\n\t\t\t\tname: 'topK',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 4,\n\t\t\t\tdescription: 'The maximum number of results to return',\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst node = this.getNode();\n\t\tconst { typeVersion } = node;\n\t\tconst name =\n\t\t\ttypeVersion <= 1\n\t\t\t\t? (this.getNodeParameter('name', itemIndex) as string)\n\t\t\t\t: nodeNameToToolName(node);\n\t\tconst toolDescription = this.getNodeParameter('description', itemIndex) as string;\n\t\tconst topK = this.getNodeParameter('topK', itemIndex, 4) as number;\n\n\t\tconst vectorStore = (await this.getInputConnectionData(\n\t\t\tNodeConnectionTypes.AiVectorStore,\n\t\t\titemIndex,\n\t\t)) as VectorStore;\n\n\t\tconst llm = (await this.getInputConnectionData(\n\t\t\tNodeConnectionTypes.AiLanguageModel,\n\t\t\t0,\n\t\t)) as BaseLanguageModel;\n\n\t\tconst description = VectorStoreQATool.getDescription(name, toolDescription);\n\t\tconst vectorStoreTool = new VectorStoreQATool(name, description, {\n\t\t\tllm,\n\t\t\tvectorStore,\n\t\t});\n\n\t\tvectorStoreTool.chain = VectorDBQAChain.fromLLM(llm, vectorStore, {\n\t\t\tk: topK,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(vectorStoreTool, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAgC;AAChC,mBAAkC;AAOlC,0BAAoC;AAEpC,qBAAmC;AACnC,wBAA2B;AAC3B,0BAA6C;AAEtC,MAAM,gBAAqC;AAAA,EAA3C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO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OACL,eAAe,IACX,KAAK,iBAAiB,QAAQ,SAAS,QACxC,mCAAmB,IAAI;AAC3B,UAAM,kBAAkB,KAAK,iBAAiB,eAAe,SAAS;AACtE,UAAM,OAAO,KAAK,iBAAiB,QAAQ,WAAW,CAAC;AAEvD,UAAM,cAAe,MAAM,KAAK;AAAA,MAC/B,wCAAoB;AAAA,MACpB;AAAA,IACD;AAEA,UAAM,MAAO,MAAM,KAAK;AAAA,MACvB,wCAAoB;AAAA,MACpB;AAAA,IACD;AAEA,UAAM,cAAc,+BAAkB,eAAe,MAAM,eAAe;AAC1E,UAAM,kBAAkB,IAAI,+BAAkB,MAAM,aAAa;AAAA,MAChE;AAAA,MACA;AAAA,IACD,CAAC;AAED,oBAAgB,QAAQ,8BAAgB,QAAQ,KAAK,aAAa;AAAA,MACjE,GAAG;AAAA,IACJ,CAAC;AAED,WAAO;AAAA,MACN,cAAU,8BAAW,iBAAiB,IAAI;AAAA,IAC3C;AAAA,EACD;AACD;","names":[]}
@@ -51,9 +51,7 @@ class ToolWikipedia {
51
51
  ]
52
52
  }
53
53
  },
54
- // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
55
54
  inputs: [],
56
- // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
57
55
  outputs: [import_n8n_workflow.NodeConnectionTypes.AiTool],
58
56
  outputNames: ["Tool"],
59
57
  properties: [(0, import_sharedFields.getConnectionHintNoticeField)([import_n8n_workflow.NodeConnectionTypes.AiAgent])]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/tools/ToolWikipedia/ToolWikipedia.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { WikipediaQueryRun } from '@langchain/community/tools/wikipedia_query_run';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class ToolWikipedia implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Wikipedia',\n\t\tname: 'toolWikipedia',\n\t\ticon: 'file:wikipedia.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Search in Wikipedia',\n\t\tdefaults: {\n\t\t\tname: 'Wikipedia',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolwikipedia/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [getConnectionHintNoticeField([NodeConnectionTypes.AiAgent])],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions): Promise<SupplyData> {\n\t\tconst WikiTool = new WikipediaQueryRun();\n\n\t\tWikiTool.description =\n\t\t\t'A tool for interacting with and fetching data from the Wikipedia API. The input should always be a string query.';\n\n\t\treturn {\n\t\t\tresponse: logWrapper(WikiTool, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iCAAkC;AAClC,0BAMO;AAEP,wBAA2B;AAC3B,0BAA6C;AAEtC,MAAM,cAAmC;AAAA,EAAzC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA;AAAA,MAEA,QAAQ,CAAC;AAAA;AAAA,MAET,SAAS,CAAC,wCAAoB,MAAM;AAAA,MACpC,aAAa,CAAC,MAAM;AAAA,MACpB,YAAY,KAAC,kDAA6B,CAAC,wCAAoB,OAAO,CAAC,CAAC;AAAA,IACzE;AAAA;AAAA,EAEA,MAAM,aAA4D;AACjE,UAAM,WAAW,IAAI,6CAAkB;AAEvC,aAAS,cACR;AAED,WAAO;AAAA,MACN,cAAU,8BAAW,UAAU,IAAI;AAAA,IACpC;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/tools/ToolWikipedia/ToolWikipedia.node.ts"],"sourcesContent":["import { WikipediaQueryRun } from '@langchain/community/tools/wikipedia_query_run';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class ToolWikipedia implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Wikipedia',\n\t\tname: 'toolWikipedia',\n\t\ticon: 'file:wikipedia.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Search in Wikipedia',\n\t\tdefaults: {\n\t\t\tname: 'Wikipedia',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolwikipedia/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [getConnectionHintNoticeField([NodeConnectionTypes.AiAgent])],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions): Promise<SupplyData> {\n\t\tconst WikiTool = new WikipediaQueryRun();\n\n\t\tWikiTool.description =\n\t\t\t'A tool for interacting with and fetching data from the Wikipedia API. The input should always be a string query.';\n\n\t\treturn {\n\t\t\tresponse: logWrapper(WikiTool, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAkC;AAClC,0BAMO;AAEP,wBAA2B;AAC3B,0BAA6C;AAEtC,MAAM,cAAmC;AAAA,EAAzC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ,CAAC;AAAA,MAET,SAAS,CAAC,wCAAoB,MAAM;AAAA,MACpC,aAAa,CAAC,MAAM;AAAA,MACpB,YAAY,KAAC,kDAA6B,CAAC,wCAAoB,OAAO,CAAC,CAAC;AAAA,IACzE;AAAA;AAAA,EAEA,MAAM,aAA4D;AACjE,UAAM,WAAW,IAAI,6CAAkB;AAEvC,aAAS,cACR;AAED,WAAO;AAAA,MACN,cAAU,8BAAW,UAAU,IAAI;AAAA,IACpC;AAAA,EACD;AACD;","names":[]}
@@ -57,9 +57,7 @@ class ToolWolframAlpha {
57
57
  ]
58
58
  }
59
59
  },
60
- // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
61
60
  inputs: [],
62
- // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
63
61
  outputs: [import_n8n_workflow.NodeConnectionTypes.AiTool],
64
62
  outputNames: ["Tool"],
65
63
  properties: [(0, import_sharedFields.getConnectionHintNoticeField)([import_n8n_workflow.NodeConnectionTypes.AiAgent])]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/tools/ToolWolframAlpha/ToolWolframAlpha.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { WolframAlphaTool } from '@langchain/community/tools/wolframalpha';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class ToolWolframAlpha implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Wolfram|Alpha',\n\t\tname: 'toolWolframAlpha',\n\t\ticon: 'file:wolfram-alpha.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: \"Connects to WolframAlpha's computational intelligence engine.\",\n\t\tdefaults: {\n\t\t\tname: 'Wolfram Alpha',\n\t\t},\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'wolframAlphaApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolwolframalpha/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [getConnectionHintNoticeField([NodeConnectionTypes.AiAgent])],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('wolframAlphaApi');\n\n\t\treturn {\n\t\t\tresponse: logWrapper(new WolframAlphaTool({ appid: credentials.appId as string }), this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAiC;AACjC,0BAMO;AAEP,wBAA2B;AAC3B,0BAA6C;AAEtC,MAAM,iBAAsC;AAAA,EAA5C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA;AAAA,MAEA,QAAQ,CAAC;AAAA;AAAA,MAET,SAAS,CAAC,wCAAoB,MAAM;AAAA,MACpC,aAAa,CAAC,MAAM;AAAA,MACpB,YAAY,KAAC,kDAA6B,CAAC,wCAAoB,OAAO,CAAC,CAAC;AAAA,IACzE;AAAA;AAAA,EAEA,MAAM,aAA4D;AACjE,UAAM,cAAc,MAAM,KAAK,eAAe,iBAAiB;AAE/D,WAAO;AAAA,MACN,cAAU,8BAAW,IAAI,qCAAiB,EAAE,OAAO,YAAY,MAAgB,CAAC,GAAG,IAAI;AAAA,IACxF;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/tools/ToolWolframAlpha/ToolWolframAlpha.node.ts"],"sourcesContent":["import { WolframAlphaTool } from '@langchain/community/tools/wolframalpha';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class ToolWolframAlpha implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Wolfram|Alpha',\n\t\tname: 'toolWolframAlpha',\n\t\ticon: 'file:wolfram-alpha.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: \"Connects to WolframAlpha's computational intelligence engine.\",\n\t\tdefaults: {\n\t\t\tname: 'Wolfram Alpha',\n\t\t},\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'wolframAlphaApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolwolframalpha/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [getConnectionHintNoticeField([NodeConnectionTypes.AiAgent])],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('wolframAlphaApi');\n\n\t\treturn {\n\t\t\tresponse: logWrapper(new WolframAlphaTool({ appid: credentials.appId as string }), this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAiC;AACjC,0BAMO;AAEP,wBAA2B;AAC3B,0BAA6C;AAEtC,MAAM,iBAAsC;AAAA,EAA5C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ,CAAC;AAAA,MAET,SAAS,CAAC,wCAAoB,MAAM;AAAA,MACpC,aAAa,CAAC,MAAM;AAAA,MACpB,YAAY,KAAC,kDAA6B,CAAC,wCAAoB,OAAO,CAAC,CAAC;AAAA,IACzE;AAAA;AAAA,EAEA,MAAM,aAA4D;AACjE,UAAM,cAAc,MAAM,KAAK,eAAe,iBAAiB;AAE/D,WAAO;AAAA,MACN,cAAU,8BAAW,IAAI,qCAAiB,EAAE,OAAO,YAAY,MAAgB,CAAC,GAAG,IAAI;AAAA,IACxF;AAAA,EACD;AACD;","names":[]}
@@ -47,9 +47,7 @@ const versionDescription = {
47
47
  ]
48
48
  }
49
49
  },
50
- // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
51
50
  inputs: [],
52
- // eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
53
51
  outputs: [import_n8n_workflow.NodeConnectionTypes.AiTool],
54
52
  outputNames: ["Tool"],
55
53
  properties: [