@easynet/agent-tool 1.0.8 → 1.0.10
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/mcpServer.d.ts.map +1 -1
- package/dist/api/main.cjs +14 -14
- package/dist/api/main.js +3 -3
- package/dist/api/runtimeFromConfig.d.ts +2 -0
- package/dist/api/runtimeFromConfig.d.ts.map +1 -1
- package/dist/{chunk-HZW5X4VL.cjs → chunk-2SH6IOCF.cjs} +9 -9
- package/dist/{chunk-HZW5X4VL.cjs.map → chunk-2SH6IOCF.cjs.map} +1 -1
- package/dist/{chunk-RQDN5DID.cjs → chunk-5BO3RL5R.cjs} +12 -12
- package/dist/{chunk-RQDN5DID.cjs.map → chunk-5BO3RL5R.cjs.map} +1 -1
- package/dist/{chunk-XYFZ7WNK.cjs → chunk-5NOAYHLP.cjs} +12 -8
- package/dist/chunk-5NOAYHLP.cjs.map +1 -0
- package/dist/{chunk-72HPGMFQ.js → chunk-CM5YKSRS.js} +3 -3
- package/dist/{chunk-72HPGMFQ.js.map → chunk-CM5YKSRS.js.map} +1 -1
- package/dist/{chunk-4RPX5UAU.js → chunk-FQQDPJ7Z.js} +44 -8
- package/dist/chunk-FQQDPJ7Z.js.map +1 -0
- package/dist/{chunk-MLHFH6H6.js → chunk-FQS77UEY.js} +8 -4
- package/dist/chunk-FQS77UEY.js.map +1 -0
- package/dist/{chunk-CS3GYMY6.cjs → chunk-ORKC2PK2.cjs} +45 -9
- package/dist/chunk-ORKC2PK2.cjs.map +1 -0
- package/dist/{chunk-ONYNCKHC.js → chunk-UTRTRLZW.js} +3 -3
- package/dist/{chunk-ONYNCKHC.js.map → chunk-UTRTRLZW.js.map} +1 -1
- package/dist/index.cjs +47 -47
- package/dist/index.js +5 -5
- package/dist/tools/util/toolConfig.d.ts +8 -4
- package/dist/tools/util/toolConfig.d.ts.map +1 -1
- package/dist/utils/cli/index.cjs +53 -35
- 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 +41 -23
- package/dist/utils/cli/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4RPX5UAU.js.map +0 -1
- package/dist/chunk-CS3GYMY6.cjs.map +0 -1
- package/dist/chunk-MLHFH6H6.js.map +0 -1
- package/dist/chunk-XYFZ7WNK.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk5BO3RL5R_cjs = require('./chunk-5BO3RL5R.cjs');
|
|
4
|
+
var chunk2SH6IOCF_cjs = require('./chunk-2SH6IOCF.cjs');
|
|
5
5
|
var chunkSOFUWEZ6_cjs = require('./chunk-SOFUWEZ6.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkORKC2PK2_cjs = require('./chunk-ORKC2PK2.cjs');
|
|
7
7
|
var chunkZNJBRLKN_cjs = require('./chunk-ZNJBRLKN.cjs');
|
|
8
8
|
require('./chunk-6F5JHLZ7.cjs');
|
|
9
9
|
var path = require('path');
|
|
@@ -21,7 +21,7 @@ var MCPClientAdapter = class {
|
|
|
21
21
|
constructor(client) {
|
|
22
22
|
this.client = client;
|
|
23
23
|
}
|
|
24
|
-
kind =
|
|
24
|
+
kind = chunkORKC2PK2_cjs.MCP_KIND;
|
|
25
25
|
async invoke(spec, args, _ctx) {
|
|
26
26
|
const params = args != null && typeof args === "object" && !Array.isArray(args) ? args : {};
|
|
27
27
|
const result = await this.client.callTool({ name: spec.name, arguments: params });
|
|
@@ -62,7 +62,7 @@ function mcpToolsToSpecs(tools) {
|
|
|
62
62
|
return tools.map((t) => ({
|
|
63
63
|
name: t.name,
|
|
64
64
|
version: "1.0.0",
|
|
65
|
-
kind:
|
|
65
|
+
kind: chunkORKC2PK2_cjs.MCP_KIND,
|
|
66
66
|
description: t.description ?? `MCP tool: ${t.name}`,
|
|
67
67
|
inputSchema: t.inputSchema ?? chunkSOFUWEZ6_cjs.DEFAULT_INPUT_SCHEMA,
|
|
68
68
|
outputSchema: chunkSOFUWEZ6_cjs.DEFAULT_OUTPUT_SCHEMA,
|
|
@@ -102,8 +102,8 @@ async function registerMCPToolsFromConfig(runtime, registry, options = {}) {
|
|
|
102
102
|
const configPath = options.configPath ?? process.env.MCP_CONFIG_PATH ?? path.join(process.cwd(), "mcp.json");
|
|
103
103
|
const dirPath = path.dirname(configPath);
|
|
104
104
|
const entryPoint = path.basename(configPath);
|
|
105
|
-
const toolName = options.toolName ??
|
|
106
|
-
const loaded = await
|
|
105
|
+
const toolName = options.toolName ?? chunkORKC2PK2_cjs.MCP_KIND;
|
|
106
|
+
const loaded = await chunk2SH6IOCF_cjs.loadMCPTool(dirPath, { kind: chunkORKC2PK2_cjs.MCP_KIND, name: toolName, entryPoint });
|
|
107
107
|
if (!loaded.mcpConfig) {
|
|
108
108
|
throw new Error("mcp.json must have command or url");
|
|
109
109
|
}
|
|
@@ -119,71 +119,71 @@ async function registerMCPToolsFromConfig(runtime, registry, options = {}) {
|
|
|
119
119
|
|
|
120
120
|
Object.defineProperty(exports, "LangChainToolsHub", {
|
|
121
121
|
enumerable: true,
|
|
122
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunk5BO3RL5R_cjs.LangChainToolsHub; }
|
|
123
123
|
});
|
|
124
124
|
Object.defineProperty(exports, "createAgentTools", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunk5BO3RL5R_cjs.createAgentTools; }
|
|
127
127
|
});
|
|
128
128
|
Object.defineProperty(exports, "DirectoryScanner", {
|
|
129
129
|
enumerable: true,
|
|
130
|
-
get: function () { return
|
|
130
|
+
get: function () { return chunk2SH6IOCF_cjs.DirectoryScanner; }
|
|
131
131
|
});
|
|
132
132
|
Object.defineProperty(exports, "DiscoveryError", {
|
|
133
133
|
enumerable: true,
|
|
134
|
-
get: function () { return
|
|
134
|
+
get: function () { return chunk2SH6IOCF_cjs.DiscoveryError; }
|
|
135
135
|
});
|
|
136
136
|
Object.defineProperty(exports, "SkillManifestError", {
|
|
137
137
|
enumerable: true,
|
|
138
|
-
get: function () { return
|
|
138
|
+
get: function () { return chunk2SH6IOCF_cjs.SkillManifestError; }
|
|
139
139
|
});
|
|
140
140
|
Object.defineProperty(exports, "buildFunctionToTool", {
|
|
141
141
|
enumerable: true,
|
|
142
|
-
get: function () { return
|
|
142
|
+
get: function () { return chunk2SH6IOCF_cjs.buildFunctionToTool; }
|
|
143
143
|
});
|
|
144
144
|
Object.defineProperty(exports, "buildMcpPackage", {
|
|
145
145
|
enumerable: true,
|
|
146
|
-
get: function () { return
|
|
146
|
+
get: function () { return chunk2SH6IOCF_cjs.buildMcpPackage; }
|
|
147
147
|
});
|
|
148
148
|
Object.defineProperty(exports, "initProject", {
|
|
149
149
|
enumerable: true,
|
|
150
|
-
get: function () { return
|
|
150
|
+
get: function () { return chunk2SH6IOCF_cjs.initProject; }
|
|
151
151
|
});
|
|
152
152
|
Object.defineProperty(exports, "loadMCPTool", {
|
|
153
153
|
enumerable: true,
|
|
154
|
-
get: function () { return
|
|
154
|
+
get: function () { return chunk2SH6IOCF_cjs.loadMCPTool; }
|
|
155
155
|
});
|
|
156
156
|
Object.defineProperty(exports, "loadSkillDefinition", {
|
|
157
157
|
enumerable: true,
|
|
158
|
-
get: function () { return
|
|
158
|
+
get: function () { return chunk2SH6IOCF_cjs.loadSkillDefinition; }
|
|
159
159
|
});
|
|
160
160
|
Object.defineProperty(exports, "parseSkillMd", {
|
|
161
161
|
enumerable: true,
|
|
162
|
-
get: function () { return
|
|
162
|
+
get: function () { return chunk2SH6IOCF_cjs.parseSkillMd; }
|
|
163
163
|
});
|
|
164
164
|
Object.defineProperty(exports, "runGeneratedMCP", {
|
|
165
165
|
enumerable: true,
|
|
166
|
-
get: function () { return
|
|
166
|
+
get: function () { return chunk2SH6IOCF_cjs.runGeneratedMCP; }
|
|
167
167
|
});
|
|
168
168
|
Object.defineProperty(exports, "runMcpServer", {
|
|
169
169
|
enumerable: true,
|
|
170
|
-
get: function () { return
|
|
170
|
+
get: function () { return chunk2SH6IOCF_cjs.runMcpServer; }
|
|
171
171
|
});
|
|
172
172
|
Object.defineProperty(exports, "scan", {
|
|
173
173
|
enumerable: true,
|
|
174
|
-
get: function () { return
|
|
174
|
+
get: function () { return chunk2SH6IOCF_cjs.scan; }
|
|
175
175
|
});
|
|
176
176
|
Object.defineProperty(exports, "scanForTools", {
|
|
177
177
|
enumerable: true,
|
|
178
|
-
get: function () { return
|
|
178
|
+
get: function () { return chunk2SH6IOCF_cjs.scanForTools; }
|
|
179
179
|
});
|
|
180
180
|
Object.defineProperty(exports, "scanSkillResources", {
|
|
181
181
|
enumerable: true,
|
|
182
|
-
get: function () { return
|
|
182
|
+
get: function () { return chunk2SH6IOCF_cjs.scanSkillResources; }
|
|
183
183
|
});
|
|
184
184
|
Object.defineProperty(exports, "validateFrontmatter", {
|
|
185
185
|
enumerable: true,
|
|
186
|
-
get: function () { return
|
|
186
|
+
get: function () { return chunk2SH6IOCF_cjs.validateFrontmatter; }
|
|
187
187
|
});
|
|
188
188
|
Object.defineProperty(exports, "DEFAULT_INPUT_SCHEMA", {
|
|
189
189
|
enumerable: true,
|
|
@@ -199,95 +199,95 @@ Object.defineProperty(exports, "createToolSpec", {
|
|
|
199
199
|
});
|
|
200
200
|
Object.defineProperty(exports, "BudgetManager", {
|
|
201
201
|
enumerable: true,
|
|
202
|
-
get: function () { return
|
|
202
|
+
get: function () { return chunkORKC2PK2_cjs.BudgetManager; }
|
|
203
203
|
});
|
|
204
204
|
Object.defineProperty(exports, "EventLog", {
|
|
205
205
|
enumerable: true,
|
|
206
|
-
get: function () { return
|
|
206
|
+
get: function () { return chunkORKC2PK2_cjs.EventLog; }
|
|
207
207
|
});
|
|
208
208
|
Object.defineProperty(exports, "Metrics", {
|
|
209
209
|
enumerable: true,
|
|
210
|
-
get: function () { return
|
|
210
|
+
get: function () { return chunkORKC2PK2_cjs.Metrics; }
|
|
211
211
|
});
|
|
212
212
|
Object.defineProperty(exports, "PTCRuntime", {
|
|
213
213
|
enumerable: true,
|
|
214
|
-
get: function () { return
|
|
214
|
+
get: function () { return chunkORKC2PK2_cjs.PTCRuntime; }
|
|
215
215
|
});
|
|
216
216
|
Object.defineProperty(exports, "PolicyDeniedError", {
|
|
217
217
|
enumerable: true,
|
|
218
|
-
get: function () { return
|
|
218
|
+
get: function () { return chunkORKC2PK2_cjs.PolicyDeniedError; }
|
|
219
219
|
});
|
|
220
220
|
Object.defineProperty(exports, "PolicyEngine", {
|
|
221
221
|
enumerable: true,
|
|
222
|
-
get: function () { return
|
|
222
|
+
get: function () { return chunkORKC2PK2_cjs.PolicyEngine; }
|
|
223
223
|
});
|
|
224
224
|
Object.defineProperty(exports, "SchemaValidationError", {
|
|
225
225
|
enumerable: true,
|
|
226
|
-
get: function () { return
|
|
226
|
+
get: function () { return chunkORKC2PK2_cjs.SchemaValidationError; }
|
|
227
227
|
});
|
|
228
228
|
Object.defineProperty(exports, "SchemaValidator", {
|
|
229
229
|
enumerable: true,
|
|
230
|
-
get: function () { return
|
|
230
|
+
get: function () { return chunkORKC2PK2_cjs.SchemaValidator; }
|
|
231
231
|
});
|
|
232
232
|
Object.defineProperty(exports, "Tracing", {
|
|
233
233
|
enumerable: true,
|
|
234
|
-
get: function () { return
|
|
234
|
+
get: function () { return chunkORKC2PK2_cjs.Tracing; }
|
|
235
235
|
});
|
|
236
236
|
Object.defineProperty(exports, "buildEvidence", {
|
|
237
237
|
enumerable: true,
|
|
238
|
-
get: function () { return
|
|
238
|
+
get: function () { return chunkORKC2PK2_cjs.buildEvidence; }
|
|
239
239
|
});
|
|
240
240
|
Object.defineProperty(exports, "createLogger", {
|
|
241
241
|
enumerable: true,
|
|
242
|
-
get: function () { return
|
|
242
|
+
get: function () { return chunkORKC2PK2_cjs.createLogger; }
|
|
243
243
|
});
|
|
244
244
|
Object.defineProperty(exports, "ensurePackageInCache", {
|
|
245
245
|
enumerable: true,
|
|
246
|
-
get: function () { return
|
|
246
|
+
get: function () { return chunkORKC2PK2_cjs.ensurePackageInCache; }
|
|
247
247
|
});
|
|
248
248
|
Object.defineProperty(exports, "expandToolDescriptorsToRegistryNames", {
|
|
249
249
|
enumerable: true,
|
|
250
|
-
get: function () { return
|
|
250
|
+
get: function () { return chunkORKC2PK2_cjs.expandToolDescriptorsToRegistryNames; }
|
|
251
251
|
});
|
|
252
252
|
Object.defineProperty(exports, "getPackageEntryPath", {
|
|
253
253
|
enumerable: true,
|
|
254
|
-
get: function () { return
|
|
254
|
+
get: function () { return chunkORKC2PK2_cjs.getPackageEntryPath; }
|
|
255
255
|
});
|
|
256
256
|
Object.defineProperty(exports, "importFromCache", {
|
|
257
257
|
enumerable: true,
|
|
258
|
-
get: function () { return
|
|
258
|
+
get: function () { return chunkORKC2PK2_cjs.importFromCache; }
|
|
259
259
|
});
|
|
260
260
|
Object.defineProperty(exports, "isNpmToolDescriptor", {
|
|
261
261
|
enumerable: true,
|
|
262
|
-
get: function () { return
|
|
262
|
+
get: function () { return chunkORKC2PK2_cjs.isNpmToolDescriptor; }
|
|
263
263
|
});
|
|
264
264
|
Object.defineProperty(exports, "loadToolConfig", {
|
|
265
265
|
enumerable: true,
|
|
266
|
-
get: function () { return
|
|
266
|
+
get: function () { return chunkORKC2PK2_cjs.loadToolConfig; }
|
|
267
267
|
});
|
|
268
268
|
Object.defineProperty(exports, "normalizeToolList", {
|
|
269
269
|
enumerable: true,
|
|
270
|
-
get: function () { return
|
|
270
|
+
get: function () { return chunkORKC2PK2_cjs.normalizeToolList; }
|
|
271
271
|
});
|
|
272
272
|
Object.defineProperty(exports, "parseNpmToolDescriptor", {
|
|
273
273
|
enumerable: true,
|
|
274
|
-
get: function () { return
|
|
274
|
+
get: function () { return chunkORKC2PK2_cjs.parseNpmToolDescriptor; }
|
|
275
275
|
});
|
|
276
276
|
Object.defineProperty(exports, "resolveNpmToolDescriptor", {
|
|
277
277
|
enumerable: true,
|
|
278
|
-
get: function () { return
|
|
278
|
+
get: function () { return chunkORKC2PK2_cjs.resolveNpmToolDescriptor; }
|
|
279
279
|
});
|
|
280
280
|
Object.defineProperty(exports, "resolveToolDescriptor", {
|
|
281
281
|
enumerable: true,
|
|
282
|
-
get: function () { return
|
|
282
|
+
get: function () { return chunkORKC2PK2_cjs.resolveToolDescriptor; }
|
|
283
283
|
});
|
|
284
284
|
Object.defineProperty(exports, "sanitizeForLog", {
|
|
285
285
|
enumerable: true,
|
|
286
|
-
get: function () { return
|
|
286
|
+
get: function () { return chunkORKC2PK2_cjs.sanitizeForLog; }
|
|
287
287
|
});
|
|
288
288
|
Object.defineProperty(exports, "summarizeForLog", {
|
|
289
289
|
enumerable: true,
|
|
290
|
-
get: function () { return
|
|
290
|
+
get: function () { return chunkORKC2PK2_cjs.summarizeForLog; }
|
|
291
291
|
});
|
|
292
292
|
Object.defineProperty(exports, "ToolRegistry", {
|
|
293
293
|
enumerable: true,
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { LangChainToolsHub, createAgentTools } from './chunk-
|
|
2
|
-
import { loadMCPTool } from './chunk-
|
|
3
|
-
export { DirectoryScanner, DiscoveryError, SkillManifestError, buildFunctionToTool, buildMcpPackage, initProject, loadMCPTool, loadSkillDefinition, parseSkillMd, runGeneratedMCP, runMcpServer, scan, scanForTools, scanSkillResources, validateFrontmatter } from './chunk-
|
|
1
|
+
export { LangChainToolsHub, createAgentTools } from './chunk-UTRTRLZW.js';
|
|
2
|
+
import { loadMCPTool } from './chunk-CM5YKSRS.js';
|
|
3
|
+
export { DirectoryScanner, DiscoveryError, SkillManifestError, buildFunctionToTool, buildMcpPackage, initProject, loadMCPTool, loadSkillDefinition, parseSkillMd, runGeneratedMCP, runMcpServer, scan, scanForTools, scanSkillResources, validateFrontmatter } from './chunk-CM5YKSRS.js';
|
|
4
4
|
import { DEFAULT_OUTPUT_SCHEMA, DEFAULT_INPUT_SCHEMA } from './chunk-5SWSNVMI.js';
|
|
5
5
|
export { DEFAULT_INPUT_SCHEMA, DEFAULT_OUTPUT_SCHEMA, createToolSpec } from './chunk-5SWSNVMI.js';
|
|
6
|
-
import { MCP_KIND } from './chunk-
|
|
7
|
-
export { BudgetManager, EventLog, Metrics, PTCRuntime, PolicyDeniedError, PolicyEngine, SchemaValidationError, SchemaValidator, Tracing, buildEvidence, createLogger, ensurePackageInCache, expandToolDescriptorsToRegistryNames, getPackageEntryPath, importFromCache, isNpmToolDescriptor, loadToolConfig, normalizeToolList, parseNpmToolDescriptor, resolveNpmToolDescriptor, resolveToolDescriptor, sanitizeForLog, summarizeForLog } from './chunk-
|
|
6
|
+
import { MCP_KIND } from './chunk-FQQDPJ7Z.js';
|
|
7
|
+
export { BudgetManager, EventLog, Metrics, PTCRuntime, PolicyDeniedError, PolicyEngine, SchemaValidationError, SchemaValidator, Tracing, buildEvidence, createLogger, ensurePackageInCache, expandToolDescriptorsToRegistryNames, getPackageEntryPath, importFromCache, isNpmToolDescriptor, loadToolConfig, normalizeToolList, parseNpmToolDescriptor, resolveNpmToolDescriptor, resolveToolDescriptor, sanitizeForLog, summarizeForLog } from './chunk-FQQDPJ7Z.js';
|
|
8
8
|
export { ToolRegistry, createTaggedError, isRetryable, withRetry } from './chunk-AE6FSNGY.js';
|
|
9
9
|
import './chunk-FR2CXERF.js';
|
|
10
10
|
import { join, dirname, basename } from 'path';
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Load tool.yaml:
|
|
3
|
-
*
|
|
2
|
+
* Load tool.yaml: tools config (sandboxedPath + list) or legacy top-level tools + sandboxedPath.
|
|
3
|
+
* Normalized shape: tools (array of descriptors) and sandboxedPath.
|
|
4
4
|
*/
|
|
5
|
-
/**
|
|
5
|
+
/** Normalized shape returned by loadToolConfig: tools list and optional sandboxedPath. */
|
|
6
6
|
export interface ToolYamlShape {
|
|
7
|
+
/** List of tool descriptors (npm:@scope/pkg#path or plain names). */
|
|
7
8
|
tools?: string[];
|
|
8
9
|
/** Root path for fs sandbox; tools can only access under this path. Resolved relative to tool.yaml dir. */
|
|
9
10
|
sandboxedPath?: string;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
|
-
* Load tool.yaml and return tools
|
|
13
|
+
* Load tool.yaml and return normalized shape (tools array + sandboxedPath).
|
|
14
|
+
* Supports:
|
|
15
|
+
* - New format: tools: { sandboxedPath: "...", list: [...] }
|
|
16
|
+
* - Legacy format: tools: [...], sandboxedPath: "..." (top-level)
|
|
13
17
|
*/
|
|
14
18
|
export declare function loadToolConfig(toolYamlPath: string): ToolYamlShape;
|
|
15
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolConfig.d.ts","sourceRoot":"","sources":["../../../src/tools/util/toolConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,
|
|
1
|
+
{"version":3,"file":"toolConfig.d.ts","sourceRoot":"","sources":["../../../src/tools/util/toolConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,0FAA0F;AAC1F,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,2GAA2G;IAC3G,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAcD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAiBlE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CASxF;AAED,oEAAoE;AACpE,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKnF;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAU1F"}
|
package/dist/utils/cli/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunk2SH6IOCF_cjs = require('../../chunk-2SH6IOCF.cjs');
|
|
5
5
|
require('../../chunk-SOFUWEZ6.cjs');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var chunk5NOAYHLP_cjs = require('../../chunk-5NOAYHLP.cjs');
|
|
7
|
+
var chunkORKC2PK2_cjs = require('../../chunk-ORKC2PK2.cjs');
|
|
8
8
|
require('../../chunk-ZNJBRLKN.cjs');
|
|
9
9
|
var chunk6F5JHLZ7_cjs = require('../../chunk-6F5JHLZ7.cjs');
|
|
10
10
|
var path = require('path');
|
|
@@ -18,19 +18,33 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
18
18
|
|
|
19
19
|
({
|
|
20
20
|
sandboxRoot: process.cwd()});
|
|
21
|
-
async function getRuntimeWithTools(pathOpt) {
|
|
21
|
+
async function getRuntimeWithTools(pathOpt, verbose = false) {
|
|
22
22
|
const cwd = process.cwd();
|
|
23
23
|
const searchDir = path__default.default.resolve(cwd, pathOpt ?? ".");
|
|
24
|
-
const
|
|
24
|
+
const stepLog = verbose ? (msg) => process.stderr.write(`[agent-tool] ${msg}
|
|
25
|
+
`) : void 0;
|
|
26
|
+
if (stepLog) stepLog(`Loading tool config from ${searchDir}`);
|
|
27
|
+
const config = chunkORKC2PK2_cjs.findAndLoadToolConfig(searchDir);
|
|
25
28
|
let sandboxRoot = cwd;
|
|
26
29
|
if (config.sandboxedPath && typeof config.sandboxedPath === "string" && config.configPath) {
|
|
27
|
-
sandboxRoot =
|
|
30
|
+
sandboxRoot = chunkORKC2PK2_cjs.resolveSandboxedPath(config.configPath, config.sandboxedPath);
|
|
31
|
+
}
|
|
32
|
+
if (stepLog) {
|
|
33
|
+
if (config.configPath) {
|
|
34
|
+
const n = Array.isArray(config.tools) ? config.tools.length : 0;
|
|
35
|
+
stepLog(`Config: ${config.configPath} (${n} tool(s)), sandbox: ${sandboxRoot}`);
|
|
36
|
+
} else {
|
|
37
|
+
stepLog("No tool.yaml found");
|
|
38
|
+
}
|
|
28
39
|
}
|
|
29
40
|
const coreConfig = { sandboxRoot, allowedHosts: [] };
|
|
30
|
-
|
|
41
|
+
const result = await chunkORKC2PK2_cjs.createRuntimeFromConfig({
|
|
31
42
|
coreTools: coreConfig,
|
|
32
|
-
configFilePath: config.configPath
|
|
43
|
+
configFilePath: config.configPath,
|
|
44
|
+
stepLog
|
|
33
45
|
});
|
|
46
|
+
if (stepLog) stepLog(`Registered ${result.registry.snapshot().length} tool(s)`);
|
|
47
|
+
return result;
|
|
34
48
|
}
|
|
35
49
|
function parseToolName(fullName) {
|
|
36
50
|
const i = fullName.indexOf("/");
|
|
@@ -42,6 +56,7 @@ function parseArgv(argv) {
|
|
|
42
56
|
let command = "help";
|
|
43
57
|
let startSub = "http";
|
|
44
58
|
let help = false;
|
|
59
|
+
let verbose = false;
|
|
45
60
|
let pathOpt = "";
|
|
46
61
|
let outDir = "";
|
|
47
62
|
let include = [];
|
|
@@ -67,6 +82,8 @@ function parseArgv(argv) {
|
|
|
67
82
|
const arg = args[i];
|
|
68
83
|
if (arg === "--help" || arg === "-h") {
|
|
69
84
|
help = true;
|
|
85
|
+
} else if (arg === "--verbose" || arg === "-v") {
|
|
86
|
+
verbose = true;
|
|
70
87
|
} else if (arg === "--path" || arg === "-p") {
|
|
71
88
|
pathOpt = path__default.default.resolve(process.cwd(), args[++i] ?? "");
|
|
72
89
|
} else if (arg === "--out" || arg === "-o") {
|
|
@@ -98,7 +115,7 @@ function parseArgv(argv) {
|
|
|
98
115
|
}
|
|
99
116
|
}
|
|
100
117
|
}
|
|
101
|
-
return { command, startSub, help, pathOpt, outDir, include, includeN8n, toolName, toolArgsJson, port, host };
|
|
118
|
+
return { command, startSub, help, verbose, pathOpt, outDir, include, includeN8n, toolName, toolArgsJson, port, host };
|
|
102
119
|
}
|
|
103
120
|
function printHelp() {
|
|
104
121
|
const bin = "agent-tool";
|
|
@@ -125,6 +142,7 @@ Options:
|
|
|
125
142
|
--out, -o <path> For build: output directory.
|
|
126
143
|
--include, -i <glob> For build: glob for TS files.
|
|
127
144
|
--include-n8n For build: include n8n workflow tools.
|
|
145
|
+
--verbose, -v Print step logs (config load, cache, tools registered).
|
|
128
146
|
--port <number> For start http: port (default: 3000).
|
|
129
147
|
--host <string> For start http: host (default: 127.0.0.1).
|
|
130
148
|
--help, -h Show this help.
|
|
@@ -142,7 +160,7 @@ For agent run (ReAct + agent.yaml): npx @easynet/agent-orchestra run "task" -c a
|
|
|
142
160
|
}
|
|
143
161
|
async function cmdInit(pathOpt) {
|
|
144
162
|
try {
|
|
145
|
-
const { targetPath, filesCreated } = await
|
|
163
|
+
const { targetPath, filesCreated } = await chunk2SH6IOCF_cjs.initProject({ targetPath: pathOpt || void 0 });
|
|
146
164
|
process.stdout.write(`Initialized project at ${targetPath}
|
|
147
165
|
Created: ${filesCreated.join(", ")}
|
|
148
166
|
Next: npm install && npm run build
|
|
@@ -156,7 +174,7 @@ Next: npm install && npm run build
|
|
|
156
174
|
}
|
|
157
175
|
async function cmdBuild(pathOpt, outDir, include, includeN8n) {
|
|
158
176
|
try {
|
|
159
|
-
const result = await
|
|
177
|
+
const result = await chunk2SH6IOCF_cjs.buildMcpPackage({
|
|
160
178
|
projectPath: pathOpt || void 0,
|
|
161
179
|
outDir: outDir || void 0,
|
|
162
180
|
include: include.length > 0 ? include : void 0,
|
|
@@ -177,7 +195,7 @@ mcp.json: ${result.mcpJsonPath}
|
|
|
177
195
|
}
|
|
178
196
|
async function cmdServe(pathOpt) {
|
|
179
197
|
try {
|
|
180
|
-
const { process: child } = await
|
|
198
|
+
const { process: child } = await chunk2SH6IOCF_cjs.runMcpServer({ path: pathOpt || void 0 });
|
|
181
199
|
child.stdin?.pipe(process.stdin);
|
|
182
200
|
child.stdout?.pipe(process.stdout);
|
|
183
201
|
process.stdin?.unref();
|
|
@@ -195,7 +213,7 @@ var LS_DESC_MAX = 72;
|
|
|
195
213
|
function formatLsOutput(specs) {
|
|
196
214
|
const rows = specs.map((spec) => {
|
|
197
215
|
const { name } = parseToolName(spec.name);
|
|
198
|
-
const scope =
|
|
216
|
+
const scope = chunkORKC2PK2_cjs.getDisplayScope(spec.name, spec.kind, spec.version);
|
|
199
217
|
const desc = (spec.description ?? "").replace(/\n/g, " ").trim().slice(0, LS_DESC_MAX);
|
|
200
218
|
return { scope, name, description: desc || "(no description)" };
|
|
201
219
|
});
|
|
@@ -222,7 +240,7 @@ function formatLsOutput(specs) {
|
|
|
222
240
|
}
|
|
223
241
|
function formatDescribeOutput(spec) {
|
|
224
242
|
const { name: localName } = parseToolName(spec.name);
|
|
225
|
-
const scope =
|
|
243
|
+
const scope = chunkORKC2PK2_cjs.getDisplayScope(spec.name, spec.kind, spec.version);
|
|
226
244
|
const sections = [];
|
|
227
245
|
sections.push("\u250C\u2500 Tool");
|
|
228
246
|
sections.push(`\u2502 name: ${spec.name}`);
|
|
@@ -250,15 +268,15 @@ function formatDescribeOutput(spec) {
|
|
|
250
268
|
);
|
|
251
269
|
return sections.join("\n");
|
|
252
270
|
}
|
|
253
|
-
async function cmdLs(pathOpt) {
|
|
271
|
+
async function cmdLs(pathOpt, verbose = false) {
|
|
254
272
|
try {
|
|
255
|
-
const { registry } = await getRuntimeWithTools(pathOpt);
|
|
273
|
+
const { registry } = await getRuntimeWithTools(pathOpt, verbose);
|
|
256
274
|
const specs = registry.snapshot();
|
|
257
275
|
if (specs.length === 0) {
|
|
258
276
|
process.stdout.write("No tools registered.\n");
|
|
259
277
|
const cwd = process.cwd();
|
|
260
278
|
const searchDir = path__default.default.resolve(cwd, pathOpt ?? ".");
|
|
261
|
-
const config =
|
|
279
|
+
const config = chunkORKC2PK2_cjs.findAndLoadToolConfig(searchDir);
|
|
262
280
|
const hasNpmTools = Array.isArray(config.tools) && config.tools.some((t) => typeof t === "string" && t.startsWith("npm:"));
|
|
263
281
|
if (hasNpmTools) {
|
|
264
282
|
process.stdout.write("Tip: Install builtin tools in this directory: npm init -y && npm install @easynet/agent-tool-buildin\n");
|
|
@@ -274,14 +292,14 @@ async function cmdLs(pathOpt) {
|
|
|
274
292
|
return 1;
|
|
275
293
|
}
|
|
276
294
|
}
|
|
277
|
-
async function cmdDescribe(toolName, pathOpt) {
|
|
295
|
+
async function cmdDescribe(toolName, pathOpt, verbose = false) {
|
|
278
296
|
if (!toolName.trim()) {
|
|
279
297
|
process.stderr.write("Usage: agent-tool describe <tool path>\n");
|
|
280
298
|
return 1;
|
|
281
299
|
}
|
|
282
300
|
try {
|
|
283
|
-
const { registry } = await getRuntimeWithTools(pathOpt);
|
|
284
|
-
const registryName =
|
|
301
|
+
const { registry } = await getRuntimeWithTools(pathOpt, verbose);
|
|
302
|
+
const registryName = chunkORKC2PK2_cjs.resolveToolDescriptor(toolName.trim());
|
|
285
303
|
const spec = registry.get(registryName);
|
|
286
304
|
if (!spec) {
|
|
287
305
|
process.stderr.write(`Tool not found: ${toolName}
|
|
@@ -313,7 +331,7 @@ function defaultExecContext() {
|
|
|
313
331
|
]
|
|
314
332
|
};
|
|
315
333
|
}
|
|
316
|
-
async function cmdRun(toolName, toolArgsJson, pathOpt) {
|
|
334
|
+
async function cmdRun(toolName, toolArgsJson, pathOpt, verbose = false) {
|
|
317
335
|
if (!toolName.trim()) {
|
|
318
336
|
process.stderr.write("Usage: agent-tool run <tool path> [<json params>]\n");
|
|
319
337
|
return 1;
|
|
@@ -329,8 +347,8 @@ async function cmdRun(toolName, toolArgsJson, pathOpt) {
|
|
|
329
347
|
}
|
|
330
348
|
}
|
|
331
349
|
try {
|
|
332
|
-
const { runtime, registry } = await getRuntimeWithTools(pathOpt);
|
|
333
|
-
const registryName =
|
|
350
|
+
const { runtime, registry } = await getRuntimeWithTools(pathOpt, verbose);
|
|
351
|
+
const registryName = chunkORKC2PK2_cjs.resolveToolDescriptor(toolName.trim());
|
|
334
352
|
if (!registry.get(registryName)) {
|
|
335
353
|
process.stderr.write(`Tool not found: ${toolName}
|
|
336
354
|
`);
|
|
@@ -354,10 +372,10 @@ async function cmdRun(toolName, toolArgsJson, pathOpt) {
|
|
|
354
372
|
return 1;
|
|
355
373
|
}
|
|
356
374
|
}
|
|
357
|
-
async function cmdStartMcp(pathOpt) {
|
|
375
|
+
async function cmdStartMcp(pathOpt, verbose = false) {
|
|
358
376
|
try {
|
|
359
|
-
const { runtime } = await getRuntimeWithTools(pathOpt);
|
|
360
|
-
await
|
|
377
|
+
const { runtime } = await getRuntimeWithTools(pathOpt, verbose);
|
|
378
|
+
await chunk5NOAYHLP_cjs.runMCPServerOverStdio(runtime);
|
|
361
379
|
return 0;
|
|
362
380
|
} catch (err) {
|
|
363
381
|
process.stderr.write(`start mcp failed: ${err instanceof Error ? err.message : String(err)}
|
|
@@ -365,10 +383,10 @@ async function cmdStartMcp(pathOpt) {
|
|
|
365
383
|
return 1;
|
|
366
384
|
}
|
|
367
385
|
}
|
|
368
|
-
async function cmdStartHttp(port, host, pathOpt) {
|
|
386
|
+
async function cmdStartHttp(port, host, pathOpt, verbose = false) {
|
|
369
387
|
try {
|
|
370
|
-
const { runtime } = await getRuntimeWithTools(pathOpt);
|
|
371
|
-
const http = await
|
|
388
|
+
const { runtime } = await getRuntimeWithTools(pathOpt, verbose);
|
|
389
|
+
const http = await chunk5NOAYHLP_cjs.createHttpService(runtime);
|
|
372
390
|
const { port: actualPort, host: actualHost } = await http.listen({ port, host });
|
|
373
391
|
const base = `http://${actualHost}:${actualPort}`;
|
|
374
392
|
process.stdout.write(`API: ${base}/invoke (POST), ${base}/tools (GET)
|
|
@@ -385,7 +403,7 @@ async function cmdStartHttp(port, host, pathOpt) {
|
|
|
385
403
|
}
|
|
386
404
|
}
|
|
387
405
|
async function main(argv = process.argv) {
|
|
388
|
-
const { command, startSub, help, pathOpt, outDir, include, includeN8n, toolName, toolArgsJson, port, host } = parseArgv(argv);
|
|
406
|
+
const { command, startSub, help, verbose, pathOpt, outDir, include, includeN8n, toolName, toolArgsJson, port, host } = parseArgv(argv);
|
|
389
407
|
if (help || command === "help") {
|
|
390
408
|
printHelp();
|
|
391
409
|
return 0;
|
|
@@ -393,12 +411,12 @@ async function main(argv = process.argv) {
|
|
|
393
411
|
if (command === "init") return cmdInit(pathOpt);
|
|
394
412
|
if (command === "build") return cmdBuild(pathOpt, outDir, include, includeN8n);
|
|
395
413
|
if (command === "serve") return cmdServe(pathOpt);
|
|
396
|
-
if (command === "ls" || command === "list") return cmdLs(pathOpt);
|
|
397
|
-
if (command === "describe" || command === "show") return cmdDescribe(toolName, pathOpt);
|
|
398
|
-
if (command === "run") return cmdRun(toolName, toolArgsJson, pathOpt);
|
|
414
|
+
if (command === "ls" || command === "list") return cmdLs(pathOpt, verbose);
|
|
415
|
+
if (command === "describe" || command === "show") return cmdDescribe(toolName, pathOpt, verbose);
|
|
416
|
+
if (command === "run") return cmdRun(toolName, toolArgsJson, pathOpt, verbose);
|
|
399
417
|
if (command === "start") {
|
|
400
|
-
if (startSub === "mcp") return cmdStartMcp(pathOpt);
|
|
401
|
-
if (startSub === "http") return cmdStartHttp(port, host, pathOpt);
|
|
418
|
+
if (startSub === "mcp") return cmdStartMcp(pathOpt, verbose);
|
|
419
|
+
if (startSub === "http") return cmdStartHttp(port, host, pathOpt, verbose);
|
|
402
420
|
process.stderr.write("Usage: agent-tool start mcp | agent-tool start http [--port 3000] [--host 127.0.0.1]\n");
|
|
403
421
|
return 1;
|
|
404
422
|
}
|