@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,8 +1,8 @@
|
|
|
1
|
-
import { DirectoryScanner, MCP_KIND } from './chunk-
|
|
1
|
+
import { DirectoryScanner, MCP_KIND } from './chunk-2Y6T67HJ.js';
|
|
2
2
|
import { setSandboxValidationEnabled, ToolRegistry, createTaggedError, withRetry } from './chunk-IVL4TBFB.js';
|
|
3
3
|
import { normalizeToolName } from './chunk-BDUSB6GT.js';
|
|
4
4
|
import { enrichSpecWithCanonicalSchema } from './chunk-NTWOVFEY.js';
|
|
5
|
-
import { readFileSync, existsSync,
|
|
5
|
+
import { readFileSync, existsSync, rmSync, mkdirSync, readdirSync, renameSync, statSync } from 'fs';
|
|
6
6
|
import { join, resolve, dirname, isAbsolute, basename } from 'path';
|
|
7
7
|
import { parseYamlContent, resolveConfigPath } from '@easynet/agent-common/config';
|
|
8
8
|
import { createRequire } from 'module';
|
|
@@ -38,8 +38,33 @@ function normalizeOpenApiConfig(raw) {
|
|
|
38
38
|
}
|
|
39
39
|
function normalizeToolSources(raw) {
|
|
40
40
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
41
|
+
const source = raw;
|
|
41
42
|
const out = {};
|
|
42
|
-
|
|
43
|
+
const customized = source.customized;
|
|
44
|
+
if (customized && typeof customized === "object" && !Array.isArray(customized)) {
|
|
45
|
+
const customizedSource = customized;
|
|
46
|
+
const descriptorGrouped = Object.keys(customizedSource).some((key) => /^(npm|file):/.test(key));
|
|
47
|
+
if (descriptorGrouped) {
|
|
48
|
+
for (const [sourceKey, sourceValue] of Object.entries(customizedSource)) {
|
|
49
|
+
if (!sourceValue || typeof sourceValue !== "object" || Array.isArray(sourceValue)) continue;
|
|
50
|
+
const toolMap = {};
|
|
51
|
+
for (const [toolName, toolValue] of Object.entries(sourceValue)) {
|
|
52
|
+
if (!toolValue || typeof toolValue !== "object" || Array.isArray(toolValue)) continue;
|
|
53
|
+
toolMap[toolName] = toolValue;
|
|
54
|
+
}
|
|
55
|
+
out[sourceKey] = toolMap;
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
const toolMap = {};
|
|
59
|
+
for (const [toolName, toolValue] of Object.entries(customizedSource)) {
|
|
60
|
+
if (!toolValue || typeof toolValue !== "object" || Array.isArray(toolValue)) continue;
|
|
61
|
+
toolMap[toolName] = toolValue;
|
|
62
|
+
}
|
|
63
|
+
if (Object.keys(toolMap).length > 0) out.self = toolMap;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const [sourceKey, sourceValue] of Object.entries(source)) {
|
|
67
|
+
if (sourceKey === "customized" || sourceKey === "deepagents") continue;
|
|
43
68
|
if (!sourceValue || typeof sourceValue !== "object" || Array.isArray(sourceValue)) continue;
|
|
44
69
|
const toolMap = {};
|
|
45
70
|
for (const [toolName, toolValue] of Object.entries(sourceValue)) {
|
|
@@ -50,6 +75,19 @@ function normalizeToolSources(raw) {
|
|
|
50
75
|
}
|
|
51
76
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
52
77
|
}
|
|
78
|
+
function normalizePathSources(raw) {
|
|
79
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
80
|
+
const source = raw;
|
|
81
|
+
const out = {};
|
|
82
|
+
for (const [descriptor, value] of Object.entries(source)) {
|
|
83
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
84
|
+
out[descriptor] = {};
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
out[descriptor] = value;
|
|
88
|
+
}
|
|
89
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
90
|
+
}
|
|
53
91
|
function loadToolConfig(toolYamlPath) {
|
|
54
92
|
const abs = resolve(toolYamlPath);
|
|
55
93
|
const raw = readFileSync(abs, "utf8");
|
|
@@ -60,6 +98,10 @@ function loadToolConfig(toolYamlPath) {
|
|
|
60
98
|
const source = parsed.spec && typeof parsed.spec === "object" && !Array.isArray(parsed.spec) ? parsed.spec : parsed;
|
|
61
99
|
return {
|
|
62
100
|
sandboxedPath: typeof source.sandboxedPath === "string" ? source.sandboxedPath : void 0,
|
|
101
|
+
cacheDir: typeof source.cacheDir === "string" ? source.cacheDir : void 0,
|
|
102
|
+
toolPath: typeof source.toolPath === "string" ? source.toolPath : void 0,
|
|
103
|
+
skillPath: typeof source.skillPath === "string" ? source.skillPath : void 0,
|
|
104
|
+
paths: normalizePathSources(source.paths),
|
|
63
105
|
enableSandboxValidation: typeof source.enableSandboxValidation === "boolean" ? source.enableSandboxValidation : void 0,
|
|
64
106
|
allowedHosts: Array.isArray(source.allowedHosts) ? source.allowedHosts : void 0,
|
|
65
107
|
blockedHosts: Array.isArray(source.blockedHosts) ? source.blockedHosts : void 0,
|
|
@@ -73,15 +115,29 @@ function getToolSourceDescriptors(config, options) {
|
|
|
73
115
|
const includeSelf = options?.includeSelf ?? false;
|
|
74
116
|
return Object.keys(config.tools ?? {}).filter((key) => includeSelf || key !== "self");
|
|
75
117
|
}
|
|
118
|
+
function getPathSourceDescriptors(config) {
|
|
119
|
+
const fromPaths = Object.keys(config.paths ?? {});
|
|
120
|
+
if (fromPaths.length > 0) return fromPaths;
|
|
121
|
+
return getToolSourceDescriptors(config);
|
|
122
|
+
}
|
|
76
123
|
function resolveSandboxedPath(toolYamlPath, sandboxedPath) {
|
|
77
124
|
const configDir = dirname(resolve(toolYamlPath));
|
|
78
125
|
return resolveConfigPath(sandboxedPath, configDir, {
|
|
79
126
|
expandHome: true
|
|
80
127
|
});
|
|
81
128
|
}
|
|
129
|
+
function resolveCacheDir(toolYamlPath, cacheDir) {
|
|
130
|
+
const configDir = dirname(resolve(toolYamlPath));
|
|
131
|
+
return resolveConfigPath(cacheDir, configDir, {
|
|
132
|
+
expandHome: true
|
|
133
|
+
});
|
|
134
|
+
}
|
|
82
135
|
var CACHE_SUBDIR = ".agent/cache";
|
|
83
136
|
function getCacheBaseFromToolConfig(toolYamlPath) {
|
|
84
137
|
const config = loadToolConfig(toolYamlPath);
|
|
138
|
+
if (config.cacheDir && typeof config.cacheDir === "string") {
|
|
139
|
+
return resolveCacheDir(toolYamlPath, config.cacheDir);
|
|
140
|
+
}
|
|
85
141
|
if (!config.sandboxedPath || typeof config.sandboxedPath !== "string") return void 0;
|
|
86
142
|
const sandboxRoot = resolveSandboxedPath(toolYamlPath, config.sandboxedPath);
|
|
87
143
|
return join(sandboxRoot, CACHE_SUBDIR);
|
|
@@ -1156,14 +1212,19 @@ var Tracing = class {
|
|
|
1156
1212
|
function resolveTool(toolName, registry) {
|
|
1157
1213
|
const key = normalizeToolName(toolName);
|
|
1158
1214
|
const spec = registry.get(key);
|
|
1159
|
-
if (
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1215
|
+
if (spec) {
|
|
1216
|
+
return spec;
|
|
1217
|
+
}
|
|
1218
|
+
const suffixMatches = registry.snapshot().filter((candidate) => candidate.name.endsWith(`.${key}`));
|
|
1219
|
+
const uniqueSuffixMatch = suffixMatches[0];
|
|
1220
|
+
if (suffixMatches.length === 1 && uniqueSuffixMatch !== void 0) {
|
|
1221
|
+
return uniqueSuffixMatch;
|
|
1222
|
+
}
|
|
1223
|
+
throw createTaggedError(
|
|
1224
|
+
"TOOL_NOT_FOUND",
|
|
1225
|
+
`Tool not found: ${toolName}`,
|
|
1226
|
+
{ availableTools: registry.snapshot().slice(0, 20).map((s) => s.name) }
|
|
1227
|
+
);
|
|
1167
1228
|
}
|
|
1168
1229
|
var INPUT_ALIASES = {
|
|
1169
1230
|
q: "query"
|
|
@@ -1788,7 +1849,7 @@ function packagePathSegments(name) {
|
|
|
1788
1849
|
const withoutScope = name.replace(/^@/, "");
|
|
1789
1850
|
return withoutScope.split("/").filter(Boolean);
|
|
1790
1851
|
}
|
|
1791
|
-
function
|
|
1852
|
+
function resolveCacheDir2(cacheBase, packageName, version) {
|
|
1792
1853
|
const segments = packagePathSegments(packageName);
|
|
1793
1854
|
return join(cacheBase, ...segments, version);
|
|
1794
1855
|
}
|
|
@@ -1796,7 +1857,7 @@ function ensurePackageInCache(packageName, version = "latest", options = {}) {
|
|
|
1796
1857
|
const cacheBase = options.cacheBase ?? DEFAULT_CACHE_BASE;
|
|
1797
1858
|
const cwd = options.cwd ?? process.cwd();
|
|
1798
1859
|
const resolvedVersion = isLatestRequest(version) ? resolveLatestVersionFromRegistry(packageName, { cwd }) : version;
|
|
1799
|
-
const cacheDir =
|
|
1860
|
+
const cacheDir = resolveCacheDir2(cacheBase, packageName, resolvedVersion);
|
|
1800
1861
|
const packageJsonPath = join(cacheDir, "package.json");
|
|
1801
1862
|
const nodeModulesPath = join(cacheDir, "node_modules");
|
|
1802
1863
|
if (existsSync(packageJsonPath) && existsSync(nodeModulesPath)) {
|
|
@@ -2041,9 +2102,11 @@ function parseNpmDescriptor(entry) {
|
|
|
2041
2102
|
return { packageName, version };
|
|
2042
2103
|
}
|
|
2043
2104
|
|
|
2105
|
+
// src/api/runtimeFromConfig.types.ts
|
|
2106
|
+
var DEFAULT_EXTENSION_PACKAGES = [];
|
|
2107
|
+
|
|
2044
2108
|
// src/api/runtimeFromConfig.ts
|
|
2045
2109
|
var requireFromPackage2 = createRequire(import.meta.url);
|
|
2046
|
-
var DEFAULT_EXTENSION_PACKAGES = [];
|
|
2047
2110
|
function resolveEffectiveCoreTools(options) {
|
|
2048
2111
|
if (options.coreTools) return options.coreTools;
|
|
2049
2112
|
if (options.configFilePath) return {};
|
|
@@ -2177,7 +2240,7 @@ function loadAllExtensionsFromToolYamlSync(configFilePath, stepLog) {
|
|
|
2177
2240
|
const localPath = isAbsolute(configFilePath) ? configFilePath : resolve(process.cwd(), configFilePath);
|
|
2178
2241
|
if (!existsSync(localPath)) return [];
|
|
2179
2242
|
const config = loadToolConfig(localPath);
|
|
2180
|
-
const tools =
|
|
2243
|
+
const tools = getPathSourceDescriptors(config);
|
|
2181
2244
|
if (!Array.isArray(tools) || tools.length === 0) return [];
|
|
2182
2245
|
if (stepLog) stepLog("Loading extensions from tool.yaml (npm + file)");
|
|
2183
2246
|
const loaded = [];
|
|
@@ -2280,7 +2343,7 @@ async function loadAllExtensionsFromToolYamlAsync(configFilePath, stepLog) {
|
|
|
2280
2343
|
const localPath = isAbsolute(configFilePath) ? configFilePath : resolve(process.cwd(), configFilePath);
|
|
2281
2344
|
if (!existsSync(localPath)) return [];
|
|
2282
2345
|
const config = loadToolConfig(localPath);
|
|
2283
|
-
const tools =
|
|
2346
|
+
const tools = getPathSourceDescriptors(config);
|
|
2284
2347
|
if (!Array.isArray(tools) || tools.length === 0) return [];
|
|
2285
2348
|
if (stepLog) stepLog("Loading extensions from tool.yaml (async)");
|
|
2286
2349
|
const loaded = [];
|
|
@@ -2942,6 +3005,6 @@ async function createHttpService(runtimeOrConfig, options = {}) {
|
|
|
2942
3005
|
};
|
|
2943
3006
|
}
|
|
2944
3007
|
|
|
2945
|
-
export { createHttpService, createMCPServerStreamableHttp, createRuntimeFromConfig, expandToolDescriptorsToRegistryNames, fileDescriptorToPackagePrefix, findAndLoadToolConfig, getDisplayScope, getToolSourceDescriptors, isBarePackageDescriptor, loadToolConfig, npmDescriptorToPackagePrefix, resolveSandboxedPath, resolveToolDescriptor, runMCPServerOverStdio, toToolObservationText };
|
|
2946
|
-
//# sourceMappingURL=chunk-
|
|
2947
|
-
//# sourceMappingURL=chunk-
|
|
3008
|
+
export { createHttpService, createMCPServerStreamableHttp, createRuntimeFromConfig, ensurePackageInCache, expandToolDescriptorsToRegistryNames, fileDescriptorToPackagePrefix, findAndLoadToolConfig, getCacheBaseFromToolConfig, getDisplayScope, getPathSourceDescriptors, getToolSourceDescriptors, isBarePackageDescriptor, loadToolConfig, npmDescriptorToPackagePrefix, parseNpmDescriptor, parseToolPath, resolveLatestVersionFromRegistry, resolveSandboxedPath, resolveToolDescriptor, runMCPServerOverStdio, toToolObservationText };
|
|
3009
|
+
//# sourceMappingURL=chunk-2MSEJB6X.js.map
|
|
3010
|
+
//# sourceMappingURL=chunk-2MSEJB6X.js.map
|