@easynet/agent-tool 1.0.103 → 1.0.105
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/expose/openapiHttp.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-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-KTPQDVP6.cjs → chunk-MQXOFUSU.cjs} +117 -59
- package/dist/chunk-MQXOFUSU.cjs.map +1 -0
- package/dist/{chunk-3C4VJ4DI.js → chunk-OZUNZILF.js} +109 -57
- package/dist/chunk-OZUNZILF.js.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 +17 -17
- 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,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');
|
|
@@ -52,14 +52,25 @@ function normalizeToolSources(raw) {
|
|
|
52
52
|
const out = {};
|
|
53
53
|
const customized = source.customized;
|
|
54
54
|
if (customized && typeof customized === "object" && !Array.isArray(customized)) {
|
|
55
|
-
|
|
56
|
-
|
|
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 {
|
|
57
68
|
const toolMap = {};
|
|
58
|
-
for (const [toolName, toolValue] of Object.entries(
|
|
69
|
+
for (const [toolName, toolValue] of Object.entries(customizedSource)) {
|
|
59
70
|
if (!toolValue || typeof toolValue !== "object" || Array.isArray(toolValue)) continue;
|
|
60
71
|
toolMap[toolName] = toolValue;
|
|
61
72
|
}
|
|
62
|
-
out
|
|
73
|
+
if (Object.keys(toolMap).length > 0) out.self = toolMap;
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
76
|
for (const [sourceKey, sourceValue] of Object.entries(source)) {
|
|
@@ -74,6 +85,19 @@ function normalizeToolSources(raw) {
|
|
|
74
85
|
}
|
|
75
86
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
76
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
|
+
}
|
|
77
101
|
function loadToolConfig(toolYamlPath) {
|
|
78
102
|
const abs = path.resolve(toolYamlPath);
|
|
79
103
|
const raw = fs.readFileSync(abs, "utf8");
|
|
@@ -84,6 +108,10 @@ function loadToolConfig(toolYamlPath) {
|
|
|
84
108
|
const source = parsed.spec && typeof parsed.spec === "object" && !Array.isArray(parsed.spec) ? parsed.spec : parsed;
|
|
85
109
|
return {
|
|
86
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),
|
|
87
115
|
enableSandboxValidation: typeof source.enableSandboxValidation === "boolean" ? source.enableSandboxValidation : void 0,
|
|
88
116
|
allowedHosts: Array.isArray(source.allowedHosts) ? source.allowedHosts : void 0,
|
|
89
117
|
blockedHosts: Array.isArray(source.blockedHosts) ? source.blockedHosts : void 0,
|
|
@@ -97,15 +125,29 @@ function getToolSourceDescriptors(config, options) {
|
|
|
97
125
|
const includeSelf = options?.includeSelf ?? false;
|
|
98
126
|
return Object.keys(config.tools ?? {}).filter((key) => includeSelf || key !== "self");
|
|
99
127
|
}
|
|
128
|
+
function getPathSourceDescriptors(config) {
|
|
129
|
+
const fromPaths = Object.keys(config.paths ?? {});
|
|
130
|
+
if (fromPaths.length > 0) return fromPaths;
|
|
131
|
+
return getToolSourceDescriptors(config);
|
|
132
|
+
}
|
|
100
133
|
function resolveSandboxedPath(toolYamlPath, sandboxedPath) {
|
|
101
134
|
const configDir = path.dirname(path.resolve(toolYamlPath));
|
|
102
135
|
return config.resolveConfigPath(sandboxedPath, configDir, {
|
|
103
136
|
expandHome: true
|
|
104
137
|
});
|
|
105
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
|
+
}
|
|
106
145
|
var CACHE_SUBDIR = ".agent/cache";
|
|
107
146
|
function getCacheBaseFromToolConfig(toolYamlPath) {
|
|
108
147
|
const config = loadToolConfig(toolYamlPath);
|
|
148
|
+
if (config.cacheDir && typeof config.cacheDir === "string") {
|
|
149
|
+
return resolveCacheDir(toolYamlPath, config.cacheDir);
|
|
150
|
+
}
|
|
109
151
|
if (!config.sandboxedPath || typeof config.sandboxedPath !== "string") return void 0;
|
|
110
152
|
const sandboxRoot = resolveSandboxedPath(toolYamlPath, config.sandboxedPath);
|
|
111
153
|
return path.join(sandboxRoot, CACHE_SUBDIR);
|
|
@@ -1180,14 +1222,19 @@ var Tracing = class {
|
|
|
1180
1222
|
function resolveTool(toolName, registry) {
|
|
1181
1223
|
const key = chunkJW4EMVTE_cjs.normalizeToolName(toolName);
|
|
1182
1224
|
const spec = registry.get(key);
|
|
1183
|
-
if (
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
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
|
+
);
|
|
1191
1238
|
}
|
|
1192
1239
|
var INPUT_ALIASES = {
|
|
1193
1240
|
q: "query"
|
|
@@ -1812,7 +1859,7 @@ function packagePathSegments(name) {
|
|
|
1812
1859
|
const withoutScope = name.replace(/^@/, "");
|
|
1813
1860
|
return withoutScope.split("/").filter(Boolean);
|
|
1814
1861
|
}
|
|
1815
|
-
function
|
|
1862
|
+
function resolveCacheDir2(cacheBase, packageName, version) {
|
|
1816
1863
|
const segments = packagePathSegments(packageName);
|
|
1817
1864
|
return path.join(cacheBase, ...segments, version);
|
|
1818
1865
|
}
|
|
@@ -1820,7 +1867,7 @@ function ensurePackageInCache(packageName, version = "latest", options = {}) {
|
|
|
1820
1867
|
const cacheBase = options.cacheBase ?? DEFAULT_CACHE_BASE;
|
|
1821
1868
|
const cwd = options.cwd ?? process.cwd();
|
|
1822
1869
|
const resolvedVersion = isLatestRequest(version) ? resolveLatestVersionFromRegistry(packageName, { cwd }) : version;
|
|
1823
|
-
const cacheDir =
|
|
1870
|
+
const cacheDir = resolveCacheDir2(cacheBase, packageName, resolvedVersion);
|
|
1824
1871
|
const packageJsonPath = path.join(cacheDir, "package.json");
|
|
1825
1872
|
const nodeModulesPath = path.join(cacheDir, "node_modules");
|
|
1826
1873
|
if (fs.existsSync(packageJsonPath) && fs.existsSync(nodeModulesPath)) {
|
|
@@ -1900,7 +1947,7 @@ async function importFromCache(packageRoot) {
|
|
|
1900
1947
|
fileUrl
|
|
1901
1948
|
);
|
|
1902
1949
|
}
|
|
1903
|
-
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-MQXOFUSU.cjs', document.baseURI).href)));
|
|
1904
1951
|
function getProjectRequire() {
|
|
1905
1952
|
const cwd = process.cwd();
|
|
1906
1953
|
if (fs.existsSync(path.join(cwd, "package.json"))) return module$1.createRequire(path.join(cwd, "package.json"));
|
|
@@ -2065,9 +2112,11 @@ function parseNpmDescriptor(entry) {
|
|
|
2065
2112
|
return { packageName, version };
|
|
2066
2113
|
}
|
|
2067
2114
|
|
|
2068
|
-
// src/api/runtimeFromConfig.ts
|
|
2069
|
-
var requireFromPackage2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-KTPQDVP6.cjs', document.baseURI).href)));
|
|
2115
|
+
// src/api/runtimeFromConfig.types.ts
|
|
2070
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-MQXOFUSU.cjs', document.baseURI).href)));
|
|
2071
2120
|
function resolveEffectiveCoreTools(options) {
|
|
2072
2121
|
if (options.coreTools) return options.coreTools;
|
|
2073
2122
|
if (options.configFilePath) return {};
|
|
@@ -2201,7 +2250,7 @@ function loadAllExtensionsFromToolYamlSync(configFilePath, stepLog) {
|
|
|
2201
2250
|
const localPath = path.isAbsolute(configFilePath) ? configFilePath : path.resolve(process.cwd(), configFilePath);
|
|
2202
2251
|
if (!fs.existsSync(localPath)) return [];
|
|
2203
2252
|
const config = loadToolConfig(localPath);
|
|
2204
|
-
const tools =
|
|
2253
|
+
const tools = getPathSourceDescriptors(config);
|
|
2205
2254
|
if (!Array.isArray(tools) || tools.length === 0) return [];
|
|
2206
2255
|
if (stepLog) stepLog("Loading extensions from tool.yaml (npm + file)");
|
|
2207
2256
|
const loaded = [];
|
|
@@ -2282,7 +2331,7 @@ async function loadLocalDirectoryForFileDescriptor(descriptor, configFilePath, s
|
|
|
2282
2331
|
if (!resolvedPath || !fs.existsSync(resolvedPath) || !fs.statSync(resolvedPath).isDirectory()) return null;
|
|
2283
2332
|
if (fs.existsSync(path.join(resolvedPath, "package.json"))) return null;
|
|
2284
2333
|
const scanErrors = [];
|
|
2285
|
-
const scanner = new
|
|
2334
|
+
const scanner = new chunk45MCEW2Y_cjs.DirectoryScanner({
|
|
2286
2335
|
roots: [{ path: resolvedPath, namespace: "local" }],
|
|
2287
2336
|
onError: (toolDir, error) => scanErrors.push(`${toolDir}: ${error.message}`)
|
|
2288
2337
|
});
|
|
@@ -2304,7 +2353,7 @@ async function loadAllExtensionsFromToolYamlAsync(configFilePath, stepLog) {
|
|
|
2304
2353
|
const localPath = path.isAbsolute(configFilePath) ? configFilePath : path.resolve(process.cwd(), configFilePath);
|
|
2305
2354
|
if (!fs.existsSync(localPath)) return [];
|
|
2306
2355
|
const config = loadToolConfig(localPath);
|
|
2307
|
-
const tools =
|
|
2356
|
+
const tools = getPathSourceDescriptors(config);
|
|
2308
2357
|
if (!Array.isArray(tools) || tools.length === 0) return [];
|
|
2309
2358
|
if (stepLog) stepLog("Loading extensions from tool.yaml (async)");
|
|
2310
2359
|
const loaded = [];
|
|
@@ -2490,7 +2539,7 @@ async function createMcpServerWithTools(runtime, options) {
|
|
|
2490
2539
|
async (args) => {
|
|
2491
2540
|
const ctx = ctxFactory();
|
|
2492
2541
|
const result = await runtime.invoke(
|
|
2493
|
-
{ tool: spec.name, args: args ?? {}, purpose:
|
|
2542
|
+
{ tool: spec.name, args: args ?? {}, purpose: chunk45MCEW2Y_cjs.MCP_KIND },
|
|
2494
2543
|
ctx
|
|
2495
2544
|
);
|
|
2496
2545
|
if (result.ok) {
|
|
@@ -2826,42 +2875,27 @@ async function invokeAndSend(runtime, ctx, res, tool, args) {
|
|
|
2826
2875
|
details: result.error?.details
|
|
2827
2876
|
});
|
|
2828
2877
|
}
|
|
2829
|
-
function
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
app.use(express__default.default.text({ type: "*/*" }));
|
|
2835
|
-
router.get("/", (_req, res) => {
|
|
2836
|
-
const specPath = basePath ? `${basePath}/openapi.json` : "/openapi.json";
|
|
2837
|
-
res.type("text/html; charset=utf-8").send(swaggerUiHtml(specPath));
|
|
2878
|
+
function buildSpec(runtime, basePath) {
|
|
2879
|
+
return toolsToOpenAPISpec(runtime.getRegistry(), {
|
|
2880
|
+
title: "Tool API",
|
|
2881
|
+
version: "1.0.0",
|
|
2882
|
+
basePath: basePath || void 0
|
|
2838
2883
|
});
|
|
2839
|
-
|
|
2884
|
+
}
|
|
2885
|
+
function registerSpecRoutes(router, runtime, basePath) {
|
|
2886
|
+
const sendSpec = (_req, res) => {
|
|
2887
|
+
sendJson(res, 200, buildSpec(runtime, basePath));
|
|
2888
|
+
};
|
|
2889
|
+
const sendSwagger = (_req, res) => {
|
|
2840
2890
|
const specPath = basePath ? `${basePath}/openapi.json` : "/openapi.json";
|
|
2841
2891
|
res.type("text/html; charset=utf-8").send(swaggerUiHtml(specPath));
|
|
2842
|
-
}
|
|
2843
|
-
router.get("/
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
version: "1.0.0",
|
|
2850
|
-
basePath: basePath || void 0
|
|
2851
|
-
})
|
|
2852
|
-
);
|
|
2853
|
-
});
|
|
2854
|
-
router.get("/spec", (_req, res) => {
|
|
2855
|
-
sendJson(
|
|
2856
|
-
res,
|
|
2857
|
-
200,
|
|
2858
|
-
toolsToOpenAPISpec(runtime.getRegistry(), {
|
|
2859
|
-
title: "Tool API",
|
|
2860
|
-
version: "1.0.0",
|
|
2861
|
-
basePath: basePath || void 0
|
|
2862
|
-
})
|
|
2863
|
-
);
|
|
2864
|
-
});
|
|
2892
|
+
};
|
|
2893
|
+
router.get("/", sendSwagger);
|
|
2894
|
+
router.get("/swagger", sendSwagger);
|
|
2895
|
+
router.get("/openapi.json", sendSpec);
|
|
2896
|
+
router.get("/spec", sendSpec);
|
|
2897
|
+
}
|
|
2898
|
+
function registerToolRoutes(router, runtime, ctxFactory) {
|
|
2865
2899
|
router.get("/tools", async (_req, res, next) => {
|
|
2866
2900
|
try {
|
|
2867
2901
|
const { enrichSpecWithCanonicalSchema: enrichSpecWithCanonicalSchema2 } = await import('./canonicalCoreSchemas-TY7NCWCC.cjs');
|
|
@@ -2901,11 +2935,15 @@ function createOpenAPIHttpServer(runtime, options = {}) {
|
|
|
2901
2935
|
}
|
|
2902
2936
|
await invokeAndSend(runtime, ctxFactory(req), res, slugToToolName(req.params?.slug ?? ""), args);
|
|
2903
2937
|
});
|
|
2938
|
+
}
|
|
2939
|
+
function mountRouter(app, router, basePath) {
|
|
2904
2940
|
if (basePath) {
|
|
2905
2941
|
app.use(basePath, router);
|
|
2906
|
-
|
|
2907
|
-
app.use(router);
|
|
2942
|
+
return;
|
|
2908
2943
|
}
|
|
2944
|
+
app.use(router);
|
|
2945
|
+
}
|
|
2946
|
+
function registerErrorHandlers(app) {
|
|
2909
2947
|
app.use((req, res) => {
|
|
2910
2948
|
sendJson(res, 404, { error: "Not found", path: req.url ?? "/" });
|
|
2911
2949
|
});
|
|
@@ -2913,6 +2951,8 @@ function createOpenAPIHttpServer(runtime, options = {}) {
|
|
|
2913
2951
|
const message = err instanceof Error ? err.message : String(err);
|
|
2914
2952
|
sendJson(res, 500, { error: message, kind: "INTERNAL_ERROR" });
|
|
2915
2953
|
});
|
|
2954
|
+
}
|
|
2955
|
+
function patchListenDefaults(app, options) {
|
|
2916
2956
|
const originalListen = app.listen.bind(app);
|
|
2917
2957
|
const defaultPort = options.port;
|
|
2918
2958
|
const defaultHost = options.host;
|
|
@@ -2925,6 +2965,18 @@ function createOpenAPIHttpServer(runtime, options = {}) {
|
|
|
2925
2965
|
}
|
|
2926
2966
|
return originalListen(...args);
|
|
2927
2967
|
});
|
|
2968
|
+
}
|
|
2969
|
+
function createOpenAPIHttpServer(runtime, options = {}) {
|
|
2970
|
+
const app = express__default.default();
|
|
2971
|
+
const router = express__default.default.Router();
|
|
2972
|
+
const basePath = (options.basePath ?? "").replace(/\/$/, "");
|
|
2973
|
+
const ctxFactory = options.execContextFactory ?? (() => ({ ...DEFAULT_CTX2 }));
|
|
2974
|
+
app.use(express__default.default.text({ type: "*/*" }));
|
|
2975
|
+
registerSpecRoutes(router, runtime, basePath);
|
|
2976
|
+
registerToolRoutes(router, runtime, ctxFactory);
|
|
2977
|
+
mountRouter(app, router, basePath);
|
|
2978
|
+
registerErrorHandlers(app);
|
|
2979
|
+
patchListenDefaults(app, options);
|
|
2928
2980
|
return app;
|
|
2929
2981
|
}
|
|
2930
2982
|
function listenOpenAPIHttpServer(app, options = {}) {
|
|
@@ -2969,17 +3021,23 @@ async function createHttpService(runtimeOrConfig, options = {}) {
|
|
|
2969
3021
|
exports.createHttpService = createHttpService;
|
|
2970
3022
|
exports.createMCPServerStreamableHttp = createMCPServerStreamableHttp;
|
|
2971
3023
|
exports.createRuntimeFromConfig = createRuntimeFromConfig;
|
|
3024
|
+
exports.ensurePackageInCache = ensurePackageInCache;
|
|
2972
3025
|
exports.expandToolDescriptorsToRegistryNames = expandToolDescriptorsToRegistryNames;
|
|
2973
3026
|
exports.fileDescriptorToPackagePrefix = fileDescriptorToPackagePrefix;
|
|
2974
3027
|
exports.findAndLoadToolConfig = findAndLoadToolConfig;
|
|
3028
|
+
exports.getCacheBaseFromToolConfig = getCacheBaseFromToolConfig;
|
|
2975
3029
|
exports.getDisplayScope = getDisplayScope;
|
|
3030
|
+
exports.getPathSourceDescriptors = getPathSourceDescriptors;
|
|
2976
3031
|
exports.getToolSourceDescriptors = getToolSourceDescriptors;
|
|
2977
3032
|
exports.isBarePackageDescriptor = isBarePackageDescriptor;
|
|
2978
3033
|
exports.loadToolConfig = loadToolConfig;
|
|
2979
3034
|
exports.npmDescriptorToPackagePrefix = npmDescriptorToPackagePrefix;
|
|
3035
|
+
exports.parseNpmDescriptor = parseNpmDescriptor;
|
|
3036
|
+
exports.parseToolPath = parseToolPath;
|
|
3037
|
+
exports.resolveLatestVersionFromRegistry = resolveLatestVersionFromRegistry;
|
|
2980
3038
|
exports.resolveSandboxedPath = resolveSandboxedPath;
|
|
2981
3039
|
exports.resolveToolDescriptor = resolveToolDescriptor;
|
|
2982
3040
|
exports.runMCPServerOverStdio = runMCPServerOverStdio;
|
|
2983
3041
|
exports.toToolObservationText = toToolObservationText;
|
|
2984
|
-
//# sourceMappingURL=chunk-
|
|
2985
|
-
//# sourceMappingURL=chunk-
|
|
3042
|
+
//# sourceMappingURL=chunk-MQXOFUSU.cjs.map
|
|
3043
|
+
//# sourceMappingURL=chunk-MQXOFUSU.cjs.map
|