@easynet/agent-tool 1.0.97 → 1.0.98

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.
@@ -36,6 +36,20 @@ function normalizeOpenApiConfig(raw) {
36
36
  if (typeof source.port === "number" && Number.isFinite(source.port)) out.port = source.port;
37
37
  return Object.keys(out).length > 0 ? out : void 0;
38
38
  }
39
+ function normalizeToolSources(raw) {
40
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
41
+ const out = {};
42
+ for (const [sourceKey, sourceValue] of Object.entries(raw)) {
43
+ if (!sourceValue || typeof sourceValue !== "object" || Array.isArray(sourceValue)) continue;
44
+ const toolMap = {};
45
+ for (const [toolName, toolValue] of Object.entries(sourceValue)) {
46
+ if (!toolValue || typeof toolValue !== "object" || Array.isArray(toolValue)) continue;
47
+ toolMap[toolName] = toolValue;
48
+ }
49
+ out[sourceKey] = toolMap;
50
+ }
51
+ return Object.keys(out).length > 0 ? out : void 0;
52
+ }
39
53
  function loadToolConfig(toolYamlPath) {
40
54
  const abs = resolve(toolYamlPath);
41
55
  const raw = readFileSync(abs, "utf8");
@@ -44,41 +58,21 @@ function loadToolConfig(toolYamlPath) {
44
58
  });
45
59
  if (!parsed || typeof parsed !== "object") return {};
46
60
  const source = parsed.spec && typeof parsed.spec === "object" && !Array.isArray(parsed.spec) ? parsed.spec : parsed;
47
- const mcpConfig = normalizeMcpConfig(source.expose?.mcp ?? source.mcp);
48
- const openApiConfig = normalizeOpenApiConfig(source.expose?.openapi ?? source.openapi);
49
- const toolsBlock = source.tools;
50
- if (toolsBlock != null && typeof toolsBlock === "object" && !Array.isArray(toolsBlock)) {
51
- const toolDefaults = toolsBlock.defaults != null && typeof toolsBlock.defaults === "object" && !Array.isArray(toolsBlock.defaults) ? toolsBlock.defaults : void 0;
52
- const packageToolDefaults2 = toolsBlock.packages != null && typeof toolsBlock.packages === "object" && !Array.isArray(toolsBlock.packages) ? toolsBlock.packages : void 0;
53
- const list2 = Array.isArray(toolsBlock.list) && toolsBlock.list.length > 0 ? toolsBlock.list : void 0;
54
- return {
55
- tools: list2 ?? (packageToolDefaults2 ? Object.keys(packageToolDefaults2) : void 0),
56
- sandboxedPath: typeof toolsBlock.sandboxedPath === "string" ? toolsBlock.sandboxedPath : source.sandboxedPath,
57
- enableSandboxValidation: typeof toolsBlock.enableSandboxValidation === "boolean" ? toolsBlock.enableSandboxValidation : source.enableSandboxValidation,
58
- allowedHosts: Array.isArray(toolsBlock.allowedHosts) ? toolsBlock.allowedHosts : source.allowedHosts,
59
- blockedHosts: Array.isArray(toolsBlock.blockedHosts) ? toolsBlock.blockedHosts : source.blockedHosts,
60
- blockedCidrs: Array.isArray(toolsBlock.blockedCidrs) ? toolsBlock.blockedCidrs : source.blockedCidrs,
61
- toolDefaults,
62
- packageToolDefaults: packageToolDefaults2,
63
- mcp: mcpConfig,
64
- openapi: openApiConfig
65
- };
66
- }
67
- const packageToolDefaults = typeof source.packageToolDefaults === "object" && !Array.isArray(source.packageToolDefaults) ? source.packageToolDefaults : void 0;
68
- const list = Array.isArray(source.tools) && source.tools.length > 0 ? source.tools : void 0;
69
61
  return {
70
- tools: list ?? (packageToolDefaults ? Object.keys(packageToolDefaults) : void 0),
71
- sandboxedPath: source.sandboxedPath,
62
+ sandboxedPath: typeof source.sandboxedPath === "string" ? source.sandboxedPath : void 0,
72
63
  enableSandboxValidation: typeof source.enableSandboxValidation === "boolean" ? source.enableSandboxValidation : void 0,
73
64
  allowedHosts: Array.isArray(source.allowedHosts) ? source.allowedHosts : void 0,
74
65
  blockedHosts: Array.isArray(source.blockedHosts) ? source.blockedHosts : void 0,
75
66
  blockedCidrs: Array.isArray(source.blockedCidrs) ? source.blockedCidrs : void 0,
76
- toolDefaults: typeof source.toolDefaults === "object" && !Array.isArray(source.toolDefaults) ? source.toolDefaults : void 0,
77
- packageToolDefaults,
78
- mcp: mcpConfig,
79
- openapi: openApiConfig
67
+ tools: normalizeToolSources(source.tools),
68
+ mcp: normalizeMcpConfig(source.expose?.mcp ?? source.mcp),
69
+ openapi: normalizeOpenApiConfig(source.expose?.openapi ?? source.openapi)
80
70
  };
