@n8n/ai-utilities 0.30.0 → 0.30.2
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.
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/typecheck.tsbuildinfo +1 -1
- package/dist/cjs/utils/http-proxy-agent.d.ts +8 -2
- package/dist/cjs/utils/http-proxy-agent.js +12 -14
- package/dist/cjs/utils/http-proxy-agent.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/typecheck.tsbuildinfo +1 -1
- package/dist/esm/utils/http-proxy-agent.d.ts +8 -2
- package/dist/esm/utils/http-proxy-agent.js +12 -14
- package/dist/esm/utils/http-proxy-agent.js.map +1 -1
- package/package.json +8 -8
|
@@ -6,6 +6,12 @@ export interface AgentTimeoutOptions {
|
|
|
6
6
|
bodyTimeout?: number;
|
|
7
7
|
connectTimeout?: number;
|
|
8
8
|
}
|
|
9
|
-
export declare function getProxyAgent(targetUrl?: string, timeoutOptions?: AgentTimeoutOptions, lookup?: LookupFunction): Agent | ProxyAgent
|
|
10
|
-
export
|
|
9
|
+
export declare function getProxyAgent(targetUrl?: string, timeoutOptions?: AgentTimeoutOptions, lookup?: LookupFunction): Agent | ProxyAgent;
|
|
10
|
+
export interface ProxyFetchOptions {
|
|
11
|
+
input: RequestInfo | URL;
|
|
12
|
+
init?: RequestInit;
|
|
13
|
+
timeoutOptions?: AgentTimeoutOptions;
|
|
14
|
+
lookup: LookupFunction;
|
|
15
|
+
}
|
|
16
|
+
export declare function proxyFetch({ input, init, timeoutOptions, lookup, }: ProxyFetchOptions): Promise<Response>;
|
|
11
17
|
export declare function getNodeProxyAgent(targetUrl?: string, agentOptions?: AgentOptions): import("https").Agent | undefined;
|
|
@@ -4,10 +4,12 @@ exports.getProxyAgent = getProxyAgent;
|
|
|
4
4
|
exports.proxyFetch = proxyFetch;
|
|
5
5
|
exports.getNodeProxyAgent = getNodeProxyAgent;
|
|
6
6
|
const proxy_1 = require("@n8n/backend-network/proxy");
|
|
7
|
+
const node_dns_1 = require("node:dns");
|
|
7
8
|
const undici_1 = require("undici");
|
|
8
9
|
const DEFAULT_TIMEOUT = parseInt(process.env.N8N_AI_TIMEOUT_MAX ?? '3600000', 10);
|
|
9
10
|
const PROXY_FALLBACK_TARGET = 'https://example.nonexistent/';
|
|
10
|
-
|
|
11
|
+
let sharedAgent;
|
|
12
|
+
function getProxyAgent(targetUrl, timeoutOptions, lookup = node_dns_1.lookup) {
|
|
11
13
|
const proxyUrl = (0, proxy_1.resolveProxyUrl)(targetUrl, PROXY_FALLBACK_TARGET);
|
|
12
14
|
const agentOptions = {
|
|
13
15
|
headersTimeout: timeoutOptions?.headersTimeout ?? DEFAULT_TIMEOUT,
|
|
@@ -16,21 +18,17 @@ function getProxyAgent(targetUrl, timeoutOptions, lookup) {
|
|
|
16
18
|
connectTimeout: timeoutOptions.connectTimeout,
|
|
17
19
|
}),
|
|
18
20
|
};
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (process.env.N8N_AI_TIMEOUT_MAX) {
|
|
27
|
-
return new undici_1.Agent(agentOptions);
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
21
|
+
if (proxyUrl) {
|
|
22
|
+
return new undici_1.ProxyAgent({ uri: proxyUrl, ...agentOptions });
|
|
23
|
+
}
|
|
24
|
+
const isDefaultCase = !timeoutOptions && !process.env.N8N_AI_TIMEOUT_MAX && lookup === node_dns_1.lookup;
|
|
25
|
+
if (isDefaultCase) {
|
|
26
|
+
sharedAgent ??= new undici_1.Agent({ ...agentOptions, connect: { lookup } });
|
|
27
|
+
return sharedAgent;
|
|
30
28
|
}
|
|
31
|
-
return new undici_1.
|
|
29
|
+
return new undici_1.Agent({ ...agentOptions, connect: { lookup } });
|
|
32
30
|
}
|
|
33
|
-
async function proxyFetch(input, init, timeoutOptions, lookup) {
|
|
31
|
+
async function proxyFetch({ input, init, timeoutOptions, lookup, }) {
|
|
34
32
|
const targetUrl = input instanceof Request ? input.url : input.toString();
|
|
35
33
|
const dispatcher = getProxyAgent(targetUrl, timeoutOptions, lookup);
|
|
36
34
|
return (await (0, undici_1.fetch)(input, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-proxy-agent.js","sourceRoot":"","sources":["../../../src/utils/http-proxy-agent.ts"],"names":[],"mappings":";;;;;AAkBA,sDAAoF;
|
|
1
|
+
{"version":3,"file":"http-proxy-agent.js","sourceRoot":"","sources":["../../../src/utils/http-proxy-agent.ts"],"names":[],"mappings":";;;;;AAkBA,sDAAoF;AACpF,uCAAmD;AAInD,mCAAiE;AAejE,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,SAAS,EAAE,EAAE,CAAC,CAAC;AAMlF,MAAM,qBAAqB,GAAG,8BAA8B,CAAC;AAO7D,IAAI,WAA8B,CAAC;AAkBnC,uBACC,SAAkB,EAClB,cAAoC,EACpC,MAAM,GAAmB,iBAAa;IAEtC,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;IAEnE,MAAM,YAAY,GAAG;QACpB,cAAc,EAAE,cAAc,EAAE,cAAc,IAAI,eAAe;QACjE,WAAW,EAAE,cAAc,EAAE,WAAW,IAAI,eAAe;QAC3D,GAAG,CAAC,cAAc,EAAE,cAAc,KAAK,SAAS,IAAI;YACnD,cAAc,EAAE,cAAc,CAAC,cAAc;SAC7C,CAAC;KACF,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,mBAAU,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,MAA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{ N8nPdfLoader } from './utils/loaders/n8n-pdf-loader';
|
|
10
10
|
export { N8nLlmTracing } from './utils/n8n-llm-tracing';
|
|
11
|
+
export { redactHeaderValues } from './utils/redact-headers';
|
|
11
12
|
export { TextEditorDocument, NoMatchFoundError, MultipleMatchesError, InvalidLineNumberError, InvalidViewRangeError, InvalidPathError, FileExistsError, FileNotFoundError, BatchReplacementError, formatTextWithLineNumbers, findDivergenceContext, parseStrReplacements, } from './utils/workflow-text-editor';
|
|
12
13
|
export type { ViewCommand, CreateCommand, StrReplaceCommand, InsertCommand, BatchStrReplaceCommand, TextEditorCommand, TextEditorCommandWithBatch, TextEditorToolCall, TextEditorResult, StrReplacement, BatchReplaceResult, TextEditorDocumentOptions, } from './utils/workflow-text-editor';
|
|
13
14
|
export { estimateTokensFromStringList, estimateTokensByCharCount, estimateTextSplitsByTokens, } from './utils/tokenizer/token-estimator';
|
|
14
15
|
export { encodingForModel, getEncoding } from './utils/tokenizer/tiktoken';
|
|
15
16
|
export { makeN8nLlmFailedAttemptHandler } from './utils/failed-attempt-handler/n8nLlmFailedAttemptHandler';
|
|
16
|
-
export { getProxyAgent, getNodeProxyAgent, proxyFetch, type AgentTimeoutOptions, } from './utils/http-proxy-agent';
|
|
17
|
+
export { getProxyAgent, getNodeProxyAgent, proxyFetch, type AgentTimeoutOptions, type ProxyFetchOptions, } from './utils/http-proxy-agent';
|
|
17
18
|
export { braveSearch, searxngSearch, type BraveSearchOptions } from './web-search';
|
|
18
19
|
export type { WebSearchOptions, WebSearchResponse, WebSearchResult } from './web-search';
|
|
19
20
|
export { fetchFollowingRedirects, type FollowRedirectsOptions, } from './utils/follow-redirects';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.supplyModel = exports.supplyMemory = exports.WindowedChatMemory = exports.BaseChatMemory = exports.BaseChatHistory = exports.BaseChatModel = exports.LangchainChatModelAdapter = exports.isToolsInstance = exports.isChatInstance = exports.isBaseChatMessageHistory = exports.isBaseChatMemory = exports.fromLcContent = exports.toLcContent = void 0;
|
|
3
|
+
exports.fromLcMessage = exports.getParametersJsonSchema = exports.processDocument = exports.processDocuments = exports.MemoryVectorStoreManager = exports.createVectorStoreNode = exports.extractFromAIParameters = exports.createZodSchemaFromArgs = exports.createToolFromNode = exports.getTemplateNoticeField = exports.getBatchingOptionFields = exports.metadataFilterField = exports.getConnectionHintNoticeField = exports.fetchFollowingRedirects = exports.searxngSearch = exports.braveSearch = exports.proxyFetch = exports.getNodeProxyAgent = exports.getProxyAgent = exports.makeN8nLlmFailedAttemptHandler = exports.getEncoding = exports.encodingForModel = exports.estimateTextSplitsByTokens = exports.estimateTokensByCharCount = exports.estimateTokensFromStringList = exports.parseStrReplacements = exports.findDivergenceContext = exports.formatTextWithLineNumbers = exports.BatchReplacementError = exports.FileNotFoundError = exports.FileExistsError = exports.InvalidPathError = exports.InvalidViewRangeError = exports.InvalidLineNumberError = exports.MultipleMatchesError = exports.NoMatchFoundError = exports.TextEditorDocument = exports.redactHeaderValues = exports.N8nLlmTracing = exports.N8nPdfLoader = exports.N8nJsonLoader = exports.N8nBinaryLoader = exports.hasLongSequentialRepeat = exports.getMetadataFiltersValues = exports.validateEmbedDocumentsInput = exports.validateEmbedQueryInput = exports.parseSSEStream = exports.logAiEvent = exports.logWrapper = exports.AI_NODE_SDK_VERSION = void 0;
|
|
4
|
+
exports.supplyModel = exports.supplyMemory = exports.WindowedChatMemory = exports.BaseChatMemory = exports.BaseChatHistory = exports.BaseChatModel = exports.LangchainChatModelAdapter = exports.isToolsInstance = exports.isChatInstance = exports.isBaseChatMessageHistory = exports.isBaseChatMemory = exports.fromLcContent = exports.toLcContent = exports.toLcMessage = void 0;
|
|
5
5
|
var ai_node_sdk_version_1 = require("./ai-node-sdk-version");
|
|
6
6
|
Object.defineProperty(exports, "AI_NODE_SDK_VERSION", { enumerable: true, get: function () { return ai_node_sdk_version_1.AI_NODE_SDK_VERSION; } });
|
|
7
7
|
var log_wrapper_1 = require("./utils/log-wrapper");
|
|
@@ -24,6 +24,8 @@ var n8n_pdf_loader_1 = require("./utils/loaders/n8n-pdf-loader");
|
|
|
24
24
|
Object.defineProperty(exports, "N8nPdfLoader", { enumerable: true, get: function () { return n8n_pdf_loader_1.N8nPdfLoader; } });
|
|
25
25
|
var n8n_llm_tracing_1 = require("./utils/n8n-llm-tracing");
|
|
26
26
|
Object.defineProperty(exports, "N8nLlmTracing", { enumerable: true, get: function () { return n8n_llm_tracing_1.N8nLlmTracing; } });
|
|
27
|
+
var redact_headers_1 = require("./utils/redact-headers");
|
|
28
|
+
Object.defineProperty(exports, "redactHeaderValues", { enumerable: true, get: function () { return redact_headers_1.redactHeaderValues; } });
|
|
27
29
|
var workflow_text_editor_1 = require("./utils/workflow-text-editor");
|
|
28
30
|
Object.defineProperty(exports, "TextEditorDocument", { enumerable: true, get: function () { return workflow_text_editor_1.TextEditorDocument; } });
|
|
29
31
|
Object.defineProperty(exports, "NoMatchFoundError", { enumerable: true, get: function () { return workflow_text_editor_1.NoMatchFoundError; } });
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AACA,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAG5B,mDAAiD;AAAxC,yGAAA,UAAU,OAAA;AACnB,qDAAkD;AAAzC,0GAAA,UAAU,OAAA;AACnB,mCAA6C;AAApC,qGAAA,cAAc,OAAA;AACvB,mFAG6C;AAF5C,sIAAA,uBAAuB,OAAA;AACvB,0IAAA,2BAA2B,OAAA;AAE5B,2CAAoF;AAA3E,mHAAA,wBAAwB,OAAA;AAAE,kHAAA,uBAAuB,OAAA;AAC1D,+DAA4D;AAAnD,oHAAA,eAAe,OAAA;AACxB,2DAAwD;AAA/C,gHAAA,aAAa,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