matimo 0.1.0-alpha.1 → 0.1.0-alpha.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.
Files changed (88) hide show
  1. package/README.md +83 -28
  2. package/dist/core/schema.d.ts +1 -1
  3. package/dist/core/schema.d.ts.map +1 -1
  4. package/dist/core/schema.js +8 -3
  5. package/dist/core/schema.js.map +1 -1
  6. package/dist/core/tool-loader.d.ts.map +1 -1
  7. package/dist/core/tool-loader.js +15 -4
  8. package/dist/core/tool-loader.js.map +1 -1
  9. package/dist/core/tool-registry.d.ts.map +1 -1
  10. package/dist/core/tool-registry.js +5 -1
  11. package/dist/core/tool-registry.js.map +1 -1
  12. package/dist/decorators/tool-decorator.d.ts.map +1 -1
  13. package/dist/decorators/tool-decorator.js +7 -4
  14. package/dist/decorators/tool-decorator.js.map +1 -1
  15. package/dist/encodings/parameter-encoding.d.ts.map +1 -1
  16. package/dist/encodings/parameter-encoding.js +9 -2
  17. package/dist/encodings/parameter-encoding.js.map +1 -1
  18. package/dist/executors/command-executor.d.ts.map +1 -1
  19. package/dist/executors/command-executor.js +5 -1
  20. package/dist/executors/command-executor.js.map +1 -1
  21. package/dist/executors/http-executor.d.ts.map +1 -1
  22. package/dist/executors/http-executor.js +5 -1
  23. package/dist/executors/http-executor.js.map +1 -1
  24. package/package.json +4 -4
  25. package/tools/calculator/calculator.ts +78 -0
  26. package/tools/calculator/definition.yaml +71 -0
  27. package/tools/echo-tool/definition.yaml +35 -0
  28. package/tools/examples/calculator.yaml +54 -0
  29. package/tools/examples/echo-tool.yaml +35 -0
  30. package/tools/examples/http-client.yaml +66 -0
  31. package/tools/github/definition.yaml +41 -0
  32. package/tools/gmail/README.md +1189 -0
  33. package/tools/gmail/create-draft/definition.yaml +99 -0
  34. package/tools/gmail/definition.yaml +49 -0
  35. package/tools/gmail/delete-message/definition.yaml +42 -0
  36. package/tools/gmail/get-message/definition.yaml +89 -0
  37. package/tools/gmail/list-messages/definition.yaml +84 -0
  38. package/tools/gmail/send-email/definition.yaml +95 -0
  39. package/tools/http-client/definition.yaml +73 -0
  40. package/tools/slack/README.md +200 -0
  41. package/tools/slack/assets/icon.svg +9 -0
  42. package/tools/slack/assets/logo-dark.svg +14 -0
  43. package/tools/slack/assets/logo-light.svg +14 -0
  44. package/tools/slack/assets/logo.svg +14 -0
  45. package/tools/slack/definition.yaml +54 -0
  46. package/tools/slack/get-user/definition.yaml +31 -0
  47. package/tools/slack/list-channels/definition.yaml +46 -0
  48. package/tools/slack/send-message/definition.yaml +30 -0
  49. package/tools/slack/slack_add_reaction/definition.yaml +45 -0
  50. package/tools/slack/slack_create_channel/definition.yaml +41 -0
  51. package/tools/slack/slack_get_channel_history/definition.yaml +58 -0
  52. package/tools/slack/slack_get_reactions/definition.yaml +36 -0
  53. package/tools/slack/slack_get_thread_replies/definition.yaml +45 -0
  54. package/tools/slack/slack_get_user_info/definition.yaml +32 -0
  55. package/tools/slack/slack_join_channel/definition.yaml +35 -0
  56. package/tools/slack/slack_reply_to_message/definition.yaml +49 -0
  57. package/tools/slack/slack_search_messages/definition.yaml +46 -0
  58. package/tools/slack/slack_send_channel_message/definition.yaml +34 -0
  59. package/tools/slack/slack_send_dm/definition.yaml +37 -0
  60. package/tools/slack/slack_set_channel_topic/definition.yaml +40 -0
  61. package/tools/slack/slack_upload_file/definition.yaml +152 -0
  62. package/docs/Gemfile +0 -5
  63. package/docs/RELEASES.md +0 -69
  64. package/docs/ROADMAP.md +0 -138
  65. package/docs/_config.yml +0 -27
  66. package/docs/api-reference/ERRORS.md +0 -445
  67. package/docs/api-reference/SDK.md +0 -582
  68. package/docs/api-reference/TYPES.md +0 -415
  69. package/docs/architecture/OAUTH.md +0 -1366
  70. package/docs/architecture/OVERVIEW.md +0 -564
  71. package/docs/assets/logo.png +0 -0
  72. package/docs/community/COMMIT_GUIDELINES.md +0 -552
  73. package/docs/framework-integrations/LANGCHAIN.md +0 -286
  74. package/docs/getting-started/QUICK_START.md +0 -211
  75. package/docs/getting-started/YOUR_FIRST_TOOL.md +0 -217
  76. package/docs/getting-started/installation.md +0 -124
  77. package/docs/index.md +0 -288
  78. package/docs/tool-development/DECORATOR_GUIDE.md +0 -633
  79. package/docs/tool-development/OAUTH_LINK.md +0 -5
  80. package/docs/tool-development/PROVIDER_CONFIGURATION.md +0 -458
  81. package/docs/tool-development/TESTING.md +0 -412
  82. package/docs/tool-development/TOOL_SPECIFICATION.md +0 -793
  83. package/docs/tool-development/YAML_TOOLS.md +0 -65
  84. package/docs/troubleshooting/FAQ.md +0 -391
  85. package/docs/user-guide/AUTHENTICATION.md +0 -255
  86. package/docs/user-guide/DEVELOPMENT_STANDARDS.md +0 -698
  87. package/docs/user-guide/SDK_PATTERNS.md +0 -316
  88. package/docs/user-guide/TOOL_DISCOVERY.md +0 -209
