@easynet/agent-tool 1.0.47 → 1.0.49
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/main.cjs +13 -13
- package/dist/api/main.js +2 -2
- package/dist/api/runtimeFromConfig.d.ts.map +1 -1
- package/dist/{chunk-2ZPDD7ZO.js → chunk-2S465X6Q.js} +46 -12
- package/dist/chunk-2S465X6Q.js.map +1 -0
- package/dist/{chunk-IAEVDXWS.cjs → chunk-5GXFZ4GF.cjs} +15 -15
- package/dist/{chunk-IAEVDXWS.cjs.map → chunk-5GXFZ4GF.cjs.map} +1 -1
- package/dist/{chunk-MDPU7EIO.cjs → chunk-BCMMIJAQ.cjs} +9 -9
- package/dist/{chunk-MDPU7EIO.cjs.map → chunk-BCMMIJAQ.cjs.map} +1 -1
- package/dist/{chunk-KYBIKD5R.js → chunk-C6IARXVY.js} +3 -3
- package/dist/{chunk-KYBIKD5R.js.map → chunk-C6IARXVY.js.map} +1 -1
- package/dist/{chunk-64ZQQV5C.js → chunk-FECO5FHB.js} +3 -3
- package/dist/{chunk-64ZQQV5C.js.map → chunk-FECO5FHB.js.map} +1 -1
- package/dist/{chunk-A5B6Q6EG.cjs → chunk-XHFZEA7L.cjs} +47 -13
- package/dist/chunk-XHFZEA7L.cjs.map +1 -0
- package/dist/index.cjs +24 -24
- package/dist/index.js +4 -4
- package/dist/utils/cli/index.cjs +16 -16
- package/dist/utils/cli/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-2ZPDD7ZO.js.map +0 -1
- package/dist/chunk-A5B6Q6EG.cjs.map +0 -1
|
@@ -14,6 +14,7 @@ var uuid = require('uuid');
|
|
|
14
14
|
var pTimeout = require('p-timeout');
|
|
15
15
|
var promises = require('fs/promises');
|
|
16
16
|
var module$1 = require('module');
|
|
17
|
+
var url = require('url');
|
|
17
18
|
var npm = require('@easynet/agent-common/npm');
|
|
18
19
|
var http = require('http');
|
|
19
20
|
|
|
@@ -1755,13 +1756,23 @@ function isWithinRoot(path$1, root) {
|
|
|
1755
1756
|
}
|
|
1756
1757
|
|
|
1757
1758
|
// src/api/runtimeFromConfig.ts
|
|
1758
|
-
var requireFromPackage = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
1759
|
+
var requireFromPackage = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-XHFZEA7L.cjs', document.baseURI).href)));
|
|
1759
1760
|
function getProjectRequire() {
|
|
1760
1761
|
const cwd = process.cwd();
|
|
1761
1762
|
if (fs.existsSync(path.join(cwd, "package.json"))) return module$1.createRequire(path.join(cwd, "package.json"));
|
|
1762
1763
|
if (fs.existsSync(path.join(cwd, "tool.yaml"))) return module$1.createRequire(path.join(cwd, "tool.yaml"));
|
|
1763
1764
|
return null;
|
|
1764
1765
|
}
|
|
1766
|
+
function findNearestPackageJson(startDir) {
|
|
1767
|
+
let dir = path.resolve(startDir);
|
|
1768
|
+
while (true) {
|
|
1769
|
+
const pkg = path.join(dir, "package.json");
|
|
1770
|
+
if (fs.existsSync(pkg)) return pkg;
|
|
1771
|
+
const parent = path.dirname(dir);
|
|
1772
|
+
if (parent === dir) return null;
|
|
1773
|
+
dir = parent;
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1765
1776
|
var DEFAULT_EXTENSION_PACKAGES = [];
|
|
1766
1777
|
function getInstalledPackageVersion(packageName) {
|
|
1767
1778
|
const projectRequire = getProjectRequire();
|
|
@@ -1870,9 +1881,9 @@ function loadExtensionForDescriptorSync(descriptor, configFilePath, stepLog) {
|
|
|
1870
1881
|
if (!parsed) return null;
|
|
1871
1882
|
const localPath = path.isAbsolute(configFilePath) ? configFilePath : path.resolve(process.cwd(), configFilePath);
|
|
1872
1883
|
const configDir = path.dirname(localPath);
|
|
1873
|
-
const packageJsonPath =
|
|
1874
|
-
const
|
|
1875
|
-
const
|
|
1884
|
+
const packageJsonPath = findNearestPackageJson(configDir);
|
|
1885
|
+
const configRequire = packageJsonPath ? module$1.createRequire(packageJsonPath) : null;
|
|
1886
|
+
const npmCwd = packageJsonPath ? path.dirname(packageJsonPath) : configDir;
|
|
1876
1887
|
if (configRequire) {
|
|
1877
1888
|
try {
|
|
1878
1889
|
const mod = configRequire(parsed.packageName);
|
|
@@ -1880,7 +1891,7 @@ function loadExtensionForDescriptorSync(descriptor, configFilePath, stepLog) {
|
|
|
1880
1891
|
if (typeof fn === "function") {
|
|
1881
1892
|
const installed = getInstalledPackageVersionFromRequire(parsed.packageName, configRequire);
|
|
1882
1893
|
const requested = parsed.version === "latest" || !parsed.version?.trim() ? null : parsed.version;
|
|
1883
|
-
const resolvedVersion = requested === null ? npm.resolveLatestVersionFromRegistry(parsed.packageName) : requested;
|
|
1894
|
+
const resolvedVersion = requested === null ? npm.resolveLatestVersionFromRegistry(parsed.packageName, { cwd: npmCwd }) : requested;
|
|
1884
1895
|
if (installed === resolvedVersion) {
|
|
1885
1896
|
if (stepLog) stepLog(`Loaded ${parsed.packageName}@${resolvedVersion} from node_modules`);
|
|
1886
1897
|
return { register: fn, descriptor: entryStr, resolvedVersion };
|
|
@@ -1890,8 +1901,8 @@ function loadExtensionForDescriptorSync(descriptor, configFilePath, stepLog) {
|
|
|
1890
1901
|
}
|
|
1891
1902
|
}
|
|
1892
1903
|
const cacheBase = getCacheBaseFromToolConfig(localPath);
|
|
1893
|
-
const
|
|
1894
|
-
for (const opts of
|
|
1904
|
+
const cacheOptions = cacheBase ? [{ cacheBase, cwd: npmCwd }, { cwd: npmCwd }] : [{ cwd: npmCwd }];
|
|
1905
|
+
for (const opts of cacheOptions) {
|
|
1895
1906
|
try {
|
|
1896
1907
|
const cacheDir = npm.ensurePackageInCache(parsed.packageName, parsed.version, opts);
|
|
1897
1908
|
if (stepLog) stepLog(`Loaded ${parsed.packageName} from cache: ${cacheDir}`);
|
|
@@ -1905,7 +1916,7 @@ function loadExtensionForDescriptorSync(descriptor, configFilePath, stepLog) {
|
|
|
1905
1916
|
}
|
|
1906
1917
|
break;
|
|
1907
1918
|
} catch {
|
|
1908
|
-
if (
|
|
1919
|
+
if (cacheBase && "cacheBase" in opts) continue;
|
|
1909
1920
|
break;
|
|
1910
1921
|
}
|
|
1911
1922
|
}
|
|
@@ -1948,9 +1959,32 @@ async function loadExtensionForDescriptorAsync(descriptor, configFilePath, stepL
|
|
|
1948
1959
|
const parsed = parseNpmDescriptor(entryStr);
|
|
1949
1960
|
if (!parsed) return null;
|
|
1950
1961
|
const localPath = path.isAbsolute(configFilePath) ? configFilePath : path.resolve(process.cwd(), configFilePath);
|
|
1962
|
+
const configDir = path.dirname(localPath);
|
|
1963
|
+
const packageJsonPath = findNearestPackageJson(configDir);
|
|
1964
|
+
const configRequire = packageJsonPath ? module$1.createRequire(packageJsonPath) : null;
|
|
1965
|
+
const npmCwd = packageJsonPath ? path.dirname(packageJsonPath) : configDir;
|
|
1966
|
+
if (configRequire) {
|
|
1967
|
+
try {
|
|
1968
|
+
const installed = getInstalledPackageVersionFromRequire(parsed.packageName, configRequire);
|
|
1969
|
+
const requested = parsed.version === "latest" || !parsed.version?.trim() ? null : parsed.version;
|
|
1970
|
+
const resolvedVersion = requested === null ? npm.resolveLatestVersionFromRegistry(parsed.packageName, { cwd: npmCwd }) : requested;
|
|
1971
|
+
if (installed === resolvedVersion) {
|
|
1972
|
+
const pkgJsonResolved = configRequire.resolve(`${parsed.packageName}/package.json`);
|
|
1973
|
+
const packageRoot = path.dirname(pkgJsonResolved);
|
|
1974
|
+
const entryPath = npm.getPackageEntryPath(packageRoot);
|
|
1975
|
+
const mod = await import(url.pathToFileURL(entryPath).href);
|
|
1976
|
+
const fn = getRegisterFn(mod);
|
|
1977
|
+
if (typeof fn === "function") {
|
|
1978
|
+
if (stepLog) stepLog(`Loaded ${parsed.packageName}@${resolvedVersion} from node_modules (async import)`);
|
|
1979
|
+
return { register: fn, descriptor: entryStr, resolvedVersion };
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
} catch {
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1951
1985
|
const cacheBase = getCacheBaseFromToolConfig(localPath);
|
|
1952
|
-
const
|
|
1953
|
-
for (const opts of
|
|
1986
|
+
const cacheOptions = cacheBase ? [{ cacheBase, cwd: npmCwd }, { cwd: npmCwd }] : [{ cwd: npmCwd }];
|
|
1987
|
+
for (const opts of cacheOptions) {
|
|
1954
1988
|
try {
|
|
1955
1989
|
const cacheDir = npm.ensurePackageInCache(parsed.packageName, parsed.version, opts);
|
|
1956
1990
|
if (stepLog) stepLog(`Loaded ${parsed.packageName} from cache (async): ${cacheDir}`);
|
|
@@ -1962,7 +1996,7 @@ async function loadExtensionForDescriptorAsync(descriptor, configFilePath, stepL
|
|
|
1962
1996
|
}
|
|
1963
1997
|
break;
|
|
1964
1998
|
} catch {
|
|
1965
|
-
if (
|
|
1999
|
+
if (cacheBase && "cacheBase" in opts) continue;
|
|
1966
2000
|
break;
|
|
1967
2001
|
}
|
|
1968
2002
|
}
|
|
@@ -2541,5 +2575,5 @@ exports.resolveSandboxedPath2 = resolveSandboxedPath2;
|
|
|
2541
2575
|
exports.resolveToolDescriptor = resolveToolDescriptor;
|
|
2542
2576
|
exports.runMCPServerOverStdio = runMCPServerOverStdio;
|
|
2543
2577
|
exports.setSandboxValidationEnabled = setSandboxValidationEnabled;
|
|
2544
|
-
//# sourceMappingURL=chunk-
|
|
2545
|
-
//# sourceMappingURL=chunk-
|
|
2578
|
+
//# sourceMappingURL=chunk-XHFZEA7L.cjs.map
|
|
2579
|
+
//# sourceMappingURL=chunk-XHFZEA7L.cjs.map
|