81
71
  }
72
+ function getToolSourceDescriptors(config, options) {
73
+ const includeSelf = options?.includeSelf ?? false;
74
+ return Object.keys(config.tools ?? {}).filter((key) => includeSelf || key !== "self");
75
+ }
82
76
  function resolveSandboxedPath(toolYamlPath, sandboxedPath) {
83
77
  const configDir = dirname(resolve(toolYamlPath));
84
78
  return resolveConfigPath(sandboxedPath, configDir, {
@@ -172,23 +166,6 @@ function npmDescriptorToPackagePrefix(descriptor) {
172
166
  if (!normalized) return "";
173
167
  return "npm." + normalized;
174
168
  }
175
- function npmDescriptorToPackagePrefixWithVersion(descriptor) {
176
- const s = descriptor.trim();
177
- if (typeof s !== "string" || !s.startsWith("npm:")) return "";
178
- const rest = s.slice(4).trim();
179
- const hashIdx = rest.indexOf("#");
180
- const beforeHash = hashIdx < 0 ? rest : rest.slice(0, hashIdx);
181
- const lastAt = beforeHash.lastIndexOf("@");
182
- const scopeAndPackage = lastAt <= 0 ? beforeHash : beforeHash.slice(0, lastAt);
183
- const version = lastAt <= 0 ? "" : beforeHash.slice(lastAt + 1).trim();
184
- const slashIdx = scopeAndPackage.indexOf("/");
185
- const scope = slashIdx < 0 ? scopeAndPackage : scopeAndPackage.slice(0, slashIdx).replace(/^@/, "");
186
- const pkg = slashIdx < 0 ? "" : scopeAndPackage.slice(slashIdx + 1);
187
- const segment = [scope, pkg, version].filter(Boolean).join(".");
188
- const normalized = normalizeToolName(segment);
189
- if (!normalized) return "";
190
- return "npm." + normalized;
191
- }
192
169
  function getDisplayScope(registryName, _kind, _toolVersion) {
193
170
  const i = registryName.indexOf(".");
194
171
  return i < 0 ? registryName : registryName.slice(0, i);
@@ -2168,7 +2145,7 @@ function loadAllExtensionsFromToolYamlSync(configFilePath, stepLog) {
2168
2145
  const localPath = isAbsolute(configFilePath) ? configFilePath : resolve(process.cwd(), configFilePath);
2169
2146
  if (!existsSync(localPath)) return [];
2170
2147
  const config = loadToolConfig(localPath);
2171
- const tools = config.tools;
2148
+ const tools = getToolSourceDescriptors(config);
2172
2149
  if (!Array.isArray(tools) || tools.length === 0) return [];
2173
2150
  if (stepLog) stepLog("Loading extensions from tool.yaml (npm + file)");
2174
2151
  const loaded = [];
@@ -2271,7 +2248,7 @@ async function loadAllExtensionsFromToolYamlAsync(configFilePath, stepLog) {
2271
2248
  const localPath = isAbsolute(configFilePath) ? configFilePath : resolve(process.cwd(), configFilePath);
2272
2249
  if (!existsSync(localPath)) return [];
2273
2250
  const config = loadToolConfig(localPath);
2274
- const tools = config.tools;
2251
+ const tools = getToolSourceDescriptors(config);
2275
2252
  if (!Array.isArray(tools) || tools.length === 0) return [];
2276
2253
  if (stepLog) stepLog("Loading extensions from tool.yaml (async)");
2277
2254
  const loaded = [];
@@ -2931,6 +2908,6 @@ async function createHttpService(runtimeOrConfig, options = {}) {
2931
2908
  };
2932
2909
  }
2933
2910
 
2934
- export { createHttpService, createMCPServerStreamableHttp, createRuntimeFromConfig, createRuntimeFromConfigSync, expandToolDescriptorsToRegistryNames, fileDescriptorToPackagePrefix, findAndLoadToolConfig, getDisplayScope, isBarePackageDescriptor, loadAllExtensionsFromToolYamlSync, loadToolConfig, npmDescriptorToPackagePrefixWithVersion, resolveSandboxedPath, resolveToolDescriptor, runMCPServerOverStdio, toToolObservationText };
2935
- //# sourceMappingURL=chunk-WCMZLN3F.js.map
2936
- //# sourceMappingURL=chunk-WCMZLN3F.js.map
2911
+ export { createHttpService, createMCPServerStreamableHttp, createRuntimeFromConfig, createRuntimeFromConfigSync, expandToolDescriptorsToRegistryNames, fileDescriptorToPackagePrefix, findAndLoadToolConfig, getDisplayScope, getToolSourceDescriptors, isBarePackageDescriptor, loadAllExtensionsFromToolYamlSync, loadToolConfig, npmDescriptorToPackagePrefix, resolveSandboxedPath, resolveToolDescriptor, runMCPServerOverStdio, toToolObservationText };
2912
+ //# sourceMappingURL=chunk-ODML7BYU.js.map
2913
+ //# sourceMappingURL=chunk-ODML7BYU.js.map