@matimo/core 0.1.0-alpha.4

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.
Files changed (77) hide show
  1. package/LICENSE +21 -0
  2. package/dist/src/auth/oauth2-config.d.ts +104 -0
  3. package/dist/src/auth/oauth2-config.d.ts.map +1 -0
  4. package/dist/src/auth/oauth2-config.js +38 -0
  5. package/dist/src/auth/oauth2-config.js.map +1 -0
  6. package/dist/src/auth/oauth2-handler.d.ts +130 -0
  7. package/dist/src/auth/oauth2-handler.d.ts.map +1 -0
  8. package/dist/src/auth/oauth2-handler.js +265 -0
  9. package/dist/src/auth/oauth2-handler.js.map +1 -0
  10. package/dist/src/auth/oauth2-provider-loader.d.ts +68 -0
  11. package/dist/src/auth/oauth2-provider-loader.d.ts.map +1 -0
  12. package/dist/src/auth/oauth2-provider-loader.js +120 -0
  13. package/dist/src/auth/oauth2-provider-loader.js.map +1 -0
  14. package/dist/src/core/schema.d.ts +248 -0
  15. package/dist/src/core/schema.d.ts.map +1 -0
  16. package/dist/src/core/schema.js +182 -0
  17. package/dist/src/core/schema.js.map +1 -0
  18. package/dist/src/core/tool-loader.d.ts +45 -0
  19. package/dist/src/core/tool-loader.d.ts.map +1 -0
  20. package/dist/src/core/tool-loader.js +205 -0
  21. package/dist/src/core/tool-loader.js.map +1 -0
  22. package/dist/src/core/tool-registry.d.ts +48 -0
  23. package/dist/src/core/tool-registry.d.ts.map +1 -0
  24. package/dist/src/core/tool-registry.js +93 -0
  25. package/dist/src/core/tool-registry.js.map +1 -0
  26. package/dist/src/core/types.d.ts +157 -0
  27. package/dist/src/core/types.d.ts.map +1 -0
  28. package/dist/src/core/types.js +5 -0
  29. package/dist/src/core/types.js.map +1 -0
  30. package/dist/src/decorators/index.d.ts +2 -0
  31. package/dist/src/decorators/index.d.ts.map +1 -0
  32. package/dist/src/decorators/index.js +2 -0
  33. package/dist/src/decorators/index.js.map +1 -0
  34. package/dist/src/decorators/tool-decorator.d.ts +97 -0
  35. package/dist/src/decorators/tool-decorator.d.ts.map +1 -0
  36. package/dist/src/decorators/tool-decorator.js +157 -0
  37. package/dist/src/decorators/tool-decorator.js.map +1 -0
  38. package/dist/src/encodings/parameter-encoding.d.ts +51 -0
  39. package/dist/src/encodings/parameter-encoding.d.ts.map +1 -0
  40. package/dist/src/encodings/parameter-encoding.js +123 -0
  41. package/dist/src/encodings/parameter-encoding.js.map +1 -0
  42. package/dist/src/errors/matimo-error.d.ts +34 -0
  43. package/dist/src/errors/matimo-error.d.ts.map +1 -0
  44. package/dist/src/errors/matimo-error.js +49 -0
  45. package/dist/src/errors/matimo-error.js.map +1 -0
  46. package/dist/src/executors/command-executor.d.ts +19 -0
  47. package/dist/src/executors/command-executor.d.ts.map +1 -0
  48. package/dist/src/executors/command-executor.js +98 -0
  49. package/dist/src/executors/command-executor.js.map +1 -0
  50. package/dist/src/executors/function-executor.d.ts +23 -0
  51. package/dist/src/executors/function-executor.d.ts.map +1 -0
  52. package/dist/src/executors/function-executor.js +164 -0
  53. package/dist/src/executors/function-executor.js.map +1 -0
  54. package/dist/src/executors/http-executor.d.ts +26 -0
  55. package/dist/src/executors/http-executor.d.ts.map +1 -0
  56. package/dist/src/executors/http-executor.js +137 -0
  57. package/dist/src/executors/http-executor.js.map +1 -0
  58. package/dist/src/index.d.ts +26 -0
  59. package/dist/src/index.d.ts.map +1 -0
  60. package/dist/src/index.js +26 -0
  61. package/dist/src/index.js.map +1 -0
  62. package/dist/src/integrations/langchain.d.ts +46 -0
  63. package/dist/src/integrations/langchain.d.ts.map +1 -0
  64. package/dist/src/integrations/langchain.js +197 -0
  65. package/dist/src/integrations/langchain.js.map +1 -0
  66. package/dist/src/matimo-instance.d.ts +124 -0
  67. package/dist/src/matimo-instance.d.ts.map +1 -0
  68. package/dist/src/matimo-instance.js +313 -0
  69. package/dist/src/matimo-instance.js.map +1 -0
  70. package/dist/tools/calculator/calculator.d.ts +26 -0
  71. package/dist/tools/calculator/calculator.d.ts.map +1 -0
  72. package/dist/tools/calculator/calculator.js +104 -0
  73. package/dist/tools/calculator/calculator.js.map +1 -0
  74. package/dist/tsconfig.tsbuildinfo +1 -0
  75. package/package.json +94 -0
  76. package/tools/calculator/calculator.ts +125 -0
  77. package/tools/calculator/definition.yaml +71 -0
