agent-tool-hub 1.0.1 → 1.0.3
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 +17 -198
- 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-2CEY2WAM.js → chunk-HPDQEW2P.js} +214 -233
- package/dist/chunk-HPDQEW2P.js.map +1 -0
- package/dist/{chunk-GD4JXJHB.cjs → chunk-TIKHPRMB.cjs} +216 -238
- package/dist/chunk-TIKHPRMB.cjs.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 +62 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/toolhub-runtime.cjs +12 -11
- package/dist/toolhub-runtime.js +2 -1
- package/package.json +4 -1
- package/dist/chunk-2CEY2WAM.js.map +0 -1
- package/dist/chunk-GD4JXJHB.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,216 +1,35 @@
|
|
|
1
1
|
# Agent Tool Hub
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**One registry, many protocols** — discover and run tools from MCP, LangChain, n8n, ComfyUI, and SKILL through a single PTC runtime.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
### Protocols / Tool Types
|
|
8
|
-
|
|
9
|
-
| Type | How it’s discovered/connected | Typical use |
|
|
10
|
-
| --- | --- | --- |
|
|
11
|
-
| MCP | `mcp.json` (stdio or SSE/HTTP) | Remote tool servers / ecosystem tools |
|
|
12
|
-
| LangChain Tool | `index.js/.mjs` or `langchain/` directory | Local code tools |
|
|
13
|
-
| n8n Workflow | `workflow.json` | Automation workflows |
|
|
14
|
-
| SKILL (Anthropic) | `SKILL.md` (optional `handler.js/.mjs`) | Instructional skills / subflows |
|
|
15
|
-
| Core Tools (built-in) | `roots: coreTools` | Safe FS / HTTP / Utils |
|
|
16
|
-
|
|
17
|
-
### Core Capabilities
|
|
18
|
-
|
|
19
|
-
- Unified ToolSpec abstraction with JSON Schema
|
|
20
|
-
- PTC runtime: validation, policy gating, budgets/retries, evidence
|
|
21
|
-
- Multi-root discovery with namespaces and optional hot-reload
|
|
22
|
-
- Security baseline: sandbox paths, allowlists, SSRF protections
|
|
23
|
-
- Observability: events, metrics, tracing
|
|
24
|
-
- Async workflows for n8n
|
|
25
|
-
|
|
26
|
-
## Quick Start
|
|
27
|
-
|
|
28
|
-
### Install
|
|
5
|
+
## Install
|
|
29
6
|
|
|
30
7
|
```bash
|
|
31
|
-
npm
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
- Node >= 18
|
|
35
|
-
- Optional peers: `@langchain/core`, `@modelcontextprotocol/sdk`
|
|
36
|
-
|
|
37
|
-
### Configure via `toolhub.yaml`
|
|
38
|
-
|
|
39
|
-
Agent Tool Hub is configured by a YAML file. Keep it simple:
|
|
40
|
-
|
|
41
|
-
```yaml
|
|
42
|
-
discovery:
|
|
43
|
-
roots:
|
|
44
|
-
- path: ./tools
|
|
45
|
-
namespace: app
|
|
46
|
-
- path: coreTools
|
|
47
|
-
namespace: core
|
|
48
|
-
config:
|
|
49
|
-
sandboxRoot: /tmp/toolhub-sandbox
|
|
50
|
-
allowedHosts:
|
|
51
|
-
- api.github.com
|
|
52
|
-
- "*.example.com"
|
|
53
|
-
|
|
54
|
-
adapters:
|
|
55
|
-
n8n:
|
|
56
|
-
mode: api
|
|
57
|
-
api:
|
|
58
|
-
apiBaseUrl: http://localhost:5678
|
|
59
|
-
apiKey: ""
|
|
8
|
+
npm install agent-tool-hub
|
|
60
9
|
```
|
|
61
10
|
|
|
62
|
-
|
|
11
|
+
Node 18+ required.
|
|
63
12
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
import { createAgentToolHub } from "agent-tool-hub";
|
|
68
|
-
|
|
69
|
-
const hub = await createAgentToolHub("./toolhub.yaml");
|
|
70
|
-
```
|
|
13
|
+
## Use
|
|
71
14
|
|
|
72
|
-
|
|
15
|
+
**CLI** — add a `toolhub.yaml` in your project, then:
|
|
73
16
|
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
|
|
17
|
+
```bash
|
|
18
|
+
npx agent-tool-hub scan # load tools from configured roots
|
|
19
|
+
npx agent-tool-hub verify # scan and exit 1 on errors
|
|
20
|
+
npx agent-tool-hub list # list discovered tools
|
|
77
21
|
```
|
|
78
22
|
|
|
79
|
-
|
|
23
|
+
**In code** — load from config, init, then invoke:
|
|
80
24
|
|
|
81
25
|
```ts
|
|
82
|
-
|
|
83
|
-
"core/http.fetchJson",
|
|
84
|
-
{ url: "https://api.github.com" },
|
|
85
|
-
{
|
|
86
|
-
permissions: ["network", "read:web"],
|
|
87
|
-
budget: { timeoutMs: 10_000, maxRetries: 1 },
|
|
88
|
-
},
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
if (!result.ok) {
|
|
92
|
-
console.error(result.error);
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Tool Discovery Rules
|
|
97
|
-
|
|
98
|
-
- All subdirectories under each `roots` entry are scanned.
|
|
99
|
-
- Tool kind is inferred by marker files:
|
|
100
|
-
`SKILL.md` / `workflow.json` / `mcp.json` / `index.js(.mjs)`
|
|
101
|
-
- Avoid mixing multiple marker files in the same folder.
|
|
102
|
-
|
|
103
|
-
Example structure:
|
|
104
|
-
|
|
105
|
-
```
|
|
106
|
-
tools/
|
|
107
|
-
weather/
|
|
108
|
-
mcp.json
|
|
109
|
-
notify/
|
|
110
|
-
workflow.json
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Add a New Tool (Recommended)
|
|
114
|
-
|
|
115
|
-
### 1) Create a tool folder
|
|
116
|
-
|
|
117
|
-
```
|
|
118
|
-
./tools/my-tool/
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### 2) Add the tool implementation by kind
|
|
26
|
+
import { createToolHubAndInitFromConfig } from "agent-tool-hub";
|
|
122
27
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
```json
|
|
128
|
-
{ "command": "npx", "args": ["-y", "your-mcp-server"] }
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
or remote:
|
|
132
|
-
|
|
133
|
-
```json
|
|
134
|
-
{ "url": "https://mcp.example.com" }
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
#### LangChain tool
|
|
138
|
-
|
|
139
|
-
Create `index.js/.mjs` that implements LangChain's interface (e.g., `StructuredTool`):
|
|
140
|
-
|
|
141
|
-
```js
|
|
142
|
-
import { StructuredTool } from "@langchain/core/tools";
|
|
143
|
-
import { z } from "zod";
|
|
144
|
-
|
|
145
|
-
class CalculatorTool extends StructuredTool {
|
|
146
|
-
name = "calculator";
|
|
147
|
-
description = "Evaluates simple arithmetic expressions";
|
|
148
|
-
|
|
149
|
-
schema = z.object({
|
|
150
|
-
expression: z.string(),
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
async _call({ expression }) {
|
|
154
|
-
const sanitized = expression.replace(/[^0-9+\\-*/().% ]/g, "");
|
|
155
|
-
if (sanitized !== expression) {
|
|
156
|
-
throw new Error("Invalid characters in expression");
|
|
157
|
-
}
|
|
158
|
-
const result = Function(`\"use strict\"; return (${sanitized})`)();
|
|
159
|
-
return String(result);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export default new CalculatorTool();
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
#### n8n workflow
|
|
167
|
-
|
|
168
|
-
Add `workflow.json` with a `nodes` array:
|
|
169
|
-
|
|
170
|
-
```json
|
|
171
|
-
{ "id": "wf-123", "name": "send-slack", "nodes": [] }
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
- Set `adapters.n8n.mode: api | local` in `toolhub.yaml`.
|
|
175
|
-
- Local mode auto-imports/syncs workflows.
|
|
176
|
-
|
|
177
|
-
#### SKILL
|
|
178
|
-
|
|
179
|
-
Add `SKILL.md` (Anthropic Skills format):
|
|
180
|
-
|
|
181
|
-
```md
|
|
182
|
-
---
|
|
183
|
-
name: send-email
|
|
184
|
-
description: Sends a confirmation email when user completes checkout.
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
Instructions go here.
|
|
28
|
+
const hub = await createToolHubAndInitFromConfig("toolhub.yaml");
|
|
29
|
+
const result = await hub.invokeTool("utils.calculator", { expression: "1 + 2" });
|
|
30
|
+
// result.ok, result.data, result.error, etc.
|
|
188
31
|
```
|
|
189
32
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
## Core Tools (Built-in)
|
|
193
|
-
|
|
194
|
-
- FS: `core/fs.readText`, `core/fs.writeText`, `core/fs.listDir`, `core/fs.searchText`, `core/fs.sha256`, `core/fs.deletePath`
|
|
195
|
-
- HTTP: `core/http.fetchText`, `core/http.fetchJson`, `core/http.downloadFile`, `core/http.head`
|
|
196
|
-
- Utils: `core/util.jsonSelect`, `core/util.truncate`, `core/util.hashText`, `core/util.now`, `core/util.templateRender`
|
|
197
|
-
|
|
198
|
-
Enable via `roots` entry `coreTools` and provide `sandboxRoot` + `allowedHosts`.
|
|
199
|
-
|
|
200
|
-
## Permissions and Capabilities
|
|
201
|
-
|
|
202
|
-
Common capabilities:
|
|
203
|
-
|
|
204
|
-
- `read:web`, `network`
|
|
205
|
-
- `read:fs`, `write:fs`
|
|
206
|
-
- `read:db`, `write:db`
|
|
207
|
-
- `workflow`, `gpu`
|
|
208
|
-
- `danger:destructive`
|
|
209
|
-
|
|
210
|
-
Pass `permissions` when invoking tools to satisfy policy gates.
|
|
211
|
-
|
|
212
|
-
## Publishing (maintainers)
|
|
213
|
-
|
|
214
|
-
Releases are automated via GitHub Actions (`.github/workflows/release.yml`). On push to `master`, tests and build run, then [semantic-release](https://github.com/semantic-release/semantic-release) publishes to npm (patch-only).
|
|
33
|
+
Or build the hub yourself: `createToolHub(options)` → `await hub.initAllTools()`; run tools with `hub.invokeTool(name, args, options)`.
|
|
215
34
|
|
|
216
|
-
|
|
35
|
+
See `toolhub.yaml` for config and `examples/` for tool layouts.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createToolHub, loadToolHubConfig } from './chunk-HPDQEW2P.js';
|
|
2
|
+
|
|
3
|
+
// src/toolhub-runtime.ts
|
|
4
|
+
async function createToolHubAndInit(options) {
|
|
5
|
+
const hub = createToolHub(options);
|
|
6
|
+
await hub.initAllTools();
|
|
7
|
+
return hub;
|
|
8
|
+
}
|
|
9
|
+
async function createToolHubAndInitFromConfig(configPath) {
|
|
10
|
+
const { options } = await loadToolHubConfig(configPath);
|
|
11
|
+
return createToolHubAndInit(options);
|
|
12
|
+
}
|
|
13
|
+
async function createAgentToolHub(configPath) {
|
|
14
|
+
return createToolHubAndInitFromConfig(configPath);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { createAgentToolHub, createToolHubAndInit, createToolHubAndInitFromConfig };
|
|
18
|
+
//# sourceMappingURL=chunk-57LVNNHL.js.map
|
|
19
|
+
//# sourceMappingURL=chunk-57LVNNHL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/toolhub-runtime.ts"],"names":[],"mappings":";;;AAKA,eAAsB,qBACpB,OAAA,EACA;AACA,EAAA,MAAM,GAAA,GAAM,cAAc,OAAO,CAAA;AACjC,EAAA,MAAM,IAAI,YAAA,EAAa;AACvB,EAAA,OAAO,GAAA;AACT;AAEA,eAAsB,+BAA+B,UAAA,EAAoB;AACvE,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,MAAM,kBAAkB,UAAU,CAAA;AACtD,EAAA,OAAO,qBAAqB,OAAO,CAAA;AACrC;AAEA,eAAsB,mBAAmB,UAAA,EAAoB;AAC3D,EAAA,OAAO,+BAA+B,UAAU,CAAA;AAClD","file":"chunk-57LVNNHL.js","sourcesContent":["import { ToolHub, createToolHub } from \"./tool-hub/ToolHub.js\";\nimport { loadToolHubConfig } from \"./config/ToolHubConfig.js\";\nexport { ToolHub, createToolHub };\nexport type { ToolHubInitOptions, InvokeOptions } from \"./tool-hub/ToolHub.js\";\n\nexport async function createToolHubAndInit(\n options: import(\"./tool-hub/ToolHub.js\").ToolHubInitOptions,\n) {\n const hub = createToolHub(options);\n await hub.initAllTools();\n return hub;\n}\n\nexport async function createToolHubAndInitFromConfig(configPath: string) {\n const { options } = await loadToolHubConfig(configPath);\n return createToolHubAndInit(options);\n}\n\nexport async function createAgentToolHub(configPath: string) {\n return createToolHubAndInitFromConfig(configPath);\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkTIKHPRMB_cjs = require('./chunk-TIKHPRMB.cjs');
|
|
4
|
+
|
|
5
|
+
// src/toolhub-runtime.ts
|
|
6
|
+
async function createToolHubAndInit(options) {
|
|
7
|
+
const hub = chunkTIKHPRMB_cjs.createToolHub(options);
|
|
8
|
+
await hub.initAllTools();
|
|
9
|
+
return hub;
|
|
10
|
+
}
|
|
11
|
+
async function createToolHubAndInitFromConfig(configPath) {
|
|
12
|
+
const { options } = await chunkTIKHPRMB_cjs.loadToolHubConfig(configPath);
|
|
13
|
+
return createToolHubAndInit(options);
|
|
14
|
+
}
|
|
15
|
+
async function createAgentToolHub(configPath) {
|
|
16
|
+
return createToolHubAndInitFromConfig(configPath);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.createAgentToolHub = createAgentToolHub;
|
|
20
|
+
exports.createToolHubAndInit = createToolHubAndInit;
|
|
21
|
+
exports.createToolHubAndInitFromConfig = createToolHubAndInitFromConfig;
|
|
22
|
+
//# sourceMappingURL=chunk-6QTWECRD.cjs.map
|
|
23
|
+
//# sourceMappingURL=chunk-6QTWECRD.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/toolhub-runtime.ts"],"names":["createToolHub","loadToolHubConfig"],"mappings":";;;;;AAKA,eAAsB,qBACpB,OAAA,EACA;AACA,EAAA,MAAM,GAAA,GAAMA,gCAAc,OAAO,CAAA;AACjC,EAAA,MAAM,IAAI,YAAA,EAAa;AACvB,EAAA,OAAO,GAAA;AACT;AAEA,eAAsB,+BAA+B,UAAA,EAAoB;AACvE,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,MAAMC,oCAAkB,UAAU,CAAA;AACtD,EAAA,OAAO,qBAAqB,OAAO,CAAA;AACrC;AAEA,eAAsB,mBAAmB,UAAA,EAAoB;AAC3D,EAAA,OAAO,+BAA+B,UAAU,CAAA;AAClD","file":"chunk-6QTWECRD.cjs","sourcesContent":["import { ToolHub, createToolHub } from \"./tool-hub/ToolHub.js\";\nimport { loadToolHubConfig } from \"./config/ToolHubConfig.js\";\nexport { ToolHub, createToolHub };\nexport type { ToolHubInitOptions, InvokeOptions } from \"./tool-hub/ToolHub.js\";\n\nexport async function createToolHubAndInit(\n options: import(\"./tool-hub/ToolHub.js\").ToolHubInitOptions,\n) {\n const hub = createToolHub(options);\n await hub.initAllTools();\n return hub;\n}\n\nexport async function createToolHubAndInitFromConfig(configPath: string) {\n const { options } = await loadToolHubConfig(configPath);\n return createToolHubAndInit(options);\n}\n\nexport async function createAgentToolHub(configPath: string) {\n return createToolHubAndInitFromConfig(configPath);\n}\n"]}
|