@@ -1,445 +0,0 @@
1
- # API Error Codes Reference
2
-
3
- Complete reference of error codes returned by Matimo SDK.
4
-
5
- ## Central Error Management
6
-
7
- Matimo uses a centralized error handling system via the `MatimoError` class defined in `src/errors/matimo-error.ts`. This ensures consistent error handling across all SDK operations.
8
-
9
- ### MatimoError Class
10
-
11
- All Matimo errors extend the native `Error` class and include:
12
-
13
- ```typescript
14
- import { MatimoError, ErrorCode } from 'matimo';
15
-
16
- class MatimoError extends Error {
17
- code: ErrorCode; // Machine-readable error code
18
- details?: Record<string, unknown>; // Additional context
19
-
20
- toJSON(): Record<string, unknown>; // Serialize to JSON
21
- }
22
- ```
23
-
24
- **Key Benefits:**
25
- - **Centralized Definition**: All error codes defined in one place (`ErrorCode` enum)
26
- - **Type-Safe**: TypeScript enum ensures only valid error codes can be thrown
27
- - **Serializable**: `toJSON()` method for logging and API responses
28
- - **Extensible**: Details object captures context-specific information
29
- - **Consistent**: Same error structure across all SDK methods
30
-
31
- ### Error Codes Enum
32
-
33
- All 11 error codes are defined in the `ErrorCode` enum:
34
-
35
- ```typescript
36
- export enum ErrorCode {
37
- INVALID_SCHEMA = 'INVALID_SCHEMA', // Tool definition validation failed
38
- EXECUTION_FAILED = 'EXECUTION_FAILED', // Tool execution error
39
- AUTH_FAILED = 'AUTH_FAILED', // Authentication/token error
40
- TOOL_NOT_FOUND = 'TOOL_NOT_FOUND', // Tool not in registry
41
- FILE_NOT_FOUND = 'FILE_NOT_FOUND', // File/directory missing
42
- VALIDATION_FAILED = 'VALIDATION_FAILED', // Parameter validation error
43
- RATE_LIMIT_EXCEEDED = 'RATE_LIMIT_EXCEEDED', // API rate limit hit
44
- TIMEOUT = 'TIMEOUT', // Operation timeout
45
- NETWORK_ERROR = 'NETWORK_ERROR', // Network/connection error
46
- INVALID_PARAMETER = 'INVALID_PARAMETER', // Invalid parameter value
47
- UNKNOWN_ERROR = 'UNKNOWN_ERROR', // Unknown error
48
- }
49
- ```
50
-
51
- ### Creating Errors
52
-
53
- Matimo provides helper functions for common error types:
54
-
55
- ```typescript
56
- import {
57
- createValidationError,
58
- createExecutionError,
59
- MatimoError,
60
- ErrorCode
61
- } from 'matimo';
62
-
63
- // Using helpers
64
- const validationErr = createValidationError(
65
- 'Missing required parameter',
66
- { param: 'email' }
67
- );
68
-
69
- const executionErr = createExecutionError(
70
- 'Tool returned error 500',
71
- { statusCode: 500, tool: 'gmail-send' }
72
- );
73
-
74
- // Direct instantiation
75
- const authErr = new MatimoError(
76
- 'Missing API token',
77
- ErrorCode.AUTH_FAILED,
78
- { env: 'GMAIL_ACCESS_TOKEN' }
79
- );
80
- ```
81
-
82
- ---
83
-
84
- ## Error Structure
85
-
86
- All Matimo errors follow this structure (via `MatimoError`):
87
-
88
- ```typescript
89
- {
90
- name: 'MatimoError'; // Error class name
91
- message: string; // Human-readable message
92
- code: ErrorCode; // Error code enum value
93
- details?: object; // Additional context
94
- }
95
- ```
96
-
97
- **Example:**
98
- ```typescript
99
- import { MatimoError, ErrorCode } from 'matimo';
100
-
101
- try {
102
- await m.execute('unknown-tool', {});
103
- } catch (error) {
104
- if (error instanceof MatimoError) {
105
- console.log(error.code); // ErrorCode.TOOL_NOT_FOUND
106
- console.log(error.message); // 'Tool "unknown-tool" not found'
107
- console.log(error.details); // { toolName: 'unknown-tool' }
108
- console.log(error.toJSON()); // Full error object for logging
109
- }
110
- }
111
- ```
112
-
113
- ---
114
-
115
- ## Error Codes
116
-
117
- ### TOOL_NOT_FOUND
118
-
119
- Tool name doesn't exist in registry.
120
-
121
- ```typescript
122
- if (error.code === 'TOOL_NOT_FOUND') {
123
- // Tool doesn't exist
124
- // Check tool name spelling
125
- // Use m.listTools() to see available tools
126
- }
127
- ```
128
-
129
- **Common causes:**
130
- - Typo in tool name
131
- - Tool file not loaded
132
- - Tool definition invalid
133
-
134
- **Resolution:**
135
- ```typescript
136
- // List available tools
137
- const tools = m.listTools();
138
- console.log(tools.map(t => t.name));
139
-
140
- // Use correct tool name
141
- const result = await m.execute('calculator', params);
142
- ```
143
-
144
- ---
145
-
146
- ### INVALID_PARAMETERS
147
-
148
- Required parameters missing or wrong type.
149
-
150
- ```typescript
151
- if (error.code === 'INVALID_PARAMETERS') {
152
- console.log('Missing or invalid:', error.details.invalidFields);
153
- // e.g., { invalidFields: ['operation', 'a'] }
154
- }
155
- ```
156
-
157
- **Common causes:**
158
- - Missing required parameter
159
- - Wrong parameter type (string vs number)
160
- - Parameter value outside allowed range
161
-
162
- **Resolution:**
163
- ```typescript
164
- // Get tool definition
165
- const tool = m.getTool('calculator');
166
-
167
- // Check required parameters
168
- Object.entries(tool.parameters).forEach(([name, param]) => {
169
- if (param.required) {
170
- console.log(`Required: ${name}`);
171
- }
172
- });
173
-
174
- // Execute with all required params
175
- const result = await m.execute('calculator', {
176
- operation: 'add', // required
177
- a: 5, // required
178
- b: 3 // required
179
- });
180
- ```
181
-
182
- ---
183
-
184
- ### EXECUTION_FAILED
185
-
186
- Tool execution encountered an error.
187
-
188
- ```typescript
189
- if (error.code === 'EXECUTION_FAILED') {
190
- console.log('Tool error:', error.details);
191
- // Details vary by tool type
192
- }
193
- ```
194
-
195
- **Common causes:**
196
- - Tool returned error (e.g., API returned 500)
197
- - Command execution failed
198
- - Network error
199
- - Authentication failed
200
-
201
- **Resolution:**
202
- ```typescript
203
- try {
204
- const result = await m.execute('gmail-send-email', {
205
- to: 'user@example.com',
206
- subject: 'Test',
207
- body: 'Test'
208
- });
209
- } catch (error) {
210
- if (error.code === 'EXECUTION_FAILED') {
211
- if (error.details.statusCode === 401) {
212
- console.error('❌ Authentication failed - check token');
213
- } else if (error.details.statusCode === 429) {
214
- console.error('⏱️ Rate limited - retry later');
215
- } else {
216
- console.error('Tool error:', error.message);
217
- }
218
- }
219
- }
220
- ```
221
-
222
- ---
223
-
224
- ### INVALID_SCHEMA
225
-
226
- Tool definition doesn't match schema.
227
-
228
- ```typescript
229
- if (error.code === 'INVALID_SCHEMA') {
230
- console.log('Tool definition invalid:', error.details.errors);
231
- }
232
- ```
233
-
234
- **Common causes:**
235
- - Required field missing in tool YAML
236
- - Wrong parameter type in YAML
237
- - Invalid execution configuration
238
-
239
- **Resolution:**
240
- ```bash
241
- # Validate all tools
242
- pnpm validate-tools
243
-
244
- # This will show which tools have schema errors
245
- ```
246
-
247
- See [Tool Specification](../tool-development/YAML_TOOLS.md) for correct YAML format.
248
-
249
- ---
250
-
251
- ### VALIDATION_FAILED
252
-
253
- Parameter validation failed (e.g., not in enum, wrong regex pattern).
254
-
255
- ```typescript
256
- if (error.code === 'VALIDATION_FAILED') {
257
- console.log('Validation errors:', error.details.errors);
258
- }
259
- ```
260
-
261
- **Common causes:**
262
- - Parameter value not in enum list
263
- - String doesn't match regex pattern
264
- - Number outside min/max range
265
-
266
- **Resolution:**
267
- ```typescript
268
- // Get tool definition
269
- const tool = m.getTool('calculator');
270
-
271
- // Check parameter constraints
272
- const operation = tool.parameters.operation;
273
- console.log('Allowed operations:', operation.enum);
274
- // ['add', 'subtract', 'multiply', 'divide']
275
-
276
- // Use allowed value
277
- const result = await m.execute('calculator', {
278
- operation: 'add', // Must be in enum
279
- a: 5,
280
- b: 3
281
- });
282
- ```
283
-
284
- ---
285
-
286
- ### AUTH_FAILED
287
-
288
- Authentication error (missing or invalid token).
289
-
290
- ```typescript
291
- if (error.code === 'AUTH_FAILED') {
292
- console.log('Auth error:', error.message);
293
- // e.g., "Missing GMAIL_ACCESS_TOKEN environment variable"
294
- }
295
- ```
296
-
297
- **Common causes:**
298
- - OAuth2 token not set in environment variable
299
- - Token expired
300
- - Token invalid or revoked
301
-
302
- **Resolution:**
303
- ```bash
304
- # Check token is set
305
- echo $GMAIL_ACCESS_TOKEN
306
-
307
- # If empty, set it
308
- export GMAIL_ACCESS_TOKEN="ya29.a0AfH6SMBx..."
309
-
310
- # Test execution
311
- npx tsx -e "import {matimo} from 'matimo'; const m = await matimo.init('./tools'); console.log(await m.execute('gmail-send-email', {to: 'test@example.com', subject: 'Test', body: 'Test'}));"
312
- ```
313
-
314
- See [Authentication Guide](../user-guide/AUTHENTICATION.md) for token setup.
315
-
316
- ---
317
-
318
- ### FILE_NOT_FOUND
319
-
320
- Tool file or directory doesn't exist.
321
-
322
- ```typescript
323
- if (error.code === 'FILE_NOT_FOUND') {
324
- console.log('Missing file:', error.details.path);
325
- }
326
- ```
327
-
328
- **Common causes:**
329
- - Tools directory path is wrong
330
- - Tool YAML file deleted
331
- - Incorrect file path in code
332
-
333
- **Resolution:**
334
- ```bash
335
- # Verify tools directory exists
336
- ls -la ./tools
337
-
338
- # Verify tool file exists
339
- ls -la ./tools/calculator/definition.yaml
340
-
341
- # Use correct path when initializing
342
- const m = await matimo.init('./tools');
343
- ```
344
-
345
- ---
346
-
347
- ## Handling Errors
348
-
349
- ### Pattern 1: Type Check and Handle Specific Codes
350
-
351
- ```typescript
352
- import { MatimoError, ErrorCode } from 'matimo';
353
-
354
- try {
355
- const result = await m.execute('calculator', params);
356
- } catch (error) {
357
- if (error instanceof MatimoError) {
358
- switch (error.code) {
359
- case ErrorCode.TOOL_NOT_FOUND:
360
- console.error('Tool not available');
361
- break;
362
- case ErrorCode.VALIDATION_FAILED:
363
- console.error('Bad parameters:', error.details);
364
- break;
365
- case ErrorCode.EXECUTION_FAILED:
366
- console.error('Tool execution failed:', error.details);
367
- break;
368
- default:
369
- console.error('Unknown error:', error.message);
370
- }
371
- } else {
372
- // Handle non-Matimo errors
373
- throw error;
374
- }
375
- }
376
- ```
377
-
378
- ### Pattern 2: Check Specific Error Code
379
-
380
- ```typescript
381
- import { MatimoError, ErrorCode } from 'matimo';
382
-
383
- try {
384
- await m.execute('gmail-send-email', params);
385
- } catch (error) {
386
- if (error instanceof MatimoError) {
387
- if (error.code === ErrorCode.AUTH_FAILED) {
388
- // Handle auth separately
389
- return redirectToLogin();
390
- }
391
-
392
- if (error.code === ErrorCode.EXECUTION_FAILED) {
393
- // Handle tool error
394
- return retryWithBackoff();
395
- }
396
- }
397
-
398
- // Handle others
399
- throw error;
400
- }
401
- ```
402
-
403
- ### Pattern 3: Serialize for Logging
404
-
405
- ```typescript
406
- import { MatimoError } from 'matimo';
407
-
408
- try {
409
- await m.execute(toolName, params);
410
- } catch (error) {
411
- if (error instanceof MatimoError) {
412
- // Use toJSON() for structured logging
413
- logger.error('tool_execution_failed', error.toJSON());
414
- } else {
415
- throw error;
416
- }
417
- }
418
- ```
419
-
420
- ---
421
-
422
- ## Error Codes Reference
423
-
424
- | Code | ErrorCode Enum | Cause | Resolution |
425
- |------|---|-------|-----------|
426
- | `TOOL_NOT_FOUND` | `ErrorCode.TOOL_NOT_FOUND` | Tool doesn't exist | Check tool name, use `listTools()` |
427
- | `INVALID_PARAMETERS` | `ErrorCode.INVALID_PARAMETER` | Missing/wrong params | Check tool definition |
428
- | `EXECUTION_FAILED` | `ErrorCode.EXECUTION_FAILED` | Tool execution error | Check tool error details |
429
- | `INVALID_SCHEMA` | `ErrorCode.INVALID_SCHEMA` | Bad tool definition | Fix tool YAML, run `validate-tools` |
430
- | `VALIDATION_FAILED` | `ErrorCode.VALIDATION_FAILED` | Param validation failed | Check constraints (enum, regex, range) |
431
- | `AUTH_FAILED` | `ErrorCode.AUTH_FAILED` | Missing/invalid token | Set OAuth2 env var |
432
- | `FILE_NOT_FOUND` | `ErrorCode.FILE_NOT_FOUND` | File/dir missing | Verify paths exist |
433
- | `RATE_LIMIT_EXCEEDED` | `ErrorCode.RATE_LIMIT_EXCEEDED` | API rate limit hit | Wait and retry |
434
- | `TIMEOUT` | `ErrorCode.TIMEOUT` | Operation timeout | Increase timeout or check network |
435
- | `NETWORK_ERROR` | `ErrorCode.NETWORK_ERROR` | Network/connection error | Check connectivity |
436
- | `UNKNOWN_ERROR` | `ErrorCode.UNKNOWN_ERROR` | Unknown error | Check error details |
437
-
438
- ---
439
-
440
- ## Next Steps
441
-
442
- - **Handle Errors**: [Error Handling Patterns](#handling-errors)
443
- - **Setup Auth**: [Authentication Guide](../user-guide/AUTHENTICATION.md)
444
- - **Type Definitions**: [Type Reference](./TYPES.md)
445
-