@matimo/core 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +252 -0
- package/destructive-keywords.yaml +70 -0
- package/dist/approval/approval-handler.d.ts +74 -0
- package/dist/approval/approval-handler.d.ts.map +1 -0
- package/dist/approval/approval-handler.js +210 -0
- package/dist/approval/approval-handler.js.map +1 -0
- package/dist/auth/oauth2-config.d.ts +104 -0
- package/dist/auth/oauth2-config.d.ts.map +1 -0
- package/dist/auth/oauth2-config.js +38 -0
- package/dist/auth/oauth2-config.js.map +1 -0
- package/dist/auth/oauth2-handler.d.ts +130 -0
- package/dist/auth/oauth2-handler.d.ts.map +1 -0
- package/dist/auth/oauth2-handler.js +265 -0
- package/dist/auth/oauth2-handler.js.map +1 -0
- package/dist/auth/oauth2-provider-loader.d.ts +68 -0
- package/dist/auth/oauth2-provider-loader.d.ts.map +1 -0
- package/dist/auth/oauth2-provider-loader.js +120 -0
- package/dist/auth/oauth2-provider-loader.js.map +1 -0
- package/dist/core/schema.d.ts +259 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +187 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/tool-loader.d.ts +57 -0
- package/dist/core/tool-loader.d.ts.map +1 -0
- package/dist/core/tool-loader.js +250 -0
- package/dist/core/tool-loader.js.map +1 -0
- package/dist/core/tool-registry.d.ts +48 -0
- package/dist/core/tool-registry.d.ts.map +1 -0
- package/dist/core/tool-registry.js +93 -0
- package/dist/core/tool-registry.js.map +1 -0
- package/dist/core/types.d.ts +162 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +2 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/tool-decorator.d.ts +97 -0
- package/dist/decorators/tool-decorator.d.ts.map +1 -0
- package/dist/decorators/tool-decorator.js +157 -0
- package/dist/decorators/tool-decorator.js.map +1 -0
- package/dist/encodings/parameter-encoding.d.ts +51 -0
- package/dist/encodings/parameter-encoding.d.ts.map +1 -0
- package/dist/encodings/parameter-encoding.js +124 -0
- package/dist/encodings/parameter-encoding.js.map +1 -0
- package/dist/errors/matimo-error.d.ts +41 -0
- package/dist/errors/matimo-error.d.ts.map +1 -0
- package/dist/errors/matimo-error.js +71 -0
- package/dist/errors/matimo-error.js.map +1 -0
- package/dist/executors/command-executor.d.ts +19 -0
- package/dist/executors/command-executor.d.ts.map +1 -0
- package/dist/executors/command-executor.js +98 -0
- package/dist/executors/command-executor.js.map +1 -0
- package/dist/executors/function-executor.d.ts +23 -0
- package/dist/executors/function-executor.d.ts.map +1 -0
- package/dist/executors/function-executor.js +181 -0
- package/dist/executors/function-executor.js.map +1 -0
- package/dist/executors/http-executor.d.ts +78 -0
- package/dist/executors/http-executor.d.ts.map +1 -0
- package/dist/executors/http-executor.js +279 -0
- package/dist/executors/http-executor.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/langchain.d.ts +46 -0
- package/dist/integrations/langchain.d.ts.map +1 -0
- package/dist/integrations/langchain.js +197 -0
- package/dist/integrations/langchain.js.map +1 -0
- package/dist/logging/index.d.ts +3 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +3 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.d.ts +96 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +53 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/logging/winston-logger.d.ts +29 -0
- package/dist/logging/winston-logger.d.ts.map +1 -0
- package/dist/logging/winston-logger.js +73 -0
- package/dist/logging/winston-logger.js.map +1 -0
- package/dist/matimo-instance.d.ts +140 -0
- package/dist/matimo-instance.d.ts.map +1 -0
- package/dist/matimo-instance.js +412 -0
- package/dist/matimo-instance.js.map +1 -0
- package/package.json +96 -0
- package/tools/calculator/calculator.ts +145 -0
- package/tools/calculator/definition.yaml +70 -0
- package/tools/edit/definition.yaml +115 -0
- package/tools/edit/edit.ts +187 -0
- package/tools/execute/definition.yaml +90 -0
- package/tools/execute/execute.ts +207 -0
- package/tools/read/definition.yaml +106 -0
- package/tools/read/read.ts +118 -0
- package/tools/search/definition.yaml +148 -0
- package/tools/search/search.ts +192 -0
- package/tools/web/definition.yaml +132 -0
- package/tools/web/web.ts +134 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as YAML from 'js-yaml';
|
|
4
|
+
import { validateToolDefinition } from './schema';
|
|
5
|
+
import { MatimoError, ErrorCode } from '../errors/matimo-error';
|
|
6
|
+
/**
|
|
7
|
+
* Tool Loader - Loads and validates YAML/JSON tool definitions
|
|
8
|
+
* Implements TDD pattern: test failures guide implementation
|
|
9
|
+
* Features caching for efficient discovery with thousands of tools
|
|
10
|
+
*/
|
|
11
|
+
export class ToolLoader {
|
|
12
|
+
/**
|
|
13
|
+
* Discover packages using only fs and path (no createRequire needed)
|
|
14
|
+
* Searches for tools in node_modules/@matimo/* and workspace packages
|
|
15
|
+
*/
|
|
16
|
+
getNodeModulesPath() {
|
|
17
|
+
try {
|
|
18
|
+
// Start from current working directory and search upwards
|
|
19
|
+
let currentPath = process.cwd();
|
|
20
|
+
for (let i = 0; i < 15; i++) {
|
|
21
|
+
const nodeModules = path.join(currentPath, 'node_modules');
|
|
22
|
+
if (fs.existsSync(nodeModules)) {
|
|
23
|
+
// Verify @matimo scope exists
|
|
24
|
+
const matimoScope = path.join(nodeModules, '@matimo');
|
|
25
|
+
if (fs.existsSync(matimoScope)) {
|
|
26
|
+
return nodeModules;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
currentPath = path.dirname(currentPath);
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Load a single tool from a YAML or JSON file
|
|
39
|
+
* @param filePath - Path to tool definition file
|
|
40
|
+
* @returns Validated tool definition
|
|
41
|
+
* @throws {Error} If file not found or invalid schema
|
|
42
|
+
*/
|
|
43
|
+
loadToolFromFile(filePath) {
|
|
44
|
+
// Read file
|
|
45
|
+
if (!fs.existsSync(filePath)) {
|
|
46
|
+
throw new MatimoError(`Tool file not found: ${filePath}`, ErrorCode.FILE_NOT_FOUND, {
|
|
47
|
+
filePath,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
51
|
+
// Parse based on file extension
|
|
52
|
+
let parsed;
|
|
53
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
54
|
+
if (ext === '.yaml' || ext === '.yml') {
|
|
55
|
+
parsed = YAML.load(content);
|
|
56
|
+
}
|
|
57
|
+
else if (ext === '.json') {
|
|
58
|
+
parsed = JSON.parse(content);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new MatimoError(`Unsupported file format: ${ext}. Use .yaml or .json`, ErrorCode.INVALID_SCHEMA, {
|
|
62
|
+
filePath,
|
|
63
|
+
fileExtension: ext,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// Validate against schema
|
|
67
|
+
try {
|
|
68
|
+
const tool = validateToolDefinition(parsed);
|
|
69
|
+
// Store the definition file path for relative path resolution in executors
|
|
70
|
+
tool._definitionPath = path.resolve(filePath);
|
|
71
|
+
return tool;
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
75
|
+
throw new MatimoError(`Invalid tool definition in ${filePath}:\n${message}`, ErrorCode.INVALID_SCHEMA, {
|
|
76
|
+
filePath,
|
|
77
|
+
originalError: message,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Load all tools from a directory
|
|
83
|
+
* @param dirPath - Path to directory containing tool files
|
|
84
|
+
* @returns Map of tool names to definitions
|
|
85
|
+
* @note Prefers definition.yaml/definition.json over tool.yaml/tool.json
|
|
86
|
+
*/
|
|
87
|
+
loadToolsFromDirectory(dirPath) {
|
|
88
|
+
const tools = new Map();
|
|
89
|
+
if (!fs.existsSync(dirPath)) {
|
|
90
|
+
throw new MatimoError(`Tools directory not found: ${dirPath}`, ErrorCode.FILE_NOT_FOUND, {
|
|
91
|
+
directoryPath: dirPath,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
// Recursively find all definition files (definition.yaml/definition.json preferred)
|
|
95
|
+
// Also finds tool.yaml/tool.json for backwards compatibility
|
|
96
|
+
const findToolFiles = (dir) => {
|
|
97
|
+
const files = [];
|
|
98
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
99
|
+
for (const entry of entries) {
|
|
100
|
+
const fullPath = path.join(dir, entry.name);
|
|
101
|
+
if (entry.isDirectory()) {
|
|
102
|
+
files.push(...findToolFiles(fullPath));
|
|
103
|
+
}
|
|
104
|
+
else if (entry.isFile() &&
|
|
105
|
+
(/^definition\.(yaml|yml|json)$/.test(entry.name) ||
|
|
106
|
+
/^tool\.(yaml|yml|json)$/.test(entry.name))) {
|
|
107
|
+
files.push(fullPath);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return files;
|
|
111
|
+
};
|
|
112
|
+
const toolFiles = findToolFiles(dirPath);
|
|
113
|
+
for (const file of toolFiles) {
|
|
114
|
+
try {
|
|
115
|
+
const tool = this.loadToolFromFile(file);
|
|
116
|
+
// Don't add if we already have this tool (definition.yaml takes precedence)
|
|
117
|
+
if (!tools.has(tool.name)) {
|
|
118
|
+
tools.set(tool.name, tool);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// Skip files that fail validation - they may not be tool definitions
|
|
123
|
+
// (e.g., provider definitions are in tools/ directory but are not tools)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return tools;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Load a tool from a JSON object
|
|
130
|
+
* @param data - Tool definition as object
|
|
131
|
+
* @returns Validated tool definition
|
|
132
|
+
*/
|
|
133
|
+
loadToolFromObject(data) {
|
|
134
|
+
return validateToolDefinition(data);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Auto-discover tool packages in node_modules/@matimo/* and core tools
|
|
138
|
+
* Features efficient caching: first call discovers, subsequent calls return cached result
|
|
139
|
+
* @returns Array of paths to tool directories
|
|
140
|
+
*/
|
|
141
|
+
autoDiscoverPackages() {
|
|
142
|
+
// Return cached paths if already discovered (O(1) lookup)
|
|
143
|
+
if (ToolLoader.discoveredPathsCache !== null) {
|
|
144
|
+
return ToolLoader.discoveredPathsCache;
|
|
145
|
+
}
|
|
146
|
+
const discoveredPaths = [];
|
|
147
|
+
// 1. Discover core tools from workspace (packages/core/tools) or @matimo/core in node_modules
|
|
148
|
+
try {
|
|
149
|
+
// Try node_modules first (@matimo/core)
|
|
150
|
+
const nodeModulesPath = this.getNodeModulesPath();
|
|
151
|
+
if (nodeModulesPath) {
|
|
152
|
+
const coreToolsPath = path.join(nodeModulesPath, '@matimo', 'core', 'tools');
|
|
153
|
+
if (fs.existsSync(coreToolsPath)) {
|
|
154
|
+
discoveredPaths.push(coreToolsPath);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// If not found in node_modules, try workspace
|
|
158
|
+
if (discoveredPaths.length === 0) {
|
|
159
|
+
let currentPath = process.cwd();
|
|
160
|
+
for (let i = 0; i < 20; i++) {
|
|
161
|
+
const coreToolsPath = path.join(currentPath, 'packages', 'core', 'tools');
|
|
162
|
+
if (fs.existsSync(coreToolsPath)) {
|
|
163
|
+
discoveredPaths.push(coreToolsPath);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
currentPath = path.dirname(currentPath);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// Continue if core tools discovery fails
|
|
172
|
+
}
|
|
173
|
+
// 2. Discover @matimo/* packages from node_modules (installed providers like slack, gmail)
|
|
174
|
+
try {
|
|
175
|
+
const nodeModulesPath = this.getNodeModulesPath();
|
|
176
|
+
if (nodeModulesPath && fs.existsSync(nodeModulesPath)) {
|
|
177
|
+
const matimoScopePath = path.join(nodeModulesPath, '@matimo');
|
|
178
|
+
if (fs.existsSync(matimoScopePath)) {
|
|
179
|
+
// Scan @matimo/* directories for tools/
|
|
180
|
+
const entries = fs.readdirSync(matimoScopePath, { withFileTypes: true });
|
|
181
|
+
for (const entry of entries) {
|
|
182
|
+
// Skip core if already discovered
|
|
183
|
+
if (entry.name === 'core') {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
// Handle both real directories and symlinks
|
|
187
|
+
let isDir = entry.isDirectory();
|
|
188
|
+
if (!isDir && !entry.name.startsWith('.')) {
|
|
189
|
+
try {
|
|
190
|
+
// Use statSync to follow symlinks
|
|
191
|
+
isDir = fs.statSync(path.join(matimoScopePath, entry.name)).isDirectory();
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (isDir && !entry.name.startsWith('.')) {
|
|
198
|
+
const toolsPath = path.join(matimoScopePath, entry.name, 'tools');
|
|
199
|
+
if (fs.existsSync(toolsPath)) {
|
|
200
|
+
discoveredPaths.push(toolsPath);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
// Continue even if @matimo discovery fails
|
|
209
|
+
}
|
|
210
|
+
// Cache the results for future calls - this makes subsequent autoDiscoverPackages() calls O(1)
|
|
211
|
+
ToolLoader.discoveredPathsCache = discoveredPaths;
|
|
212
|
+
return discoveredPaths;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Clear the discovery cache (useful for testing or dynamic tool loading scenarios)
|
|
216
|
+
* @internal Used for testing only
|
|
217
|
+
*/
|
|
218
|
+
static clearDiscoveryCache() {
|
|
219
|
+
ToolLoader.discoveredPathsCache = null;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Load tools from multiple directories
|
|
223
|
+
* @param dirPaths - Array of directory paths
|
|
224
|
+
* @returns Combined map of all tools
|
|
225
|
+
*/
|
|
226
|
+
loadToolsFromMultiplePaths(dirPaths) {
|
|
227
|
+
const allTools = new Map();
|
|
228
|
+
for (const dirPath of dirPaths) {
|
|
229
|
+
try {
|
|
230
|
+
const tools = this.loadToolsFromDirectory(dirPath);
|
|
231
|
+
for (const [name, definition] of tools) {
|
|
232
|
+
// Later paths can override earlier ones
|
|
233
|
+
allTools.set(name, definition);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// Continue with other paths even if one fails
|
|
238
|
+
// This allows optional tool packages
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return allTools;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Static cache for discovered paths - populated on first autoDiscover call
|
|
246
|
+
* Subsequent calls return cached result (O(1) instead of O(n))
|
|
247
|
+
*/
|
|
248
|
+
ToolLoader.discoveredPathsCache = null;
|
|
249
|
+
export default ToolLoader;
|
|
250
|
+
//# sourceMappingURL=tool-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-loader.js","sourceRoot":"","sources":["../../src/core/tool-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,K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';
|
|
2
|
+
/**
|
|
3
|
+
* Tool Registry - In-memory store for loaded tools
|
|
4
|
+
* Enables tool discovery and management
|
|
5
|
+
*/
|
|
6
|
+
export declare class ToolRegistry {
|
|
7
|
+
private tools;
|
|
8
|
+
private toolsByTag;
|
|
9
|
+
/**
|
|
10
|
+
* Register a tool in the registry
|
|
11
|
+
* @param tool - Tool definition to register
|
|
12
|
+
*/
|
|
13
|
+
register(tool: ToolDefinition): void;
|
|
14
|
+
/**
|
|
15
|
+
* Register multiple tools
|
|
16
|
+
*/
|
|
17
|
+
registerAll(tools: ToolDefinition[]): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get a tool by name
|
|
20
|
+
*/
|
|
21
|
+
get(name: string): ToolDefinition | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a tool exists
|
|
24
|
+
*/
|
|
25
|
+
has(name: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Get all tools
|
|
28
|
+
*/
|
|
29
|
+
getAll(): ToolDefinition[];
|
|
30
|
+
/**
|
|
31
|
+
* Get tools by tag
|
|
32
|
+
*/
|
|
33
|
+
getByTag(tag: string): ToolDefinition[];
|
|
34
|
+
/**
|
|
35
|
+
* Search tools by name (partial match)
|
|
36
|
+
*/
|
|
37
|
+
search(query: string): ToolDefinition[];
|
|
38
|
+
/**
|
|
39
|
+
* Get total count of registered tools
|
|
40
|
+
*/
|
|
41
|
+
count(): number;
|
|
42
|
+
/**
|
|
43
|
+
* Clear all tools
|
|
44
|
+
*/
|
|
45
|
+
clear(): void;
|
|
46
|
+
}
|
|
47
|
+
export default ToolRegistry;
|
|
48
|
+
//# sourceMappingURL=tool-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../src/core/tool-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C;;;GAGG;AAEH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAA0C;IACvD,OAAO,CAAC,UAAU,CAAuC;IAEzD;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAqBpC;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI;IAM1C;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI7C;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACH,MAAM,IAAI,cAAc,EAAE;IAI1B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,EAAE;IAQvC;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE;IASvC;;OAEG;IACH,KAAK,IAAI,MAAM;IAIf;;OAEG;IACH,KAAK,IAAI,IAAI;CAId;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { MatimoError, ErrorCode } from '../errors/matimo-error';
|
|
2
|
+
/**
|
|
3
|
+
* Tool Registry - In-memory store for loaded tools
|
|
4
|
+
* Enables tool discovery and management
|
|
5
|
+
*/
|
|
6
|
+
export class ToolRegistry {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.tools = new Map();
|
|
9
|
+
this.toolsByTag = new Map();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Register a tool in the registry
|
|
13
|
+
* @param tool - Tool definition to register
|
|
14
|
+
*/
|
|
15
|
+
register(tool) {
|
|
16
|
+
if (this.tools.has(tool.name)) {
|
|
17
|
+
throw new MatimoError(`Tool '${tool.name}' is already registered`, ErrorCode.TOOL_NOT_FOUND, {
|
|
18
|
+
toolName: tool.name,
|
|
19
|
+
reason: 'duplicate_registration',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
this.tools.set(tool.name, tool);
|
|
23
|
+
// Index by tags for discovery
|
|
24
|
+
if (tool.tags && tool.tags.length > 0) {
|
|
25
|
+
for (const tag of tool.tags) {
|
|
26
|
+
if (!this.toolsByTag.has(tag)) {
|
|
27
|
+
this.toolsByTag.set(tag, new Set());
|
|
28
|
+
}
|
|
29
|
+
this.toolsByTag.get(tag).add(tool.name);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register multiple tools
|
|
35
|
+
*/
|
|
36
|
+
registerAll(tools) {
|
|
37
|
+
for (const tool of tools) {
|
|
38
|
+
this.register(tool);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get a tool by name
|
|
43
|
+
*/
|
|
44
|
+
get(name) {
|
|
45
|
+
return this.tools.get(name);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Check if a tool exists
|
|
49
|
+
*/
|
|
50
|
+
has(name) {
|
|
51
|
+
return this.tools.has(name);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get all tools
|
|
55
|
+
*/
|
|
56
|
+
getAll() {
|
|
57
|
+
return Array.from(this.tools.values());
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get tools by tag
|
|
61
|
+
*/
|
|
62
|
+
getByTag(tag) {
|
|
63
|
+
const toolNames = this.toolsByTag.get(tag);
|
|
64
|
+
if (!toolNames)
|
|
65
|
+
return [];
|
|
66
|
+
return Array.from(toolNames)
|
|
67
|
+
.map((name) => this.tools.get(name))
|
|
68
|
+
.filter((tool) => tool !== undefined);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Search tools by name (partial match)
|
|
72
|
+
*/
|
|
73
|
+
search(query) {
|
|
74
|
+
const lowerQuery = query.toLowerCase();
|
|
75
|
+
return this.getAll().filter((tool) => tool.name.toLowerCase().includes(lowerQuery) ||
|
|
76
|
+
tool.description.toLowerCase().includes(lowerQuery));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get total count of registered tools
|
|
80
|
+
*/
|
|
81
|
+
count() {
|
|
82
|
+
return this.tools.size;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Clear all tools
|
|
86
|
+
*/
|
|
87
|
+
clear() {
|
|
88
|
+
this.tools.clear();
|
|
89
|
+
this.toolsByTag.clear();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export default ToolRegistry;
|
|
93
|
+
//# sourceMappingURL=tool-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registry.js","sourceRoot":"","sources":["../../src/core/tool-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;GAGG;AAEH,MAAM,OAAO,YAAY;IAAzB;QACU,UAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;QAC/C,eAAU,GAA6B,IAAI,GAAG,EAAE,CAAC;IA8F3D,CAAC;IA5FC;;;OAGG;IACH,QAAQ,CAAC,IAAoB;QAC3B,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,WAAW,CAAC,SAAS,IAAI,CAAC,IAAI,yBAAyB,EAAE,SAAS,CAAC,cAAc,EAAE;gBAC3F,QAAQ,EAAE,IAAI,CAAC,IAAI;gBACnB,MAAM,EAAE,wBAAwB;aACjC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEhC,8BAA8B;QAC9B,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC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AU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,MAAM,CACzB,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC5C,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CACtD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for Matimo tool ecosystem
|
|
3
|
+
*/
|
|
4
|
+
import { ParameterEncodingConfig } from '../encodings/parameter-encoding';
|
|
5
|
+
/**
|
|
6
|
+
* Parameter definition for a tool
|
|
7
|
+
*/
|
|
8
|
+
export interface Parameter {
|
|
9
|
+
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
10
|
+
description: string;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
enum?: (string | number | boolean)[];
|
|
13
|
+
default?: unknown;
|
|
14
|
+
items?: Parameter;
|
|
15
|
+
properties?: Record<string, Parameter>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Authentication configuration for a tool
|
|
19
|
+
*/
|
|
20
|
+
export interface AuthConfig {
|
|
21
|
+
type: 'none' | 'api_key' | 'oauth2' | 'basic' | 'bearer';
|
|
22
|
+
location?: 'header' | 'query' | 'body';
|
|
23
|
+
name?: string;
|
|
24
|
+
scheme?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* HTTP execution configuration
|
|
28
|
+
*/
|
|
29
|
+
export interface HttpExecution {
|
|
30
|
+
type: 'http';
|
|
31
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
32
|
+
url: string;
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
body?: Record<string, unknown>;
|
|
35
|
+
params?: Record<string, string>;
|
|
36
|
+
query_params?: Record<string, string>;
|
|
37
|
+
parameter_encoding?: ParameterEncodingConfig[];
|
|
38
|
+
timeout?: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Command execution configuration
|
|
42
|
+
*/
|
|
43
|
+
export interface CommandExecution {
|
|
44
|
+
type: 'command';
|
|
45
|
+
command: string;
|
|
46
|
+
args?: string[];
|
|
47
|
+
cwd?: string;
|
|
48
|
+
shell?: boolean;
|
|
49
|
+
timeout?: number;
|
|
50
|
+
env?: Record<string, string>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Function execution configuration
|
|
54
|
+
* Supports embedded async functions for direct execution
|
|
55
|
+
*/
|
|
56
|
+
export interface FunctionExecution {
|
|
57
|
+
type: 'function';
|
|
58
|
+
code: string;
|
|
59
|
+
timeout?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Output schema for tool response validation
|
|
63
|
+
*/
|
|
64
|
+
export interface OutputSchema {
|
|
65
|
+
type: 'object' | 'array' | 'string' | 'number' | 'boolean';
|
|
66
|
+
properties?: Record<string, OutputSchema>;
|
|
67
|
+
items?: OutputSchema;
|
|
68
|
+
description?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Rate limiting configuration
|
|
72
|
+
*/
|
|
73
|
+
export interface RateLimitConfig {
|
|
74
|
+
enabled?: boolean;
|
|
75
|
+
requests_per_minute?: number;
|
|
76
|
+
requests_per_hour?: number;
|
|
77
|
+
burst_size?: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Error handling configuration
|
|
81
|
+
*/
|
|
82
|
+
export interface ErrorHandlingConfig {
|
|
83
|
+
retry?: number;
|
|
84
|
+
backoff_type?: 'exponential' | 'linear' | 'fixed';
|
|
85
|
+
initial_delay_ms?: number;
|
|
86
|
+
max_delay_ms?: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Tool example configuration
|
|
90
|
+
*/
|
|
91
|
+
export interface ToolExample {
|
|
92
|
+
name: string;
|
|
93
|
+
params: Record<string, unknown>;
|
|
94
|
+
description?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Complete tool definition
|
|
98
|
+
*/
|
|
99
|
+
export interface ToolDefinition {
|
|
100
|
+
name: string;
|
|
101
|
+
version: string;
|
|
102
|
+
description: string;
|
|
103
|
+
parameters: Record<string, Parameter>;
|
|
104
|
+
execution: HttpExecution | CommandExecution | FunctionExecution;
|
|
105
|
+
authentication?: AuthConfig;
|
|
106
|
+
output_schema?: OutputSchema;
|
|
107
|
+
rate_limiting?: RateLimitConfig;
|
|
108
|
+
error_handling?: ErrorHandlingConfig;
|
|
109
|
+
examples?: ToolExample[];
|
|
110
|
+
deprecated?: boolean;
|
|
111
|
+
deprecation_message?: string;
|
|
112
|
+
tags?: string[];
|
|
113
|
+
/**
|
|
114
|
+
* Whether this tool requires approval before execution
|
|
115
|
+
* Set to true for destructive operations (CREATE, DELETE, DROP, etc.)
|
|
116
|
+
*/
|
|
117
|
+
requires_approval?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Internal: Path to the tool definition file (set by ToolLoader)
|
|
120
|
+
* Used to resolve relative paths for function executors
|
|
121
|
+
*/
|
|
122
|
+
_definitionPath?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Tool execution result
|
|
126
|
+
*/
|
|
127
|
+
export interface ExecutionResult {
|
|
128
|
+
success: boolean;
|
|
129
|
+
data?: unknown;
|
|
130
|
+
error?: string;
|
|
131
|
+
statusCode?: number;
|
|
132
|
+
duration: number;
|
|
133
|
+
traceId: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Execution context for a tool run
|
|
137
|
+
*/
|
|
138
|
+
export interface ExecutionContext {
|
|
139
|
+
traceId: string;
|
|
140
|
+
userId?: string;
|
|
141
|
+
toolName: string;
|
|
142
|
+
parameters: Record<string, unknown>;
|
|
143
|
+
timestamp: Date;
|
|
144
|
+
secrets: Record<string, string>;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Schema validation error
|
|
148
|
+
*/
|
|
149
|
+
export interface ValidationError {
|
|
150
|
+
field: string;
|
|
151
|
+
message: string;
|
|
152
|
+
expectedType?: string;
|
|
153
|
+
receivedValue?: unknown;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Validation result
|
|
157
|
+
*/
|
|
158
|
+
export interface ValidationResult {
|
|
159
|
+
valid: boolean;
|
|
160
|
+
errors: ValidationError[];
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI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W,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC"}
|