@easynet/agent-tool-hub 1.0.8 → 1.0.9
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/ToolRegistry-wObXj92k.d.cts +196 -0
- package/dist/ToolRegistry-wObXj92k.d.ts +196 -0
- package/dist/chunk-GBNFC46A.js +147 -0
- package/dist/chunk-GBNFC46A.js.map +1 -0
- package/dist/chunk-OOGCRR3P.cjs +151 -0
- package/dist/chunk-OOGCRR3P.cjs.map +1 -0
- package/dist/index.cjs +17 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -53
- package/dist/index.d.ts +6 -53
- package/dist/index.js +2 -64
- package/dist/index.js.map +1 -1
- package/dist/llm-export.cjs +20 -0
- package/dist/llm-export.cjs.map +1 -0
- package/dist/llm-export.d.cts +94 -0
- package/dist/llm-export.d.ts +94 -0
- package/dist/llm-export.js +3 -0
- package/dist/llm-export.js.map +1 -0
- package/dist/{toolhub-runtime-Du3j3gS3.d.cts → toolhub-runtime-DqZOyihh.d.cts} +2 -196
- package/dist/{toolhub-runtime-Du3j3gS3.d.ts → toolhub-runtime-EP-3hIOW.d.ts} +2 -196
- package/dist/toolhub-runtime.d.cts +2 -1
- package/dist/toolhub-runtime.d.ts +2 -1
- package/package.json +2 -1
|
@@ -1,135 +1,8 @@
|
|
|
1
|
+
import { E as Evidence, T as ToolError, a as ToolSpec, b as ExecContext, C as Capability, c as ToolRegistry, d as ToolAdapter, e as ToolIntent, f as ToolResult, B as BudgetConfig } from './ToolRegistry-wObXj92k.js';
|
|
1
2
|
import { N8nLocal } from '@easynet/n8n-local';
|
|
2
3
|
import { ErrorObject } from 'ajv';
|
|
3
4
|
import { BulkheadPolicy, CircuitBreakerPolicy } from 'cockatiel';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* Budget constraints for a tool invocation.
|
|
7
|
-
*/
|
|
8
|
-
interface BudgetConfig {
|
|
9
|
-
timeoutMs?: number;
|
|
10
|
-
maxRetries?: number;
|
|
11
|
-
maxToolCalls?: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Execution context passed from agent-orchestra.
|
|
15
|
-
* Contains permissions, budget, and observability context.
|
|
16
|
-
*/
|
|
17
|
-
interface ExecContext {
|
|
18
|
-
requestId: string;
|
|
19
|
-
taskId: string;
|
|
20
|
-
/** Allowed capabilities for this invocation */
|
|
21
|
-
permissions: Capability[];
|
|
22
|
-
budget?: BudgetConfig;
|
|
23
|
-
/** OpenTelemetry-compatible trace ID */
|
|
24
|
-
traceId?: string;
|
|
25
|
-
userId?: string;
|
|
26
|
-
/** Optional: enable dry-run mode for two-phase commit */
|
|
27
|
-
dryRun?: boolean;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Tool invocation intent from agent-orchestra.
|
|
31
|
-
* Represents what the agent wants to do (untrusted input).
|
|
32
|
-
*/
|
|
33
|
-
interface ToolIntent {
|
|
34
|
-
/** ToolSpec.name reference */
|
|
35
|
-
tool: string;
|
|
36
|
-
/** Untrusted input arguments */
|
|
37
|
-
args: unknown;
|
|
38
|
-
/** Human-readable purpose for audit trail */
|
|
39
|
-
purpose: string;
|
|
40
|
-
/** Idempotency key: recommended format requestId:taskId:tool */
|
|
41
|
-
idempotencyKey?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Unified tool kinds supported by the tools package.
|
|
46
|
-
*/
|
|
47
|
-
type ToolKind = "mcp" | "langchain" | "n8n" | "comfyui" | "skill" | "core";
|
|
48
|
-
/**
|
|
49
|
-
* Capability declarations for tools.
|
|
50
|
-
* Used by PolicyEngine for permission gating.
|
|
51
|
-
*/
|
|
52
|
-
type Capability = "read:web" | "read:fs" | "write:fs" | "read:db" | "write:db" | "network" | "gpu" | "workflow" | "danger:destructive";
|
|
53
|
-
/**
|
|
54
|
-
* Cost hints for tools, used by Budget and routing.
|
|
55
|
-
*/
|
|
56
|
-
interface CostHints {
|
|
57
|
-
latencyMsP50?: number;
|
|
58
|
-
latencyMsP95?: number;
|
|
59
|
-
isAsync?: boolean;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Unified tool specification.
|
|
63
|
-
* All tool types (MCP, LangChain, n8n, ComfyUI, SKILL) are described by this interface.
|
|
64
|
-
*/
|
|
65
|
-
interface ToolSpec {
|
|
66
|
-
/** Globally unique name, recommended format: namespace/name */
|
|
67
|
-
name: string;
|
|
68
|
-
/** Semver version */
|
|
69
|
-
version: string;
|
|
70
|
-
/** Tool kind determines which adapter handles execution */
|
|
71
|
-
kind: ToolKind;
|
|
72
|
-
description?: string;
|
|
73
|
-
tags?: string[];
|
|
74
|
-
/** JSON Schema for input validation */
|
|
75
|
-
inputSchema: object;
|
|
76
|
-
/** JSON Schema for output validation */
|
|
77
|
-
outputSchema: object;
|
|
78
|
-
/** Required capabilities for this tool */
|
|
79
|
-
capabilities: Capability[];
|
|
80
|
-
costHints?: CostHints;
|
|
81
|
-
/** Adapter-specific: endpoint URL (MCP/n8n/ComfyUI) */
|
|
82
|
-
endpoint?: string;
|
|
83
|
-
/** Adapter-specific: resource identifier (workflowId, promptId, etc.) */
|
|
84
|
-
resourceId?: string;
|
|
85
|
-
/** Adapter-specific: implementation reference (LangChain Tool instance, skill handler) */
|
|
86
|
-
impl?: unknown;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Unified adapter interface.
|
|
90
|
-
* Each protocol adapter (MCP, LangChain, n8n, ComfyUI, SKILL) implements this.
|
|
91
|
-
*/
|
|
92
|
-
interface ToolAdapter {
|
|
93
|
-
kind: ToolKind;
|
|
94
|
-
/** Optional: supports dynamic tool discovery */
|
|
95
|
-
listTools?(): Promise<ToolSpec[]>;
|
|
96
|
-
/** Execute the tool with validated args */
|
|
97
|
-
invoke(spec: ToolSpec, args: unknown, ctx: ExecContext): Promise<{
|
|
98
|
-
result: unknown;
|
|
99
|
-
raw?: unknown;
|
|
100
|
-
}>;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Evidence attached to a tool result for audit trail.
|
|
105
|
-
*/
|
|
106
|
-
interface Evidence {
|
|
107
|
-
type: "tool" | "file" | "url" | "text" | "metric";
|
|
108
|
-
ref: string;
|
|
109
|
-
summary: string;
|
|
110
|
-
createdAt: string;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Error information in a tool result.
|
|
114
|
-
*/
|
|
115
|
-
interface ToolError {
|
|
116
|
-
kind?: "TOOL_NOT_FOUND" | "INPUT_SCHEMA_INVALID" | "POLICY_DENIED" | "BUDGET_EXCEEDED" | "TIMEOUT" | "UPSTREAM_ERROR" | "OUTPUT_SCHEMA_INVALID" | "PATH_OUTSIDE_SANDBOX" | "FILE_TOO_LARGE" | "HTTP_DISALLOWED_HOST" | "HTTP_TIMEOUT" | "HTTP_TOO_LARGE";
|
|
117
|
-
message: string;
|
|
118
|
-
details?: unknown;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Unified tool result returned to agent-orchestra.
|
|
122
|
-
* Always structured, never throws raw exceptions.
|
|
123
|
-
*/
|
|
124
|
-
interface ToolResult {
|
|
125
|
-
ok: boolean;
|
|
126
|
-
result?: unknown;
|
|
127
|
-
evidence: Evidence[];
|
|
128
|
-
error?: ToolError;
|
|
129
|
-
/** Raw response for debugging (can be disabled in production) */
|
|
130
|
-
raw?: unknown;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
6
|
/**
|
|
134
7
|
* Event types emitted by PTCRuntime and observability layer.
|
|
135
8
|
*/
|
|
@@ -205,73 +78,6 @@ interface JobFailedEvent extends ToolEvent {
|
|
|
205
78
|
*/
|
|
206
79
|
type AnyToolEvent = ToolCalledEvent | ToolResultEvent | PolicyDeniedEvent | RetryEvent | JobSubmittedEvent | JobCompletedEvent | JobFailedEvent;
|
|
207
80
|
|
|
208
|
-
/**
|
|
209
|
-
* Search query for tools.
|
|
210
|
-
*/
|
|
211
|
-
interface ToolSearchQuery {
|
|
212
|
-
/** Text search in name/description/tags */
|
|
213
|
-
text?: string;
|
|
214
|
-
/** Filter by tool kind */
|
|
215
|
-
kind?: ToolKind;
|
|
216
|
-
/** Filter by required capabilities */
|
|
217
|
-
capabilities?: Capability[];
|
|
218
|
-
/** Filter by tags */
|
|
219
|
-
tags?: string[];
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Tool Registry: manages tool registration, lookup, and search.
|
|
223
|
-
* Supports both static registration and dynamic discovery via adapters.
|
|
224
|
-
*/
|
|
225
|
-
declare class ToolRegistry {
|
|
226
|
-
private readonly tools;
|
|
227
|
-
private readonly tagIndex;
|
|
228
|
-
private readonly kindIndex;
|
|
229
|
-
/**
|
|
230
|
-
* Register a single tool spec.
|
|
231
|
-
* Overwrites if same name already exists.
|
|
232
|
-
*/
|
|
233
|
-
register(spec: ToolSpec): void;
|
|
234
|
-
/**
|
|
235
|
-
* Register multiple tool specs at once.
|
|
236
|
-
*/
|
|
237
|
-
bulkRegister(specs: ToolSpec[]): void;
|
|
238
|
-
/**
|
|
239
|
-
* Unregister a tool by name.
|
|
240
|
-
*/
|
|
241
|
-
unregister(name: string): boolean;
|
|
242
|
-
/**
|
|
243
|
-
* Get a tool spec by name.
|
|
244
|
-
*/
|
|
245
|
-
get(name: string): ToolSpec | undefined;
|
|
246
|
-
/**
|
|
247
|
-
* Check if a tool exists.
|
|
248
|
-
*/
|
|
249
|
-
has(name: string): boolean;
|
|
250
|
-
/**
|
|
251
|
-
* Search tools by query.
|
|
252
|
-
*/
|
|
253
|
-
search(query: ToolSearchQuery): ToolSpec[];
|
|
254
|
-
/**
|
|
255
|
-
* List all registered tool names.
|
|
256
|
-
*/
|
|
257
|
-
list(): string[];
|
|
258
|
-
/**
|
|
259
|
-
* Get count of registered tools.
|
|
260
|
-
*/
|
|
261
|
-
get size(): number;
|
|
262
|
-
/**
|
|
263
|
-
* Export a snapshot of all registered tools (for debugging/routing).
|
|
264
|
-
*/
|
|
265
|
-
snapshot(): ToolSpec[];
|
|
266
|
-
/**
|
|
267
|
-
* Clear all registered tools.
|
|
268
|
-
*/
|
|
269
|
-
clear(): void;
|
|
270
|
-
private validateSpec;
|
|
271
|
-
private indexTool;
|
|
272
|
-
private deindexTool;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
81
|
/**
|
|
276
82
|
* Schema validation result.
|
|
277
83
|
*/
|
|
@@ -1612,4 +1418,4 @@ declare function createToolHubAndInitFromConfig(configPath: string): Promise<Too
|
|
|
1612
1418
|
*/
|
|
1613
1419
|
declare function createAgentToolHub(configPath: string): Promise<AgentToolHub>;
|
|
1614
1420
|
|
|
1615
|
-
export {
|
|
1421
|
+
export { PolicyEngine as $, AgentToolHub as A, BudgetManager as B, ComfyUIAdapter as C, DEFAULT_CORE_TOOLS_CONFIG as D, type EventListener as E, type MCPCallResult as F, type MCPClientLike as G, type HistogramValue as H, type InvokeOptions as I, type JobCompletedEvent as J, type MCPToolDefinition as K, LangChainAdapter as L, MCPAdapter as M, Metrics as N, N8nAdapter as O, type N8nAdapterOptions as P, type N8nInvokeMode as Q, N8nLocalAdapter as R, type SkillDefinition as S, type ToolHubInitOptions as T, type N8nLocalAdapterOptions as U, PTCRuntime as V, type PTCRuntimeConfig as W, type PolicyCheckResult as X, type PolicyConfig as Y, PolicyDeniedError as Z, type PolicyDeniedEvent as _, type SkillFrontmatter as a, type ResolvedDebugOptions as a0, type RetryEvent as a1, SchemaValidationError as a2, SchemaValidator as a3, SkillAdapter as a4, type SkillAdapterOptions as a5, type SkillContext as a6, type SkillHandler as a7, type SkillInstructionResult as a8, type SkillInvocationContext as a9, SkillManifestError as aa, type SkillOutput as ab, type Span as ac, type SpanEvent as ad, type ToolCalledEvent as ae, type ToolDescription as af, type ToolEvent as ag, type ToolEventType as ah, ToolHub as ai, type ToolMetadata as aj, type ToolResultEvent as ak, Tracing as al, type ValidationResult as am, createAgentToolHub as an, createLogger as ao, createToolHub as ap, createToolHubAndInitFromConfig as aq, registerCoreTools as ar, sanitizeForLog as as, summarizeForLog as at, validateFrontmatter as au, createToolHubAndInit as av, type SkillResource as b, type AnyToolEvent as c, type BudgetOptions as d, type ComfyUIAdapterOptions as e, type ComfyUIHistoryEntry as f, type ComfyUIHttpClient as g, type ComfyUIQueueResponse as h, CoreAdapter as i, type CoreToolContext as j, type CoreToolHandler as k, type CoreToolResult as l, type CoreToolsConfig as m, type CoreToolsUserConfig as n, type CounterValue as o, type DebugOptions as p, EventLog as q, type HttpClient as r, type JobFailedEvent as s, type JobSubmittedEvent as t, type LangChainAdapterOptions as u, type LangChainToolLike as v, type LogEntry as w, type LogLevel as x, type Logger as y, type MCPAdapterOptions as z };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { A as AgentToolHub, I as InvokeOptions,
|
|
1
|
+
export { A as AgentToolHub, I as InvokeOptions, ai as ToolHub, T as ToolHubInitOptions, an as createAgentToolHub, ap as createToolHub, av as createToolHubAndInit, aq as createToolHubAndInitFromConfig } from './toolhub-runtime-DqZOyihh.cjs';
|
|
2
|
+
import './ToolRegistry-wObXj92k.cjs';
|
|
2
3
|
import '@easynet/n8n-local';
|
|
3
4
|
import 'ajv';
|
|
4
5
|
import 'cockatiel';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { A as AgentToolHub, I as InvokeOptions,
|
|
1
|
+
export { A as AgentToolHub, I as InvokeOptions, ai as ToolHub, T as ToolHubInitOptions, an as createAgentToolHub, ap as createToolHub, av as createToolHubAndInit, aq as createToolHubAndInitFromConfig } from './toolhub-runtime-EP-3hIOW.js';
|
|
2
|
+
import './ToolRegistry-wObXj92k.js';
|
|
2
3
|
import '@easynet/n8n-local';
|
|
3
4
|
import 'ajv';
|
|
4
5
|
import 'cockatiel';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easynet/agent-tool-hub",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Agent Tool Hub: multi-protocol tool registry, PTC runtime, and adapter layer for MCP/LangChain/n8n/ComfyUI/SKILL",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tsup",
|
|
27
27
|
"dev": "tsup --watch",
|
|
28
|
+
"example:agent-toolhub": "node examples/agent-toolhub-example.mjs",
|
|
28
29
|
"test": "vitest run",
|
|
29
30
|
"test:watch": "vitest",
|
|
30
31
|
"typecheck": "tsc --noEmit",
|