agent-tool-hub 1.0.1 → 1.0.3
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 +17 -198
- package/dist/chunk-57LVNNHL.js +19 -0
- package/dist/chunk-57LVNNHL.js.map +1 -0
- package/dist/chunk-6QTWECRD.cjs +23 -0
- package/dist/chunk-6QTWECRD.cjs.map +1 -0
- package/dist/{chunk-2CEY2WAM.js → chunk-HPDQEW2P.js} +214 -233
- package/dist/chunk-HPDQEW2P.js.map +1 -0
- package/dist/{chunk-GD4JXJHB.cjs → chunk-TIKHPRMB.cjs} +216 -238
- package/dist/chunk-TIKHPRMB.cjs.map +1 -0
- package/dist/cli.cjs +194 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +10 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +186 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +62 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/toolhub-runtime.cjs +12 -11
- package/dist/toolhub-runtime.js +2 -1
- package/package.json +4 -1
- package/dist/chunk-2CEY2WAM.js.map +0 -1
- package/dist/chunk-GD4JXJHB.cjs.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkNTTBDQUF_cjs = require('./chunk-NTTBDQUF.cjs');
|
|
4
|
-
var
|
|
4
|
+
var fs = require('fs/promises');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var yaml = require('js-yaml');
|
|
5
7
|
var Ajv = require('ajv');
|
|
6
8
|
var addFormats = require('ajv-formats');
|
|
7
9
|
var cockatiel = require('cockatiel');
|
|
@@ -9,23 +11,121 @@ var eventemitter3 = require('eventemitter3');
|
|
|
9
11
|
var uuid = require('uuid');
|
|
10
12
|
var pRetry = require('p-retry');
|
|
11
13
|
var pTimeout = require('p-timeout');
|
|
12
|
-
var fs = require('fs/promises');
|
|
13
|
-
var path = require('path');
|
|
14
14
|
var url = require('url');
|
|
15
|
+
var crypto = require('crypto');
|
|
15
16
|
var fs$1 = require('fs');
|
|
16
17
|
var readline = require('readline');
|
|
17
18
|
var promises = require('dns/promises');
|
|
18
|
-
var yaml = require('js-yaml');
|
|
19
19
|
|
|
20
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
21
|
|
|
22
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
23
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
24
|
+
var yaml__default = /*#__PURE__*/_interopDefault(yaml);
|
|
22
25
|
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
23
26
|
var addFormats__default = /*#__PURE__*/_interopDefault(addFormats);
|
|
24
27
|
var pRetry__default = /*#__PURE__*/_interopDefault(pRetry);
|
|
25
28
|
var pTimeout__default = /*#__PURE__*/_interopDefault(pTimeout);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
function resolveRoots(rootsRaw, configDir) {
|
|
31
|
+
let coreToolsInlineConfig;
|
|
32
|
+
const roots = rootsRaw.map((root) => {
|
|
33
|
+
if (typeof root === "string") {
|
|
34
|
+
if (root === "coreTools") return root;
|
|
35
|
+
return path__default.default.isAbsolute(root) ? root : path__default.default.resolve(configDir, root);
|
|
36
|
+
}
|
|
37
|
+
if (root.path === "coreTools") {
|
|
38
|
+
coreToolsInlineConfig = root.config;
|
|
39
|
+
return root;
|
|
40
|
+
}
|
|
41
|
+
const resolvedPath = path__default.default.isAbsolute(root.path) ? root.path : path__default.default.resolve(configDir, root.path);
|
|
42
|
+
return { path: resolvedPath, namespace: root.namespace };
|
|
43
|
+
});
|
|
44
|
+
return { roots, coreToolsInlineConfig };
|
|
45
|
+
}
|
|
46
|
+
function extractCoreToolsConfig(coreTools, security, system, configDir) {
|
|
47
|
+
const sandboxRoot = coreTools.sandboxRoot ?? coreTools.sandbox?.root ?? security.sandbox?.root ?? system.sandbox?.root;
|
|
48
|
+
const allowedHosts = coreTools.allowedHosts ?? coreTools.network?.allowedHosts ?? security.network?.allowedHosts ?? system.network?.allowedHosts;
|
|
49
|
+
const blockedCidrs = coreTools.blockedCidrs ?? coreTools.network?.blockedCidrs ?? security.network?.blockedCidrs ?? system.network?.blockedCidrs;
|
|
50
|
+
const maxReadBytes = coreTools.maxReadBytes ?? coreTools.limits?.maxReadBytes;
|
|
51
|
+
const maxHttpBytes = coreTools.maxHttpBytes ?? coreTools.limits?.maxHttpBytes;
|
|
52
|
+
const maxDownloadBytes = coreTools.maxDownloadBytes ?? coreTools.limits?.maxDownloadBytes;
|
|
53
|
+
const defaultTimeoutMs = coreTools.defaultTimeoutMs ?? coreTools.limits?.defaultTimeoutMs;
|
|
54
|
+
const httpUserAgent = coreTools.httpUserAgent ?? coreTools.http?.userAgent;
|
|
55
|
+
const enableAutoWriteLargeResponses = coreTools.enableAutoWriteLargeResponses ?? coreTools.http?.enableAutoWriteLargeResponses;
|
|
56
|
+
return {
|
|
57
|
+
sandboxRoot: sandboxRoot ? path__default.default.isAbsolute(String(sandboxRoot)) ? String(sandboxRoot) : path__default.default.resolve(configDir, String(sandboxRoot)) : sandboxRoot,
|
|
58
|
+
allowedHosts: allowedHosts ?? [],
|
|
59
|
+
maxReadBytes,
|
|
60
|
+
maxHttpBytes,
|
|
61
|
+
maxDownloadBytes,
|
|
62
|
+
blockedCidrs,
|
|
63
|
+
defaultTimeoutMs,
|
|
64
|
+
httpUserAgent,
|
|
65
|
+
enableAutoWriteLargeResponses
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function extractAdapterConfigs(adapters) {
|
|
69
|
+
const comfyuiRaw = adapters.comfyui ?? {};
|
|
70
|
+
const comfyuiConfig = Object.keys(comfyuiRaw).length > 0 ? {
|
|
71
|
+
...comfyuiRaw,
|
|
72
|
+
baseUrl: comfyuiRaw.baseUrl ?? comfyuiRaw.apiBaseUrl
|
|
73
|
+
} : void 0;
|
|
74
|
+
const n8nRaw = adapters.n8n ?? {};
|
|
75
|
+
const n8nMode = n8nRaw.mode ?? (n8nRaw.local ? "local" : void 0) ?? (n8nRaw.api ? "api" : void 0);
|
|
76
|
+
const n8nLocal = n8nRaw.local ?? void 0;
|
|
77
|
+
const n8nApi = n8nRaw.api ?? void 0;
|
|
78
|
+
return {
|
|
79
|
+
langchain: adapters.langchain,
|
|
80
|
+
mcp: adapters.mcp,
|
|
81
|
+
n8nMode,
|
|
82
|
+
n8nLocal: n8nMode === "local" ? n8nLocal : void 0,
|
|
83
|
+
n8n: n8nMode === "api" ? n8nApi : void 0,
|
|
84
|
+
comfyui: comfyuiConfig,
|
|
85
|
+
skill: adapters.skill
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function mapToolHubConfig(raw, configDir) {
|
|
89
|
+
const config = raw ?? {};
|
|
90
|
+
const toolHub = config.toolHub ?? {};
|
|
91
|
+
const discovery = config.discovery ?? toolHub.discovery ?? {};
|
|
92
|
+
const system = config.system ?? {};
|
|
93
|
+
const security = config.security ?? {};
|
|
94
|
+
const runtime = system.runtime ?? config.runtime ?? {};
|
|
95
|
+
const coreToolsRaw = system.coreTools ?? config.coreTools ?? {};
|
|
96
|
+
const adapters = config.adapters ?? {};
|
|
97
|
+
const rootsRaw = discovery.roots ?? toolHub.roots ?? [];
|
|
98
|
+
const { roots, coreToolsInlineConfig } = resolveRoots(rootsRaw, configDir);
|
|
99
|
+
const coreTools = coreToolsInlineConfig ?? coreToolsRaw ?? {};
|
|
100
|
+
const includeCoreTools = roots.some((root) => {
|
|
101
|
+
if (typeof root === "string") return root === "coreTools";
|
|
102
|
+
return root.path === "coreTools";
|
|
103
|
+
});
|
|
104
|
+
const coreToolsConfig = includeCoreTools ? extractCoreToolsConfig(coreTools, security, system, configDir) : void 0;
|
|
105
|
+
const adapterConfigs = extractAdapterConfigs(adapters);
|
|
106
|
+
return {
|
|
107
|
+
roots,
|
|
108
|
+
namespace: config.namespace ?? toolHub.namespace,
|
|
109
|
+
extensions: discovery.extensions ?? config.extensions ?? toolHub.extensions,
|
|
110
|
+
debug: config.debug ?? toolHub.debug,
|
|
111
|
+
includeCoreTools,
|
|
112
|
+
coreTools: coreToolsConfig,
|
|
113
|
+
runtimeConfig: runtime,
|
|
114
|
+
watch: discovery.hotReload ?? discovery.watch ?? config.watch ?? toolHub.watch,
|
|
115
|
+
...adapterConfigs
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async function loadToolHubConfig(configPath) {
|
|
119
|
+
const resolvedPath = path__default.default.resolve(process.cwd(), configPath);
|
|
120
|
+
const rawConfigText = await fs__default.default.readFile(resolvedPath, "utf-8");
|
|
121
|
+
const rawConfig = yaml__default.default.load(rawConfigText) ?? {};
|
|
122
|
+
const options = mapToolHubConfig(rawConfig, path__default.default.dirname(resolvedPath));
|
|
123
|
+
return {
|
|
124
|
+
configPath: resolvedPath,
|
|
125
|
+
rawConfig,
|
|
126
|
+
options
|
|
127
|
+
};
|
|
128
|
+
}
|
|
29
129
|
|
|
30
130
|
// src/registry/ToolRegistry.ts
|
|
31
131
|
var ToolRegistry = class {
|
|
@@ -1408,114 +1508,6 @@ var DiscoveryError = class extends Error {
|
|
|
1408
1508
|
this.cause = cause;
|
|
1409
1509
|
}
|
|
1410
1510
|
};
|
|
1411
|
-
function isCursorFormat(obj) {
|
|
1412
|
-
return typeof obj === "object" && obj !== null && "mcpServers" in obj && typeof obj.mcpServers === "object" && obj.mcpServers !== null;
|
|
1413
|
-
}
|
|
1414
|
-
function extractMCPConfig(parsed, toolName) {
|
|
1415
|
-
if (isCursorFormat(parsed)) {
|
|
1416
|
-
const servers = parsed.mcpServers;
|
|
1417
|
-
const keys = Object.keys(servers);
|
|
1418
|
-
if (keys.length === 0) {
|
|
1419
|
-
return {};
|
|
1420
|
-
}
|
|
1421
|
-
const name = toolName && keys.includes(toolName) ? toolName : keys[0];
|
|
1422
|
-
return servers[name];
|
|
1423
|
-
}
|
|
1424
|
-
return parsed;
|
|
1425
|
-
}
|
|
1426
|
-
async function loadMCPTool(dirPath, manifest) {
|
|
1427
|
-
const mcpPath = path.join(dirPath, manifest.entryPoint ?? "mcp.json");
|
|
1428
|
-
let raw;
|
|
1429
|
-
try {
|
|
1430
|
-
raw = await fs.readFile(mcpPath, "utf-8");
|
|
1431
|
-
} catch (err) {
|
|
1432
|
-
throw new DiscoveryError(
|
|
1433
|
-
dirPath,
|
|
1434
|
-
"load",
|
|
1435
|
-
`Failed to read MCP config: ${mcpPath}`,
|
|
1436
|
-
err
|
|
1437
|
-
);
|
|
1438
|
-
}
|
|
1439
|
-
let parsed;
|
|
1440
|
-
try {
|
|
1441
|
-
parsed = JSON.parse(raw);
|
|
1442
|
-
} catch (err) {
|
|
1443
|
-
throw new DiscoveryError(
|
|
1444
|
-
dirPath,
|
|
1445
|
-
"load",
|
|
1446
|
-
`Invalid JSON in ${mcpPath}`,
|
|
1447
|
-
err
|
|
1448
|
-
);
|
|
1449
|
-
}
|
|
1450
|
-
const baseName = manifest.name?.split("/").pop();
|
|
1451
|
-
const config = extractMCPConfig(parsed, baseName);
|
|
1452
|
-
if (!config.command && !config.url) {
|
|
1453
|
-
throw new DiscoveryError(
|
|
1454
|
-
dirPath,
|
|
1455
|
-
"validate",
|
|
1456
|
-
`mcp.json must have either "command" or "url" field`
|
|
1457
|
-
);
|
|
1458
|
-
}
|
|
1459
|
-
return { manifest, dirPath, mcpConfig: config };
|
|
1460
|
-
}
|
|
1461
|
-
var DEFAULT_EXTENSIONS = [".js", ".mjs"];
|
|
1462
|
-
async function resolveEntryPoint(dirPath, baseName, extensions = DEFAULT_EXTENSIONS) {
|
|
1463
|
-
if (extensions.some((ext) => baseName.endsWith(ext))) {
|
|
1464
|
-
const fullPath = path.join(dirPath, baseName);
|
|
1465
|
-
await fs.stat(fullPath);
|
|
1466
|
-
return fullPath;
|
|
1467
|
-
}
|
|
1468
|
-
for (const ext of extensions) {
|
|
1469
|
-
const fullPath = path.join(dirPath, `${baseName}${ext}`);
|
|
1470
|
-
try {
|
|
1471
|
-
await fs.stat(fullPath);
|
|
1472
|
-
return fullPath;
|
|
1473
|
-
} catch {
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
throw new Error(
|
|
1477
|
-
`Could not find entry point in ${dirPath}. Tried: ${extensions.map((e) => baseName + e).join(", ")}`
|
|
1478
|
-
);
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
// src/discovery/loaders/LangChainLoader.ts
|
|
1482
|
-
async function loadLangChainTool(dirPath, manifest, extensions) {
|
|
1483
|
-
let entryFile;
|
|
1484
|
-
try {
|
|
1485
|
-
entryFile = await resolveEntryPoint(
|
|
1486
|
-
dirPath,
|
|
1487
|
-
manifest.entryPoint ?? "index",
|
|
1488
|
-
extensions
|
|
1489
|
-
);
|
|
1490
|
-
} catch (err) {
|
|
1491
|
-
throw new DiscoveryError(
|
|
1492
|
-
dirPath,
|
|
1493
|
-
"load",
|
|
1494
|
-
`Cannot find LangChain entry point`,
|
|
1495
|
-
err
|
|
1496
|
-
);
|
|
1497
|
-
}
|
|
1498
|
-
let mod;
|
|
1499
|
-
try {
|
|
1500
|
-
mod = await import(url.pathToFileURL(entryFile).href);
|
|
1501
|
-
} catch (err) {
|
|
1502
|
-
throw new DiscoveryError(
|
|
1503
|
-
dirPath,
|
|
1504
|
-
"load",
|
|
1505
|
-
`Failed to import ${entryFile}`,
|
|
1506
|
-
err
|
|
1507
|
-
);
|
|
1508
|
-
}
|
|
1509
|
-
const tool = mod.default ?? mod.tool ?? mod;
|
|
1510
|
-
if (!tool || typeof tool.invoke !== "function") {
|
|
1511
|
-
throw new DiscoveryError(
|
|
1512
|
-
dirPath,
|
|
1513
|
-
"validate",
|
|
1514
|
-
`Entry point must export an object with invoke() method (LangChainToolLike)`
|
|
1515
|
-
);
|
|
1516
|
-
}
|
|
1517
|
-
return { manifest, dirPath, impl: tool };
|
|
1518
|
-
}
|
|
1519
1511
|
|
|
1520
1512
|
// src/discovery/loaders/SkillManifest.ts
|
|
1521
1513
|
var SkillManifestError = class extends Error {
|
|
@@ -1583,8 +1575,6 @@ function validateFrontmatter(fm, filePath) {
|
|
|
1583
1575
|
);
|
|
1584
1576
|
}
|
|
1585
1577
|
}
|
|
1586
|
-
|
|
1587
|
-
// src/discovery/loaders/SkillMdParser.ts
|
|
1588
1578
|
var CODE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
1589
1579
|
".py",
|
|
1590
1580
|
".js",
|
|
@@ -1748,8 +1738,114 @@ async function loadSkillDefinition(dirPath) {
|
|
|
1748
1738
|
skillMdPath
|
|
1749
1739
|
};
|
|
1750
1740
|
}
|
|
1741
|
+
function isCursorFormat(obj) {
|
|
1742
|
+
return typeof obj === "object" && obj !== null && "mcpServers" in obj && typeof obj.mcpServers === "object" && obj.mcpServers !== null;
|
|
1743
|
+
}
|
|
1744
|
+
function extractMCPConfig(parsed, toolName) {
|
|
1745
|
+
if (isCursorFormat(parsed)) {
|
|
1746
|
+
const servers = parsed.mcpServers;
|
|
1747
|
+
const keys = Object.keys(servers);
|
|
1748
|
+
if (keys.length === 0) {
|
|
1749
|
+
return {};
|
|
1750
|
+
}
|
|
1751
|
+
const name = toolName && keys.includes(toolName) ? toolName : keys[0];
|
|
1752
|
+
return servers[name];
|
|
1753
|
+
}
|
|
1754
|
+
return parsed;
|
|
1755
|
+
}
|
|
1756
|
+
async function loadMCPTool(dirPath, manifest) {
|
|
1757
|
+
const mcpPath = path.join(dirPath, manifest.entryPoint ?? "mcp.json");
|
|
1758
|
+
let raw;
|
|
1759
|
+
try {
|
|
1760
|
+
raw = await fs.readFile(mcpPath, "utf-8");
|
|
1761
|
+
} catch (err) {
|
|
1762
|
+
throw new DiscoveryError(
|
|
1763
|
+
dirPath,
|
|
1764
|
+
"load",
|
|
1765
|
+
`Failed to read MCP config: ${mcpPath}`,
|
|
1766
|
+
err
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1769
|
+
let parsed;
|
|
1770
|
+
try {
|
|
1771
|
+
parsed = JSON.parse(raw);
|
|
1772
|
+
} catch (err) {
|
|
1773
|
+
throw new DiscoveryError(
|
|
1774
|
+
dirPath,
|
|
1775
|
+
"load",
|
|
1776
|
+
`Invalid JSON in ${mcpPath}`,
|
|
1777
|
+
err
|
|
1778
|
+
);
|
|
1779
|
+
}
|
|
1780
|
+
const baseName = manifest.name?.split("/").pop();
|
|
1781
|
+
const config = extractMCPConfig(parsed, baseName);
|
|
1782
|
+
if (!config.command && !config.url) {
|
|
1783
|
+
throw new DiscoveryError(
|
|
1784
|
+
dirPath,
|
|
1785
|
+
"validate",
|
|
1786
|
+
`mcp.json must have either "command" or "url" field`
|
|
1787
|
+
);
|
|
1788
|
+
}
|
|
1789
|
+
return { manifest, dirPath, mcpConfig: config };
|
|
1790
|
+
}
|
|
1791
|
+
var DEFAULT_EXTENSIONS = [".js", ".mjs"];
|
|
1792
|
+
async function resolveEntryPoint(dirPath, baseName, extensions = DEFAULT_EXTENSIONS) {
|
|
1793
|
+
if (extensions.some((ext) => baseName.endsWith(ext))) {
|
|
1794
|
+
const fullPath = path.join(dirPath, baseName);
|
|
1795
|
+
await fs.stat(fullPath);
|
|
1796
|
+
return fullPath;
|
|
1797
|
+
}
|
|
1798
|
+
for (const ext of extensions) {
|
|
1799
|
+
const fullPath = path.join(dirPath, `${baseName}${ext}`);
|
|
1800
|
+
try {
|
|
1801
|
+
await fs.stat(fullPath);
|
|
1802
|
+
return fullPath;
|
|
1803
|
+
} catch {
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
throw new Error(
|
|
1807
|
+
`Could not find entry point in ${dirPath}. Tried: ${extensions.map((e) => baseName + e).join(", ")}`
|
|
1808
|
+
);
|
|
1809
|
+
}
|
|
1751
1810
|
|
|
1752
|
-
// src/discovery/loaders/
|
|
1811
|
+
// src/discovery/loaders/LangChainLoader.ts
|
|
1812
|
+
async function loadLangChainTool(dirPath, manifest, extensions) {
|
|
1813
|
+
let entryFile;
|
|
1814
|
+
try {
|
|
1815
|
+
entryFile = await resolveEntryPoint(
|
|
1816
|
+
dirPath,
|
|
1817
|
+
manifest.entryPoint ?? "index",
|
|
1818
|
+
extensions
|
|
1819
|
+
);
|
|
1820
|
+
} catch (err) {
|
|
1821
|
+
throw new DiscoveryError(
|
|
1822
|
+
dirPath,
|
|
1823
|
+
"load",
|
|
1824
|
+
`Cannot find LangChain entry point`,
|
|
1825
|
+
err
|
|
1826
|
+
);
|
|
1827
|
+
}
|
|
1828
|
+
let mod;
|
|
1829
|
+
try {
|
|
1830
|
+
mod = await import(url.pathToFileURL(entryFile).href);
|
|
1831
|
+
} catch (err) {
|
|
1832
|
+
throw new DiscoveryError(
|
|
1833
|
+
dirPath,
|
|
1834
|
+
"load",
|
|
1835
|
+
`Failed to import ${entryFile}`,
|
|
1836
|
+
err
|
|
1837
|
+
);
|
|
1838
|
+
}
|
|
1839
|
+
const tool = mod.default ?? mod.tool ?? mod;
|
|
1840
|
+
if (!tool || typeof tool.invoke !== "function") {
|
|
1841
|
+
throw new DiscoveryError(
|
|
1842
|
+
dirPath,
|
|
1843
|
+
"validate",
|
|
1844
|
+
`Entry point must export an object with invoke() method (LangChainToolLike)`
|
|
1845
|
+
);
|
|
1846
|
+
}
|
|
1847
|
+
return { manifest, dirPath, impl: tool };
|
|
1848
|
+
}
|
|
1753
1849
|
async function loadSkillTool(dirPath, manifest, extensions) {
|
|
1754
1850
|
let skillDef;
|
|
1755
1851
|
try {
|
|
@@ -3081,8 +3177,6 @@ function isWithinRoot(path2, root) {
|
|
|
3081
3177
|
const normalizedRoot = path.normalize(root);
|
|
3082
3178
|
return normalizedPath === normalizedRoot || normalizedPath.startsWith(normalizedRoot + "/");
|
|
3083
3179
|
}
|
|
3084
|
-
|
|
3085
|
-
// src/core-tools/fs/readText.ts
|
|
3086
3180
|
var readTextInputSchema = {
|
|
3087
3181
|
type: "object",
|
|
3088
3182
|
properties: {
|
|
@@ -5163,119 +5257,6 @@ var ToolHub = class {
|
|
|
5163
5257
|
function createToolHub(options) {
|
|
5164
5258
|
return new ToolHub(options);
|
|
5165
5259
|
}
|
|
5166
|
-
function resolveRoots(rootsRaw, configDir) {
|
|
5167
|
-
let coreToolsInlineConfig;
|
|
5168
|
-
const roots = rootsRaw.map((root) => {
|
|
5169
|
-
if (typeof root === "string") {
|
|
5170
|
-
if (root === "coreTools") return root;
|
|
5171
|
-
return path__default.default.isAbsolute(root) ? root : path__default.default.resolve(configDir, root);
|
|
5172
|
-
}
|
|
5173
|
-
if (root.path === "coreTools") {
|
|
5174
|
-
coreToolsInlineConfig = root.config;
|
|
5175
|
-
return root;
|
|
5176
|
-
}
|
|
5177
|
-
const resolvedPath = path__default.default.isAbsolute(root.path) ? root.path : path__default.default.resolve(configDir, root.path);
|
|
5178
|
-
return { path: resolvedPath, namespace: root.namespace };
|
|
5179
|
-
});
|
|
5180
|
-
return { roots, coreToolsInlineConfig };
|
|
5181
|
-
}
|
|
5182
|
-
function extractCoreToolsConfig(coreTools, security, system, configDir) {
|
|
5183
|
-
const sandboxRoot = coreTools.sandboxRoot ?? coreTools.sandbox?.root ?? security.sandbox?.root ?? system.sandbox?.root;
|
|
5184
|
-
const allowedHosts = coreTools.allowedHosts ?? coreTools.network?.allowedHosts ?? security.network?.allowedHosts ?? system.network?.allowedHosts;
|
|
5185
|
-
const blockedCidrs = coreTools.blockedCidrs ?? coreTools.network?.blockedCidrs ?? security.network?.blockedCidrs ?? system.network?.blockedCidrs;
|
|
5186
|
-
const maxReadBytes = coreTools.maxReadBytes ?? coreTools.limits?.maxReadBytes;
|
|
5187
|
-
const maxHttpBytes = coreTools.maxHttpBytes ?? coreTools.limits?.maxHttpBytes;
|
|
5188
|
-
const maxDownloadBytes = coreTools.maxDownloadBytes ?? coreTools.limits?.maxDownloadBytes;
|
|
5189
|
-
const defaultTimeoutMs = coreTools.defaultTimeoutMs ?? coreTools.limits?.defaultTimeoutMs;
|
|
5190
|
-
const httpUserAgent = coreTools.httpUserAgent ?? coreTools.http?.userAgent;
|
|
5191
|
-
const enableAutoWriteLargeResponses = coreTools.enableAutoWriteLargeResponses ?? coreTools.http?.enableAutoWriteLargeResponses;
|
|
5192
|
-
return {
|
|
5193
|
-
sandboxRoot: sandboxRoot ? path__default.default.isAbsolute(String(sandboxRoot)) ? String(sandboxRoot) : path__default.default.resolve(configDir, String(sandboxRoot)) : sandboxRoot,
|
|
5194
|
-
allowedHosts: allowedHosts ?? [],
|
|
5195
|
-
maxReadBytes,
|
|
5196
|
-
maxHttpBytes,
|
|
5197
|
-
maxDownloadBytes,
|
|
5198
|
-
blockedCidrs,
|
|
5199
|
-
defaultTimeoutMs,
|
|
5200
|
-
httpUserAgent,
|
|
5201
|
-
enableAutoWriteLargeResponses
|
|
5202
|
-
};
|
|
5203
|
-
}
|
|
5204
|
-
function extractAdapterConfigs(adapters) {
|
|
5205
|
-
const comfyuiRaw = adapters.comfyui ?? {};
|
|
5206
|
-
const comfyuiConfig = Object.keys(comfyuiRaw).length > 0 ? {
|
|
5207
|
-
...comfyuiRaw,
|
|
5208
|
-
baseUrl: comfyuiRaw.baseUrl ?? comfyuiRaw.apiBaseUrl
|
|
5209
|
-
} : void 0;
|
|
5210
|
-
const n8nRaw = adapters.n8n ?? {};
|
|
5211
|
-
const n8nMode = n8nRaw.mode ?? (n8nRaw.local ? "local" : void 0) ?? (n8nRaw.api ? "api" : void 0);
|
|
5212
|
-
const n8nLocal = n8nRaw.local ?? void 0;
|
|
5213
|
-
const n8nApi = n8nRaw.api ?? void 0;
|
|
5214
|
-
return {
|
|
5215
|
-
langchain: adapters.langchain,
|
|
5216
|
-
mcp: adapters.mcp,
|
|
5217
|
-
n8nMode,
|
|
5218
|
-
n8nLocal: n8nMode === "local" ? n8nLocal : void 0,
|
|
5219
|
-
n8n: n8nMode === "api" ? n8nApi : void 0,
|
|
5220
|
-
comfyui: comfyuiConfig,
|
|
5221
|
-
skill: adapters.skill
|
|
5222
|
-
};
|
|
5223
|
-
}
|
|
5224
|
-
function mapToolHubConfig(raw, configDir) {
|
|
5225
|
-
const config = raw ?? {};
|
|
5226
|
-
const toolHub = config.toolHub ?? {};
|
|
5227
|
-
const discovery = config.discovery ?? toolHub.discovery ?? {};
|
|
5228
|
-
const system = config.system ?? {};
|
|
5229
|
-
const security = config.security ?? {};
|
|
5230
|
-
const runtime = system.runtime ?? config.runtime ?? {};
|
|
5231
|
-
const coreToolsRaw = system.coreTools ?? config.coreTools ?? {};
|
|
5232
|
-
const adapters = config.adapters ?? {};
|
|
5233
|
-
const rootsRaw = discovery.roots ?? toolHub.roots ?? [];
|
|
5234
|
-
const { roots, coreToolsInlineConfig } = resolveRoots(rootsRaw, configDir);
|
|
5235
|
-
const coreTools = coreToolsInlineConfig ?? coreToolsRaw ?? {};
|
|
5236
|
-
const includeCoreTools = roots.some((root) => {
|
|
5237
|
-
if (typeof root === "string") return root === "coreTools";
|
|
5238
|
-
return root.path === "coreTools";
|
|
5239
|
-
});
|
|
5240
|
-
const coreToolsConfig = includeCoreTools ? extractCoreToolsConfig(coreTools, security, system, configDir) : void 0;
|
|
5241
|
-
const adapterConfigs = extractAdapterConfigs(adapters);
|
|
5242
|
-
return {
|
|
5243
|
-
roots,
|
|
5244
|
-
namespace: config.namespace ?? toolHub.namespace,
|
|
5245
|
-
extensions: discovery.extensions ?? config.extensions ?? toolHub.extensions,
|
|
5246
|
-
debug: config.debug ?? toolHub.debug,
|
|
5247
|
-
includeCoreTools,
|
|
5248
|
-
coreTools: coreToolsConfig,
|
|
5249
|
-
runtimeConfig: runtime,
|
|
5250
|
-
watch: discovery.hotReload ?? discovery.watch ?? config.watch ?? toolHub.watch,
|
|
5251
|
-
...adapterConfigs
|
|
5252
|
-
};
|
|
5253
|
-
}
|
|
5254
|
-
async function loadToolHubConfig(configPath) {
|
|
5255
|
-
const resolvedPath = path__default.default.resolve(process.cwd(), configPath);
|
|
5256
|
-
const rawConfigText = await fs__default.default.readFile(resolvedPath, "utf-8");
|
|
5257
|
-
const rawConfig = yaml__default.default.load(rawConfigText) ?? {};
|
|
5258
|
-
const options = mapToolHubConfig(rawConfig, path__default.default.dirname(resolvedPath));
|
|
5259
|
-
return {
|
|
5260
|
-
configPath: resolvedPath,
|
|
5261
|
-
rawConfig,
|
|
5262
|
-
options
|
|
5263
|
-
};
|
|
5264
|
-
}
|
|
5265
|
-
|
|
5266
|
-
// src/toolhub-runtime.ts
|
|
5267
|
-
async function createToolHubAndInit(options) {
|
|
5268
|
-
const hub = createToolHub(options);
|
|
5269
|
-
await hub.initAllTools();
|
|
5270
|
-
return hub;
|
|
5271
|
-
}
|
|
5272
|
-
async function createToolHubAndInitFromConfig(configPath) {
|
|
5273
|
-
const { options } = await loadToolHubConfig(configPath);
|
|
5274
|
-
return createToolHubAndInit(options);
|
|
5275
|
-
}
|
|
5276
|
-
async function createAgentToolHub(configPath) {
|
|
5277
|
-
return createToolHubAndInitFromConfig(configPath);
|
|
5278
|
-
}
|
|
5279
5260
|
|
|
5280
5261
|
exports.BudgetManager = BudgetManager;
|
|
5281
5262
|
exports.ComfyUIAdapter = ComfyUIAdapter;
|
|
@@ -5299,11 +5280,8 @@ exports.ToolHub = ToolHub;
|
|
|
5299
5280
|
exports.ToolRegistry = ToolRegistry;
|
|
5300
5281
|
exports.Tracing = Tracing;
|
|
5301
5282
|
exports.buildEvidence = buildEvidence;
|
|
5302
|
-
exports.createAgentToolHub = createAgentToolHub;
|
|
5303
5283
|
exports.createTaggedError = createTaggedError;
|
|
5304
5284
|
exports.createToolHub = createToolHub;
|
|
5305
|
-
exports.createToolHubAndInit = createToolHubAndInit;
|
|
5306
|
-
exports.createToolHubAndInitFromConfig = createToolHubAndInitFromConfig;
|
|
5307
5285
|
exports.deletePathSpec = deletePathSpec;
|
|
5308
5286
|
exports.downloadFileSpec = downloadFileSpec;
|
|
5309
5287
|
exports.fetchJsonSpec = fetchJsonSpec;
|
|
@@ -5331,5 +5309,5 @@ exports.validateFrontmatter = validateFrontmatter;
|
|
|
5331
5309
|
exports.validateUrl = validateUrl;
|
|
5332
5310
|
exports.withRetry = withRetry;
|
|
5333
5311
|
exports.writeTextSpec = writeTextSpec;
|
|
5334
|
-
//# sourceMappingURL=chunk-
|
|
5335
|
-
//# sourceMappingURL=chunk-
|
|
5312
|
+
//# sourceMappingURL=chunk-TIKHPRMB.cjs.map
|
|
5313
|
+
//# sourceMappingURL=chunk-TIKHPRMB.cjs.map
|