@easynet/agent-tool 1.0.102 → 1.0.104
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 +33 -35
- package/config/build/build.sh +182 -0
- package/config/build/tsconfig.dts.json +34 -0
- package/config/build/tsup.config.ts +19 -0
- package/config/build/vitest.config.ts +29 -0
- package/config/tool.yaml +1 -0
- package/dist/api/adapters/LangChainToolsHub.d.ts +1 -0
- package/dist/api/adapters/LangChainToolsHub.d.ts.map +1 -1
- package/dist/api/extension/createExtension.d.ts +1 -1
- package/dist/api/extension/createExtension.d.ts.map +1 -1
- package/dist/api/extension/index.d.ts +3 -3
- package/dist/api/extension/index.d.ts.map +1 -1
- package/dist/api/extension/support/groupPrefix.d.ts.map +1 -0
- package/dist/api/extension/{types.d.ts → support/types.d.ts} +3 -3
- package/dist/api/extension/support/types.d.ts.map +1 -0
- package/dist/api/resolveAgentSkillRoots.d.ts +7 -0
- package/dist/api/resolveAgentSkillRoots.d.ts.map +1 -0
- package/dist/api/runtimeFromConfig.d.ts +2 -65
- package/dist/api/runtimeFromConfig.d.ts.map +1 -1
- package/dist/api/runtimeFromConfig.types.d.ts +37 -0
- package/dist/api/runtimeFromConfig.types.d.ts.map +1 -0
- package/dist/build.cjs +5 -5
- package/dist/build.js +2 -2
- package/dist/{chunk-34SBJLFZ.js → chunk-2MSEJB6X.js} +82 -19
- package/dist/chunk-2MSEJB6X.js.map +1 -0
- package/dist/{chunk-YBMF3C6F.cjs → chunk-2THI5UWA.cjs} +90 -21
- package/dist/chunk-2THI5UWA.cjs.map +1 -0
- package/dist/{chunk-POUTZDWB.js → chunk-2Y6T67HJ.js} +3 -3
- package/dist/chunk-2Y6T67HJ.js.map +1 -0
- package/dist/{chunk-VLV5F6HX.cjs → chunk-45MCEW2Y.cjs} +3 -3
- package/dist/chunk-45MCEW2Y.cjs.map +1 -0
- package/dist/{chunk-34SG3EMW.js → chunk-WNWMAS7C.js} +3 -3
- package/dist/{chunk-34SG3EMW.js.map → chunk-WNWMAS7C.js.map} +1 -1
- package/dist/{chunk-XUIGSBWG.cjs → chunk-YAIP4AYQ.cjs} +7 -7
- package/dist/{chunk-XUIGSBWG.cjs.map → chunk-YAIP4AYQ.cjs.map} +1 -1
- package/dist/core/runtime/PTCRuntimePipeline.d.ts.map +1 -1
- package/dist/index.cjs +120 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +112 -11
- package/dist/index.js.map +1 -1
- package/dist/sdk.cjs +1 -1
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.js +1 -1
- package/dist/sdk.js.map +1 -1
- package/dist/tools/mcp/index.d.ts +1 -0
- package/dist/tools/mcp/index.d.ts.map +1 -1
- package/dist/tools/mcp/support/types.d.ts.map +1 -0
- package/dist/tools/util/toolConfig.d.ts +7 -0
- package/dist/tools/util/toolConfig.d.ts.map +1 -1
- package/dist/utils/cli/index.cjs +19 -19
- package/dist/utils/cli/index.js +3 -3
- package/package.json +4 -4
- package/dist/api/extension/groupPrefix.d.ts.map +0 -1
- package/dist/api/extension/types.d.ts.map +0 -1
- package/dist/chunk-34SBJLFZ.js.map +0 -1
- package/dist/chunk-POUTZDWB.js.map +0 -1
- package/dist/chunk-VLV5F6HX.cjs.map +0 -1
- package/dist/chunk-YBMF3C6F.cjs.map +0 -1
- package/dist/tools/mcp/types.d.ts.map +0 -1
- /package/dist/api/extension/{groupPrefix.d.ts → support/groupPrefix.d.ts} +0 -0
- /package/dist/tools/mcp/{types.d.ts → support/types.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk45MCEW2Y_cjs = require('./chunk-45MCEW2Y.cjs');
|
|
4
4
|
var chunkAGLGFQUW_cjs = require('./chunk-AGLGFQUW.cjs');
|
|
5
5
|
var chunkJW4EMVTE_cjs = require('./chunk-JW4EMVTE.cjs');
|
|
6
6
|
var chunkUUNG3GL3_cjs = require('./chunk-UUNG3GL3.cjs');
|
|
@@ -48,8 +48,33 @@ function normalizeOpenApiConfig(raw) {
|
|
|
48
48
|
}
|
|
49
49
|
function normalizeToolSources(raw) {
|
|
50
50
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
51
|
+
const source = raw;
|
|
51
52
|
const out = {};
|
|
52
|
-
|
|
53
|
+
const customized = source.customized;
|
|
54
|
+
if (customized && typeof customized === "object" && !Array.isArray(customized)) {
|
|
55
|
+
const customizedSource = customized;
|
|
56
|
+
const descriptorGrouped = Object.keys(customizedSource).some((key) => /^(npm|file):/.test(key));
|
|
57
|
+
if (descriptorGrouped) {
|
|
58
|
+
for (const [sourceKey, sourceValue] of Object.entries(customizedSource)) {
|
|
59
|
+
if (!sourceValue || typeof sourceValue !== "object" || Array.isArray(sourceValue)) continue;
|
|
60
|
+
const toolMap = {};
|
|
61
|
+
for (const [toolName, toolValue] of Object.entries(sourceValue)) {
|
|
62
|
+
if (!toolValue || typeof toolValue !== "object" || Array.isArray(toolValue)) continue;
|
|
63
|
+
toolMap[toolName] = toolValue;
|
|
64
|
+
}
|
|
65
|
+
out[sourceKey] = toolMap;
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
const toolMap = {};
|
|
69
|
+
for (const [toolName, toolValue] of Object.entries(customizedSource)) {
|
|
70
|
+
if (!toolValue || typeof toolValue !== "object" || Array.isArray(toolValue)) continue;
|
|
71
|
+
toolMap[toolName] = toolValue;
|
|
72
|
+
}
|
|
73
|
+
if (Object.keys(toolMap).length > 0) out.self = toolMap;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (const [sourceKey, sourceValue] of Object.entries(source)) {
|
|
77
|
+
if (sourceKey === "customized" || sourceKey === "deepagents") continue;
|
|
53
78
|
if (!sourceValue || typeof sourceValue !== "object" || Array.isArray(sourceValue)) continue;
|
|
54
79
|
const toolMap = {};
|
|
55
80
|
for (const [toolName, toolValue] of Object.entries(sourceValue)) {
|
|
@@ -60,6 +85,19 @@ function normalizeToolSources(raw) {
|
|
|
60
85
|
}
|
|
61
86
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
62
87
|
}
|
|
88
|
+
function normalizePathSources(raw) {
|
|
89
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
90
|
+
const source = raw;
|
|
91
|
+
const out = {};
|
|
92
|
+
for (const [descriptor, value] of Object.entries(source)) {
|
|
93
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
94
|
+
out[descriptor] = {};
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
out[descriptor] = value;
|
|
98
|
+
}
|
|
99
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
100
|
+
}
|
|
63
101
|
function loadToolConfig(toolYamlPath) {
|
|
64
102
|
const abs = path.resolve(toolYamlPath);
|
|
65
103
|
const raw = fs.readFileSync(abs, "utf8");
|
|
@@ -70,6 +108,10 @@ function loadToolConfig(toolYamlPath) {
|
|
|
70
108
|
const source = parsed.spec && typeof parsed.spec === "object" && !Array.isArray(parsed.spec) ? parsed.spec : parsed;
|
|
71
109
|
return {
|
|
72
110
|
sandboxedPath: typeof source.sandboxedPath === "string" ? source.sandboxedPath : void 0,
|
|
111
|
+
cacheDir: typeof source.cacheDir === "string" ? source.cacheDir : void 0,
|
|
112
|
+
toolPath: typeof source.toolPath === "string" ? source.toolPath : void 0,
|
|
113
|
+
skillPath: typeof source.skillPath === "string" ? source.skillPath : void 0,
|
|
114
|
+
paths: normalizePathSources(source.paths),
|
|
73
115
|
enableSandboxValidation: typeof source.enableSandboxValidation === "boolean" ? source.enableSandboxValidation : void 0,
|
|
74
116
|
allowedHosts: Array.isArray(source.allowedHosts) ? source.allowedHosts : void 0,
|
|
75
117
|
blockedHosts: Array.isArray(source.blockedHosts) ? source.blockedHosts : void 0,
|
|
@@ -83,15 +125,29 @@ function getToolSourceDescriptors(config, options) {
|
|
|
83
125
|
const includeSelf = options?.includeSelf ?? false;
|
|
84
126
|
return Object.keys(config.tools ?? {}).filter((key) => includeSelf || key !== "self");
|
|
85
127
|
}
|
|
128
|
+
function getPathSourceDescriptors(config) {
|
|
129
|
+
const fromPaths = Object.keys(config.paths ?? {});
|
|
130
|
+
if (fromPaths.length > 0) return fromPaths;
|
|
131
|
+
return getToolSourceDescriptors(config);
|
|
132
|
+
}
|
|
86
133
|
function resolveSandboxedPath(toolYamlPath, sandboxedPath) {
|
|
87
134
|
const configDir = path.dirname(path.resolve(toolYamlPath));
|
|
88
135
|
return config.resolveConfigPath(sandboxedPath, configDir, {
|
|
89
136
|
expandHome: true
|
|
90
137
|
});
|
|
91
138
|
}
|
|
139
|
+
function resolveCacheDir(toolYamlPath, cacheDir) {
|
|
140
|
+
const configDir = path.dirname(path.resolve(toolYamlPath));
|
|
141
|
+
return config.resolveConfigPath(cacheDir, configDir, {
|
|
142
|
+
expandHome: true
|
|
143
|
+
});
|
|
144
|
+
}
|
|
92
145
|
var CACHE_SUBDIR = ".agent/cache";
|
|
93
146
|
function getCacheBaseFromToolConfig(toolYamlPath) {
|
|
94
147
|
const config = loadToolConfig(toolYamlPath);
|
|
148
|
+
if (config.cacheDir && typeof config.cacheDir === "string") {
|
|
149
|
+
return resolveCacheDir(toolYamlPath, config.cacheDir);
|
|
150
|
+
}
|
|
95
151
|
if (!config.sandboxedPath || typeof config.sandboxedPath !== "string") return void 0;
|
|
96
152
|
const sandboxRoot = resolveSandboxedPath(toolYamlPath, config.sandboxedPath);
|
|
97
153
|
return path.join(sandboxRoot, CACHE_SUBDIR);
|
|
@@ -1166,14 +1222,19 @@ var Tracing = class {
|
|
|
1166
1222
|
function resolveTool(toolName, registry) {
|
|
1167
1223
|
const key = chunkJW4EMVTE_cjs.normalizeToolName(toolName);
|
|
1168
1224
|
const spec = registry.get(key);
|
|
1169
|
-
if (
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1225
|
+
if (spec) {
|
|
1226
|
+
return spec;
|
|
1227
|
+
}
|
|
1228
|
+
const suffixMatches = registry.snapshot().filter((candidate) => candidate.name.endsWith(`.${key}`));
|
|
1229
|
+
const uniqueSuffixMatch = suffixMatches[0];
|
|
1230
|
+
if (suffixMatches.length === 1 && uniqueSuffixMatch !== void 0) {
|
|
1231
|
+
return uniqueSuffixMatch;
|
|
1232
|
+
}
|
|
1233
|
+
throw chunkAGLGFQUW_cjs.createTaggedError(
|
|
1234
|
+
"TOOL_NOT_FOUND",
|
|
1235
|
+
`Tool not found: ${toolName}`,
|
|
1236
|
+
{ availableTools: registry.snapshot().slice(0, 20).map((s) => s.name) }
|
|
1237
|
+
);
|
|
1177
1238
|
}
|
|
1178
1239
|
var INPUT_ALIASES = {
|
|
1179
1240
|
q: "query"
|
|
@@ -1798,7 +1859,7 @@ function packagePathSegments(name) {
|
|
|
1798
1859
|
const withoutScope = name.replace(/^@/, "");
|
|
1799
1860
|
return withoutScope.split("/").filter(Boolean);
|
|
1800
1861
|
}
|
|
1801
|
-
function
|
|
1862
|
+
function resolveCacheDir2(cacheBase, packageName, version) {
|
|
1802
1863
|
const segments = packagePathSegments(packageName);
|
|
1803
1864
|
return path.join(cacheBase, ...segments, version);
|
|
1804
1865
|
}
|
|
@@ -1806,7 +1867,7 @@ function ensurePackageInCache(packageName, version = "latest", options = {}) {
|
|
|
1806
1867
|
const cacheBase = options.cacheBase ?? DEFAULT_CACHE_BASE;
|
|
1807
1868
|
const cwd = options.cwd ?? process.cwd();
|
|
1808
1869
|
const resolvedVersion = isLatestRequest(version) ? resolveLatestVersionFromRegistry(packageName, { cwd }) : version;
|
|
1809
|
-
const cacheDir =
|
|
1870
|
+
const cacheDir = resolveCacheDir2(cacheBase, packageName, resolvedVersion);
|
|
1810
1871
|
const packageJsonPath = path.join(cacheDir, "package.json");
|
|
1811
1872
|
const nodeModulesPath = path.join(cacheDir, "node_modules");
|
|
1812
1873
|
if (fs.existsSync(packageJsonPath) && fs.existsSync(nodeModulesPath)) {
|
|
@@ -1886,7 +1947,7 @@ async function importFromCache(packageRoot) {
|
|
|
1886
1947
|
fileUrl
|
|
1887
1948
|
);
|
|
1888
1949
|
}
|
|
1889
|
-
var requireFromPackage = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
1950
|
+
var requireFromPackage = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-2THI5UWA.cjs', document.baseURI).href)));
|
|
1890
1951
|
function getProjectRequire() {
|
|
1891
1952
|
const cwd = process.cwd();
|
|
1892
1953
|
if (fs.existsSync(path.join(cwd, "package.json"))) return module$1.createRequire(path.join(cwd, "package.json"));
|
|
@@ -2051,9 +2112,11 @@ function parseNpmDescriptor(entry) {
|
|
|
2051
2112
|
return { packageName, version };
|
|
2052
2113
|
}
|
|
2053
2114
|
|
|
2054
|
-
// src/api/runtimeFromConfig.ts
|
|
2055
|
-
var requireFromPackage2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-YBMF3C6F.cjs', document.baseURI).href)));
|
|
2115
|
+
// src/api/runtimeFromConfig.types.ts
|
|
2056
2116
|
var DEFAULT_EXTENSION_PACKAGES = [];
|
|
2117
|
+
|
|
2118
|
+
// src/api/runtimeFromConfig.ts
|
|
2119
|
+
var requireFromPackage2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-2THI5UWA.cjs', document.baseURI).href)));
|
|
2057
2120
|
function resolveEffectiveCoreTools(options) {
|
|
2058
2121
|
if (options.coreTools) return options.coreTools;
|
|
2059
2122
|
if (options.configFilePath) return {};
|
|
@@ -2187,7 +2250,7 @@ function loadAllExtensionsFromToolYamlSync(configFilePath, stepLog) {
|
|
|
2187
2250
|
const localPath = path.isAbsolute(configFilePath) ? configFilePath : path.resolve(process.cwd(), configFilePath);
|
|
2188
2251
|
if (!fs.existsSync(localPath)) return [];
|
|
2189
2252
|
const config = loadToolConfig(localPath);
|
|
2190
|
-
const tools =
|
|
2253
|
+
const tools = getPathSourceDescriptors(config);
|
|
2191
2254
|
if (!Array.isArray(tools) || tools.length === 0) return [];
|
|
2192
2255
|
if (stepLog) stepLog("Loading extensions from tool.yaml (npm + file)");
|
|
2193
2256
|
const loaded = [];
|
|
@@ -2268,7 +2331,7 @@ async function loadLocalDirectoryForFileDescriptor(descriptor, configFilePath, s
|
|
|
2268
2331
|
if (!resolvedPath || !fs.existsSync(resolvedPath) || !fs.statSync(resolvedPath).isDirectory()) return null;
|
|
2269
2332
|
if (fs.existsSync(path.join(resolvedPath, "package.json"))) return null;
|
|
2270
2333
|
const scanErrors = [];
|
|
2271
|
-
const scanner = new
|
|
2334
|
+
const scanner = new chunk45MCEW2Y_cjs.DirectoryScanner({
|
|
2272
2335
|
roots: [{ path: resolvedPath, namespace: "local" }],
|
|
2273
2336
|
onError: (toolDir, error) => scanErrors.push(`${toolDir}: ${error.message}`)
|
|
2274
2337
|
});
|
|
@@ -2290,7 +2353,7 @@ async function loadAllExtensionsFromToolYamlAsync(configFilePath, stepLog) {
|
|
|
2290
2353
|
const localPath = path.isAbsolute(configFilePath) ? configFilePath : path.resolve(process.cwd(), configFilePath);
|
|
2291
2354
|
if (!fs.existsSync(localPath)) return [];
|
|
2292
2355
|
const config = loadToolConfig(localPath);
|
|
2293
|
-
const tools =
|
|
2356
|
+
const tools = getPathSourceDescriptors(config);
|
|
2294
2357
|
if (!Array.isArray(tools) || tools.length === 0) return [];
|
|
2295
2358
|
if (stepLog) stepLog("Loading extensions from tool.yaml (async)");
|
|
2296
2359
|
const loaded = [];
|
|
@@ -2476,7 +2539,7 @@ async function createMcpServerWithTools(runtime, options) {
|
|
|
2476
2539
|
async (args) => {
|
|
2477
2540
|
const ctx = ctxFactory();
|
|
2478
2541
|
const result = await runtime.invoke(
|
|
2479
|
-
{ tool: spec.name, args: args ?? {}, purpose:
|
|
2542
|
+
{ tool: spec.name, args: args ?? {}, purpose: chunk45MCEW2Y_cjs.MCP_KIND },
|
|
2480
2543
|
ctx
|
|
2481
2544
|
);
|
|
2482
2545
|
if (result.ok) {
|
|
@@ -2955,17 +3018,23 @@ async function createHttpService(runtimeOrConfig, options = {}) {
|
|
|
2955
3018
|
exports.createHttpService = createHttpService;
|
|
2956
3019
|
exports.createMCPServerStreamableHttp = createMCPServerStreamableHttp;
|
|
2957
3020
|
exports.createRuntimeFromConfig = createRuntimeFromConfig;
|
|
3021
|
+
exports.ensurePackageInCache = ensurePackageInCache;
|
|
2958
3022
|
exports.expandToolDescriptorsToRegistryNames = expandToolDescriptorsToRegistryNames;
|
|
2959
3023
|
exports.fileDescriptorToPackagePrefix = fileDescriptorToPackagePrefix;
|
|
2960
3024
|
exports.findAndLoadToolConfig = findAndLoadToolConfig;
|
|
3025
|
+
exports.getCacheBaseFromToolConfig = getCacheBaseFromToolConfig;
|
|
2961
3026
|
exports.getDisplayScope = getDisplayScope;
|
|
3027
|
+
exports.getPathSourceDescriptors = getPathSourceDescriptors;
|
|
2962
3028
|
exports.getToolSourceDescriptors = getToolSourceDescriptors;
|
|
2963
3029
|
exports.isBarePackageDescriptor = isBarePackageDescriptor;
|
|
2964
3030
|
exports.loadToolConfig = loadToolConfig;
|
|
2965
3031
|
exports.npmDescriptorToPackagePrefix = npmDescriptorToPackagePrefix;
|
|
3032
|
+
exports.parseNpmDescriptor = parseNpmDescriptor;
|
|
3033
|
+
exports.parseToolPath = parseToolPath;
|
|
3034
|
+
exports.resolveLatestVersionFromRegistry = resolveLatestVersionFromRegistry;
|
|
2966
3035
|
exports.resolveSandboxedPath = resolveSandboxedPath;
|
|
2967
3036
|
exports.resolveToolDescriptor = resolveToolDescriptor;
|
|
2968
3037
|
exports.runMCPServerOverStdio = runMCPServerOverStdio;
|
|
2969
3038
|
exports.toToolObservationText = toToolObservationText;
|
|
2970
|
-
//# sourceMappingURL=chunk-
|
|
2971
|
-
//# sourceMappingURL=chunk-
|
|
3039
|
+
//# sourceMappingURL=chunk-2THI5UWA.cjs.map
|
|
3040
|
+
//# sourceMappingURL=chunk-2THI5UWA.cjs.map
|