@easynet/agent-tool-hub 1.0.6
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 +132 -0
- package/dist/N8nLocalAdapter-6RKQJXJP.js +4 -0
- package/dist/N8nLocalAdapter-6RKQJXJP.js.map +1 -0
- package/dist/N8nLocalAdapter-MDWME5ZG.cjs +13 -0
- package/dist/N8nLocalAdapter-MDWME5ZG.cjs.map +1 -0
- package/dist/chunk-57LVNNHL.js +19 -0
- package/dist/chunk-57LVNNHL.js.map +1 -0
- package/dist/chunk-6QTWECRD.cjs +23 -0
- package/dist/chunk-6QTWECRD.cjs.map +1 -0
- package/dist/chunk-HPDQEW2P.js +5251 -0
- package/dist/chunk-HPDQEW2P.js.map +1 -0
- package/dist/chunk-MHEFFZBB.js +134 -0
- package/dist/chunk-MHEFFZBB.js.map +1 -0
- package/dist/chunk-NTTBDQUF.cjs +118 -0
- package/dist/chunk-NTTBDQUF.cjs.map +1 -0
- package/dist/chunk-TIKHPRMB.cjs +5313 -0
- package/dist/chunk-TIKHPRMB.cjs.map +1 -0
- package/dist/chunk-X53WXBKX.cjs +136 -0
- package/dist/chunk-X53WXBKX.cjs.map +1 -0
- package/dist/chunk-YSYEED4K.js +114 -0
- package/dist/chunk-YSYEED4K.js.map +1 -0
- package/dist/cli.cjs +194 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +10 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +186 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +592 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +552 -0
- package/dist/index.d.ts +552 -0
- package/dist/index.js +358 -0
- package/dist/index.js.map +1 -0
- package/dist/toolhub-runtime-CQkP4QVW.d.cts +1564 -0
- package/dist/toolhub-runtime-CQkP4QVW.d.ts +1564 -0
- package/dist/toolhub-runtime.cjs +30 -0
- package/dist/toolhub-runtime.cjs.map +1 -0
- package/dist/toolhub-runtime.d.cts +4 -0
- package/dist/toolhub-runtime.d.ts +4 -0
- package/dist/toolhub-runtime.js +5 -0
- package/dist/toolhub-runtime.js.map +1 -0
- package/package.json +77 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
import { T as ToolSpec, E as ExecContext, a as Evidence, b as ToolRegistry, c as ToolAdapter, S as SkillDefinition, d as SkillFrontmatter, e as SkillResource, f as ToolKind, C as Capability, g as CostHints, h as ToolHubInitOptions } from './toolhub-runtime-CQkP4QVW.js';
|
|
2
|
+
export { A as AnyToolEvent, B as BudgetConfig, i as BudgetManager, j as BudgetOptions, k as ComfyUIAdapter, l as ComfyUIAdapterOptions, m as ComfyUIHistoryEntry, n as ComfyUIHttpClient, o as ComfyUIQueueResponse, p as CoreAdapter, q as CoreToolContext, r as CoreToolHandler, s as CoreToolResult, t as CoreToolsConfig, u as CoreToolsUserConfig, v as CounterValue, D as DEFAULT_CORE_TOOLS_CONFIG, w as DebugOptions, x as EventListener, y as EventLog, H as HistogramValue, z as HttpClient, I as InvokeOptions, J as JobCompletedEvent, F as JobFailedEvent, G as JobSubmittedEvent, L as LangChainAdapter, K as LangChainAdapterOptions, M as LangChainToolLike, N as LogEntry, O as LogLevel, P as Logger, Q as MCPAdapter, R as MCPAdapterOptions, U as MCPCallResult, V as MCPClientLike, W as MCPToolDefinition, X as Metrics, Y as N8nAdapter, Z as N8nAdapterOptions, _ as N8nInvokeMode, $ as N8nLocalAdapter, a0 as N8nLocalAdapterOptions, a1 as PTCRuntime, a2 as PTCRuntimeConfig, a3 as PolicyCheckResult, a4 as PolicyConfig, a5 as PolicyDeniedError, a6 as PolicyDeniedEvent, a7 as PolicyEngine, a8 as ResolvedDebugOptions, a9 as RetryEvent, aa as SchemaValidationError, ab as SchemaValidator, ac as SkillAdapter, ad as SkillAdapterOptions, ae as SkillContext, af as SkillHandler, ag as SkillInstructionResult, ah as SkillInvocationContext, ai as SkillManifestError, aj as SkillOutput, ak as Span, al as SpanEvent, am as ToolCalledEvent, an as ToolDescription, ao as ToolError, ap as ToolEvent, aq as ToolEventType, ar as ToolHub, as as ToolIntent, at as ToolMetadata, au as ToolResult, av as ToolResultEvent, aw as ToolSearchQuery, ax as Tracing, ay as ValidationResult, az as createAgentToolHub, aA as createLogger, aB as createToolHub, aC as createToolHubAndInitFromConfig, aD as registerCoreTools, aE as sanitizeForLog, aF as summarizeForLog, aG as validateFrontmatter } from './toolhub-runtime-CQkP4QVW.js';
|
|
3
|
+
import '@easynet/n8n-local';
|
|
4
|
+
import 'ajv';
|
|
5
|
+
import 'cockatiel';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Retry configuration.
|
|
9
|
+
*/
|
|
10
|
+
interface RetryOptions {
|
|
11
|
+
/** Maximum number of retries (default: 2) */
|
|
12
|
+
maxRetries?: number;
|
|
13
|
+
/** Base delay in ms for exponential backoff (default: 1000) */
|
|
14
|
+
baseDelayMs?: number;
|
|
15
|
+
/** Maximum delay in ms (default: 10000) */
|
|
16
|
+
maxDelayMs?: number;
|
|
17
|
+
/** Jitter factor 0-1 (default: 0.1) */
|
|
18
|
+
jitter?: number;
|
|
19
|
+
/** Error filter: return true to retry, false to abort */
|
|
20
|
+
shouldRetry?: (error: Error) => boolean;
|
|
21
|
+
/** Callback on each retry attempt */
|
|
22
|
+
onRetry?: (error: Error, attempt: number) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Determine if an error is retryable.
|
|
26
|
+
*/
|
|
27
|
+
declare function isRetryable(error: unknown): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Execute a function with retry logic using exponential backoff.
|
|
30
|
+
*/
|
|
31
|
+
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Create a tagged error with a kind field for retry classification.
|
|
34
|
+
*/
|
|
35
|
+
declare function createTaggedError(kind: string, message: string, details?: unknown): Error & {
|
|
36
|
+
kind: string;
|
|
37
|
+
details?: unknown;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Options for building evidence from a tool invocation.
|
|
42
|
+
*/
|
|
43
|
+
interface BuildEvidenceOptions {
|
|
44
|
+
spec: ToolSpec;
|
|
45
|
+
args: unknown;
|
|
46
|
+
result: unknown;
|
|
47
|
+
raw?: unknown;
|
|
48
|
+
ctx: ExecContext;
|
|
49
|
+
durationMs?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build evidence records from a tool invocation result.
|
|
53
|
+
*/
|
|
54
|
+
declare function buildEvidence(options: BuildEvidenceOptions): Evidence[];
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Discovery source configuration.
|
|
58
|
+
*/
|
|
59
|
+
interface DiscoverySource {
|
|
60
|
+
/** Unique identifier for this source */
|
|
61
|
+
id: string;
|
|
62
|
+
/** The adapter that supports listTools() */
|
|
63
|
+
adapter: ToolAdapter;
|
|
64
|
+
/** Refresh interval in ms (0 = manual only) */
|
|
65
|
+
refreshIntervalMs?: number;
|
|
66
|
+
/** Whether to auto-discover on startup */
|
|
67
|
+
autoDiscover?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Discovery manager that pulls tool specs from adapters
|
|
71
|
+
* and registers them into the ToolRegistry.
|
|
72
|
+
*/
|
|
73
|
+
declare class Discovery {
|
|
74
|
+
private readonly sources;
|
|
75
|
+
private readonly timers;
|
|
76
|
+
private readonly registry;
|
|
77
|
+
private readonly lastRefresh;
|
|
78
|
+
private readonly discoveredTools;
|
|
79
|
+
constructor(registry: ToolRegistry);
|
|
80
|
+
/**
|
|
81
|
+
* Add a discovery source.
|
|
82
|
+
*/
|
|
83
|
+
addSource(source: DiscoverySource): void;
|
|
84
|
+
/**
|
|
85
|
+
* Remove a discovery source and its registered tools.
|
|
86
|
+
*/
|
|
87
|
+
removeSource(id: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Refresh tools from a specific source (or all sources).
|
|
90
|
+
*/
|
|
91
|
+
refresh(sourceId?: string): Promise<ToolSpec[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Get the last refresh timestamp for a source.
|
|
94
|
+
*/
|
|
95
|
+
getLastRefresh(sourceId: string): number | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Get all registered source IDs.
|
|
98
|
+
*/
|
|
99
|
+
getSources(): string[];
|
|
100
|
+
/**
|
|
101
|
+
* Stop all refresh timers.
|
|
102
|
+
*/
|
|
103
|
+
dispose(): void;
|
|
104
|
+
private refreshSource;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Job status in the lifecycle.
|
|
109
|
+
*/
|
|
110
|
+
type JobStatus = "queued" | "running" | "completed" | "failed";
|
|
111
|
+
/**
|
|
112
|
+
* A job record representing an async tool invocation.
|
|
113
|
+
*/
|
|
114
|
+
interface Job {
|
|
115
|
+
jobId: string;
|
|
116
|
+
toolName: string;
|
|
117
|
+
requestId: string;
|
|
118
|
+
taskId: string;
|
|
119
|
+
status: JobStatus;
|
|
120
|
+
createdAt: number;
|
|
121
|
+
updatedAt: number;
|
|
122
|
+
result?: unknown;
|
|
123
|
+
error?: string;
|
|
124
|
+
metadata?: Record<string, unknown>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Options for submitting a job.
|
|
128
|
+
*/
|
|
129
|
+
interface SubmitJobOptions {
|
|
130
|
+
toolName: string;
|
|
131
|
+
requestId: string;
|
|
132
|
+
taskId: string;
|
|
133
|
+
metadata?: Record<string, unknown>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Job store interface for pluggable backends.
|
|
137
|
+
*/
|
|
138
|
+
interface JobStore {
|
|
139
|
+
set(jobId: string, job: Job): Promise<void>;
|
|
140
|
+
get(jobId: string): Promise<Job | undefined>;
|
|
141
|
+
list(filter?: {
|
|
142
|
+
toolName?: string;
|
|
143
|
+
status?: JobStatus;
|
|
144
|
+
}): Promise<Job[]>;
|
|
145
|
+
delete(jobId: string): Promise<void>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* In-memory job store (default, for PoC and testing).
|
|
149
|
+
*/
|
|
150
|
+
declare class InMemoryJobStore implements JobStore {
|
|
151
|
+
private readonly jobs;
|
|
152
|
+
set(jobId: string, job: Job): Promise<void>;
|
|
153
|
+
get(jobId: string): Promise<Job | undefined>;
|
|
154
|
+
list(filter?: {
|
|
155
|
+
toolName?: string;
|
|
156
|
+
status?: JobStatus;
|
|
157
|
+
}): Promise<Job[]>;
|
|
158
|
+
delete(jobId: string): Promise<void>;
|
|
159
|
+
get size(): number;
|
|
160
|
+
clear(): void;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Async Job Manager: unified async task handling for tools.
|
|
164
|
+
* Provides submit/poll/getResult pattern.
|
|
165
|
+
*/
|
|
166
|
+
declare class AsyncJobManager {
|
|
167
|
+
private readonly store;
|
|
168
|
+
private readonly emitter;
|
|
169
|
+
private readonly ttlMs;
|
|
170
|
+
private cleanupTimer?;
|
|
171
|
+
constructor(options?: {
|
|
172
|
+
store?: JobStore;
|
|
173
|
+
ttlMs?: number;
|
|
174
|
+
});
|
|
175
|
+
/**
|
|
176
|
+
* Submit a new async job.
|
|
177
|
+
*/
|
|
178
|
+
submit(options: SubmitJobOptions): Promise<Job>;
|
|
179
|
+
/**
|
|
180
|
+
* Update job status to running.
|
|
181
|
+
*/
|
|
182
|
+
markRunning(jobId: string): Promise<Job | undefined>;
|
|
183
|
+
/**
|
|
184
|
+
* Complete a job with a result.
|
|
185
|
+
*/
|
|
186
|
+
complete(jobId: string, result: unknown): Promise<Job | undefined>;
|
|
187
|
+
/**
|
|
188
|
+
* Fail a job with an error message.
|
|
189
|
+
*/
|
|
190
|
+
fail(jobId: string, error: string): Promise<Job | undefined>;
|
|
191
|
+
/**
|
|
192
|
+
* Get current job status.
|
|
193
|
+
*/
|
|
194
|
+
getStatus(jobId: string): Promise<JobStatus | undefined>;
|
|
195
|
+
/**
|
|
196
|
+
* Get the full job record.
|
|
197
|
+
*/
|
|
198
|
+
getJob(jobId: string): Promise<Job | undefined>;
|
|
199
|
+
/**
|
|
200
|
+
* Get the result of a completed job.
|
|
201
|
+
*/
|
|
202
|
+
getResult(jobId: string): Promise<unknown | undefined>;
|
|
203
|
+
/**
|
|
204
|
+
* List jobs with optional filter.
|
|
205
|
+
*/
|
|
206
|
+
list(filter?: {
|
|
207
|
+
toolName?: string;
|
|
208
|
+
status?: JobStatus;
|
|
209
|
+
}): Promise<Job[]>;
|
|
210
|
+
/**
|
|
211
|
+
* Subscribe to job events.
|
|
212
|
+
*/
|
|
213
|
+
on(event: "submitted" | "running" | "completed" | "failed", listener: (job: Job) => void): () => void;
|
|
214
|
+
/**
|
|
215
|
+
* Stop cleanup timer.
|
|
216
|
+
*/
|
|
217
|
+
dispose(): void;
|
|
218
|
+
private startCleanup;
|
|
219
|
+
private cleanup;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Parse a SKILL.md file into its constituent parts:
|
|
224
|
+
* - YAML frontmatter (metadata)
|
|
225
|
+
* - Markdown body (instructions)
|
|
226
|
+
*
|
|
227
|
+
* Supports the standard YAML frontmatter format:
|
|
228
|
+
* ```
|
|
229
|
+
* ---
|
|
230
|
+
* name: my-skill
|
|
231
|
+
* description: Does something useful
|
|
232
|
+
* ---
|
|
233
|
+
*
|
|
234
|
+
* # Instructions here...
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
declare function parseSkillMd(content: string, filePath: string): {
|
|
238
|
+
frontmatter: SkillFrontmatter;
|
|
239
|
+
instructions: string;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Scan a skill directory for bundled resource files (Level 3).
|
|
243
|
+
* Recursively finds all files except SKILL.md and tool.json.
|
|
244
|
+
*/
|
|
245
|
+
declare function scanSkillResources(dirPath: string): Promise<SkillResource[]>;
|
|
246
|
+
/**
|
|
247
|
+
* Load and parse a complete skill from a directory containing SKILL.md.
|
|
248
|
+
* Returns the full SkillDefinition with all three progressive disclosure levels.
|
|
249
|
+
*/
|
|
250
|
+
declare function loadSkillDefinition(dirPath: string): Promise<SkillDefinition>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Resolve an input path to an absolute path within the sandbox.
|
|
254
|
+
* Throws PATH_OUTSIDE_SANDBOX if the resolved path escapes the sandbox root.
|
|
255
|
+
*
|
|
256
|
+
* For existing files: uses realpath to resolve symlinks.
|
|
257
|
+
* For non-existing files (write targets): resolves the parent directory.
|
|
258
|
+
*/
|
|
259
|
+
declare function resolveSandboxedPath(inputPath: string, sandboxRoot: string): Promise<string>;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Validate a URL against allowed hosts and blocked CIDRs.
|
|
263
|
+
* Prevents SSRF by checking both hostname allowlist and resolved IP addresses.
|
|
264
|
+
*
|
|
265
|
+
* @throws HTTP_DISALLOWED_HOST if the URL is blocked
|
|
266
|
+
*/
|
|
267
|
+
declare function validateUrl(url: string, allowedHosts: string[], blockedCidrs: string[]): Promise<URL>;
|
|
268
|
+
/**
|
|
269
|
+
* Check if an IPv4 address falls within any blocked CIDR range.
|
|
270
|
+
*/
|
|
271
|
+
declare function isIpInBlockedCidrs(ip: string, cidrs: string[]): boolean;
|
|
272
|
+
|
|
273
|
+
declare const readTextSpec: ToolSpec;
|
|
274
|
+
|
|
275
|
+
declare const writeTextSpec: ToolSpec;
|
|
276
|
+
|
|
277
|
+
declare const listDirSpec: ToolSpec;
|
|
278
|
+
|
|
279
|
+
declare const searchTextSpec: ToolSpec;
|
|
280
|
+
|
|
281
|
+
declare const sha256Spec: ToolSpec;
|
|
282
|
+
|
|
283
|
+
declare const deletePathSpec: ToolSpec;
|
|
284
|
+
|
|
285
|
+
declare const fetchTextSpec: ToolSpec;
|
|
286
|
+
|
|
287
|
+
declare const fetchJsonSpec: ToolSpec;
|
|
288
|
+
|
|
289
|
+
declare const downloadFileSpec: ToolSpec;
|
|
290
|
+
|
|
291
|
+
declare const headSpec: ToolSpec;
|
|
292
|
+
|
|
293
|
+
declare const jsonSelectSpec: ToolSpec;
|
|
294
|
+
|
|
295
|
+
declare const truncateSpec: ToolSpec;
|
|
296
|
+
|
|
297
|
+
declare const hashTextSpec: ToolSpec;
|
|
298
|
+
|
|
299
|
+
declare const nowSpec: ToolSpec;
|
|
300
|
+
|
|
301
|
+
declare const templateRenderSpec: ToolSpec;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Cursor-compatible MCP server configuration.
|
|
305
|
+
* Supports command-based (stdio) and URL-based (SSE/HTTP) servers.
|
|
306
|
+
*/
|
|
307
|
+
interface MCPServerConfig {
|
|
308
|
+
/** Command to spawn the MCP server process */
|
|
309
|
+
command?: string;
|
|
310
|
+
/** Arguments for the command */
|
|
311
|
+
args?: string[];
|
|
312
|
+
/** Environment variables for the spawned process */
|
|
313
|
+
env?: Record<string, string>;
|
|
314
|
+
/** SSE/HTTP URL for remote MCP server */
|
|
315
|
+
url?: string;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Discoverable tool kinds (subset of ToolKind that can be directory-discovered).
|
|
319
|
+
*/
|
|
320
|
+
type DiscoverableKind = Extract<ToolKind, "mcp" | "langchain" | "skill" | "n8n">;
|
|
321
|
+
/**
|
|
322
|
+
* Tool manifest read from tool.json or inferred from conventional files.
|
|
323
|
+
*/
|
|
324
|
+
interface ToolManifest {
|
|
325
|
+
/** Tool kind — determines which loader and adapter handle this tool */
|
|
326
|
+
kind: DiscoverableKind;
|
|
327
|
+
/** Tool name override (default: "<namespace>/<dirname>") */
|
|
328
|
+
name?: string;
|
|
329
|
+
/** Semver version (default: "1.0.0") */
|
|
330
|
+
version?: string;
|
|
331
|
+
/** Human-readable description */
|
|
332
|
+
description?: string;
|
|
333
|
+
/** Searchable tags */
|
|
334
|
+
tags?: string[];
|
|
335
|
+
/** Required capabilities for PolicyEngine gating */
|
|
336
|
+
capabilities?: Capability[];
|
|
337
|
+
/** Cost hints for routing/budgeting */
|
|
338
|
+
costHints?: CostHints;
|
|
339
|
+
/**
|
|
340
|
+
* Entry point file relative to tool directory.
|
|
341
|
+
* Defaults per kind:
|
|
342
|
+
* mcp → "mcp.json"
|
|
343
|
+
* langchain → "index" (or all *.js/*.mjs files when inside a "langchain" folder)
|
|
344
|
+
* skill → "handler"
|
|
345
|
+
* n8n → "workflow.json"
|
|
346
|
+
*/
|
|
347
|
+
entryPoint?: string;
|
|
348
|
+
/** JSON Schema for input validation */
|
|
349
|
+
inputSchema?: object;
|
|
350
|
+
/** JSON Schema for output validation */
|
|
351
|
+
outputSchema?: object;
|
|
352
|
+
/** Whether this tool is enabled (default: true). Set false to skip. */
|
|
353
|
+
enabled?: boolean;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Configuration for the DirectoryScanner.
|
|
357
|
+
*/
|
|
358
|
+
interface DirectoryScannerOptions {
|
|
359
|
+
/** One or more root directories to scan for tool subdirectories */
|
|
360
|
+
roots: Array<string | {
|
|
361
|
+
path: string;
|
|
362
|
+
namespace?: string;
|
|
363
|
+
}>;
|
|
364
|
+
/** Namespace prefix for discovered tool names (default: "dir") */
|
|
365
|
+
namespace?: string;
|
|
366
|
+
/** File extensions to try for JS/TS entry points (default: [".js", ".mjs"]) */
|
|
367
|
+
extensions?: string[];
|
|
368
|
+
/** Callback for non-fatal errors during scan (tool dir path, error) */
|
|
369
|
+
onError?: (toolDir: string, error: Error) => void;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Result from loading a single tool directory.
|
|
373
|
+
*/
|
|
374
|
+
interface LoadedTool {
|
|
375
|
+
/** The parsed manifest */
|
|
376
|
+
manifest: ToolManifest;
|
|
377
|
+
/** Absolute path to the tool directory */
|
|
378
|
+
dirPath: string;
|
|
379
|
+
/** Loaded implementation (LangChainToolLike instance or SkillHandler function) */
|
|
380
|
+
impl?: unknown;
|
|
381
|
+
/** For MCP tools: the parsed server config from mcp.json */
|
|
382
|
+
mcpConfig?: MCPServerConfig;
|
|
383
|
+
/** For n8n tools: the parsed workflow definition */
|
|
384
|
+
workflowDef?: unknown;
|
|
385
|
+
/** For Skill tools: the parsed SKILL.md definition with progressive disclosure levels */
|
|
386
|
+
skillDefinition?: SkillDefinition;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Scans filesystem directories for tool definitions.
|
|
391
|
+
* A tool can be declared via tool.json or inferred from conventional files
|
|
392
|
+
* (SKILL.md, workflow.json, mcp.json, or an index entry point).
|
|
393
|
+
*/
|
|
394
|
+
declare class DirectoryScanner {
|
|
395
|
+
private readonly roots;
|
|
396
|
+
private readonly extensions;
|
|
397
|
+
private readonly onError?;
|
|
398
|
+
constructor(options: DirectoryScannerOptions);
|
|
399
|
+
/**
|
|
400
|
+
* Scan all root directories and return discovered ToolSpecs.
|
|
401
|
+
* Errors in individual tool directories are reported via onError
|
|
402
|
+
* and do not prevent other tools from loading.
|
|
403
|
+
*/
|
|
404
|
+
scan(): Promise<ToolSpec[]>;
|
|
405
|
+
private scanRoot;
|
|
406
|
+
/**
|
|
407
|
+
* Recursively scan directories for tool definitions.
|
|
408
|
+
* Directories can be detected via tool.json or inferred markers.
|
|
409
|
+
*/
|
|
410
|
+
private scanRecursive;
|
|
411
|
+
private loadToolDir;
|
|
412
|
+
private inferManifest;
|
|
413
|
+
private fileExists;
|
|
414
|
+
private hasEntryPoint;
|
|
415
|
+
private hasLangchainFiles;
|
|
416
|
+
private listLangchainEntryFiles;
|
|
417
|
+
private loadByKind;
|
|
418
|
+
private loadLangChainTools;
|
|
419
|
+
private toToolSpec;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* A ToolAdapter that discovers tools from filesystem directories.
|
|
424
|
+
* Used as the adapter within a DiscoverySource for the Discovery system.
|
|
425
|
+
*
|
|
426
|
+
* Note: This adapter's invoke() is not called directly. Discovered tools
|
|
427
|
+
* retain their original kind (mcp/langchain/skill/n8n) and are invoked
|
|
428
|
+
* by the kind-specific adapter registered on PTCRuntime.
|
|
429
|
+
*/
|
|
430
|
+
declare class DirectoryToolAdapter implements ToolAdapter {
|
|
431
|
+
readonly kind: "mcp";
|
|
432
|
+
private readonly scanner;
|
|
433
|
+
constructor(options: DirectoryScannerOptions);
|
|
434
|
+
/**
|
|
435
|
+
* Scan directories and return discovered tool specs.
|
|
436
|
+
* Called by Discovery.refresh().
|
|
437
|
+
*/
|
|
438
|
+
listTools(): Promise<ToolSpec[]>;
|
|
439
|
+
/**
|
|
440
|
+
* Not used — actual invocation routes through kind-specific adapters.
|
|
441
|
+
*/
|
|
442
|
+
invoke(_spec: ToolSpec, _args: unknown, _ctx: ExecContext): Promise<{
|
|
443
|
+
result: unknown;
|
|
444
|
+
}>;
|
|
445
|
+
/**
|
|
446
|
+
* Get the underlying scanner for direct usage.
|
|
447
|
+
*/
|
|
448
|
+
getScanner(): DirectoryScanner;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Options for creating a directory discovery source.
|
|
452
|
+
*/
|
|
453
|
+
interface DirectoryDiscoveryOptions extends DirectoryScannerOptions {
|
|
454
|
+
/** Refresh interval in ms (0 = manual only, default: 0) */
|
|
455
|
+
refreshIntervalMs?: number;
|
|
456
|
+
/** Whether to auto-discover on startup (default: true) */
|
|
457
|
+
autoDiscover?: boolean;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Factory: create a DiscoverySource for directory-based tool discovery.
|
|
461
|
+
*
|
|
462
|
+
* Usage:
|
|
463
|
+
* ```ts
|
|
464
|
+
* const discovery = new Discovery(registry);
|
|
465
|
+
* discovery.addSource(
|
|
466
|
+
* createDirectoryDiscoverySource("local-tools", {
|
|
467
|
+
* roots: ["/path/to/tools"],
|
|
468
|
+
* namespace: "local",
|
|
469
|
+
* refreshIntervalMs: 60_000,
|
|
470
|
+
* autoDiscover: true,
|
|
471
|
+
* })
|
|
472
|
+
* );
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
declare function createDirectoryDiscoverySource(id: string, options: DirectoryDiscoveryOptions): DiscoverySource;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Connection info for an MCP server.
|
|
479
|
+
*/
|
|
480
|
+
interface MCPConnectionInfo {
|
|
481
|
+
/** Transport type: "url" for SSE/HTTP, "stdio" for command-based */
|
|
482
|
+
type: "url" | "stdio";
|
|
483
|
+
/** SSE/HTTP URL (when type="url") */
|
|
484
|
+
url?: string;
|
|
485
|
+
/** Command to spawn (when type="stdio") */
|
|
486
|
+
command?: string;
|
|
487
|
+
/** Command arguments (when type="stdio") */
|
|
488
|
+
args?: string[];
|
|
489
|
+
/** Environment variables (when type="stdio") */
|
|
490
|
+
env?: Record<string, string>;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Manages MCP server connection information extracted from directory discovery.
|
|
494
|
+
*
|
|
495
|
+
* This class provides connection configuration for MCP servers discovered
|
|
496
|
+
* from mcp.json files. The actual MCP client creation and lifecycle management
|
|
497
|
+
* is the consumer's responsibility (using @modelcontextprotocol/sdk or similar).
|
|
498
|
+
*
|
|
499
|
+
* Usage:
|
|
500
|
+
* ```ts
|
|
501
|
+
* const manager = new MCPProcessManager();
|
|
502
|
+
* const info = manager.getConnectionInfo("my-tool", mcpConfig);
|
|
503
|
+
* if (info.type === "stdio") {
|
|
504
|
+
* // Spawn process with info.command, info.args, info.env
|
|
505
|
+
* } else {
|
|
506
|
+
* // Connect SSE client to info.url
|
|
507
|
+
* }
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
declare class MCPProcessManager {
|
|
511
|
+
private readonly connections;
|
|
512
|
+
/**
|
|
513
|
+
* Get connection info for an MCP tool based on its config.
|
|
514
|
+
* Caches the result by tool name.
|
|
515
|
+
*/
|
|
516
|
+
getConnectionInfo(toolName: string, config: MCPServerConfig): MCPConnectionInfo;
|
|
517
|
+
/**
|
|
518
|
+
* Remove cached connection info for a tool.
|
|
519
|
+
*/
|
|
520
|
+
remove(toolName: string): boolean;
|
|
521
|
+
/**
|
|
522
|
+
* Get all registered tool names.
|
|
523
|
+
*/
|
|
524
|
+
getToolNames(): string[];
|
|
525
|
+
/**
|
|
526
|
+
* Clear all cached connection info.
|
|
527
|
+
*/
|
|
528
|
+
dispose(): void;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Error thrown during directory-based tool discovery.
|
|
533
|
+
*/
|
|
534
|
+
declare class DiscoveryError extends Error {
|
|
535
|
+
/** Absolute path to the tool directory that caused the error */
|
|
536
|
+
readonly toolDir: string;
|
|
537
|
+
/** Phase in which the error occurred */
|
|
538
|
+
readonly phase: "manifest" | "load" | "validate";
|
|
539
|
+
/** The underlying cause */
|
|
540
|
+
readonly cause?: Error;
|
|
541
|
+
constructor(toolDir: string, phase: "manifest" | "load" | "validate", message: string, cause?: Error);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
interface ToolHubConfigLoadResult {
|
|
545
|
+
configPath: string;
|
|
546
|
+
rawConfig: unknown;
|
|
547
|
+
options: ToolHubInitOptions;
|
|
548
|
+
}
|
|
549
|
+
declare function mapToolHubConfig(raw: unknown, configDir: string): ToolHubInitOptions;
|
|
550
|
+
declare function loadToolHubConfig(configPath: string): Promise<ToolHubConfigLoadResult>;
|
|
551
|
+
|
|
552
|
+
export { AsyncJobManager, type BuildEvidenceOptions, Capability, CostHints, type DirectoryDiscoveryOptions, DirectoryScanner, type DirectoryScannerOptions, DirectoryToolAdapter, type DiscoverableKind, Discovery, DiscoveryError, type DiscoverySource, Evidence, ExecContext, InMemoryJobStore, type Job, type JobStatus, type JobStore, type LoadedTool, type MCPConnectionInfo, MCPProcessManager, type MCPServerConfig, type RetryOptions, SkillDefinition, SkillFrontmatter, SkillResource, type SubmitJobOptions, ToolAdapter, type ToolHubConfigLoadResult, ToolHubInitOptions, ToolKind, type ToolManifest, ToolRegistry, ToolSpec, buildEvidence, createDirectoryDiscoverySource, createTaggedError, deletePathSpec, downloadFileSpec, fetchJsonSpec, fetchTextSpec, hashTextSpec, headSpec, isIpInBlockedCidrs, isRetryable, jsonSelectSpec, listDirSpec, loadSkillDefinition, loadToolHubConfig, mapToolHubConfig, nowSpec, parseSkillMd, readTextSpec, resolveSandboxedPath, scanSkillResources, searchTextSpec, sha256Spec, templateRenderSpec, truncateSpec, validateUrl, withRetry, writeTextSpec };
|