@@ -0,0 +1,205 @@
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
+ */
10
+ export class ToolLoader {
11
+ /**
12
+ * Load a single tool from a YAML or JSON file
13
+ * @param filePath - Path to tool definition file
14
+ * @returns Validated tool definition
15
+ * @throws {Error} If file not found or invalid schema
16
+ */
17
+ loadToolFromFile(filePath) {
18
+ // Read file
19
+ if (!fs.existsSync(filePath)) {
20
+ throw new MatimoError(`Tool file not found: ${filePath}`, ErrorCode.FILE_NOT_FOUND, {
21
+ filePath,
22
+ });
23
+ }
24
+ const content = fs.readFileSync(filePath, 'utf-8');
25
+ // Parse based on file extension
26
+ let parsed;
27
+ const ext = path.extname(filePath).toLowerCase();
28
+ if (ext === '.yaml' || ext === '.yml') {
29
+ parsed = YAML.load(content);
30
+ }
31
+ else if (ext === '.json') {
32
+ parsed = JSON.parse(content);
33
+ }
34
+ else {
35
+ throw new MatimoError(`Unsupported file format: ${ext}. Use .yaml or .json`, ErrorCode.INVALID_SCHEMA, {
36
+ filePath,
37
+ fileExtension: ext,
38
+ });
39
+ }
40
+ // Validate against schema
41
+ try {
42
+ const tool = validateToolDefinition(parsed);
43
+ // Store the definition file path for relative path resolution in executors
44
+ tool._definitionPath = path.resolve(filePath);
45
+ return tool;
46
+ }
47
+ catch (error) {
48
+ const message = error instanceof Error ? error.message : String(error);
49
+ throw new MatimoError(`Invalid tool definition in ${filePath}:\n${message}`, ErrorCode.INVALID_SCHEMA, {
50
+ filePath,
51
+ originalError: message,
52
+ });
53
+ }
54
+ }
55
+ /**
56
+ * Load all tools from a directory
57
+ * @param dirPath - Path to directory containing tool files
58
+ * @returns Map of tool names to definitions
59
+ * @note Prefers definition.yaml/definition.json over tool.yaml/tool.json
60
+ */
61
+ loadToolsFromDirectory(dirPath) {
62
+ const tools = new Map();
63
+ if (!fs.existsSync(dirPath)) {
64
+ throw new MatimoError(`Tools directory not found: ${dirPath}`, ErrorCode.FILE_NOT_FOUND, {
65
+ directoryPath: dirPath,
66
+ });
67
+ }
68
+ // Recursively find all definition files (definition.yaml/definition.json preferred)
69
+ // Also finds tool.yaml/tool.json for backwards compatibility
70
+ const findToolFiles = (dir) => {
71
+ const files = [];
72
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
73
+ for (const entry of entries) {
74
+ const fullPath = path.join(dir, entry.name);
75
+ if (entry.isDirectory()) {
76
+ files.push(...findToolFiles(fullPath));
77
+ }
78
+ else if (entry.isFile() &&
79
+ (/^definition\.(yaml|yml|json)$/.test(entry.name) ||
80
+ /^tool\.(yaml|yml|json)$/.test(entry.name))) {
81
+ files.push(fullPath);
82
+ }
83
+ }
84
+ return files;
85
+ };
86
+ const toolFiles = findToolFiles(dirPath);
87
+ for (const file of toolFiles) {
88
+ try {
89
+ const tool = this.loadToolFromFile(file);
90
+ // Don't add if we already have this tool (definition.yaml takes precedence)
91
+ if (!tools.has(tool.name)) {
92
+ tools.set(tool.name, tool);
93
+ }
94
+ }
95
+ catch {
96
+ // Skip files that fail validation - they may not be tool definitions
97
+ // (e.g., provider definitions are in tools/ directory but are not tools)
98
+ }
99
+ }
100
+ return tools;
101
+ }
102
+ /**
103
+ * Load a tool from a JSON object
104
+ * @param data - Tool definition as object
105
+ * @returns Validated tool definition
106
+ */
107
+ loadToolFromObject(data) {
108
+ return validateToolDefinition(data);
109
+ }
110
+ /**
111
+ * Auto-discover tool packages in node_modules/@matimo/*
112
+ * @returns Array of paths to tool directories
113
+ */
114
+ autoDiscoverPackages() {
115
+ try {
116
+ // Get the node_modules path (handle both workspace and normal installations)
117
+ const nodeModulesPath = this.getNodeModulesPath();
118
+ if (!nodeModulesPath || !fs.existsSync(nodeModulesPath)) {
119
+ return [];
120
+ }
121
+ const matimoScopePath = path.join(nodeModulesPath, '@matimo');
122
+ if (!fs.existsSync(matimoScopePath)) {
123
+ return [];
124
+ }
125
+ // Scan @matimo/* directories for tools/
126
+ const discoveredPaths = [];
127
+ const entries = fs.readdirSync(matimoScopePath, { withFileTypes: true });
128
+ for (const entry of entries) {
129
+ // Handle both real directories and symlinks
130
+ // isDirectory() returns false for symlinks, so we need to check the actual target
131
+ let isDir = entry.isDirectory();
132
+ if (!isDir && !entry.name.startsWith('.')) {
133
+ try {
134
+ // Use statSync to follow symlinks
135
+ isDir = fs.statSync(path.join(matimoScopePath, entry.name)).isDirectory();
136
+ }
137
+ catch {
138
+ // If statSync fails, skip this entry
139
+ continue;
140
+ }
141
+ }
142
+ if (isDir && !entry.name.startsWith('.')) {
143
+ const toolsPath = path.join(matimoScopePath, entry.name, 'tools');
144
+ if (fs.existsSync(toolsPath)) {
145
+ discoveredPaths.push(toolsPath);
146
+ }
147
+ }
148
+ }
149
+ return discoveredPaths;
150
+ }
151
+ catch {
152
+ // If auto-discovery fails (e.g., in development), return empty array
153
+ return [];
154
+ }
155
+ }
156
+ /**
157
+ * Get node_modules path intelligently
158
+ * Works in both normal and monorepo installations
159
+ */
160
+ getNodeModulesPath() {
161
+ try {
162
+ // Start from current working directory and search upwards
163
+ let currentPath = process.cwd();
164
+ for (let i = 0; i < 15; i++) {
165
+ const nodeModules = path.join(currentPath, 'node_modules');
166
+ if (fs.existsSync(nodeModules)) {
167
+ // Verify @matimo scope exists
168
+ const matimoScope = path.join(nodeModules, '@matimo');
169
+ if (fs.existsSync(matimoScope)) {
170
+ return nodeModules;
171
+ }
172
+ }
173
+ currentPath = path.dirname(currentPath);
174
+ }
175
+ return null;
176
+ }
177
+ catch {
178
+ return null;
179
+ }
180
+ }
181
+ /**
182
+ * Load tools from multiple directories
183
+ * @param dirPaths - Array of directory paths
184
+ * @returns Combined map of all tools
185
+ */
186
+ loadToolsFromMultiplePaths(dirPaths) {
187
+ const allTools = new Map();
188
+ for (const dirPath of dirPaths) {
189
+ try {
190
+ const tools = this.loadToolsFromDirectory(dirPath);
191
+ for (const [name, definition] of tools) {
192
+ // Later paths can override earlier ones
193
+ allTools.set(name, definition);
194
+ }
195
+ }
196
+ catch {
197
+ // Continue with other paths even if one fails
198
+ // This allows optional tool packages
199
+ }
200
+ }
201
+ return allTools;
202
+ }
203
+ }
204
+ export default ToolLoader;
205
+ //# 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,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAkB,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;GAGG;AAEH,MAAM,OAAO,UAAU;IACrB;;;;;OAKG;IACH,gBAAgB,CAAC,QAAgB;QAC/B,YAAY;QACZ,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,WAAW,CAAC,wBAAwB,QAAQ,EAAE,EAAE,SAAS,CAAC,cAAc,EAAE;gBAClF,QAAQ;aACT,CAAC,CAAC;QACL,CAAC;QAED,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAEnD,gCAAgC;QAChC,IAAI,MAAe,CAAC;QACpB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,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AC,QAAkB;QAC3C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;QAEnD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;gBACnD,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,KAAK,EAAE,CAAC;oBACvC,wCAAwC;oBACxC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBACjC,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,8CAA8C;gBAC9C,qCAAqC;YACvC,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { ToolDefinition } from './schema';
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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AAe,YAAY,CAAC"}
@@ -0,0 +1,157 @@
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
+ * Internal: Path to the tool definition file (set by ToolLoader)
115
+ * Used to resolve relative paths for function executors
116
+ */
117
+ _definitionPath?: string;
118
+ }
119
+ /**
120
+ * Tool execution result
121
+ */
122
+ export interface ExecutionResult {
123
+ success: boolean;
124
+ data?: unknown;
125
+ error?: string;
126
+ statusCode?: number;
127
+ duration: number;
128
+ traceId: string;
129
+ }
130
+ /**
131
+ * Execution context for a tool run
132
+ */
133
+ export interface ExecutionContext {
134
+ traceId: string;
135
+ userId?: string;
136
+ toolName: string;
137
+ parameters: Record<string, unknown>;
138
+ timestamp: Date;
139
+ secrets: Record<string, string>;
140
+ }
141
+ /**
142
+ * Schema validation error
143
+ */
144
+ export interface ValidationError {
145
+ field: string;
146
+ message: string;
147
+ expectedType?: string;
148
+ receivedValue?: unknown;
149
+ }
150
+ /**
151
+ * Validation result
152
+ */
153
+ export interface ValidationResult {
154
+ valid: boolean;
155
+ errors: ValidationError[];
156
+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AC,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,5 @@
1
+ /**
2
+ * Core type definitions for Matimo tool ecosystem
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,2 @@
1
+ export { tool, setGlobalMatimoInstance, getGlobalMatimoInstance } from './tool-decorator';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -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,2 @@
1
+ export { tool, setGlobalMatimoInstance, getGlobalMatimoInstance } from './tool-decorator';
2
+ //# sourceMappingURL=index.js.map
@@ -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"}
@@ -0,0 +1,97 @@
1
+ import { ToolDefinition } from '../core/types.js';
2
+ import type { MatimoInstance } from '../matimo-instance.js';
3
+ /**
4
+ * Set the global Matimo instance for decorator usage
5
+ *
6
+ * Must be called before any @tool decorated methods are invoked
7
+ *
8
+ * @param instance - The MatimoInstance to use globally
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const matimo = await MatimoInstance.init('./tools');
13
+ * setGlobalMatimoInstance(matimo);
14
+ *
15
+ * class MyAgent {
16
+ * @tool('calculator')
17
+ * async calculate(operation: string, a: number, b: number) { }
18
+ * }
19
+ *
20
+ * const agent = new MyAgent();
21
+ * await agent.calculate('add', 5, 3);
22
+ * ```
23
+ */
24
+ export declare function setGlobalMatimoInstance(instance: MatimoInstance | null): void;
25
+ /**
26
+ * Get the global Matimo instance
27
+ *
28
+ * @throws {Error} If no global instance is set
29
+ */
30
+ export declare function getGlobalMatimoInstance(): MatimoInstance;
31
+ /**
32
+ * Tool decorator - transforms a method into a tool executor
33
+ *
34
+ * Automatically calls matimo.execute() with the method's arguments mapped to tool parameters.
35
+ * Must be used in a class that has a `matimo` property or after setGlobalMatimoInstance() is called.
36
+ *
37
+ * Works with both traditional and modern TypeScript decorator syntax.
38
+ *
39
+ * @param toolName - Name of the tool to execute (e.g., 'calculator', 'github-get-repo')
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // Using global instance
44
+ * const matimo = await MatimoInstance.init('./tools');
45
+ * setGlobalMatimoInstance(matimo);
46
+ *
47
+ * class MyAgent {
48
+ * @tool('calculator')
49
+ * async calculate(operation: string, a: number, b: number) {
50
+ * // Automatically executes: matimo.execute('calculator', { operation, a, b })
51
+ * }
52
+ *
53
+ * @tool('github-get-repo')
54
+ * async getRepo(owner: string, repo: string) {
55
+ * // Automatically executes: matimo.execute('github-get-repo', { owner, repo })
56
+ * }
57
+ * }
58
+ *
59
+ * const agent = new MyAgent();
60
+ * const result = await agent.calculate('add', 5, 3);
61
+ * ```
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Using instance property
66
+ * class MyAgent {
67
+ * constructor(public matimo: MatimoInstance) {}
68
+ *
69
+ * @tool('calculator')
70
+ * async calculate(operation: string, a: number, b: number) { }
71
+ * }
72
+ *
73
+ * const matimo = await MatimoInstance.init('./tools');
74
+ * const agent = new MyAgent(matimo);
75
+ * const result = await agent.calculate('add', 5, 3);
76
+ * ```
77
+ */
78
+ export declare function tool(toolName: string): <This, Args extends unknown[], Return>(_target: (this: This, ...args: Args) => Return, _context: any) => (this: any, ...args: Args) => Promise<unknown>;
79
+ /**
80
+ * Execute tool via decorator - shared logic for both decorator syntaxes
81
+ * Exported for testing purposes
82
+ */
83
+ export declare function executeToolViaDecorator(toolName: string, thisArg: unknown, args: any[]): Promise<unknown>;
84
+ /**
85
+ * Convert positional arguments to named parameters object
86
+ * Maps function arguments to tool parameter names in order
87
+ * Exported for testing purposes
88
+ *
89
+ * @example
90
+ * ```
91
+ * Tool has parameters: { operation, a, b }
92
+ * Args: ['add', 5, 3]
93
+ * Result: { operation: 'add', a: 5, b: 3 }
94
+ * ```
95
+ */
96
+ export declare function convertArgsToParams(args: unknown[], toolDef: ToolDefinition): Record<string, unknown>;
97
+ //# sourceMappingURL=tool-decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-decorator.d.ts","sourceRoot":"","sources":["../../../src/decorators/tool-decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAS5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,cAAc,CAQxD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,IAClB,IAAI,EAAE,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EACnD,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,EAE9C,UAAU,GAAG,MAOU,MAAM,GAAG,EAAE,GAAG,MAAM,IAAI,KAAG,OAAO,CAAC,OAAO,CAAC,CAIrE;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAEhB,IAAI,EAAE,GAAG,EAAE,GACV,OAAO,CAAC,OAAO,CAAC,CAuClB;AACD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,OAAO,EAAE,EACf,OAAO,EAAE,cAAc,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAczB"}