@agentforge/tools 0.16.76 → 0.16.78
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/README.md +21 -0
- package/dist/index.cjs +479 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +148 -63
- package/dist/index.d.ts +148 -63
- package/dist/index.js +468 -118
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { toolBuilder, ToolCategory, LogLevel, createLogger } from '@agentforge/core';
|
|
2
|
-
import
|
|
2
|
+
import { lookup } from 'dns/promises';
|
|
3
|
+
import net from 'net';
|
|
4
|
+
import axios13 from 'axios';
|
|
3
5
|
import { z } from 'zod';
|
|
4
6
|
import * as cheerio from 'cheerio';
|
|
5
7
|
import { WebClient } from '@slack/web-api';
|
|
@@ -12,7 +14,7 @@ import { EventEmitter } from 'events';
|
|
|
12
14
|
import { Readable } from 'stream';
|
|
13
15
|
import { createHash, randomUUID } from 'crypto';
|
|
14
16
|
import { promises } from 'fs';
|
|
15
|
-
import * as
|
|
17
|
+
import * as path from 'path';
|
|
16
18
|
import { format, parse as parse$1, isValid, add, sub, differenceInDays, differenceInHours, differenceInMinutes, isAfter, isBefore } from 'date-fns';
|
|
17
19
|
|
|
18
20
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -21,6 +23,204 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
21
23
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
22
24
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
23
25
|
});
|
|
26
|
+
var DEFAULT_MAX_REDIRECTS = 5;
|
|
27
|
+
var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
28
|
+
var IPV4_MAPPED_NETWORK = "::ffff:0:0";
|
|
29
|
+
var SENSITIVE_REDIRECT_HEADERS = /* @__PURE__ */ new Set(["authorization", "cookie", "proxy-authorization"]);
|
|
30
|
+
var DEFAULT_DESTINATION_POLICY = Object.freeze({
|
|
31
|
+
allowLocalhost: false,
|
|
32
|
+
allowPrivateNetwork: false,
|
|
33
|
+
allowLinkLocal: false,
|
|
34
|
+
allowMetadata: false,
|
|
35
|
+
allowRedirects: true,
|
|
36
|
+
maxRedirects: DEFAULT_MAX_REDIRECTS
|
|
37
|
+
});
|
|
38
|
+
var DestinationPolicyError = class extends Error {
|
|
39
|
+
constructor(url, reason, message) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.url = url;
|
|
42
|
+
this.reason = reason;
|
|
43
|
+
this.name = "DestinationPolicyError";
|
|
44
|
+
}
|
|
45
|
+
code = "WEB_DESTINATION_BLOCKED";
|
|
46
|
+
};
|
|
47
|
+
function ipv4ToNumber(address) {
|
|
48
|
+
const octets = address.split(".").map(Number);
|
|
49
|
+
if (octets.length !== 4 || octets.some((octet) => !Number.isInteger(octet) || octet < 0 || octet > 255)) return void 0;
|
|
50
|
+
return ((octets[0] * 256 + octets[1]) * 256 + octets[2]) * 256 + octets[3] >>> 0;
|
|
51
|
+
}
|
|
52
|
+
function ipv4InCidr(address, network, prefix) {
|
|
53
|
+
const value = ipv4ToNumber(address);
|
|
54
|
+
const networkValue = ipv4ToNumber(network);
|
|
55
|
+
if (value === void 0 || networkValue === void 0) return false;
|
|
56
|
+
const mask = prefix === 0 ? 0 : 4294967295 << 32 - prefix >>> 0;
|
|
57
|
+
return (value & mask) === (networkValue & mask);
|
|
58
|
+
}
|
|
59
|
+
function expandIpv6(address) {
|
|
60
|
+
const normalized = address.toLowerCase().split("%")[0];
|
|
61
|
+
let input = normalized;
|
|
62
|
+
const ipv4Start = normalized.lastIndexOf(":") + 1;
|
|
63
|
+
const ipv4 = normalized.slice(ipv4Start);
|
|
64
|
+
if (net.isIP(ipv4) === 4) {
|
|
65
|
+
const value = ipv4ToNumber(ipv4);
|
|
66
|
+
if (value === void 0) return void 0;
|
|
67
|
+
input = `${normalized.slice(0, ipv4Start)}${(value >>> 16).toString(16)}:${(value & 65535).toString(16)}`;
|
|
68
|
+
}
|
|
69
|
+
const halves = input.split("::");
|
|
70
|
+
if (halves.length > 2) return void 0;
|
|
71
|
+
const left = halves[0] ? halves[0].split(":").filter(Boolean) : [];
|
|
72
|
+
const right = halves.length === 2 && halves[1] ? halves[1].split(":").filter(Boolean) : [];
|
|
73
|
+
const missing = 8 - left.length - right.length;
|
|
74
|
+
if (missing < 0 || halves.length === 1 && missing !== 0) return void 0;
|
|
75
|
+
const groups = [...left, ...Array.from({ length: missing }, () => "0"), ...right];
|
|
76
|
+
if (groups.length !== 8 || groups.some((group) => !/^[0-9a-f]{1,4}$/.test(group))) return void 0;
|
|
77
|
+
return groups.reduce((value, group) => value << 16n | BigInt(parseInt(group, 16)), 0n);
|
|
78
|
+
}
|
|
79
|
+
function ipv6InCidr(address, network, prefix) {
|
|
80
|
+
return prefix === 0 || address >> BigInt(128 - prefix) === network >> BigInt(128 - prefix);
|
|
81
|
+
}
|
|
82
|
+
function ipv6ToIpv4(address) {
|
|
83
|
+
const mappedNetwork = expandIpv6(IPV4_MAPPED_NETWORK);
|
|
84
|
+
if (mappedNetwork === void 0 || !ipv6InCidr(address, mappedNetwork, 96)) return void 0;
|
|
85
|
+
const value = Number(address & 0xffffffffn) >>> 0;
|
|
86
|
+
return [value >>> 24, value >>> 16 & 255, value >>> 8 & 255, value & 255].join(".");
|
|
87
|
+
}
|
|
88
|
+
function classifyIp(address) {
|
|
89
|
+
const normalized = address.replace(/^\[|\]$/g, "").toLowerCase();
|
|
90
|
+
const version = net.isIP(normalized);
|
|
91
|
+
if (version === 4) {
|
|
92
|
+
if (normalized === "169.254.169.254") return "metadata";
|
|
93
|
+
if (ipv4InCidr(normalized, "127.0.0.0", 8)) return "localhost";
|
|
94
|
+
if (ipv4InCidr(normalized, "169.254.0.0", 16)) return "link-local";
|
|
95
|
+
if (ipv4InCidr(normalized, "10.0.0.0", 8) || ipv4InCidr(normalized, "172.16.0.0", 12) || ipv4InCidr(normalized, "192.168.0.0", 16) || ipv4InCidr(normalized, "100.64.0.0", 10)) return "private-network";
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
if (version !== 6) return void 0;
|
|
99
|
+
const value = expandIpv6(normalized);
|
|
100
|
+
if (value === void 0) return void 0;
|
|
101
|
+
const mappedIpv4 = ipv6ToIpv4(value);
|
|
102
|
+
if (mappedIpv4) return classifyIp(mappedIpv4);
|
|
103
|
+
if (value === expandIpv6("fd00:ec2::254")) return "metadata";
|
|
104
|
+
if (value === expandIpv6("::1")) return "localhost";
|
|
105
|
+
if (ipv6InCidr(value, expandIpv6("fe80::"), 10)) return "link-local";
|
|
106
|
+
if (ipv6InCidr(value, expandIpv6("fc00::"), 7)) return "private-network";
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
function classifyHostname(hostname) {
|
|
110
|
+
const normalized = hostname.toLowerCase().replace(/\.$/, "");
|
|
111
|
+
if (normalized === "localhost" || normalized.endsWith(".localhost") || normalized === "localhost.localdomain") return "localhost";
|
|
112
|
+
if (normalized === "metadata" || normalized === "metadata.google.internal" || normalized === "instance-data") return "metadata";
|
|
113
|
+
return classifyIp(normalized);
|
|
114
|
+
}
|
|
115
|
+
function policyAllows(reason, policy) {
|
|
116
|
+
if (reason === "localhost") return policy.allowLocalhost === true;
|
|
117
|
+
if (reason === "metadata") return policy.allowMetadata === true;
|
|
118
|
+
if (reason === "private-network") return policy.allowPrivateNetwork === true;
|
|
119
|
+
if (reason === "link-local") return policy.allowLinkLocal === true;
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
async function resolveDestinationAddresses(hostname) {
|
|
123
|
+
try {
|
|
124
|
+
const addresses = await lookup(hostname, { all: true, verbatim: true });
|
|
125
|
+
return addresses.map(({ address, family }) => ({ address, family }));
|
|
126
|
+
} catch (error) {
|
|
127
|
+
throw new DestinationPolicyError(hostname, "dns-resolution-failed", `Destination policy could not resolve hostname "${hostname}" before making a request: ${error instanceof Error ? error.message : String(error)}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function blockDestination(url, reason) {
|
|
131
|
+
throw new DestinationPolicyError(url, reason, `Destination blocked by web egress policy (${reason}): ${url}`);
|
|
132
|
+
}
|
|
133
|
+
async function validateDestinationAllowed(url, policy) {
|
|
134
|
+
const effectivePolicy = { ...DEFAULT_DESTINATION_POLICY, ...policy };
|
|
135
|
+
let parsed;
|
|
136
|
+
try {
|
|
137
|
+
parsed = new URL(url);
|
|
138
|
+
} catch {
|
|
139
|
+
blockDestination(url, "unsupported-protocol");
|
|
140
|
+
}
|
|
141
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") blockDestination(url, "unsupported-protocol");
|
|
142
|
+
const hostname = parsed.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
143
|
+
const directReason = classifyHostname(hostname);
|
|
144
|
+
if (directReason && !policyAllows(directReason, effectivePolicy)) blockDestination(url, directReason);
|
|
145
|
+
const version = net.isIP(hostname);
|
|
146
|
+
if (version !== 0) return [{ address: hostname, family: version }];
|
|
147
|
+
const addresses = await resolveDestinationAddresses(hostname);
|
|
148
|
+
for (const { address } of addresses) {
|
|
149
|
+
const reason = classifyIp(address);
|
|
150
|
+
if (reason && !policyAllows(reason, effectivePolicy)) blockDestination(url, reason);
|
|
151
|
+
}
|
|
152
|
+
return addresses;
|
|
153
|
+
}
|
|
154
|
+
async function assertDestinationAllowed(url, policy = {}) {
|
|
155
|
+
await validateDestinationAllowed(url, policy);
|
|
156
|
+
}
|
|
157
|
+
function isRedirectStatus(status) {
|
|
158
|
+
return REDIRECT_STATUSES.has(status);
|
|
159
|
+
}
|
|
160
|
+
function responseLocation(response) {
|
|
161
|
+
const headers = response.headers;
|
|
162
|
+
return headers.location ?? headers.Location;
|
|
163
|
+
}
|
|
164
|
+
function stripSensitiveRedirectHeaders(headers) {
|
|
165
|
+
if (!headers) return headers;
|
|
166
|
+
const sanitizedHeaders = { ...headers };
|
|
167
|
+
for (const headerName of Object.keys(sanitizedHeaders)) {
|
|
168
|
+
if (SENSITIVE_REDIRECT_HEADERS.has(headerName.toLowerCase())) delete sanitizedHeaders[headerName];
|
|
169
|
+
}
|
|
170
|
+
return sanitizedHeaders;
|
|
171
|
+
}
|
|
172
|
+
function createPinnedLookup(addresses) {
|
|
173
|
+
return (_hostname, options, callback) => {
|
|
174
|
+
const requestedFamily = "family" in options && (options.family === 4 || options.family === 6) ? options.family : void 0;
|
|
175
|
+
const candidates = requestedFamily ? addresses.filter(({ family: family2 }) => family2 === requestedFamily) : addresses;
|
|
176
|
+
if (candidates.length === 0) {
|
|
177
|
+
callback(new Error(`No validated destination address matches the requested address family: ${requestedFamily}`), "", void 0);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if ("all" in options && options.all === true) {
|
|
181
|
+
callback(null, candidates, void 0);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const [{ address, family }] = candidates;
|
|
185
|
+
callback(null, address, family);
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
async function requestWithDestinationPolicy(config, policy = {}) {
|
|
189
|
+
if (!config.url) throw new Error("A request URL is required for destination policy enforcement");
|
|
190
|
+
const effectivePolicy = { ...DEFAULT_DESTINATION_POLICY, ...policy };
|
|
191
|
+
const maxRedirects = effectivePolicy.maxRedirects;
|
|
192
|
+
if (!Number.isInteger(maxRedirects) || maxRedirects < 0) throw new Error("maxRedirects must be a non-negative integer");
|
|
193
|
+
let currentUrl = config.url;
|
|
194
|
+
let currentConfig = {
|
|
195
|
+
...config,
|
|
196
|
+
url: currentUrl,
|
|
197
|
+
maxRedirects: 0,
|
|
198
|
+
validateStatus: (status) => isRedirectStatus(status) || (config.validateStatus ? config.validateStatus(status) : status >= 200 && status < 300)
|
|
199
|
+
};
|
|
200
|
+
for (let redirectCount = 0; ; redirectCount += 1) {
|
|
201
|
+
const validatedAddresses = await validateDestinationAllowed(currentUrl, effectivePolicy);
|
|
202
|
+
currentConfig.lookup = createPinnedLookup(validatedAddresses);
|
|
203
|
+
const response = await axios13(currentConfig);
|
|
204
|
+
if (!isRedirectStatus(response.status)) return response;
|
|
205
|
+
if (effectivePolicy.allowRedirects === false) blockDestination(currentUrl, "redirect");
|
|
206
|
+
if (redirectCount >= maxRedirects) throw new DestinationPolicyError(currentUrl, "redirect", `Maximum redirect count (${maxRedirects}) exceeded for ${currentUrl}`);
|
|
207
|
+
const location = responseLocation(response);
|
|
208
|
+
if (!location) throw new DestinationPolicyError(currentUrl, "redirect", `Redirect response did not include a Location header: ${currentUrl}`);
|
|
209
|
+
const previousUrl = currentUrl;
|
|
210
|
+
try {
|
|
211
|
+
currentUrl = new URL(location, currentUrl).toString();
|
|
212
|
+
} catch {
|
|
213
|
+
throw new DestinationPolicyError(currentUrl, "redirect", `Redirect response included an invalid Location header: ${location}`);
|
|
214
|
+
}
|
|
215
|
+
const method = String(currentConfig.method ?? "GET").toUpperCase();
|
|
216
|
+
const nextMethod = response.status === 303 || (response.status === 301 || response.status === 302) && method === "POST" ? "GET" : method;
|
|
217
|
+
currentConfig = { ...currentConfig, url: currentUrl, method: nextMethod };
|
|
218
|
+
if (new URL(previousUrl).origin !== new URL(currentUrl).origin) {
|
|
219
|
+
currentConfig.headers = stripSensitiveRedirectHeaders(currentConfig.headers);
|
|
220
|
+
}
|
|
221
|
+
if (nextMethod === "GET" || nextMethod === "HEAD") delete currentConfig.data;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
24
224
|
var HttpMethod = z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]);
|
|
25
225
|
var httpRequestSchema = z.object({
|
|
26
226
|
url: z.string().url().describe("The URL to make the request to"),
|
|
@@ -42,8 +242,8 @@ var httpPostSchema = z.object({
|
|
|
42
242
|
});
|
|
43
243
|
|
|
44
244
|
// src/web/http/tools/http-client.ts
|
|
45
|
-
function createHttpClientTool(defaultTimeout = 3e4, defaultHeaders = {}) {
|
|
46
|
-
return toolBuilder().name("http-client").description("Make HTTP requests to web APIs and services. Supports GET, POST, PUT, DELETE, PATCH methods with custom headers and body.").category(ToolCategory.WEB).tags(["http", "api", "request", "web"]).schema(httpRequestSchema).implement(async (input) => {
|
|
245
|
+
function createHttpClientTool(defaultTimeout = 3e4, defaultHeaders = {}, destinationPolicy = {}) {
|
|
246
|
+
return toolBuilder().name("http-client").description("Make policy-checked HTTP requests to web APIs and services. Supports GET, POST, PUT, DELETE, PATCH methods with custom headers and body. Local, metadata, link-local, and private-network destinations are blocked by default.").category(ToolCategory.WEB).tags(["http", "api", "request", "web"]).schema(httpRequestSchema).implement(async (input) => {
|
|
47
247
|
const config = {
|
|
48
248
|
method: input.method,
|
|
49
249
|
url: input.url,
|
|
@@ -54,37 +254,42 @@ function createHttpClientTool(defaultTimeout = 3e4, defaultHeaders = {}) {
|
|
|
54
254
|
validateStatus: () => true
|
|
55
255
|
// Don't throw on any status code
|
|
56
256
|
};
|
|
57
|
-
const response = await
|
|
257
|
+
const response = await requestWithDestinationPolicy(config, destinationPolicy);
|
|
58
258
|
return {
|
|
59
259
|
status: response.status,
|
|
60
260
|
statusText: response.statusText,
|
|
61
261
|
headers: response.headers,
|
|
62
262
|
data: response.data,
|
|
63
|
-
url: input.url,
|
|
263
|
+
url: response.config.url ?? input.url,
|
|
64
264
|
method: input.method ?? "GET"
|
|
65
265
|
};
|
|
66
266
|
}).build();
|
|
67
267
|
}
|
|
68
|
-
function createHttpGetTool(defaultTimeout = 3e4, defaultHeaders = {}) {
|
|
69
|
-
return toolBuilder().name("http-get").description("Make a
|
|
70
|
-
const response = await
|
|
268
|
+
function createHttpGetTool(defaultTimeout = 3e4, defaultHeaders = {}, destinationPolicy = {}) {
|
|
269
|
+
return toolBuilder().name("http-get").description("Make a policy-checked HTTP GET request to a URL and return the response data. Local, metadata, link-local, and private-network destinations are blocked by default.").category(ToolCategory.WEB).tags(["http", "get", "fetch", "web"]).schema(httpGetSchema).implement(async (input) => {
|
|
270
|
+
const response = await requestWithDestinationPolicy({
|
|
271
|
+
method: "GET",
|
|
272
|
+
url: input.url,
|
|
71
273
|
headers: { ...defaultHeaders, ...input.headers },
|
|
72
274
|
params: input.params,
|
|
73
275
|
timeout: defaultTimeout
|
|
74
|
-
});
|
|
276
|
+
}, destinationPolicy);
|
|
75
277
|
return response.data;
|
|
76
278
|
}).build();
|
|
77
279
|
}
|
|
78
|
-
function createHttpPostTool(defaultTimeout = 3e4, defaultHeaders = {}) {
|
|
79
|
-
return toolBuilder().name("http-post").description("Make a
|
|
80
|
-
const response = await
|
|
280
|
+
function createHttpPostTool(defaultTimeout = 3e4, defaultHeaders = {}, destinationPolicy = {}) {
|
|
281
|
+
return toolBuilder().name("http-post").description("Make a policy-checked HTTP POST request with JSON body and return the response data. Local, metadata, link-local, and private-network destinations are blocked by default.").category(ToolCategory.WEB).tags(["http", "post", "api", "web"]).schema(httpPostSchema).implement(async (input) => {
|
|
282
|
+
const response = await requestWithDestinationPolicy({
|
|
283
|
+
method: "POST",
|
|
284
|
+
url: input.url,
|
|
285
|
+
data: input.body,
|
|
81
286
|
headers: {
|
|
82
287
|
"Content-Type": "application/json",
|
|
83
288
|
...defaultHeaders,
|
|
84
289
|
...input.headers
|
|
85
290
|
},
|
|
86
291
|
timeout: defaultTimeout
|
|
87
|
-
});
|
|
292
|
+
}, destinationPolicy);
|
|
88
293
|
return response.data;
|
|
89
294
|
}).build();
|
|
90
295
|
}
|
|
@@ -95,11 +300,11 @@ var httpGet = createHttpGetTool();
|
|
|
95
300
|
var httpPost = createHttpPostTool();
|
|
96
301
|
var httpTools = [httpClient, httpGet, httpPost];
|
|
97
302
|
function createHttpTools(config = {}) {
|
|
98
|
-
const { defaultTimeout = 3e4, defaultHeaders = {} } = config;
|
|
303
|
+
const { defaultTimeout = 3e4, defaultHeaders = {}, destinationPolicy = {} } = config;
|
|
99
304
|
return [
|
|
100
|
-
createHttpClientTool(defaultTimeout, defaultHeaders),
|
|
101
|
-
createHttpGetTool(defaultTimeout, defaultHeaders),
|
|
102
|
-
createHttpPostTool(defaultTimeout, defaultHeaders)
|
|
305
|
+
createHttpClientTool(defaultTimeout, defaultHeaders, destinationPolicy),
|
|
306
|
+
createHttpGetTool(defaultTimeout, defaultHeaders, destinationPolicy),
|
|
307
|
+
createHttpPostTool(defaultTimeout, defaultHeaders, destinationPolicy)
|
|
103
308
|
];
|
|
104
309
|
}
|
|
105
310
|
var webScraperSchema = z.object({
|
|
@@ -112,18 +317,20 @@ var webScraperSchema = z.object({
|
|
|
112
317
|
extractMetadata: z.boolean().default(false).describe("Extract meta tags (title, description, etc.)"),
|
|
113
318
|
timeout: z.number().default(3e4).describe("Request timeout in milliseconds")
|
|
114
319
|
});
|
|
115
|
-
function createWebScraperTool(defaultTimeout = 3e4, userAgent = "Mozilla/5.0 (compatible; AgentForge/1.0; +https://agentforge.dev)") {
|
|
116
|
-
return toolBuilder().name("web-scraper").description("Scrape and extract data from web pages.
|
|
117
|
-
const response = await
|
|
320
|
+
function createWebScraperTool(defaultTimeout = 3e4, userAgent = "Mozilla/5.0 (compatible; AgentForge/1.0; +https://agentforge.dev)", destinationPolicy = {}) {
|
|
321
|
+
return toolBuilder().name("web-scraper").description("Scrape and extract data from policy-checked web pages. Local, metadata, link-local, and private-network destinations are blocked by default. Supports text, HTML, links, images, and CSS selectors.").category(ToolCategory.WEB).tags(["scraper", "web", "html", "extract", "parse"]).schema(webScraperSchema).implement(async (input) => {
|
|
322
|
+
const response = await requestWithDestinationPolicy({
|
|
323
|
+
method: "GET",
|
|
324
|
+
url: input.url,
|
|
118
325
|
timeout: input.timeout || defaultTimeout,
|
|
119
326
|
headers: {
|
|
120
327
|
"User-Agent": userAgent
|
|
121
328
|
}
|
|
122
|
-
});
|
|
329
|
+
}, destinationPolicy);
|
|
123
330
|
const html = response.data;
|
|
124
331
|
const $ = cheerio.load(html);
|
|
125
332
|
const result = {
|
|
126
|
-
url: input.url
|
|
333
|
+
url: response.config.url ?? input.url
|
|
127
334
|
};
|
|
128
335
|
const $selected = input.selector ? $(input.selector) : $("body");
|
|
129
336
|
if (input.extractText) {
|
|
@@ -188,8 +395,8 @@ function createWebScraperTool(defaultTimeout = 3e4, userAgent = "Mozilla/5.0 (co
|
|
|
188
395
|
var webScraper = createWebScraperTool();
|
|
189
396
|
var scraperTools = [webScraper];
|
|
190
397
|
function createScraperTools(config = {}) {
|
|
191
|
-
const { defaultTimeout = 3e4, userAgent = "Mozilla/5.0 (compatible; AgentForge/1.0; +https://agentforge.dev)" } = config;
|
|
192
|
-
return [createWebScraperTool(defaultTimeout, userAgent)];
|
|
398
|
+
const { defaultTimeout = 3e4, userAgent = "Mozilla/5.0 (compatible; AgentForge/1.0; +https://agentforge.dev)", destinationPolicy = {} } = config;
|
|
399
|
+
return [createWebScraperTool(defaultTimeout, userAgent, destinationPolicy)];
|
|
193
400
|
}
|
|
194
401
|
var htmlParserSchema = z.object({
|
|
195
402
|
html: z.string().describe("The HTML content to parse"),
|
|
@@ -463,7 +670,7 @@ function isRetryableError(error) {
|
|
|
463
670
|
return false;
|
|
464
671
|
}
|
|
465
672
|
function sleep(ms) {
|
|
466
|
-
return new Promise((
|
|
673
|
+
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
467
674
|
}
|
|
468
675
|
async function retryWithBackoff(fn, config = DEFAULT_RETRY_CONFIG) {
|
|
469
676
|
let lastError;
|
|
@@ -504,7 +711,7 @@ var DuckDuckGoProvider = class {
|
|
|
504
711
|
async search(query, maxResults, timeout = DEFAULT_TIMEOUT) {
|
|
505
712
|
return retryWithBackoff(async () => {
|
|
506
713
|
try {
|
|
507
|
-
const response = await
|
|
714
|
+
const response = await axios13.get(
|
|
508
715
|
"https://api.duckduckgo.com/",
|
|
509
716
|
{
|
|
510
717
|
params: {
|
|
@@ -608,7 +815,7 @@ var SerperProvider = class {
|
|
|
608
815
|
}
|
|
609
816
|
return retryWithBackoff(async () => {
|
|
610
817
|
try {
|
|
611
|
-
const response = await
|
|
818
|
+
const response = await axios13.post(
|
|
612
819
|
"https://google.serper.dev/search",
|
|
613
820
|
{
|
|
614
821
|
q: query,
|
|
@@ -1042,7 +1249,7 @@ function createSearchConfluenceTool(getAuth, getAuthHeader2, logger19) {
|
|
|
1042
1249
|
logger19.info("search-confluence called", { query, limit });
|
|
1043
1250
|
try {
|
|
1044
1251
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1045
|
-
const response = await
|
|
1252
|
+
const response = await axios13.get(`${ATLASSIAN_SITE_URL}/wiki/rest/api/content/search`, {
|
|
1046
1253
|
headers: {
|
|
1047
1254
|
Authorization: getAuthHeader2(),
|
|
1048
1255
|
Accept: "application/json"
|
|
@@ -1104,7 +1311,7 @@ function createGetConfluencePageTool(getAuth, getAuthHeader2, logger19) {
|
|
|
1104
1311
|
logger19.info("get-confluence-page called", { page_id });
|
|
1105
1312
|
try {
|
|
1106
1313
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1107
|
-
const response = await
|
|
1314
|
+
const response = await axios13.get(`${ATLASSIAN_SITE_URL}/wiki/rest/api/content/${page_id}`, {
|
|
1108
1315
|
headers: {
|
|
1109
1316
|
Authorization: getAuthHeader2(),
|
|
1110
1317
|
Accept: "application/json"
|
|
@@ -1155,7 +1362,7 @@ function createListConfluenceSpacesTool(getAuth, getAuthHeader2, logger19) {
|
|
|
1155
1362
|
logger19.info("list-confluence-spaces called", { limit });
|
|
1156
1363
|
try {
|
|
1157
1364
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1158
|
-
const response = await
|
|
1365
|
+
const response = await axios13.get(`${ATLASSIAN_SITE_URL}/wiki/rest/api/space`, {
|
|
1159
1366
|
headers: {
|
|
1160
1367
|
Authorization: getAuthHeader2(),
|
|
1161
1368
|
Accept: "application/json"
|
|
@@ -1201,7 +1408,7 @@ function createGetSpacePagesTool(getAuth, getAuthHeader2, logger19) {
|
|
|
1201
1408
|
logger19.info("get-space-pages called", { space_key, limit });
|
|
1202
1409
|
try {
|
|
1203
1410
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1204
|
-
const response = await
|
|
1411
|
+
const response = await axios13.get(`${ATLASSIAN_SITE_URL}/wiki/rest/api/content`, {
|
|
1205
1412
|
headers: {
|
|
1206
1413
|
Authorization: getAuthHeader2(),
|
|
1207
1414
|
Accept: "application/json"
|
|
@@ -1275,7 +1482,7 @@ function createCreateConfluencePageTool(getAuth, getAuthHeader2, logger19) {
|
|
|
1275
1482
|
if (parent_page_id) {
|
|
1276
1483
|
pageData.ancestors = [{ id: parent_page_id }];
|
|
1277
1484
|
}
|
|
1278
|
-
const response = await
|
|
1485
|
+
const response = await axios13.post(
|
|
1279
1486
|
`${ATLASSIAN_SITE_URL}/wiki/rest/api/content`,
|
|
1280
1487
|
pageData,
|
|
1281
1488
|
{
|
|
@@ -1323,7 +1530,7 @@ function createUpdateConfluencePageTool(getAuth, getAuthHeader2, logger19) {
|
|
|
1323
1530
|
logger19.info("update-confluence-page called", { page_id, title });
|
|
1324
1531
|
try {
|
|
1325
1532
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1326
|
-
const getResponse = await
|
|
1533
|
+
const getResponse = await axios13.get(
|
|
1327
1534
|
`${ATLASSIAN_SITE_URL}/wiki/rest/api/content/${page_id}`,
|
|
1328
1535
|
{
|
|
1329
1536
|
headers: {
|
|
@@ -1333,7 +1540,7 @@ function createUpdateConfluencePageTool(getAuth, getAuthHeader2, logger19) {
|
|
|
1333
1540
|
}
|
|
1334
1541
|
);
|
|
1335
1542
|
const currentVersion = getResponse.data.version.number;
|
|
1336
|
-
const updateResponse = await
|
|
1543
|
+
const updateResponse = await axios13.put(
|
|
1337
1544
|
`${ATLASSIAN_SITE_URL}/wiki/rest/api/content/${page_id}`,
|
|
1338
1545
|
{
|
|
1339
1546
|
type: "page",
|
|
@@ -1394,7 +1601,7 @@ function createArchiveConfluencePageTool(getAuth, getAuthHeader2, logger19) {
|
|
|
1394
1601
|
});
|
|
1395
1602
|
try {
|
|
1396
1603
|
const { ATLASSIAN_SITE_URL } = getAuth();
|
|
1397
|
-
const getResponse = await
|
|
1604
|
+
const getResponse = await axios13.get(
|
|
1398
1605
|
`${ATLASSIAN_SITE_URL}/wiki/rest/api/content/${page_id}`,
|
|
1399
1606
|
{
|
|
1400
1607
|
headers: {
|
|
@@ -1405,7 +1612,7 @@ function createArchiveConfluencePageTool(getAuth, getAuthHeader2, logger19) {
|
|
|
1405
1612
|
);
|
|
1406
1613
|
const currentVersion = getResponse.data.version.number;
|
|
1407
1614
|
const pageData = getResponse.data;
|
|
1408
|
-
await
|
|
1615
|
+
await axios13.put(
|
|
1409
1616
|
`${ATLASSIAN_SITE_URL}/wiki/rest/api/content/${page_id}`,
|
|
1410
1617
|
{
|
|
1411
1618
|
version: { number: currentVersion + 1 },
|
|
@@ -1972,8 +2179,8 @@ var objectOmitSchema = z.object({
|
|
|
1972
2179
|
});
|
|
1973
2180
|
|
|
1974
2181
|
// src/data/transformer/tools/shared.ts
|
|
1975
|
-
function getNestedValue(value,
|
|
1976
|
-
return
|
|
2182
|
+
function getNestedValue(value, path13) {
|
|
2183
|
+
return path13.split(".").reduce((current, key) => {
|
|
1977
2184
|
if (current == null) {
|
|
1978
2185
|
return void 0;
|
|
1979
2186
|
}
|
|
@@ -2363,7 +2570,7 @@ function isRetryableError2(error) {
|
|
|
2363
2570
|
return false;
|
|
2364
2571
|
}
|
|
2365
2572
|
function sleep2(ms) {
|
|
2366
|
-
return new Promise((
|
|
2573
|
+
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
2367
2574
|
}
|
|
2368
2575
|
async function retryWithBackoff2(fn, config = DEFAULT_RETRY_CONFIG2) {
|
|
2369
2576
|
let lastError;
|
|
@@ -2470,7 +2677,7 @@ var OpenAIEmbeddingProvider = class {
|
|
|
2470
2677
|
const modelToUse = model || this.defaultModel;
|
|
2471
2678
|
return retryWithBackoff2(async () => {
|
|
2472
2679
|
try {
|
|
2473
|
-
const response = await
|
|
2680
|
+
const response = await axios13.post(
|
|
2474
2681
|
`${this.baseURL}/embeddings`,
|
|
2475
2682
|
{
|
|
2476
2683
|
input: text,
|
|
@@ -2534,7 +2741,7 @@ var OpenAIEmbeddingProvider = class {
|
|
|
2534
2741
|
const modelToUse = model || this.defaultModel;
|
|
2535
2742
|
return retryWithBackoff2(async () => {
|
|
2536
2743
|
try {
|
|
2537
|
-
const response = await
|
|
2744
|
+
const response = await axios13.post(
|
|
2538
2745
|
`${this.baseURL}/embeddings`,
|
|
2539
2746
|
{
|
|
2540
2747
|
input: texts,
|
|
@@ -2614,7 +2821,7 @@ var CohereEmbeddingProvider = class {
|
|
|
2614
2821
|
const modelToUse = model || this.defaultModel;
|
|
2615
2822
|
return retryWithBackoff2(async () => {
|
|
2616
2823
|
try {
|
|
2617
|
-
const response = await
|
|
2824
|
+
const response = await axios13.post(
|
|
2618
2825
|
`${this.baseUrl}/embed`,
|
|
2619
2826
|
{
|
|
2620
2827
|
texts,
|
|
@@ -2642,7 +2849,7 @@ var CohereEmbeddingProvider = class {
|
|
|
2642
2849
|
} : void 0
|
|
2643
2850
|
};
|
|
2644
2851
|
} catch (error) {
|
|
2645
|
-
if (
|
|
2852
|
+
if (axios13.isAxiosError(error)) {
|
|
2646
2853
|
const status = error.response?.status;
|
|
2647
2854
|
const message = error.response?.data?.message || error.message;
|
|
2648
2855
|
let wrappedError;
|
|
@@ -2682,7 +2889,7 @@ var HuggingFaceEmbeddingProvider = class {
|
|
|
2682
2889
|
const modelToUse = model || this.defaultModel;
|
|
2683
2890
|
return retryWithBackoff2(async () => {
|
|
2684
2891
|
try {
|
|
2685
|
-
const response = await
|
|
2892
|
+
const response = await axios13.post(
|
|
2686
2893
|
`${this.baseUrl}/${modelToUse}`,
|
|
2687
2894
|
{
|
|
2688
2895
|
inputs: text,
|
|
@@ -2704,7 +2911,7 @@ var HuggingFaceEmbeddingProvider = class {
|
|
|
2704
2911
|
dimensions: embedding.length
|
|
2705
2912
|
};
|
|
2706
2913
|
} catch (error) {
|
|
2707
|
-
if (
|
|
2914
|
+
if (axios13.isAxiosError(error)) {
|
|
2708
2915
|
const status = error.response?.status;
|
|
2709
2916
|
const message = error.response?.data?.error || error.message;
|
|
2710
2917
|
let wrappedError;
|
|
@@ -2731,7 +2938,7 @@ var HuggingFaceEmbeddingProvider = class {
|
|
|
2731
2938
|
const modelToUse = model || this.defaultModel;
|
|
2732
2939
|
return retryWithBackoff2(async () => {
|
|
2733
2940
|
try {
|
|
2734
|
-
const response = await
|
|
2941
|
+
const response = await axios13.post(
|
|
2735
2942
|
`${this.baseUrl}/${modelToUse}`,
|
|
2736
2943
|
{
|
|
2737
2944
|
inputs: texts,
|
|
@@ -2754,7 +2961,7 @@ var HuggingFaceEmbeddingProvider = class {
|
|
|
2754
2961
|
dimensions
|
|
2755
2962
|
};
|
|
2756
2963
|
} catch (error) {
|
|
2757
|
-
if (
|
|
2964
|
+
if (axios13.isAxiosError(error)) {
|
|
2758
2965
|
const status = error.response?.status;
|
|
2759
2966
|
const message = error.response?.data?.error || error.message;
|
|
2760
2967
|
let wrappedError;
|
|
@@ -2805,7 +3012,7 @@ var VoyageEmbeddingProvider = class {
|
|
|
2805
3012
|
const modelToUse = model || this.defaultModel;
|
|
2806
3013
|
return retryWithBackoff2(async () => {
|
|
2807
3014
|
try {
|
|
2808
|
-
const response = await
|
|
3015
|
+
const response = await axios13.post(
|
|
2809
3016
|
`${this.baseUrl}/embeddings`,
|
|
2810
3017
|
{
|
|
2811
3018
|
input: texts,
|
|
@@ -2832,7 +3039,7 @@ var VoyageEmbeddingProvider = class {
|
|
|
2832
3039
|
} : void 0
|
|
2833
3040
|
};
|
|
2834
3041
|
} catch (error) {
|
|
2835
|
-
if (
|
|
3042
|
+
if (axios13.isAxiosError(error)) {
|
|
2836
3043
|
const status = error.response?.status;
|
|
2837
3044
|
const message = error.response?.data?.message || error.message;
|
|
2838
3045
|
let wrappedError;
|
|
@@ -2871,7 +3078,7 @@ var OllamaEmbeddingProvider = class {
|
|
|
2871
3078
|
const modelToUse = model || this.defaultModel;
|
|
2872
3079
|
return retryWithBackoff2(async () => {
|
|
2873
3080
|
try {
|
|
2874
|
-
const response = await
|
|
3081
|
+
const response = await axios13.post(
|
|
2875
3082
|
`${this.baseUrl}/api/embeddings`,
|
|
2876
3083
|
{
|
|
2877
3084
|
model: modelToUse,
|
|
@@ -2890,7 +3097,7 @@ var OllamaEmbeddingProvider = class {
|
|
|
2890
3097
|
dimensions: embedding.length
|
|
2891
3098
|
};
|
|
2892
3099
|
} catch (error) {
|
|
2893
|
-
if (
|
|
3100
|
+
if (axios13.isAxiosError(error)) {
|
|
2894
3101
|
const status = error.response?.status;
|
|
2895
3102
|
const message = error.response?.data?.error || error.message;
|
|
2896
3103
|
let wrappedError;
|
|
@@ -3262,16 +3469,16 @@ function formatRelationship(rel) {
|
|
|
3262
3469
|
properties: formatValue(rel.properties)
|
|
3263
3470
|
};
|
|
3264
3471
|
}
|
|
3265
|
-
function formatPath(
|
|
3472
|
+
function formatPath(path13) {
|
|
3266
3473
|
return {
|
|
3267
|
-
start: formatNode(
|
|
3268
|
-
end: formatNode(
|
|
3269
|
-
segments:
|
|
3474
|
+
start: formatNode(path13.start),
|
|
3475
|
+
end: formatNode(path13.end),
|
|
3476
|
+
segments: path13.segments.map((segment) => ({
|
|
3270
3477
|
start: formatNode(segment.start),
|
|
3271
3478
|
relationship: formatRelationship(segment.relationship),
|
|
3272
3479
|
end: formatNode(segment.end)
|
|
3273
3480
|
})),
|
|
3274
|
-
length:
|
|
3481
|
+
length: path13.length
|
|
3275
3482
|
};
|
|
3276
3483
|
}
|
|
3277
3484
|
function formatResults(records) {
|
|
@@ -5448,8 +5655,8 @@ function toBatchErrorMessage(error) {
|
|
|
5448
5655
|
return error instanceof Error ? error.message : String(error);
|
|
5449
5656
|
}
|
|
5450
5657
|
function delayBatchRetry(ms) {
|
|
5451
|
-
return new Promise((
|
|
5452
|
-
setTimeout(
|
|
5658
|
+
return new Promise((resolve3) => {
|
|
5659
|
+
setTimeout(resolve3, ms);
|
|
5453
5660
|
});
|
|
5454
5661
|
}
|
|
5455
5662
|
|
|
@@ -5875,7 +6082,7 @@ function withTransactionTimeout(operation, timeoutMs, onTimeout) {
|
|
|
5875
6082
|
if (!timeoutMs) {
|
|
5876
6083
|
return operation;
|
|
5877
6084
|
}
|
|
5878
|
-
return new Promise((
|
|
6085
|
+
return new Promise((resolve3, reject) => {
|
|
5879
6086
|
let timedOut = false;
|
|
5880
6087
|
const timer = setTimeout(() => {
|
|
5881
6088
|
timedOut = true;
|
|
@@ -5887,7 +6094,7 @@ function withTransactionTimeout(operation, timeoutMs, onTimeout) {
|
|
|
5887
6094
|
return;
|
|
5888
6095
|
}
|
|
5889
6096
|
clearTimeout(timer);
|
|
5890
|
-
|
|
6097
|
+
resolve3(result);
|
|
5891
6098
|
}).catch((error) => {
|
|
5892
6099
|
if (timedOut) {
|
|
5893
6100
|
return;
|
|
@@ -9120,11 +9327,135 @@ var fileDeleteSchema = z.object({
|
|
|
9120
9327
|
var fileExistsSchema = z.object({
|
|
9121
9328
|
path: z.string().describe("Path to check")
|
|
9122
9329
|
});
|
|
9123
|
-
|
|
9330
|
+
var FileSystemPolicyError = class extends Error {
|
|
9331
|
+
constructor(message, operation, inputPath) {
|
|
9332
|
+
super(message);
|
|
9333
|
+
this.operation = operation;
|
|
9334
|
+
this.inputPath = inputPath;
|
|
9335
|
+
this.name = "FileSystemPolicyError";
|
|
9336
|
+
}
|
|
9337
|
+
code = "FILE_SYSTEM_POLICY_VIOLATION";
|
|
9338
|
+
};
|
|
9339
|
+
function containsTraversal(inputPath) {
|
|
9340
|
+
return inputPath.split(/[\\/]+/).includes("..");
|
|
9341
|
+
}
|
|
9342
|
+
function isWithinRoot(root, target) {
|
|
9343
|
+
const relative4 = path.relative(root, target);
|
|
9344
|
+
return relative4 === "" || !relative4.startsWith(`..${path.sep}`) && relative4 !== ".." && !path.isAbsolute(relative4);
|
|
9345
|
+
}
|
|
9346
|
+
async function resolveWithMissingTail(inputPath) {
|
|
9347
|
+
let currentPath = inputPath;
|
|
9348
|
+
const missingSegments = [];
|
|
9349
|
+
while (true) {
|
|
9350
|
+
try {
|
|
9351
|
+
const resolvedPath = await promises.realpath(currentPath);
|
|
9352
|
+
return path.join(resolvedPath, ...missingSegments);
|
|
9353
|
+
} catch (error) {
|
|
9354
|
+
const code = error.code;
|
|
9355
|
+
if (code !== "ENOENT" && code !== "ENOTDIR") {
|
|
9356
|
+
throw error;
|
|
9357
|
+
}
|
|
9358
|
+
const parentPath = path.dirname(currentPath);
|
|
9359
|
+
if (parentPath === currentPath) {
|
|
9360
|
+
throw error;
|
|
9361
|
+
}
|
|
9362
|
+
missingSegments.unshift(path.basename(currentPath));
|
|
9363
|
+
currentPath = parentPath;
|
|
9364
|
+
}
|
|
9365
|
+
}
|
|
9366
|
+
}
|
|
9367
|
+
var FileSystemPolicy = class {
|
|
9368
|
+
allowedRoots;
|
|
9369
|
+
allowOutsideRoots;
|
|
9370
|
+
allowRootDeletion;
|
|
9371
|
+
baseDirectory;
|
|
9372
|
+
constructor(options = {}) {
|
|
9373
|
+
const configuredRoots = [
|
|
9374
|
+
...options.allowedRoots ?? [],
|
|
9375
|
+
...options.workspaceRoot ? [options.workspaceRoot] : []
|
|
9376
|
+
];
|
|
9377
|
+
this.allowedRoots = [...new Set(configuredRoots.map((root) => path.resolve(root)))];
|
|
9378
|
+
this.baseDirectory = path.resolve(options.workspaceRoot ?? process.cwd());
|
|
9379
|
+
this.allowOutsideRoots = options.allowOutsideRoots ?? this.allowedRoots.length === 0;
|
|
9380
|
+
this.allowRootDeletion = options.allowRootDeletion ?? this.allowOutsideRoots;
|
|
9381
|
+
}
|
|
9382
|
+
async resolvePath(inputPath, operation) {
|
|
9383
|
+
const { resolvedPath } = await this.resolvePathWithRoots(inputPath, operation);
|
|
9384
|
+
return resolvedPath;
|
|
9385
|
+
}
|
|
9386
|
+
async resolveDeletePath(inputPath, recursive) {
|
|
9387
|
+
const { resolvedPath, resolvedRoots } = await this.resolvePathWithRoots(inputPath, "directory deletion");
|
|
9388
|
+
if (recursive && !this.allowRootDeletion && resolvedRoots.some((root) => root === resolvedPath)) {
|
|
9389
|
+
throw new FileSystemPolicyError(
|
|
9390
|
+
"Filesystem policy blocked directory deletion: recursive deletion of an allowed root is not permitted",
|
|
9391
|
+
"directory deletion",
|
|
9392
|
+
inputPath
|
|
9393
|
+
);
|
|
9394
|
+
}
|
|
9395
|
+
return resolvedPath;
|
|
9396
|
+
}
|
|
9397
|
+
async resolvePathWithRoots(inputPath, operation) {
|
|
9398
|
+
const absolutePath = path.resolve(this.baseDirectory, inputPath);
|
|
9399
|
+
if (this.allowOutsideRoots) {
|
|
9400
|
+
return { resolvedPath: absolutePath, resolvedRoots: [] };
|
|
9401
|
+
}
|
|
9402
|
+
if (containsTraversal(inputPath)) {
|
|
9403
|
+
throw new FileSystemPolicyError(
|
|
9404
|
+
`Filesystem policy blocked ${operation}: path traversal is not allowed`,
|
|
9405
|
+
operation,
|
|
9406
|
+
inputPath
|
|
9407
|
+
);
|
|
9408
|
+
}
|
|
9409
|
+
let resolvedPath;
|
|
9410
|
+
try {
|
|
9411
|
+
resolvedPath = await resolveWithMissingTail(absolutePath);
|
|
9412
|
+
} catch {
|
|
9413
|
+
throw new FileSystemPolicyError(
|
|
9414
|
+
`Filesystem policy could not resolve ${operation} path`,
|
|
9415
|
+
operation,
|
|
9416
|
+
inputPath
|
|
9417
|
+
);
|
|
9418
|
+
}
|
|
9419
|
+
const resolvedRoots = await this.resolveRoots(operation, inputPath);
|
|
9420
|
+
if (!resolvedRoots.some((root) => isWithinRoot(root, resolvedPath))) {
|
|
9421
|
+
throw new FileSystemPolicyError(
|
|
9422
|
+
`Filesystem policy blocked ${operation}: path is outside the allowed roots`,
|
|
9423
|
+
operation,
|
|
9424
|
+
inputPath
|
|
9425
|
+
);
|
|
9426
|
+
}
|
|
9427
|
+
return { resolvedPath, resolvedRoots };
|
|
9428
|
+
}
|
|
9429
|
+
async resolveRoots(operation, inputPath) {
|
|
9430
|
+
try {
|
|
9431
|
+
return await Promise.all(this.allowedRoots.map((root) => promises.realpath(root)));
|
|
9432
|
+
} catch {
|
|
9433
|
+
throw new FileSystemPolicyError(
|
|
9434
|
+
`Filesystem policy could not resolve an allowed root for ${operation}`,
|
|
9435
|
+
operation,
|
|
9436
|
+
inputPath
|
|
9437
|
+
);
|
|
9438
|
+
}
|
|
9439
|
+
}
|
|
9440
|
+
};
|
|
9441
|
+
var DEFAULT_FILE_SYSTEM_POLICY = new FileSystemPolicy();
|
|
9442
|
+
function createFileSystemPolicy(options = {}) {
|
|
9443
|
+
return new FileSystemPolicy(options);
|
|
9444
|
+
}
|
|
9445
|
+
function resolveFileSystemPolicy(policy) {
|
|
9446
|
+
if (!policy) {
|
|
9447
|
+
return DEFAULT_FILE_SYSTEM_POLICY;
|
|
9448
|
+
}
|
|
9449
|
+
return policy instanceof FileSystemPolicy ? policy : createFileSystemPolicy(policy);
|
|
9450
|
+
}
|
|
9451
|
+
|
|
9452
|
+
// src/file/operations/tools/file-reader.ts
|
|
9453
|
+
function createFileReaderTool(defaultEncoding = "utf8", policy = DEFAULT_FILE_SYSTEM_POLICY) {
|
|
9124
9454
|
return toolBuilder().name("file-reader").description("Read the contents of a file from the file system. Supports text and binary files with various encodings.").category(ToolCategory.FILE_SYSTEM).tags(["file", "read", "io", "filesystem"]).schema(fileReaderSchema).implementSafe(async (input) => {
|
|
9125
9455
|
const encoding = input.encoding || defaultEncoding;
|
|
9126
|
-
const
|
|
9127
|
-
const
|
|
9456
|
+
const safePath = await policy.resolvePath(input.path, "file read");
|
|
9457
|
+
const content = await promises.readFile(safePath, encoding);
|
|
9458
|
+
const stats = await promises.stat(safePath);
|
|
9128
9459
|
return {
|
|
9129
9460
|
content,
|
|
9130
9461
|
size: stats.size,
|
|
@@ -9133,16 +9464,17 @@ function createFileReaderTool(defaultEncoding = "utf8") {
|
|
|
9133
9464
|
};
|
|
9134
9465
|
}).build();
|
|
9135
9466
|
}
|
|
9136
|
-
function createFileWriterTool(defaultEncoding = "utf8", createDirsDefault = false) {
|
|
9467
|
+
function createFileWriterTool(defaultEncoding = "utf8", createDirsDefault = false, policy = DEFAULT_FILE_SYSTEM_POLICY) {
|
|
9137
9468
|
return toolBuilder().name("file-writer").description("Write content to a file. Creates the file if it doesn't exist, or overwrites it if it does.").category(ToolCategory.FILE_SYSTEM).tags(["file", "write", "io", "filesystem"]).schema(fileWriterSchema).implementSafe(async (input) => {
|
|
9138
9469
|
const encoding = input.encoding || defaultEncoding;
|
|
9139
9470
|
const createDirs = input.createDirs ?? createDirsDefault;
|
|
9471
|
+
const safePath = await policy.resolvePath(input.path, "file write");
|
|
9140
9472
|
if (createDirs) {
|
|
9141
|
-
const dir =
|
|
9473
|
+
const dir = path.dirname(safePath);
|
|
9142
9474
|
await promises.mkdir(dir, { recursive: true });
|
|
9143
9475
|
}
|
|
9144
|
-
await promises.writeFile(
|
|
9145
|
-
const stats = await promises.stat(
|
|
9476
|
+
await promises.writeFile(safePath, input.content, encoding);
|
|
9477
|
+
const stats = await promises.stat(safePath);
|
|
9146
9478
|
return {
|
|
9147
9479
|
path: input.path,
|
|
9148
9480
|
size: stats.size,
|
|
@@ -9150,31 +9482,34 @@ function createFileWriterTool(defaultEncoding = "utf8", createDirsDefault = fals
|
|
|
9150
9482
|
};
|
|
9151
9483
|
}).build();
|
|
9152
9484
|
}
|
|
9153
|
-
function createFileAppendTool(defaultEncoding = "utf8") {
|
|
9485
|
+
function createFileAppendTool(defaultEncoding = "utf8", policy = DEFAULT_FILE_SYSTEM_POLICY) {
|
|
9154
9486
|
return toolBuilder().name("file-append").description("Append content to the end of a file. Creates the file if it doesn't exist.").category(ToolCategory.FILE_SYSTEM).tags(["file", "append", "io", "filesystem"]).schema(fileAppendSchema).implementSafe(async (input) => {
|
|
9155
9487
|
const encoding = input.encoding || defaultEncoding;
|
|
9156
|
-
await
|
|
9157
|
-
|
|
9488
|
+
const safePath = await policy.resolvePath(input.path, "file append");
|
|
9489
|
+
await promises.appendFile(safePath, input.content, encoding);
|
|
9490
|
+
const stats = await promises.stat(safePath);
|
|
9158
9491
|
return {
|
|
9159
9492
|
path: input.path,
|
|
9160
9493
|
size: stats.size
|
|
9161
9494
|
};
|
|
9162
9495
|
}).build();
|
|
9163
9496
|
}
|
|
9164
|
-
function createFileDeleteTool() {
|
|
9497
|
+
function createFileDeleteTool(policy = DEFAULT_FILE_SYSTEM_POLICY) {
|
|
9165
9498
|
return toolBuilder().name("file-delete").description("Delete a file from the file system. Returns an error if the file doesn't exist.").category(ToolCategory.FILE_SYSTEM).tags(["file", "delete", "remove", "filesystem"]).schema(fileDeleteSchema).implementSafe(async (input) => {
|
|
9166
|
-
await
|
|
9499
|
+
const safePath = await policy.resolvePath(input.path, "file deletion");
|
|
9500
|
+
await promises.unlink(safePath);
|
|
9167
9501
|
return {
|
|
9168
9502
|
path: input.path,
|
|
9169
9503
|
message: "File deleted successfully"
|
|
9170
9504
|
};
|
|
9171
9505
|
}).build();
|
|
9172
9506
|
}
|
|
9173
|
-
function createFileExistsTool() {
|
|
9507
|
+
function createFileExistsTool(policy = DEFAULT_FILE_SYSTEM_POLICY) {
|
|
9174
9508
|
return toolBuilder().name("file-exists").description("Check if a file or directory exists at the specified path.").category(ToolCategory.FILE_SYSTEM).tags(["file", "exists", "check", "filesystem"]).schema(fileExistsSchema).implement(async (input) => {
|
|
9175
9509
|
try {
|
|
9176
|
-
await
|
|
9177
|
-
|
|
9510
|
+
const safePath = await policy.resolvePath(input.path, "file existence check");
|
|
9511
|
+
await promises.access(safePath);
|
|
9512
|
+
const stats = await promises.stat(safePath);
|
|
9178
9513
|
return {
|
|
9179
9514
|
exists: true,
|
|
9180
9515
|
path: input.path,
|
|
@@ -9183,7 +9518,13 @@ function createFileExistsTool() {
|
|
|
9183
9518
|
size: stats.size,
|
|
9184
9519
|
modified: stats.mtime.toISOString()
|
|
9185
9520
|
};
|
|
9186
|
-
} catch {
|
|
9521
|
+
} catch (error) {
|
|
9522
|
+
if (error instanceof FileSystemPolicyError) {
|
|
9523
|
+
return {
|
|
9524
|
+
success: false,
|
|
9525
|
+
error: error.message
|
|
9526
|
+
};
|
|
9527
|
+
}
|
|
9187
9528
|
return {
|
|
9188
9529
|
exists: false,
|
|
9189
9530
|
path: input.path
|
|
@@ -9208,14 +9549,16 @@ var fileOperationTools = [
|
|
|
9208
9549
|
function createFileOperationTools(config = {}) {
|
|
9209
9550
|
const {
|
|
9210
9551
|
defaultEncoding = "utf8",
|
|
9211
|
-
createDirsDefault = false
|
|
9552
|
+
createDirsDefault = false,
|
|
9553
|
+
policy: policyInput
|
|
9212
9554
|
} = config;
|
|
9555
|
+
const policy = resolveFileSystemPolicy(policyInput);
|
|
9213
9556
|
return [
|
|
9214
|
-
createFileReaderTool(defaultEncoding),
|
|
9215
|
-
createFileWriterTool(defaultEncoding, createDirsDefault),
|
|
9216
|
-
createFileAppendTool(defaultEncoding),
|
|
9217
|
-
createFileDeleteTool(),
|
|
9218
|
-
createFileExistsTool()
|
|
9557
|
+
createFileReaderTool(defaultEncoding, policy),
|
|
9558
|
+
createFileWriterTool(defaultEncoding, createDirsDefault, policy),
|
|
9559
|
+
createFileAppendTool(defaultEncoding, policy),
|
|
9560
|
+
createFileDeleteTool(policy),
|
|
9561
|
+
createFileExistsTool(policy)
|
|
9219
9562
|
];
|
|
9220
9563
|
}
|
|
9221
9564
|
var directoryListSchema = z.object({
|
|
@@ -9238,21 +9581,23 @@ var fileSearchSchema = z.object({
|
|
|
9238
9581
|
recursive: z.boolean().default(true).describe("Search in subdirectories"),
|
|
9239
9582
|
caseSensitive: z.boolean().default(false).describe("Case-sensitive pattern matching")
|
|
9240
9583
|
});
|
|
9241
|
-
function createDirectoryListTool(defaultRecursive = false, defaultIncludeDetails = false) {
|
|
9584
|
+
function createDirectoryListTool(defaultRecursive = false, defaultIncludeDetails = false, policy = DEFAULT_FILE_SYSTEM_POLICY) {
|
|
9242
9585
|
return toolBuilder().name("directory-list").description("List all files and directories in a directory. Can optionally include file details and filter by extension.").category(ToolCategory.FILE_SYSTEM).tags(["directory", "list", "files", "filesystem"]).schema(directoryListSchema).implementSafe(async (input) => {
|
|
9586
|
+
const safePath = await policy.resolvePath(input.path, "directory listing");
|
|
9587
|
+
const includeDetails = input.includeDetails ?? defaultIncludeDetails;
|
|
9243
9588
|
const listFiles = async (dir, recursive2) => {
|
|
9244
9589
|
const entries = await promises.readdir(dir, { withFileTypes: true });
|
|
9245
9590
|
const files2 = [];
|
|
9246
9591
|
for (const entry of entries) {
|
|
9247
|
-
const fullPath =
|
|
9248
|
-
const relativePath =
|
|
9592
|
+
const fullPath = path.join(dir, entry.name);
|
|
9593
|
+
const relativePath = path.relative(safePath, fullPath);
|
|
9249
9594
|
if (input.extension && !entry.name.endsWith(input.extension)) {
|
|
9250
9595
|
if (!entry.isDirectory() || !recursive2) {
|
|
9251
9596
|
continue;
|
|
9252
9597
|
}
|
|
9253
9598
|
}
|
|
9254
|
-
if (
|
|
9255
|
-
const stats = await promises.
|
|
9599
|
+
if (includeDetails) {
|
|
9600
|
+
const stats = await promises.lstat(fullPath);
|
|
9256
9601
|
files2.push({
|
|
9257
9602
|
name: entry.name,
|
|
9258
9603
|
path: relativePath,
|
|
@@ -9278,7 +9623,7 @@ function createDirectoryListTool(defaultRecursive = false, defaultIncludeDetails
|
|
|
9278
9623
|
return files2;
|
|
9279
9624
|
};
|
|
9280
9625
|
const recursive = input.recursive ?? defaultRecursive;
|
|
9281
|
-
const files = await listFiles(
|
|
9626
|
+
const files = await listFiles(safePath, recursive);
|
|
9282
9627
|
return {
|
|
9283
9628
|
path: input.path,
|
|
9284
9629
|
files,
|
|
@@ -9286,37 +9631,40 @@ function createDirectoryListTool(defaultRecursive = false, defaultIncludeDetails
|
|
|
9286
9631
|
};
|
|
9287
9632
|
}).build();
|
|
9288
9633
|
}
|
|
9289
|
-
function createDirectoryCreateTool(defaultRecursive = true) {
|
|
9634
|
+
function createDirectoryCreateTool(defaultRecursive = true, policy = DEFAULT_FILE_SYSTEM_POLICY) {
|
|
9290
9635
|
return toolBuilder().name("directory-create").description("Create a new directory. Can optionally create parent directories if they don't exist.").category(ToolCategory.FILE_SYSTEM).tags(["directory", "create", "mkdir", "filesystem"]).schema(directoryCreateSchema).implementSafe(async (input) => {
|
|
9291
9636
|
const recursive = input.recursive ?? defaultRecursive;
|
|
9292
|
-
await
|
|
9637
|
+
const safePath = await policy.resolvePath(input.path, "directory creation");
|
|
9638
|
+
await promises.mkdir(safePath, { recursive });
|
|
9293
9639
|
return {
|
|
9294
9640
|
path: input.path,
|
|
9295
9641
|
message: "Directory created successfully"
|
|
9296
9642
|
};
|
|
9297
9643
|
}).build();
|
|
9298
9644
|
}
|
|
9299
|
-
function createDirectoryDeleteTool(defaultRecursive = false) {
|
|
9645
|
+
function createDirectoryDeleteTool(defaultRecursive = false, policy = DEFAULT_FILE_SYSTEM_POLICY) {
|
|
9300
9646
|
return toolBuilder().name("directory-delete").description("Delete a directory. Can optionally delete non-empty directories recursively.").category(ToolCategory.FILE_SYSTEM).tags(["directory", "delete", "remove", "filesystem"]).schema(directoryDeleteSchema).implementSafe(async (input) => {
|
|
9301
9647
|
const recursive = input.recursive ?? defaultRecursive;
|
|
9302
|
-
await
|
|
9648
|
+
const safePath = await policy.resolveDeletePath(input.path, recursive);
|
|
9649
|
+
await promises.rm(safePath, { recursive, force: false });
|
|
9303
9650
|
return {
|
|
9304
9651
|
path: input.path,
|
|
9305
9652
|
message: "Directory deleted successfully"
|
|
9306
9653
|
};
|
|
9307
9654
|
}).build();
|
|
9308
9655
|
}
|
|
9309
|
-
function createFileSearchTool(defaultRecursive = true, defaultCaseSensitive = false) {
|
|
9656
|
+
function createFileSearchTool(defaultRecursive = true, defaultCaseSensitive = false, policy = DEFAULT_FILE_SYSTEM_POLICY) {
|
|
9310
9657
|
return toolBuilder().name("file-search").description("Search for files by name pattern in a directory. Supports wildcards and recursive search.").category(ToolCategory.FILE_SYSTEM).tags(["file", "search", "find", "filesystem"]).schema(fileSearchSchema).implementSafe(async (input) => {
|
|
9311
9658
|
const recursive = input.recursive ?? defaultRecursive;
|
|
9312
9659
|
const caseSensitive = input.caseSensitive ?? defaultCaseSensitive;
|
|
9660
|
+
const safeDirectory = await policy.resolvePath(input.directory, "file search");
|
|
9313
9661
|
const searchFiles = async (dir) => {
|
|
9314
9662
|
const entries = await promises.readdir(dir, { withFileTypes: true });
|
|
9315
9663
|
const matches2 = [];
|
|
9316
9664
|
const regexPattern = input.pattern.replace(/\./g, "\\.").replace(/\*/g, ".*");
|
|
9317
9665
|
const regex = new RegExp(`^${regexPattern}$`, caseSensitive ? "" : "i");
|
|
9318
9666
|
for (const entry of entries) {
|
|
9319
|
-
const fullPath =
|
|
9667
|
+
const fullPath = path.join(dir, entry.name);
|
|
9320
9668
|
if (entry.isFile() && regex.test(entry.name)) {
|
|
9321
9669
|
matches2.push(fullPath);
|
|
9322
9670
|
}
|
|
@@ -9327,7 +9675,7 @@ function createFileSearchTool(defaultRecursive = true, defaultCaseSensitive = fa
|
|
|
9327
9675
|
}
|
|
9328
9676
|
return matches2;
|
|
9329
9677
|
};
|
|
9330
|
-
const matches = await searchFiles(
|
|
9678
|
+
const matches = await searchFiles(safeDirectory);
|
|
9331
9679
|
return {
|
|
9332
9680
|
directory: input.directory,
|
|
9333
9681
|
pattern: input.pattern,
|
|
@@ -9352,15 +9700,17 @@ function createDirectoryOperationTools(config = {}) {
|
|
|
9352
9700
|
const {
|
|
9353
9701
|
defaultRecursive = false,
|
|
9354
9702
|
defaultIncludeDetails = false,
|
|
9355
|
-
defaultCaseSensitive = false
|
|
9703
|
+
defaultCaseSensitive = false,
|
|
9704
|
+
policy: policyInput
|
|
9356
9705
|
} = config;
|
|
9706
|
+
const policy = resolveFileSystemPolicy(policyInput);
|
|
9357
9707
|
return [
|
|
9358
|
-
createDirectoryListTool(defaultRecursive, defaultIncludeDetails),
|
|
9359
|
-
createDirectoryCreateTool(true),
|
|
9708
|
+
createDirectoryListTool(defaultRecursive, defaultIncludeDetails, policy),
|
|
9709
|
+
createDirectoryCreateTool(true, policy),
|
|
9360
9710
|
// Always default to true for create
|
|
9361
|
-
createDirectoryDeleteTool(false),
|
|
9711
|
+
createDirectoryDeleteTool(false, policy),
|
|
9362
9712
|
// Always default to false for delete (safety)
|
|
9363
|
-
createFileSearchTool(defaultRecursive, defaultCaseSensitive)
|
|
9713
|
+
createFileSearchTool(defaultRecursive, defaultCaseSensitive, policy)
|
|
9364
9714
|
];
|
|
9365
9715
|
}
|
|
9366
9716
|
var pathJoinSchema = z.object({
|
|
@@ -9391,7 +9741,7 @@ var pathNormalizeSchema = z.object({
|
|
|
9391
9741
|
});
|
|
9392
9742
|
function createPathJoinTool() {
|
|
9393
9743
|
return toolBuilder().name("path-join").description("Join multiple path segments into a single path. Handles platform-specific separators.").category(ToolCategory.FILE_SYSTEM).tags(["path", "join", "filesystem"]).schema(pathJoinSchema).implement(async (input) => {
|
|
9394
|
-
const joined =
|
|
9744
|
+
const joined = path.join(...input.segments);
|
|
9395
9745
|
return {
|
|
9396
9746
|
path: joined,
|
|
9397
9747
|
segments: input.segments
|
|
@@ -9400,59 +9750,59 @@ function createPathJoinTool() {
|
|
|
9400
9750
|
}
|
|
9401
9751
|
function createPathResolveTool() {
|
|
9402
9752
|
return toolBuilder().name("path-resolve").description("Resolve a sequence of paths into an absolute path. Resolves relative paths from the current working directory.").category(ToolCategory.FILE_SYSTEM).tags(["path", "resolve", "absolute", "filesystem"]).schema(pathResolveSchema).implement(async (input) => {
|
|
9403
|
-
const resolved =
|
|
9753
|
+
const resolved = path.resolve(...input.paths);
|
|
9404
9754
|
return {
|
|
9405
9755
|
path: resolved,
|
|
9406
|
-
isAbsolute:
|
|
9756
|
+
isAbsolute: path.isAbsolute(resolved)
|
|
9407
9757
|
};
|
|
9408
9758
|
}).build();
|
|
9409
9759
|
}
|
|
9410
9760
|
function createPathParseTool() {
|
|
9411
9761
|
return toolBuilder().name("path-parse").description("Parse a file path into its components (directory, filename, extension, etc.).").category(ToolCategory.FILE_SYSTEM).tags(["path", "parse", "filesystem"]).schema(pathParseSchema).implement(async (input) => {
|
|
9412
|
-
const parsed =
|
|
9762
|
+
const parsed = path.parse(input.path);
|
|
9413
9763
|
return {
|
|
9414
9764
|
root: parsed.root,
|
|
9415
9765
|
dir: parsed.dir,
|
|
9416
9766
|
base: parsed.base,
|
|
9417
9767
|
name: parsed.name,
|
|
9418
9768
|
ext: parsed.ext,
|
|
9419
|
-
isAbsolute:
|
|
9769
|
+
isAbsolute: path.isAbsolute(input.path)
|
|
9420
9770
|
};
|
|
9421
9771
|
}).build();
|
|
9422
9772
|
}
|
|
9423
9773
|
function createPathBasenameTool() {
|
|
9424
9774
|
return toolBuilder().name("path-basename").description("Get the last portion of a path (filename with extension). Optionally remove the extension.").category(ToolCategory.FILE_SYSTEM).tags(["path", "basename", "filename", "filesystem"]).schema(pathBasenameSchema).implement(async (input) => {
|
|
9425
|
-
const
|
|
9775
|
+
const basename5 = input.removeExtension ? path.basename(input.path, path.extname(input.path)) : path.basename(input.path);
|
|
9426
9776
|
return {
|
|
9427
|
-
basename:
|
|
9428
|
-
extension:
|
|
9777
|
+
basename: basename5,
|
|
9778
|
+
extension: path.extname(input.path)
|
|
9429
9779
|
};
|
|
9430
9780
|
}).build();
|
|
9431
9781
|
}
|
|
9432
9782
|
function createPathDirnameTool() {
|
|
9433
9783
|
return toolBuilder().name("path-dirname").description("Get the directory name of a path (everything except the last portion).").category(ToolCategory.FILE_SYSTEM).tags(["path", "dirname", "directory", "filesystem"]).schema(pathDirnameSchema).implement(async (input) => {
|
|
9434
|
-
const
|
|
9784
|
+
const dirname4 = path.dirname(input.path);
|
|
9435
9785
|
return {
|
|
9436
|
-
dirname:
|
|
9437
|
-
basename:
|
|
9786
|
+
dirname: dirname4,
|
|
9787
|
+
basename: path.basename(input.path)
|
|
9438
9788
|
};
|
|
9439
9789
|
}).build();
|
|
9440
9790
|
}
|
|
9441
9791
|
function createPathExtensionTool() {
|
|
9442
9792
|
return toolBuilder().name("path-extension").description('Get the file extension from a path (including the dot, e.g., ".txt").').category(ToolCategory.FILE_SYSTEM).tags(["path", "extension", "ext", "filesystem"]).schema(pathExtensionSchema).implement(async (input) => {
|
|
9443
|
-
const ext =
|
|
9793
|
+
const ext = path.extname(input.path);
|
|
9444
9794
|
return {
|
|
9445
9795
|
extension: ext,
|
|
9446
9796
|
hasExtension: ext.length > 0,
|
|
9447
|
-
filename:
|
|
9797
|
+
filename: path.basename(input.path, ext)
|
|
9448
9798
|
};
|
|
9449
9799
|
}).build();
|
|
9450
9800
|
}
|
|
9451
9801
|
function createPathRelativeTool() {
|
|
9452
9802
|
return toolBuilder().name("path-relative").description("Get the relative path from one path to another.").category(ToolCategory.FILE_SYSTEM).tags(["path", "relative", "filesystem"]).schema(pathRelativeSchema).implement(async (input) => {
|
|
9453
|
-
const
|
|
9803
|
+
const relative4 = path.relative(input.from, input.to);
|
|
9454
9804
|
return {
|
|
9455
|
-
relativePath:
|
|
9805
|
+
relativePath: relative4,
|
|
9456
9806
|
from: input.from,
|
|
9457
9807
|
to: input.to
|
|
9458
9808
|
};
|
|
@@ -9460,7 +9810,7 @@ function createPathRelativeTool() {
|
|
|
9460
9810
|
}
|
|
9461
9811
|
function createPathNormalizeTool() {
|
|
9462
9812
|
return toolBuilder().name("path-normalize").description('Normalize a path by resolving ".." and "." segments and removing duplicate separators.').category(ToolCategory.FILE_SYSTEM).tags(["path", "normalize", "filesystem"]).schema(pathNormalizeSchema).implement(async (input) => {
|
|
9463
|
-
const normalized =
|
|
9813
|
+
const normalized = path.normalize(input.path);
|
|
9464
9814
|
return {
|
|
9465
9815
|
normalized,
|
|
9466
9816
|
original: input.path
|
|
@@ -10360,6 +10710,6 @@ function createAskHumanTool() {
|
|
|
10360
10710
|
}
|
|
10361
10711
|
var askHumanTool = createAskHumanTool();
|
|
10362
10712
|
|
|
10363
|
-
export { AskHumanInputSchema, CalculatorSchema, ConnectionManager, ConnectionState, CreditCardValidatorSchema, CurrentDateTimeSchema, DEFAULT_BATCH_SIZE, DEFAULT_CHUNK_SIZE, DEFAULT_RETRY_CONFIG2 as DEFAULT_RETRY_CONFIG, DateArithmeticSchema, DateComparisonSchema, DateDifferenceSchema, DateFormatterSchema, DuckDuckGoProvider, EmailValidatorSchema, EmbeddingManager, HttpMethod, IpValidatorSchema, MAX_BATCH_SIZE, MathFunctionsSchema, MissingPeerDependencyError, OpenAIEmbeddingProvider, PhoneValidatorSchema, RandomNumberSchema, SchemaInspector, SerperProvider, StatisticsSchema, StringCaseConverterSchema, StringJoinSchema, StringLengthSchema, StringReplaceSchema, StringSplitSchema, StringSubstringSchema, StringTrimSchema, UrlValidatorSimpleSchema, UuidValidatorSchema, archiveConfluencePage, arrayFilter, arrayFilterSchema, arrayGroupBy, arrayGroupBySchema, arrayMap, arrayMapSchema, arraySort, arraySortSchema, askHumanTool, benchmarkBatchExecution, benchmarkStreamingSelectMemory, buildDeleteQuery, buildInsertQuery, buildSelectQuery, buildUpdateQuery, calculator, checkPeerDependency, confluenceTools, createArrayFilterTool, createArrayGroupByTool, createArrayMapTool, createArraySortTool, createAskHumanTool, createCalculatorTool, createConfluencePage, createConfluenceTools, createCreditCardValidatorTool, createCsvGeneratorTool, createCsvParserTool, createCsvToJsonTool, createCsvTools, createCurrentDateTimeTool, createDateArithmeticTool, createDateComparisonTool, createDateDifferenceTool, createDateFormatterTool, createDateTimeTools, createDirectoryCreateTool, createDirectoryDeleteTool, createDirectoryListTool, createDirectoryOperationTools, createDuckDuckGoProvider, createEmailValidatorTool, createExtractImagesTool, createExtractLinksTool, createFileAppendTool, createFileDeleteTool, createFileExistsTool, createFileOperationTools, createFileReaderTool, createFileSearchTool, createFileWriterTool, createHtmlParserTool, createHtmlParserTools, createHttpTools, createIpValidatorTool, createJsonMergeTool, createJsonParserTool, createJsonQueryTool, createJsonStringifyTool, createJsonToCsvTool, createJsonToXmlTool, createJsonTools, createJsonValidatorTool, createMathFunctionsTool, createMathOperationTools, createNeo4jCreateNodeWithEmbeddingTool, createNeo4jFindNodesTool, createNeo4jGetSchemaTool, createNeo4jQueryTool, createNeo4jTools, createNeo4jTraverseTool, createNeo4jVectorSearchTool, createNeo4jVectorSearchWithEmbeddingTool, createObjectOmitTool, createObjectPickTool, createPathBasenameTool, createPathDirnameTool, createPathExtensionTool, createPathJoinTool, createPathNormalizeTool, createPathParseTool, createPathRelativeTool, createPathResolveTool, createPathUtilityTools, createPhoneValidatorTool, createRandomNumberTool, createScraperTools, createSelectReadableStream, createSerperProvider, createSlackTools, createStatisticsTool, createStringCaseConverterTool, createStringJoinTool, createStringLengthTool, createStringReplaceTool, createStringSplitTool, createStringSubstringTool, createStringTrimTool, createStringUtilityTools, createTransformerTools, createUrlBuilderTool, createUrlQueryParserTool, createUrlValidatorSimpleTool, createUrlValidatorTool, createUrlValidatorTools, createUuidValidatorTool, createValidationTools, createWebScraperTool, createXmlGeneratorTool, createXmlParserTool, createXmlToJsonTool, createXmlTools, creditCardValidator, csvGenerator, csvGeneratorSchema, csvParser, csvParserSchema, csvToJson, csvToJsonSchema, csvTools, currentDateTime, dateArithmetic, dateComparison, dateDifference, dateFormatter, dateTimeTools, diffSchemas, directoryCreate, directoryCreateSchema, directoryDelete, directoryDeleteSchema, directoryList, directoryListSchema, directoryOperationTools, emailValidator, embeddingManager, executeBatchedTask, executeQuery2 as executeQuery, executeStreamingSelect, exportSchemaToJson, extractImages, extractImagesSchema, extractLinks, extractLinksSchema, fileAppend, fileAppendSchema, fileDelete, fileDeleteSchema, fileExists, fileExistsSchema, fileOperationTools, fileReader, fileReaderSchema, fileSearch, fileSearchSchema, fileWriter, fileWriterSchema, generateBatchEmbeddings, generateEmbedding, getCohereApiKey, getConfluencePage, getEmbeddingModel, getEmbeddingProvider, getHuggingFaceApiKey, getInstallationInstructions, getOllamaBaseUrl, getOpenAIApiKey, getPeerDependencyName, getSlackChannels, getSlackMessages, getSpacePages, getVendorTypeMap, getVoyageApiKey, htmlParser, htmlParserSchema, htmlParserTools, httpClient, httpGet, httpGetSchema, httpPost, httpPostSchema, httpRequestSchema, httpTools, importSchemaFromJson, initializeEmbeddings, initializeEmbeddingsWithConfig, initializeFromEnv, initializeNeo4jTools, ipValidator, isRetryableError2 as isRetryableError, jsonMerge, jsonMergeSchema, jsonParser, jsonParserSchema, jsonQuery, jsonQuerySchema, jsonStringify, jsonStringifySchema, jsonToCsv, jsonToCsvSchema, jsonToXml, jsonToXmlSchema, jsonTools, jsonValidator, jsonValidatorSchema, listConfluenceSpaces, mapColumnType, mapSchemaTypes, mathFunctions, mathOperationTools, neo4jCoreTools, neo4jCreateNodeWithEmbedding, neo4jCreateNodeWithEmbeddingSchema, neo4jFindNodes, neo4jFindNodesSchema, neo4jGetSchema, neo4jGetSchemaSchema, neo4jPool, neo4jQuery, neo4jQuerySchema, neo4jTools, neo4jTraverse, neo4jTraverseSchema, neo4jVectorSearch, neo4jVectorSearchSchema, neo4jVectorSearchWithEmbedding, neo4jVectorSearchWithEmbeddingSchema, notifySlack, objectOmit, objectOmitSchema, objectPick, objectPickSchema, pathBasename, pathBasenameSchema, pathDirname, pathDirnameSchema, pathExtension, pathExtensionSchema, pathJoin, pathJoinSchema, pathNormalize, pathNormalizeSchema, pathParse, pathParseSchema, pathRelative, pathRelativeSchema, pathResolve, pathResolveSchema, pathUtilityTools, phoneValidator, randomNumber, relationalDelete, relationalGetSchema, relationalInsert, relationalQuery, relationalSelect, relationalUpdate, retryWithBackoff2 as retryWithBackoff, scraperTools, searchConfluence, searchResultSchema, sendSlackMessage, slackTools, statistics, streamSelectChunks, stringCaseConverter, stringJoin, stringLength, stringReplace, stringSplit, stringSubstring, stringTrim, stringUtilityTools, transformerArraySchema, transformerObjectSchema, transformerTools, transformerValueSchema, updateConfluencePage, urlBuilder, urlBuilderSchema, urlQueryParser, urlQueryParserSchema, urlValidator, urlValidatorSchema, urlValidatorSimple, urlValidatorTools, uuidValidator, validateBatch, validateColumnTypes, validateColumnsExist, validateTableExists, validateText, validationTools, webScraper, webScraperSchema, webSearch, webSearchOutputSchema, webSearchSchema, withTransaction, xmlGenerator, xmlGeneratorSchema, xmlParser, xmlParserSchema, xmlToJson, xmlToJsonSchema, xmlTools };
|
|
10713
|
+
export { AskHumanInputSchema, CalculatorSchema, ConnectionManager, ConnectionState, CreditCardValidatorSchema, CurrentDateTimeSchema, DEFAULT_BATCH_SIZE, DEFAULT_CHUNK_SIZE, DEFAULT_DESTINATION_POLICY, DEFAULT_FILE_SYSTEM_POLICY, DEFAULT_RETRY_CONFIG2 as DEFAULT_RETRY_CONFIG, DateArithmeticSchema, DateComparisonSchema, DateDifferenceSchema, DateFormatterSchema, DestinationPolicyError, DuckDuckGoProvider, EmailValidatorSchema, EmbeddingManager, FileSystemPolicy, FileSystemPolicyError, HttpMethod, IpValidatorSchema, MAX_BATCH_SIZE, MathFunctionsSchema, MissingPeerDependencyError, OpenAIEmbeddingProvider, PhoneValidatorSchema, RandomNumberSchema, SchemaInspector, SerperProvider, StatisticsSchema, StringCaseConverterSchema, StringJoinSchema, StringLengthSchema, StringReplaceSchema, StringSplitSchema, StringSubstringSchema, StringTrimSchema, UrlValidatorSimpleSchema, UuidValidatorSchema, archiveConfluencePage, arrayFilter, arrayFilterSchema, arrayGroupBy, arrayGroupBySchema, arrayMap, arrayMapSchema, arraySort, arraySortSchema, askHumanTool, assertDestinationAllowed, benchmarkBatchExecution, benchmarkStreamingSelectMemory, buildDeleteQuery, buildInsertQuery, buildSelectQuery, buildUpdateQuery, calculator, checkPeerDependency, confluenceTools, createArrayFilterTool, createArrayGroupByTool, createArrayMapTool, createArraySortTool, createAskHumanTool, createCalculatorTool, createConfluencePage, createConfluenceTools, createCreditCardValidatorTool, createCsvGeneratorTool, createCsvParserTool, createCsvToJsonTool, createCsvTools, createCurrentDateTimeTool, createDateArithmeticTool, createDateComparisonTool, createDateDifferenceTool, createDateFormatterTool, createDateTimeTools, createDirectoryCreateTool, createDirectoryDeleteTool, createDirectoryListTool, createDirectoryOperationTools, createDuckDuckGoProvider, createEmailValidatorTool, createExtractImagesTool, createExtractLinksTool, createFileAppendTool, createFileDeleteTool, createFileExistsTool, createFileOperationTools, createFileReaderTool, createFileSearchTool, createFileSystemPolicy, createFileWriterTool, createHtmlParserTool, createHtmlParserTools, createHttpTools, createIpValidatorTool, createJsonMergeTool, createJsonParserTool, createJsonQueryTool, createJsonStringifyTool, createJsonToCsvTool, createJsonToXmlTool, createJsonTools, createJsonValidatorTool, createMathFunctionsTool, createMathOperationTools, createNeo4jCreateNodeWithEmbeddingTool, createNeo4jFindNodesTool, createNeo4jGetSchemaTool, createNeo4jQueryTool, createNeo4jTools, createNeo4jTraverseTool, createNeo4jVectorSearchTool, createNeo4jVectorSearchWithEmbeddingTool, createObjectOmitTool, createObjectPickTool, createPathBasenameTool, createPathDirnameTool, createPathExtensionTool, createPathJoinTool, createPathNormalizeTool, createPathParseTool, createPathRelativeTool, createPathResolveTool, createPathUtilityTools, createPhoneValidatorTool, createRandomNumberTool, createScraperTools, createSelectReadableStream, createSerperProvider, createSlackTools, createStatisticsTool, createStringCaseConverterTool, createStringJoinTool, createStringLengthTool, createStringReplaceTool, createStringSplitTool, createStringSubstringTool, createStringTrimTool, createStringUtilityTools, createTransformerTools, createUrlBuilderTool, createUrlQueryParserTool, createUrlValidatorSimpleTool, createUrlValidatorTool, createUrlValidatorTools, createUuidValidatorTool, createValidationTools, createWebScraperTool, createXmlGeneratorTool, createXmlParserTool, createXmlToJsonTool, createXmlTools, creditCardValidator, csvGenerator, csvGeneratorSchema, csvParser, csvParserSchema, csvToJson, csvToJsonSchema, csvTools, currentDateTime, dateArithmetic, dateComparison, dateDifference, dateFormatter, dateTimeTools, diffSchemas, directoryCreate, directoryCreateSchema, directoryDelete, directoryDeleteSchema, directoryList, directoryListSchema, directoryOperationTools, emailValidator, embeddingManager, executeBatchedTask, executeQuery2 as executeQuery, executeStreamingSelect, exportSchemaToJson, extractImages, extractImagesSchema, extractLinks, extractLinksSchema, fileAppend, fileAppendSchema, fileDelete, fileDeleteSchema, fileExists, fileExistsSchema, fileOperationTools, fileReader, fileReaderSchema, fileSearch, fileSearchSchema, fileWriter, fileWriterSchema, generateBatchEmbeddings, generateEmbedding, getCohereApiKey, getConfluencePage, getEmbeddingModel, getEmbeddingProvider, getHuggingFaceApiKey, getInstallationInstructions, getOllamaBaseUrl, getOpenAIApiKey, getPeerDependencyName, getSlackChannels, getSlackMessages, getSpacePages, getVendorTypeMap, getVoyageApiKey, htmlParser, htmlParserSchema, htmlParserTools, httpClient, httpGet, httpGetSchema, httpPost, httpPostSchema, httpRequestSchema, httpTools, importSchemaFromJson, initializeEmbeddings, initializeEmbeddingsWithConfig, initializeFromEnv, initializeNeo4jTools, ipValidator, isRetryableError2 as isRetryableError, jsonMerge, jsonMergeSchema, jsonParser, jsonParserSchema, jsonQuery, jsonQuerySchema, jsonStringify, jsonStringifySchema, jsonToCsv, jsonToCsvSchema, jsonToXml, jsonToXmlSchema, jsonTools, jsonValidator, jsonValidatorSchema, listConfluenceSpaces, mapColumnType, mapSchemaTypes, mathFunctions, mathOperationTools, neo4jCoreTools, neo4jCreateNodeWithEmbedding, neo4jCreateNodeWithEmbeddingSchema, neo4jFindNodes, neo4jFindNodesSchema, neo4jGetSchema, neo4jGetSchemaSchema, neo4jPool, neo4jQuery, neo4jQuerySchema, neo4jTools, neo4jTraverse, neo4jTraverseSchema, neo4jVectorSearch, neo4jVectorSearchSchema, neo4jVectorSearchWithEmbedding, neo4jVectorSearchWithEmbeddingSchema, notifySlack, objectOmit, objectOmitSchema, objectPick, objectPickSchema, pathBasename, pathBasenameSchema, pathDirname, pathDirnameSchema, pathExtension, pathExtensionSchema, pathJoin, pathJoinSchema, pathNormalize, pathNormalizeSchema, pathParse, pathParseSchema, pathRelative, pathRelativeSchema, pathResolve, pathResolveSchema, pathUtilityTools, phoneValidator, randomNumber, relationalDelete, relationalGetSchema, relationalInsert, relationalQuery, relationalSelect, relationalUpdate, requestWithDestinationPolicy, resolveFileSystemPolicy, retryWithBackoff2 as retryWithBackoff, scraperTools, searchConfluence, searchResultSchema, sendSlackMessage, slackTools, statistics, streamSelectChunks, stringCaseConverter, stringJoin, stringLength, stringReplace, stringSplit, stringSubstring, stringTrim, stringUtilityTools, transformerArraySchema, transformerObjectSchema, transformerTools, transformerValueSchema, updateConfluencePage, urlBuilder, urlBuilderSchema, urlQueryParser, urlQueryParserSchema, urlValidator, urlValidatorSchema, urlValidatorSimple, urlValidatorTools, uuidValidator, validateBatch, validateColumnTypes, validateColumnsExist, validateTableExists, validateText, validationTools, webScraper, webScraperSchema, webSearch, webSearchOutputSchema, webSearchSchema, withTransaction, xmlGenerator, xmlGeneratorSchema, xmlParser, xmlParserSchema, xmlToJson, xmlToJsonSchema, xmlTools };
|
|
10364
10714
|
//# sourceMappingURL=index.js.map
|
|
10365
10715
|
//# sourceMappingURL=index.js.map
|