@easynet/agent-tool 1.0.6 → 1.0.8
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 +14 -15
- package/dist/api/main.js +3 -4
- package/dist/api/runtimeFromConfig.d.ts +4 -2
- package/dist/api/runtimeFromConfig.d.ts.map +1 -1
- package/dist/{canonicalCoreSchemas-MI6NURRD.cjs → canonicalCoreSchemas-CTW6CCFY.cjs} +2 -3
- package/dist/{canonicalCoreSchemas-MI6NURRD.cjs.map → canonicalCoreSchemas-CTW6CCFY.cjs.map} +1 -1
- package/dist/canonicalCoreSchemas-YLHVHYJZ.js +3 -0
- package/dist/{canonicalCoreSchemas-MM5HFUT5.js.map → canonicalCoreSchemas-YLHVHYJZ.js.map} +1 -1
- package/dist/{chunk-TQBNZYB4.js → chunk-4RPX5UAU.js} +184 -11
- package/dist/chunk-4RPX5UAU.js.map +1 -0
- package/dist/{chunk-HX57FKJD.js → chunk-72HPGMFQ.js} +3 -3
- package/dist/{chunk-HX57FKJD.js.map → chunk-72HPGMFQ.js.map} +1 -1
- package/dist/{chunk-THSC7EOF.cjs → chunk-CS3GYMY6.cjs} +185 -9
- package/dist/chunk-CS3GYMY6.cjs.map +1 -0
- package/dist/{chunk-OFGOQZDI.cjs → chunk-HZW5X4VL.cjs} +9 -9
- package/dist/{chunk-OFGOQZDI.cjs.map → chunk-HZW5X4VL.cjs.map} +1 -1
- package/dist/{chunk-2MFY776F.js → chunk-MLHFH6H6.js} +4 -4
- package/dist/{chunk-2MFY776F.js.map → chunk-MLHFH6H6.js.map} +1 -1
- package/dist/{chunk-BCDIVUGG.js → chunk-ONYNCKHC.js} +3 -3
- package/dist/{chunk-BCDIVUGG.js.map → chunk-ONYNCKHC.js.map} +1 -1
- package/dist/{chunk-5UTVU3NX.cjs → chunk-RQDN5DID.cjs} +12 -12
- package/dist/{chunk-5UTVU3NX.cjs.map → chunk-RQDN5DID.cjs.map} +1 -1
- package/dist/{chunk-CDWQNC7O.cjs → chunk-XYFZ7WNK.cjs} +8 -8
- package/dist/{chunk-CDWQNC7O.cjs.map → chunk-XYFZ7WNK.cjs.map} +1 -1
- package/dist/core/index.cjs +0 -1
- package/dist/core/index.js +0 -1
- package/dist/core/runtime.cjs +0 -1
- package/dist/core/runtime.js +0 -1
- package/dist/index.cjs +68 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -98
- package/dist/index.js.map +1 -1
- package/dist/tools/util/toolConfig.d.ts +2 -0
- package/dist/tools/util/toolConfig.d.ts.map +1 -1
- package/dist/utils/cli/index.cjs +27 -25
- package/dist/utils/cli/index.cjs.map +1 -1
- package/dist/utils/cli/index.d.ts.map +1 -1
- package/dist/utils/cli/index.js +15 -13
- package/dist/utils/cli/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/canonicalCoreSchemas-MM5HFUT5.js +0 -4
- package/dist/chunk-DGUM43GV.js +0 -10
- package/dist/chunk-DGUM43GV.js.map +0 -1
- package/dist/chunk-JEQ2X3Z6.cjs +0 -12
- package/dist/chunk-JEQ2X3Z6.cjs.map +0 -1
- package/dist/chunk-THSC7EOF.cjs.map +0 -1
- package/dist/chunk-TQBNZYB4.js.map +0 -1
package/dist/api/main.cjs
CHANGED
|
@@ -1,57 +1,56 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkRQDN5DID_cjs = require('../chunk-RQDN5DID.cjs');
|
|
4
|
+
var chunkXYFZ7WNK_cjs = require('../chunk-XYFZ7WNK.cjs');
|
|
5
|
+
var chunkCS3GYMY6_cjs = require('../chunk-CS3GYMY6.cjs');
|
|
6
6
|
require('../chunk-ZNJBRLKN.cjs');
|
|
7
7
|
require('../chunk-6F5JHLZ7.cjs');
|
|
8
|
-
require('../chunk-JEQ2X3Z6.cjs');
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
Object.defineProperty(exports, "createAgentTools", {
|
|
13
12
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkRQDN5DID_cjs.createAgentTools; }
|
|
15
14
|
});
|
|
16
15
|
Object.defineProperty(exports, "createLangChainToolsAsync", {
|
|
17
16
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkRQDN5DID_cjs.createLangChainToolsAsync; }
|
|
19
18
|
});
|
|
20
19
|
Object.defineProperty(exports, "createHttpService", {
|
|
21
20
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkXYFZ7WNK_cjs.createHttpService; }
|
|
23
22
|
});
|
|
24
23
|
Object.defineProperty(exports, "createMCPServer", {
|
|
25
24
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkXYFZ7WNK_cjs.createMCPServer; }
|
|
27
26
|
});
|
|
28
27
|
Object.defineProperty(exports, "createMCPServerStreamableHttp", {
|
|
29
28
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkXYFZ7WNK_cjs.createMCPServerStreamableHttp; }
|
|
31
30
|
});
|
|
32
31
|
Object.defineProperty(exports, "createMCPStreamableHttpHandler", {
|
|
33
32
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkXYFZ7WNK_cjs.createMCPStreamableHttpHandler; }
|
|
35
34
|
});
|
|
36
35
|
Object.defineProperty(exports, "createOpenAPIServer", {
|
|
37
36
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkXYFZ7WNK_cjs.createHttpService; }
|
|
39
38
|
});
|
|
40
39
|
Object.defineProperty(exports, "runMCPServerOverStdio", {
|
|
41
40
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkXYFZ7WNK_cjs.runMCPServerOverStdio; }
|
|
43
42
|
});
|
|
44
43
|
Object.defineProperty(exports, "PTCRuntime", {
|
|
45
44
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkCS3GYMY6_cjs.PTCRuntime; }
|
|
47
46
|
});
|
|
48
47
|
Object.defineProperty(exports, "createRuntimeFromConfig", {
|
|
49
48
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkCS3GYMY6_cjs.createRuntimeFromConfig; }
|
|
51
50
|
});
|
|
52
51
|
Object.defineProperty(exports, "createRuntimeFromConfigSync", {
|
|
53
52
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkCS3GYMY6_cjs.createRuntimeFromConfigSync; }
|
|
55
54
|
});
|
|
56
55
|
//# sourceMappingURL=main.cjs.map
|
|
57
56
|
//# sourceMappingURL=main.cjs.map
|
package/dist/api/main.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export { createAgentTools, createLangChainToolsAsync } from '../chunk-
|
|
2
|
-
export { createHttpService, createMCPServer, createMCPServerStreamableHttp, createMCPStreamableHttpHandler, createHttpService as createOpenAPIServer, runMCPServerOverStdio } from '../chunk-
|
|
3
|
-
export { PTCRuntime, createRuntimeFromConfig, createRuntimeFromConfigSync } from '../chunk-
|
|
1
|
+
export { createAgentTools, createLangChainToolsAsync } from '../chunk-ONYNCKHC.js';
|
|
2
|
+
export { createHttpService, createMCPServer, createMCPServerStreamableHttp, createMCPStreamableHttpHandler, createHttpService as createOpenAPIServer, runMCPServerOverStdio } from '../chunk-MLHFH6H6.js';
|
|
3
|
+
export { PTCRuntime, createRuntimeFromConfig, createRuntimeFromConfigSync } from '../chunk-4RPX5UAU.js';
|
|
4
4
|
import '../chunk-AE6FSNGY.js';
|
|
5
5
|
import '../chunk-FR2CXERF.js';
|
|
6
|
-
import '../chunk-DGUM43GV.js';
|
|
7
6
|
//# sourceMappingURL=main.js.map
|
|
8
7
|
//# sourceMappingURL=main.js.map
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Registers core/example adapters only when coreTools/exampleTools options are provided.
|
|
4
4
|
* Extensions (@easynet/agent-tool-builtin-tools, @easynet/agent-tool-example-tools) are
|
|
5
5
|
* loaded optionally so the CLI works when they are not installed (e.g. npx @easynet/agent-tool).
|
|
6
|
+
* When configFilePath (tool.yaml) lists npm:@easynet/agent-tool-buildin@version, the package
|
|
7
|
+
* is loaded from cache (~/.agent/cache or sandboxedPath/.agent/cache) if not in node_modules.
|
|
6
8
|
*/
|
|
7
9
|
import { ToolRegistry } from "../core/registry/ToolRegistry.js";
|
|
8
10
|
import { PTCRuntime } from "../core/runtime/PTCRuntime.js";
|
|
@@ -36,8 +38,8 @@ export interface CreateRuntimeResult {
|
|
|
36
38
|
*/
|
|
37
39
|
export declare function createRuntimeFromConfigSync(options?: CreateRuntimeOptions): CreateRuntimeResult;
|
|
38
40
|
/**
|
|
39
|
-
* Create runtime and registry asynchronously.
|
|
40
|
-
*
|
|
41
|
+
* Create runtime and registry asynchronously. Tries sync first; when configFilePath is set
|
|
42
|
+
* and no builtin was found (e.g. ESM package), tries loading from tool.yaml npm: entry via cache (dynamic import).
|
|
41
43
|
*/
|
|
42
44
|
export declare function createRuntimeFromConfig(options?: CreateRuntimeOptions): Promise<CreateRuntimeResult>;
|
|
43
45
|
//# sourceMappingURL=runtimeFromConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeFromConfig.d.ts","sourceRoot":"","sources":["../../src/api/runtimeFromConfig.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"runtimeFromConfig.d.ts","sourceRoot":"","sources":["../../src/api/runtimeFromConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAoB3D,+FAA+F;AAC/F,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,wFAAwF;AACxF,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,oEAAoE;IACpE,YAAY,CAAC,EAAE,sBAAsB,CAAC;CACvC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,YAAY,CAAC;CACxB;AA8FD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,oBAAyB,GAAG,mBAAmB,CAqCnG;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAa9B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk6F5JHLZ7_cjs = require('./chunk-6F5JHLZ7.cjs');
|
|
4
|
-
require('./chunk-JEQ2X3Z6.cjs');
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
|
|
@@ -17,5 +16,5 @@ Object.defineProperty(exports, "isGenericSchema", {
|
|
|
17
16
|
enumerable: true,
|
|
18
17
|
get: function () { return chunk6F5JHLZ7_cjs.isGenericSchema; }
|
|
19
18
|
});
|
|
20
|
-
//# sourceMappingURL=canonicalCoreSchemas-
|
|
21
|
-
//# sourceMappingURL=canonicalCoreSchemas-
|
|
19
|
+
//# sourceMappingURL=canonicalCoreSchemas-CTW6CCFY.cjs.map
|
|
20
|
+
//# sourceMappingURL=canonicalCoreSchemas-CTW6CCFY.cjs.map
|
package/dist/{canonicalCoreSchemas-MI6NURRD.cjs.map → canonicalCoreSchemas-CTW6CCFY.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"canonicalCoreSchemas-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"canonicalCoreSchemas-CTW6CCFY.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"canonicalCoreSchemas-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"canonicalCoreSchemas-YLHVHYJZ.js"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { ToolRegistry, createTaggedError, withRetry } from './chunk-AE6FSNGY.js';
|
|
2
|
-
import { __require } from './chunk-DGUM43GV.js';
|
|
3
2
|
import Ajv from 'ajv';
|
|
4
3
|
import addFormats from 'ajv-formats';
|
|
5
4
|
import { bulkhead, circuitBreaker, handleAll, ConsecutiveBreaker } from 'cockatiel';
|
|
6
5
|
import { EventEmitter } from 'eventemitter3';
|
|
7
6
|
import { v4 } from 'uuid';
|
|
8
7
|
import pTimeout from 'p-timeout';
|
|
9
|
-
import { readFileSync, existsSync } from 'fs';
|
|
10
|
-
import { resolve, dirname,
|
|
8
|
+
import { readFileSync, existsSync, mkdirSync, readdirSync, rmSync, renameSync } from 'fs';
|
|
9
|
+
import { join, resolve, dirname, isAbsolute } from 'path';
|
|
10
|
+
import { homedir } from 'os';
|
|
11
11
|
import yaml from 'js-yaml';
|
|
12
|
+
import { execSync } from 'child_process';
|
|
13
|
+
import { pathToFileURL } from 'url';
|
|
12
14
|
import { createRequire } from 'module';
|
|
13
15
|
|
|
14
16
|
var SchemaValidator = class {
|
|
@@ -1534,11 +1536,20 @@ function loadToolConfig(toolYamlPath) {
|
|
|
1534
1536
|
return parsed;
|
|
1535
1537
|
}
|
|
1536
1538
|
function resolveSandboxedPath(toolYamlPath, sandboxedPath) {
|
|
1539
|
+
const expanded = sandboxedPath.startsWith("~/") ? join(homedir(), sandboxedPath.slice(2)) : sandboxedPath === "~" ? homedir() : sandboxedPath.startsWith("~") && (sandboxedPath.length === 1 || sandboxedPath[1] === "/") ? join(homedir(), sandboxedPath.slice(1)) : sandboxedPath;
|
|
1537
1540
|
const configDir = dirname(resolve(toolYamlPath));
|
|
1538
|
-
return resolve(configDir,
|
|
1541
|
+
return resolve(configDir, expanded);
|
|
1542
|
+
}
|
|
1543
|
+
var CACHE_SUBDIR = ".agent/cache";
|
|
1544
|
+
function getCacheBaseFromToolConfig(toolYamlPath) {
|
|
1545
|
+
const config = loadToolConfig(toolYamlPath);
|
|
1546
|
+
if (!config.sandboxedPath || typeof config.sandboxedPath !== "string") return void 0;
|
|
1547
|
+
const sandboxRoot = resolveSandboxedPath(toolYamlPath, config.sandboxedPath);
|
|
1548
|
+
return join(sandboxRoot, CACHE_SUBDIR);
|
|
1539
1549
|
}
|
|
1540
1550
|
function findAndLoadToolConfig(dir) {
|
|
1541
|
-
const
|
|
1551
|
+
const resolvedDir = resolve(dir);
|
|
1552
|
+
const candidates = [join(resolvedDir, "tool.yaml"), join(resolvedDir, ".tool.yaml")];
|
|
1542
1553
|
for (const p of candidates) {
|
|
1543
1554
|
if (existsSync(p)) {
|
|
1544
1555
|
const config = loadToolConfig(p);
|
|
@@ -1547,6 +1558,93 @@ function findAndLoadToolConfig(dir) {
|
|
|
1547
1558
|
}
|
|
1548
1559
|
return {};
|
|
1549
1560
|
}
|
|
1561
|
+
var DEFAULT_CACHE_BASE = join(homedir(), ".agent", "cache");
|
|
1562
|
+
function packagePathSegments(name) {
|
|
1563
|
+
const withoutScope = name.replace(/^@/, "");
|
|
1564
|
+
return withoutScope.split("/").filter(Boolean);
|
|
1565
|
+
}
|
|
1566
|
+
function resolveCacheDir(cacheBase, packageName, version) {
|
|
1567
|
+
const segments = packagePathSegments(packageName);
|
|
1568
|
+
return join(cacheBase, ...segments, version);
|
|
1569
|
+
}
|
|
1570
|
+
function getVersionFromTarball(tgzName) {
|
|
1571
|
+
const base = tgzName.replace(/\.tgz$/i, "");
|
|
1572
|
+
const match = base.match(/-(\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?)$/);
|
|
1573
|
+
return match ? match[1] : base;
|
|
1574
|
+
}
|
|
1575
|
+
function ensurePackageInCache(packageName, version = "latest", options = {}) {
|
|
1576
|
+
const cacheBase = options.cacheBase ?? DEFAULT_CACHE_BASE;
|
|
1577
|
+
const packDest = join(cacheBase, ".pack-tmp", packageName.replace(/@/g, "").replace(/\//g, "_"));
|
|
1578
|
+
mkdirSync(packDest, { recursive: true });
|
|
1579
|
+
try {
|
|
1580
|
+
execSync(`npm pack ${packageName}@${version} --pack-destination "${packDest}"`, {
|
|
1581
|
+
cwd: process.cwd(),
|
|
1582
|
+
stdio: "pipe",
|
|
1583
|
+
encoding: "utf-8"
|
|
1584
|
+
});
|
|
1585
|
+
const files = readdirSync(packDest);
|
|
1586
|
+
const tgz = files.find((f) => f.endsWith(".tgz"));
|
|
1587
|
+
if (!tgz) {
|
|
1588
|
+
throw new Error(`npm pack did not produce a .tgz in ${packDest}`);
|
|
1589
|
+
}
|
|
1590
|
+
const resolvedVersion = getVersionFromTarball(tgz);
|
|
1591
|
+
const cacheDir = resolveCacheDir(cacheBase, packageName, resolvedVersion);
|
|
1592
|
+
const packageJsonPath = join(cacheDir, "package.json");
|
|
1593
|
+
const nodeModulesPath = join(cacheDir, "node_modules");
|
|
1594
|
+
if (existsSync(packageJsonPath) && existsSync(nodeModulesPath)) {
|
|
1595
|
+
options.afterInstall?.(cacheDir, packageName);
|
|
1596
|
+
rmSync(packDest, { recursive: true, force: true });
|
|
1597
|
+
return cacheDir;
|
|
1598
|
+
}
|
|
1599
|
+
const extractDir = join(packDest, "extract");
|
|
1600
|
+
mkdirSync(extractDir, { recursive: true });
|
|
1601
|
+
execSync(`tar -xzf "${join(packDest, tgz)}" -C "${extractDir}"`, {
|
|
1602
|
+
stdio: "pipe",
|
|
1603
|
+
encoding: "utf-8"
|
|
1604
|
+
});
|
|
1605
|
+
const extractedPackage = join(extractDir, "package");
|
|
1606
|
+
if (!existsSync(extractedPackage)) {
|
|
1607
|
+
throw new Error(`Extracted tarball did not contain "package" dir in ${extractDir}`);
|
|
1608
|
+
}
|
|
1609
|
+
mkdirSync(join(cacheDir, ".."), { recursive: true });
|
|
1610
|
+
if (existsSync(cacheDir)) {
|
|
1611
|
+
rmSync(cacheDir, { recursive: true, force: true });
|
|
1612
|
+
}
|
|
1613
|
+
renameSync(extractedPackage, cacheDir);
|
|
1614
|
+
execSync("npm install", {
|
|
1615
|
+
cwd: cacheDir,
|
|
1616
|
+
stdio: "pipe",
|
|
1617
|
+
encoding: "utf-8"
|
|
1618
|
+
});
|
|
1619
|
+
options.afterInstall?.(cacheDir, packageName);
|
|
1620
|
+
return cacheDir;
|
|
1621
|
+
} finally {
|
|
1622
|
+
if (existsSync(packDest)) {
|
|
1623
|
+
rmSync(packDest, { recursive: true, force: true });
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
function getPackageEntryPath(packageRoot) {
|
|
1628
|
+
const pkgPath = join(packageRoot, "package.json");
|
|
1629
|
+
if (!existsSync(pkgPath)) {
|
|
1630
|
+
throw new Error(`No package.json in ${packageRoot}`);
|
|
1631
|
+
}
|
|
1632
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
1633
|
+
const main = pkg.main ?? "dist/index.js";
|
|
1634
|
+
const entry = join(packageRoot, main);
|
|
1635
|
+
if (!existsSync(entry)) {
|
|
1636
|
+
throw new Error(`Entry not found: ${entry}`);
|
|
1637
|
+
}
|
|
1638
|
+
return entry;
|
|
1639
|
+
}
|
|
1640
|
+
async function importFromCache(packageRoot) {
|
|
1641
|
+
const entryPath = getPackageEntryPath(packageRoot);
|
|
1642
|
+
const fileUrl = pathToFileURL(entryPath).href;
|
|
1643
|
+
return import(
|
|
1644
|
+
/* @vite-ignore */
|
|
1645
|
+
fileUrl
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1550
1648
|
var requireFromPackage = createRequire(import.meta.url);
|
|
1551
1649
|
function getProjectRequire() {
|
|
1552
1650
|
const cwd = process.cwd();
|
|
@@ -1575,9 +1673,70 @@ function loadBuiltinTools() {
|
|
|
1575
1673
|
}
|
|
1576
1674
|
return null;
|
|
1577
1675
|
}
|
|
1676
|
+
function parseNpmDescriptor(entry) {
|
|
1677
|
+
if (typeof entry !== "string" || !entry.startsWith("npm:")) return null;
|
|
1678
|
+
const rest = entry.slice(4).trim();
|
|
1679
|
+
const at = rest.indexOf("@", 1);
|
|
1680
|
+
if (at < 0) return { packageName: rest, version: "latest" };
|
|
1681
|
+
const packageName = rest.slice(0, at);
|
|
1682
|
+
const version = rest.slice(at + 1).split("#")[0]?.trim() || "latest";
|
|
1683
|
+
return { packageName, version };
|
|
1684
|
+
}
|
|
1685
|
+
function loadBuiltinFromToolYamlCache(configFilePath) {
|
|
1686
|
+
const localPath = isAbsolute(configFilePath) ? configFilePath : resolve(process.cwd(), configFilePath);
|
|
1687
|
+
if (!existsSync(localPath)) return null;
|
|
1688
|
+
const config = loadToolConfig(localPath);
|
|
1689
|
+
const tools = config.tools;
|
|
1690
|
+
if (!Array.isArray(tools)) return null;
|
|
1691
|
+
const cacheBase = getCacheBaseFromToolConfig(localPath);
|
|
1692
|
+
const cacheOpts = cacheBase ? { cacheBase } : {};
|
|
1693
|
+
for (const entry of tools) {
|
|
1694
|
+
const parsed = parseNpmDescriptor(String(entry));
|
|
1695
|
+
if (!parsed || !BUILTIN_PKG_NAMES.includes(parsed.packageName)) continue;
|
|
1696
|
+
for (const opts of [cacheOpts, {}]) {
|
|
1697
|
+
try {
|
|
1698
|
+
const cacheDir = ensurePackageInCache(parsed.packageName, parsed.version, opts);
|
|
1699
|
+
const entryPath = getPackageEntryPath(cacheDir);
|
|
1700
|
+
const req = createRequire(join(cacheDir, "package.json"));
|
|
1701
|
+
const mod = req(entryPath);
|
|
1702
|
+
if (mod && typeof mod.registerCoreTools === "function") return mod;
|
|
1703
|
+
break;
|
|
1704
|
+
} catch {
|
|
1705
|
+
if (Object.keys(opts).length > 0) continue;
|
|
1706
|
+
break;
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
return null;
|
|
1711
|
+
}
|
|
1712
|
+
async function loadBuiltinFromToolYamlCacheAsync(configFilePath) {
|
|
1713
|
+
const localPath = isAbsolute(configFilePath) ? configFilePath : resolve(process.cwd(), configFilePath);
|
|
1714
|
+
if (!existsSync(localPath)) return null;
|
|
1715
|
+
const config = loadToolConfig(localPath);
|
|
1716
|
+
const tools = config.tools;
|
|
1717
|
+
if (!Array.isArray(tools)) return null;
|
|
1718
|
+
const cacheBase = getCacheBaseFromToolConfig(localPath);
|
|
1719
|
+
const cacheOpts = cacheBase ? { cacheBase } : {};
|
|
1720
|
+
for (const entry of tools) {
|
|
1721
|
+
const parsed = parseNpmDescriptor(String(entry));
|
|
1722
|
+
if (!parsed || !BUILTIN_PKG_NAMES.includes(parsed.packageName)) continue;
|
|
1723
|
+
for (const opts of [cacheOpts, {}]) {
|
|
1724
|
+
try {
|
|
1725
|
+
const cacheDir = ensurePackageInCache(parsed.packageName, parsed.version, opts);
|
|
1726
|
+
const mod = await importFromCache(cacheDir);
|
|
1727
|
+
if (mod && typeof mod.registerCoreTools === "function") return mod;
|
|
1728
|
+
break;
|
|
1729
|
+
} catch {
|
|
1730
|
+
if (Object.keys(opts).length > 0) continue;
|
|
1731
|
+
break;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
return null;
|
|
1736
|
+
}
|
|
1578
1737
|
function loadExampleTools() {
|
|
1579
1738
|
try {
|
|
1580
|
-
return
|
|
1739
|
+
return requireFromPackage("@easynet/agent-tool-example-tools");
|
|
1581
1740
|
} catch {
|
|
1582
1741
|
return null;
|
|
1583
1742
|
}
|
|
@@ -1585,7 +1744,10 @@ function loadExampleTools() {
|
|
|
1585
1744
|
function createRuntimeFromConfigSync(options = {}) {
|
|
1586
1745
|
const registry = new ToolRegistry();
|
|
1587
1746
|
if (options.coreTools !== void 0) {
|
|
1588
|
-
|
|
1747
|
+
let builtin = loadBuiltinTools();
|
|
1748
|
+
if (!builtin && options.configFilePath) {
|
|
1749
|
+
builtin = loadBuiltinFromToolYamlCache(options.configFilePath);
|
|
1750
|
+
}
|
|
1589
1751
|
if (builtin) {
|
|
1590
1752
|
const coreAdapter = builtin.registerCoreTools(registry, options.coreTools);
|
|
1591
1753
|
const runtime3 = new PTCRuntime({ registry });
|
|
@@ -1615,7 +1777,18 @@ function createRuntimeFromConfigSync(options = {}) {
|
|
|
1615
1777
|
return { runtime, registry };
|
|
1616
1778
|
}
|
|
1617
1779
|
async function createRuntimeFromConfig(options = {}) {
|
|
1618
|
-
|
|
1780
|
+
const syncResult = createRuntimeFromConfigSync(options);
|
|
1781
|
+
if (options.coreTools !== void 0 && options.configFilePath && syncResult.registry.snapshot().length === 0) {
|
|
1782
|
+
const builtin = await loadBuiltinFromToolYamlCacheAsync(options.configFilePath);
|
|
1783
|
+
if (builtin) {
|
|
1784
|
+
const registry = new ToolRegistry();
|
|
1785
|
+
const coreAdapter = builtin.registerCoreTools(registry, options.coreTools);
|
|
1786
|
+
const runtime = new PTCRuntime({ registry });
|
|
1787
|
+
runtime.registerAdapter(coreAdapter);
|
|
1788
|
+
return { runtime, registry };
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
return syncResult;
|
|
1619
1792
|
}
|
|
1620
1793
|
|
|
1621
1794
|
// src/tools/mcp/types.ts
|
|
@@ -1625,6 +1798,6 @@ var MCP_KIND = "mcp";
|
|
|
1625
1798
|
var LANGCHAIN_KIND = "langchain";
|
|
1626
1799
|
var LANGCHAIN_DIR_NAME = "langchain";
|
|
1627
1800
|
|
|
1628
|
-
export { BudgetManager, EventLog, LANGCHAIN_DIR_NAME, LANGCHAIN_KIND, MCP_KIND, Metrics, PTCRuntime, PolicyDeniedError, PolicyEngine, SchemaValidationError, SchemaValidator, Tracing, buildEvidence, createLogger, createRuntimeFromConfig, createRuntimeFromConfigSync, expandToolDescriptorsToRegistryNames, findAndLoadToolConfig, getDisplayScope, isNpmToolDescriptor, loadToolConfig, normalizeToolList, parseNpmToolDescriptor, resolveNpmToolDescriptor, resolveSandboxedPath, resolveToolDescriptor, sanitizeForLog, summarizeForLog };
|
|
1629
|
-
//# sourceMappingURL=chunk-
|
|
1630
|
-
//# sourceMappingURL=chunk-
|
|
1801
|
+
export { BudgetManager, EventLog, LANGCHAIN_DIR_NAME, LANGCHAIN_KIND, MCP_KIND, Metrics, PTCRuntime, PolicyDeniedError, PolicyEngine, SchemaValidationError, SchemaValidator, Tracing, buildEvidence, createLogger, createRuntimeFromConfig, createRuntimeFromConfigSync, ensurePackageInCache, expandToolDescriptorsToRegistryNames, findAndLoadToolConfig, getDisplayScope, getPackageEntryPath, importFromCache, isNpmToolDescriptor, loadToolConfig, normalizeToolList, parseNpmToolDescriptor, resolveNpmToolDescriptor, resolveSandboxedPath, resolveToolDescriptor, sanitizeForLog, summarizeForLog };
|
|
1802
|
+
//# sourceMappingURL=chunk-4RPX5UAU.js.map
|
|
1803
|
+
//# sourceMappingURL=chunk-4RPX5UAU.js.map
|