matimo 0.1.0-alpha.2 → 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.
- package/README.md +128 -548
- package/package.json +24 -28
- package/packages/cli/bin/matimo.cjs +26 -0
- package/packages/cli/dist/cli.d.ts +6 -0
- package/packages/cli/dist/cli.d.ts.map +1 -0
- package/packages/cli/dist/cli.js +95 -0
- package/packages/cli/dist/cli.js.map +1 -0
- package/packages/cli/dist/commands/install.d.ts +6 -0
- package/packages/cli/dist/commands/install.d.ts.map +1 -0
- package/packages/cli/dist/commands/install.js +48 -0
- package/packages/cli/dist/commands/install.js.map +1 -0
- package/packages/cli/dist/commands/list.d.ts +9 -0
- package/packages/cli/dist/commands/list.d.ts.map +1 -0
- package/packages/cli/dist/commands/list.js +70 -0
- package/packages/cli/dist/commands/list.js.map +1 -0
- package/packages/cli/dist/commands/search.d.ts +2 -0
- package/packages/cli/dist/commands/search.d.ts.map +1 -0
- package/packages/cli/dist/commands/search.js +148 -0
- package/packages/cli/dist/commands/search.js.map +1 -0
- package/packages/core/dist/src/auth/oauth2-config.d.ts.map +1 -0
- package/packages/core/dist/src/auth/oauth2-config.js.map +1 -0
- package/packages/core/dist/src/auth/oauth2-handler.d.ts.map +1 -0
- package/packages/core/dist/src/auth/oauth2-handler.js.map +1 -0
- package/packages/core/dist/src/auth/oauth2-provider-loader.d.ts.map +1 -0
- package/packages/core/dist/src/auth/oauth2-provider-loader.js.map +1 -0
- package/{dist → packages/core/dist/src}/core/schema.d.ts +12 -2
- package/packages/core/dist/src/core/schema.d.ts.map +1 -0
- package/{dist → packages/core/dist/src}/core/schema.js +20 -6
- package/packages/core/dist/src/core/schema.js.map +1 -0
- package/{dist → packages/core/dist/src}/core/tool-loader.d.ts +16 -0
- package/packages/core/dist/src/core/tool-loader.d.ts.map +1 -0
- package/packages/core/dist/src/core/tool-loader.js +205 -0
- package/packages/core/dist/src/core/tool-loader.js.map +1 -0
- package/packages/core/dist/src/core/tool-registry.d.ts.map +1 -0
- package/{dist → packages/core/dist/src}/core/tool-registry.js +5 -1
- package/packages/core/dist/src/core/tool-registry.js.map +1 -0
- package/{dist → packages/core/dist/src}/core/types.d.ts +15 -1
- package/packages/core/dist/src/core/types.d.ts.map +1 -0
- package/{dist → packages/core/dist/src}/core/types.js.map +1 -1
- package/packages/core/dist/src/decorators/index.d.ts.map +1 -0
- package/packages/core/dist/src/decorators/index.js.map +1 -0
- package/packages/core/dist/src/decorators/tool-decorator.d.ts.map +1 -0
- package/{dist → packages/core/dist/src}/decorators/tool-decorator.js +7 -4
- package/packages/core/dist/src/decorators/tool-decorator.js.map +1 -0
- package/packages/core/dist/src/encodings/parameter-encoding.d.ts.map +1 -0
- package/{dist → packages/core/dist/src}/encodings/parameter-encoding.js +9 -2
- package/packages/core/dist/src/encodings/parameter-encoding.js.map +1 -0
- package/packages/core/dist/src/errors/matimo-error.d.ts.map +1 -0
- package/packages/core/dist/src/errors/matimo-error.js.map +1 -0
- package/packages/core/dist/src/executors/command-executor.d.ts.map +1 -0
- package/{dist → packages/core/dist/src}/executors/command-executor.js +5 -1
- package/packages/core/dist/src/executors/command-executor.js.map +1 -0
- package/packages/core/dist/src/executors/function-executor.d.ts +23 -0
- package/packages/core/dist/src/executors/function-executor.d.ts.map +1 -0
- package/packages/core/dist/src/executors/function-executor.js +164 -0
- package/packages/core/dist/src/executors/function-executor.js.map +1 -0
- package/packages/core/dist/src/executors/http-executor.d.ts.map +1 -0
- package/{dist → packages/core/dist/src}/executors/http-executor.js +5 -1
- package/packages/core/dist/src/executors/http-executor.js.map +1 -0
- package/{dist → packages/core/dist/src}/index.d.ts +5 -1
- package/packages/core/dist/src/index.d.ts.map +1 -0
- package/{dist → packages/core/dist/src}/index.js +3 -0
- package/packages/core/dist/src/index.js.map +1 -0
- package/packages/core/dist/src/integrations/langchain.d.ts +46 -0
- package/packages/core/dist/src/integrations/langchain.d.ts.map +1 -0
- package/packages/core/dist/src/integrations/langchain.js +197 -0
- package/packages/core/dist/src/integrations/langchain.js.map +1 -0
- package/{dist → packages/core/dist/src}/matimo-instance.d.ts +30 -4
- package/packages/core/dist/src/matimo-instance.d.ts.map +1 -0
- package/{dist → packages/core/dist/src}/matimo-instance.js +63 -10
- package/packages/core/dist/src/matimo-instance.js.map +1 -0
- package/packages/core/dist/tools/calculator/calculator.d.ts +26 -0
- package/packages/core/dist/tools/calculator/calculator.d.ts.map +1 -0
- package/packages/core/dist/tools/calculator/calculator.js +104 -0
- package/packages/core/dist/tools/calculator/calculator.js.map +1 -0
- package/packages/core/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/auth/oauth2-config.d.ts.map +0 -1
- package/dist/auth/oauth2-config.js.map +0 -1
- package/dist/auth/oauth2-handler.d.ts.map +0 -1
- package/dist/auth/oauth2-handler.js.map +0 -1
- package/dist/auth/oauth2-provider-loader.d.ts.map +0 -1
- package/dist/auth/oauth2-provider-loader.js.map +0 -1
- package/dist/core/schema.d.ts.map +0 -1
- package/dist/core/schema.js.map +0 -1
- package/dist/core/tool-loader.d.ts.map +0 -1
- package/dist/core/tool-loader.js +0 -98
- package/dist/core/tool-loader.js.map +0 -1
- package/dist/core/tool-registry.d.ts.map +0 -1
- package/dist/core/tool-registry.js.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/decorators/index.d.ts.map +0 -1
- package/dist/decorators/index.js.map +0 -1
- package/dist/decorators/tool-decorator.d.ts.map +0 -1
- package/dist/decorators/tool-decorator.js.map +0 -1
- package/dist/encodings/parameter-encoding.d.ts.map +0 -1
- package/dist/encodings/parameter-encoding.js.map +0 -1
- package/dist/errors/matimo-error.d.ts.map +0 -1
- package/dist/errors/matimo-error.js.map +0 -1
- package/dist/executors/command-executor.d.ts.map +0 -1
- package/dist/executors/command-executor.js.map +0 -1
- package/dist/executors/http-executor.d.ts.map +0 -1
- package/dist/executors/http-executor.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/matimo-instance.d.ts.map +0 -1
- package/dist/matimo-instance.js.map +0 -1
- package/docs/Gemfile +0 -5
- package/docs/RELEASES.md +0 -90
- package/docs/ROADMAP.md +0 -138
- package/docs/_config.yml +0 -27
- package/docs/api-reference/ERRORS.md +0 -445
- package/docs/api-reference/SDK.md +0 -582
- package/docs/api-reference/TYPES.md +0 -415
- package/docs/architecture/OAUTH.md +0 -1366
- package/docs/architecture/OVERVIEW.md +0 -564
- package/docs/assets/logo.png +0 -0
- package/docs/community/COMMIT_GUIDELINES.md +0 -552
- package/docs/framework-integrations/LANGCHAIN.md +0 -286
- package/docs/getting-started/QUICK_START.md +0 -212
- package/docs/getting-started/YOUR_FIRST_TOOL.md +0 -217
- package/docs/getting-started/installation.md +0 -124
- package/docs/index.md +0 -289
- package/docs/tool-development/DECORATOR_GUIDE.md +0 -633
- package/docs/tool-development/OAUTH_LINK.md +0 -5
- package/docs/tool-development/PROVIDER_CONFIGURATION.md +0 -458
- package/docs/tool-development/TESTING.md +0 -412
- package/docs/tool-development/TOOL_SPECIFICATION.md +0 -793
- package/docs/tool-development/YAML_TOOLS.md +0 -65
- package/docs/troubleshooting/FAQ.md +0 -391
- package/docs/user-guide/AUTHENTICATION.md +0 -255
- package/docs/user-guide/DEVELOPMENT_STANDARDS.md +0 -698
- package/docs/user-guide/SDK_PATTERNS.md +0 -316
- package/docs/user-guide/TOOL_DISCOVERY.md +0 -209
- /package/{dist → packages/core/dist/src}/auth/oauth2-config.d.ts +0 -0
- /package/{dist → packages/core/dist/src}/auth/oauth2-config.js +0 -0
- /package/{dist → packages/core/dist/src}/auth/oauth2-handler.d.ts +0 -0
- /package/{dist → packages/core/dist/src}/auth/oauth2-handler.js +0 -0
- /package/{dist → packages/core/dist/src}/auth/oauth2-provider-loader.d.ts +0 -0
- /package/{dist → packages/core/dist/src}/auth/oauth2-provider-loader.js +0 -0
- /package/{dist → packages/core/dist/src}/core/tool-registry.d.ts +0 -0
- /package/{dist → packages/core/dist/src}/core/types.js +0 -0
- /package/{dist → packages/core/dist/src}/decorators/index.d.ts +0 -0
- /package/{dist → packages/core/dist/src}/decorators/index.js +0 -0
- /package/{dist → packages/core/dist/src}/decorators/tool-decorator.d.ts +0 -0
- /package/{dist → packages/core/dist/src}/encodings/parameter-encoding.d.ts +0 -0
- /package/{dist → packages/core/dist/src}/errors/matimo-error.d.ts +0 -0
- /package/{dist → packages/core/dist/src}/errors/matimo-error.js +0 -0
- /package/{dist → packages/core/dist/src}/executors/command-executor.d.ts +0 -0
- /package/{dist → packages/core/dist/src}/executors/http-executor.d.ts +0 -0
|
@@ -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
|
-
|