@easynet/agent-tool 1.0.104 → 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/dist/api/expose/openapiHttp.d.ts.map +1 -1
- package/dist/{chunk-2THI5UWA.cjs → chunk-MQXOFUSU.cjs} +42 -39
- package/dist/chunk-MQXOFUSU.cjs.map +1 -0
- package/dist/{chunk-2MSEJB6X.js → chunk-OZUNZILF.js} +40 -37
- package/dist/chunk-OZUNZILF.js.map +1 -0
- package/dist/index.cjs +17 -17
- package/dist/index.js +1 -1
- package/dist/utils/cli/index.cjs +14 -14
- package/dist/utils/cli/index.js +1 -1
- package/package.json +14 -14
- package/dist/chunk-2MSEJB6X.js.map +0 -1
- package/dist/chunk-2THI5UWA.cjs.map +0 -1
|
@@ -2865,42 +2865,27 @@ async function invokeAndSend(runtime, ctx, res, tool, args) {
|
|
|
2865
2865
|
details: result.error?.details
|
|
2866
2866
|
});
|
|
2867
2867
|
}
|
|
2868
|
-
function
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
app.use(express.text({ type: "*/*" }));
|
|
2874
|
-
router.get("/", (_req, res) => {
|
|
2875
|
-
const specPath = basePath ? `${basePath}/openapi.json` : "/openapi.json";
|
|
2876
|
-
res.type("text/html; charset=utf-8").send(swaggerUiHtml(specPath));
|
|
2868
|
+
function buildSpec(runtime, basePath) {
|
|
2869
|
+
return toolsToOpenAPISpec(runtime.getRegistry(), {
|
|
2870
|
+
title: "Tool API",
|
|
2871
|
+
version: "1.0.0",
|
|
2872
|
+
basePath: basePath || void 0
|
|
2877
2873
|
});
|
|
2878
|
-
|
|
2874
|
+
}
|
|
2875
|
+
function registerSpecRoutes(router, runtime, basePath) {
|
|
2876
|
+
const sendSpec = (_req, res) => {
|
|
2877
|
+
sendJson(res, 200, buildSpec(runtime, basePath));
|
|
2878
|
+
};
|
|
2879
|
+
const sendSwagger = (_req, res) => {
|
|
2879
2880
|
const specPath = basePath ? `${basePath}/openapi.json` : "/openapi.json";
|
|
2880
2881
|
res.type("text/html; charset=utf-8").send(swaggerUiHtml(specPath));
|
|
2881
|
-
}
|
|
2882
|
-
router.get("/
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
version: "1.0.0",
|
|
2889
|
-
basePath: basePath || void 0
|
|
2890
|
-
})
|
|
2891
|
-
);
|
|
2892
|
-
});
|
|
2893
|
-
router.get("/spec", (_req, res) => {
|
|
2894
|
-
sendJson(
|
|
2895
|
-
res,
|
|
2896
|
-
200,
|
|
2897
|
-
toolsToOpenAPISpec(runtime.getRegistry(), {
|
|
2898
|
-
title: "Tool API",
|
|
2899
|
-
version: "1.0.0",
|
|
2900
|
-
basePath: basePath || void 0
|
|
2901
|
-
})
|
|
2902
|
-
);
|
|
2903
|
-
});
|
|
2882
|
+
};
|
|
2883
|
+
router.get("/", sendSwagger);
|
|
2884
|
+
router.get("/swagger", sendSwagger);
|
|
2885
|
+
router.get("/openapi.json", sendSpec);
|
|
2886
|
+
router.get("/spec", sendSpec);
|
|
2887
|
+
}
|
|
2888
|
+
function registerToolRoutes(router, runtime, ctxFactory) {
|
|
2904
2889
|
router.get("/tools", async (_req, res, next) => {
|
|
2905
2890
|
try {
|
|
2906
2891
|
const { enrichSpecWithCanonicalSchema: enrichSpecWithCanonicalSchema2 } = await import('./canonicalCoreSchemas-PHGTNPN5.js');
|
|
@@ -2940,11 +2925,15 @@ function createOpenAPIHttpServer(runtime, options = {}) {
|
|
|
2940
2925
|
}
|
|
2941
2926
|
await invokeAndSend(runtime, ctxFactory(req), res, slugToToolName(req.params?.slug ?? ""), args);
|
|
2942
2927
|
});
|
|
2928
|
+
}
|
|
2929
|
+
function mountRouter(app, router, basePath) {
|
|
2943
2930
|
if (basePath) {
|
|
2944
2931
|
app.use(basePath, router);
|
|
2945
|
-
|
|
2946
|
-
app.use(router);
|
|
2932
|
+
return;
|
|
2947
2933
|
}
|
|
2934
|
+
app.use(router);
|
|
2935
|
+
}
|
|
2936
|
+
function registerErrorHandlers(app) {
|
|
2948
2937
|
app.use((req, res) => {
|
|
2949
2938
|
sendJson(res, 404, { error: "Not found", path: req.url ?? "/" });
|
|
2950
2939
|
});
|
|
@@ -2952,6 +2941,8 @@ function createOpenAPIHttpServer(runtime, options = {}) {
|
|
|
2952
2941
|
const message = err instanceof Error ? err.message : String(err);
|
|
2953
2942
|
sendJson(res, 500, { error: message, kind: "INTERNAL_ERROR" });
|
|
2954
2943
|
});
|
|
2944
|
+
}
|
|
2945
|
+
function patchListenDefaults(app, options) {
|
|
2955
2946
|
const originalListen = app.listen.bind(app);
|
|
2956
2947
|
const defaultPort = options.port;
|
|
2957
2948
|
const defaultHost = options.host;
|
|
@@ -2964,6 +2955,18 @@ function createOpenAPIHttpServer(runtime, options = {}) {
|
|
|
2964
2955
|
}
|
|
2965
2956
|
return originalListen(...args);
|
|
2966
2957
|
});
|
|
2958
|
+
}
|
|
2959
|
+
function createOpenAPIHttpServer(runtime, options = {}) {
|
|
2960
|
+
const app = express();
|
|
2961
|
+
const router = express.Router();
|
|
2962
|
+
const basePath = (options.basePath ?? "").replace(/\/$/, "");
|
|
2963
|
+
const ctxFactory = options.execContextFactory ?? (() => ({ ...DEFAULT_CTX2 }));
|
|
2964
|
+
app.use(express.text({ type: "*/*" }));
|
|
2965
|
+
registerSpecRoutes(router, runtime, basePath);
|
|
2966
|
+
registerToolRoutes(router, runtime, ctxFactory);
|
|
2967
|
+
mountRouter(app, router, basePath);
|
|
2968
|
+
registerErrorHandlers(app);
|
|
2969
|
+
patchListenDefaults(app, options);
|
|
2967
2970
|
return app;
|
|
2968
2971
|
}
|
|
2969
2972
|
function listenOpenAPIHttpServer(app, options = {}) {
|
|
@@ -3006,5 +3009,5 @@ async function createHttpService(runtimeOrConfig, options = {}) {
|
|
|
3006
3009
|
}
|
|
3007
3010
|
|
|
3008
3011
|
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-
|
|
3010
|
-
//# sourceMappingURL=chunk-
|
|
3012
|
+
//# sourceMappingURL=chunk-OZUNZILF.js.map
|
|
3013
|
+
//# sourceMappingURL=chunk-OZUNZILF.js.map
|