@easynet/agent-tool 1.0.103 → 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-3C4VJ4DI.js → chunk-2MSEJB6X.js} +71 -22
- package/dist/chunk-2MSEJB6X.js.map +1 -0
- package/dist/{chunk-KTPQDVP6.cjs → chunk-2THI5UWA.cjs} +79 -24
- 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-3C4VJ4DI.js.map +0 -1
- package/dist/chunk-KTPQDVP6.cjs.map +0 -1
- package/dist/chunk-POUTZDWB.js.map +0 -1
- package/dist/chunk-VLV5F6HX.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';
|
|
@@ -42,14 +42,25 @@ function normalizeToolSources(raw) {
|
|
|
42
42
|
const out = {};
|
|
43
43
|
const customized = source.customized;
|
|
44
44
|
if (customized && typeof customized === "object" && !Array.isArray(customized)) {
|
|
45
|
-
|
|
46
|
-
|
|
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 {
|
|
47
58
|
const toolMap = {};
|
|
48
|
-
for (const [toolName, toolValue] of Object.entries(
|
|
59
|
+
for (const [toolName, toolValue] of Object.entries(customizedSource)) {
|
|
49
60
|
if (!toolValue || typeof toolValue !== "object" || Array.isArray(toolValue)) continue;
|
|
50
61
|
toolMap[toolName] = toolValue;
|
|
51
62
|
}
|
|
52
|
-
out
|
|
63
|
+
if (Object.keys(toolMap).length > 0) out.self = toolMap;
|
|
53
64
|
}
|
|
54
65
|
}
|
|
55
66
|
for (const [sourceKey, sourceValue] of Object.entries(source)) {
|
|
@@ -64,6 +75,19 @@ function normalizeToolSources(raw) {
|
|
|
64
75
|
}
|
|
65
76
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
66
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
|
+
}
|
|
67
91
|
function loadToolConfig(toolYamlPath) {
|
|
68
92
|
const abs = resolve(toolYamlPath);
|
|
69
93
|
const raw = readFileSync(abs, "utf8");
|
|
@@ -74,6 +98,10 @@ function loadToolConfig(toolYamlPath) {
|
|
|
74
98
|
const source = parsed.spec && typeof parsed.spec === "object" && !Array.isArray(parsed.spec) ? parsed.spec : parsed;
|
|
75
99
|
return {
|
|
76
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),
|
|
77
105
|
enableSandboxValidation: typeof source.enableSandboxValidation === "boolean" ? source.enableSandboxValidation : void 0,
|
|
78
106
|
allowedHosts: Array.isArray(source.allowedHosts) ? source.allowedHosts : void 0,
|
|
79
107
|
blockedHosts: Array.isArray(source.blockedHosts) ? source.blockedHosts : void 0,
|
|
@@ -87,15 +115,29 @@ function getToolSourceDescriptors(config, options) {
|
|
|
87
115
|
const includeSelf = options?.includeSelf ?? false;
|
|
88
116
|
return Object.keys(config.tools ?? {}).filter((key) => includeSelf || key !== "self");
|
|
89
117
|
}
|
|
118
|
+
function getPathSourceDescriptors(config) {
|
|
119
|
+
const fromPaths = Object.keys(config.paths ?? {});
|
|
120
|
+
if (fromPaths.length > 0) return fromPaths;
|
|
121
|
+
return getToolSourceDescriptors(config);
|
|
122
|
+
}
|
|
90
123
|
function resolveSandboxedPath(toolYamlPath, sandboxedPath) {
|
|
91
124
|
const configDir = dirname(resolve(toolYamlPath));
|
|
92
125
|
return resolveConfigPath(sandboxedPath, configDir, {
|
|
93
126
|
expandHome: true
|
|
94
127
|
});
|
|
95
128
|
}
|
|
129
|
+
function resolveCacheDir(toolYamlPath, cacheDir) {
|
|
130
|
+
const configDir = dirname(resolve(toolYamlPath));
|
|
131
|
+
return resolveConfigPath(cacheDir, configDir, {
|
|
132
|
+
expandHome: true
|
|
133
|
+
});
|
|
134
|
+
}
|
|
96
135
|
var CACHE_SUBDIR = ".agent/cache";
|
|
97
136
|
function getCacheBaseFromToolConfig(toolYamlPath) {
|
|
98
137
|
const config = loadToolConfig(toolYamlPath);
|
|
138
|
+
if (config.cacheDir && typeof config.cacheDir === "string") {
|
|
139
|
+
return resolveCacheDir(toolYamlPath, config.cacheDir);
|
|
140
|
+
}
|
|
99
141
|
if (!config.sandboxedPath || typeof config.sandboxedPath !== "string") return void 0;
|
|
100
142
|
const sandboxRoot = resolveSandboxedPath(toolYamlPath, config.sandboxedPath);
|
|
101
143
|
return join(sandboxRoot, CACHE_SUBDIR);
|
|
@@ -1170,14 +1212,19 @@ var Tracing = class {
|
|
|
1170
1212
|
function resolveTool(toolName, registry) {
|
|
1171
1213
|
const key = normalizeToolName(toolName);
|
|
1172
1214
|
const spec = registry.get(key);
|
|
1173
|
-
if (
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
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
|
+
);
|
|
1181
1228
|
}
|
|
1182
1229
|
var INPUT_ALIASES = {
|
|
1183
1230
|
q: "query"
|
|
@@ -1802,7 +1849,7 @@ function packagePathSegments(name) {
|
|
|
1802
1849
|
const withoutScope = name.replace(/^@/, "");
|
|
1803
1850
|
return withoutScope.split("/").filter(Boolean);
|
|
1804
1851
|
}
|
|
1805
|
-
function
|
|
1852
|
+
function resolveCacheDir2(cacheBase, packageName, version) {
|
|
1806
1853
|
const segments = packagePathSegments(packageName);
|
|
1807
1854
|
return join(cacheBase, ...segments, version);
|
|
1808
1855
|
}
|
|
@@ -1810,7 +1857,7 @@ function ensurePackageInCache(packageName, version = "latest", options = {}) {
|
|
|
1810
1857
|
const cacheBase = options.cacheBase ?? DEFAULT_CACHE_BASE;
|
|
1811
1858
|
const cwd = options.cwd ?? process.cwd();
|
|
1812
1859
|
const resolvedVersion = isLatestRequest(version) ? resolveLatestVersionFromRegistry(packageName, { cwd }) : version;
|
|
1813
|
-
const cacheDir =
|
|
1860
|
+
const cacheDir = resolveCacheDir2(cacheBase, packageName, resolvedVersion);
|
|
1814
1861
|
const packageJsonPath = join(cacheDir, "package.json");
|
|
1815
1862
|
const nodeModulesPath = join(cacheDir, "node_modules");
|
|
1816
1863
|
if (existsSync(packageJsonPath) && existsSync(nodeModulesPath)) {
|
|
@@ -2055,9 +2102,11 @@ function parseNpmDescriptor(entry) {
|
|
|
2055
2102
|
return { packageName, version };
|
|
2056
2103
|
}
|
|
2057
2104
|
|
|
2105
|
+
// src/api/runtimeFromConfig.types.ts
|
|
2106
|
+
var DEFAULT_EXTENSION_PACKAGES = [];
|
|
2107
|
+
|
|
2058
2108
|
// src/api/runtimeFromConfig.ts
|
|
2059
2109
|
var requireFromPackage2 = createRequire(import.meta.url);
|
|
2060
|
-
var DEFAULT_EXTENSION_PACKAGES = [];
|
|
2061
2110
|
function resolveEffectiveCoreTools(options) {
|
|
2062
2111
|
if (options.coreTools) return options.coreTools;
|
|
2063
2112
|
if (options.configFilePath) return {};
|
|
@@ -2191,7 +2240,7 @@ function loadAllExtensionsFromToolYamlSync(configFilePath, stepLog) {
|
|
|
2191
2240
|
const localPath = isAbsolute(configFilePath) ? configFilePath : resolve(process.cwd(), configFilePath);
|
|
2192
2241
|
if (!existsSync(localPath)) return [];
|
|
2193
2242
|
const config = loadToolConfig(localPath);
|
|
2194
|
-
const tools =
|
|
2243
|
+
const tools = getPathSourceDescriptors(config);
|
|
2195
2244
|
if (!Array.isArray(tools) || tools.length === 0) return [];
|
|
2196
2245
|
if (stepLog) stepLog("Loading extensions from tool.yaml (npm + file)");
|
|
2197
2246
|
const loaded = [];
|
|
@@ -2294,7 +2343,7 @@ async function loadAllExtensionsFromToolYamlAsync(configFilePath, stepLog) {
|
|
|
2294
2343
|
const localPath = isAbsolute(configFilePath) ? configFilePath : resolve(process.cwd(), configFilePath);
|
|
2295
2344
|
if (!existsSync(localPath)) return [];
|
|
2296
2345
|
const config = loadToolConfig(localPath);
|
|
2297
|
-
const tools =
|
|
2346
|
+
const tools = getPathSourceDescriptors(config);
|
|
2298
2347
|
if (!Array.isArray(tools) || tools.length === 0) return [];
|
|
2299
2348
|
if (stepLog) stepLog("Loading extensions from tool.yaml (async)");
|
|
2300
2349
|
const loaded = [];
|
|
@@ -2956,6 +3005,6 @@ async function createHttpService(runtimeOrConfig, options = {}) {
|
|
|
2956
3005
|
};
|
|
2957
3006
|
}
|
|
2958
3007
|
|
|
2959
|
-
export { createHttpService, createMCPServerStreamableHttp, createRuntimeFromConfig, expandToolDescriptorsToRegistryNames, fileDescriptorToPackagePrefix, findAndLoadToolConfig, getDisplayScope, getToolSourceDescriptors, isBarePackageDescriptor, loadToolConfig, npmDescriptorToPackagePrefix, resolveSandboxedPath, resolveToolDescriptor, runMCPServerOverStdio, toToolObservationText };
|
|
2960
|
-
//# sourceMappingURL=chunk-
|
|
2961
|
-
//# 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
|