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.
Files changed (149) hide show
  1. package/README.md +128 -548
  2. package/package.json +24 -28
  3. package/packages/cli/bin/matimo.cjs +26 -0
  4. package/packages/cli/dist/cli.d.ts +6 -0
  5. package/packages/cli/dist/cli.d.ts.map +1 -0
  6. package/packages/cli/dist/cli.js +95 -0
  7. package/packages/cli/dist/cli.js.map +1 -0
  8. package/packages/cli/dist/commands/install.d.ts +6 -0
  9. package/packages/cli/dist/commands/install.d.ts.map +1 -0
  10. package/packages/cli/dist/commands/install.js +48 -0
  11. package/packages/cli/dist/commands/install.js.map +1 -0
  12. package/packages/cli/dist/commands/list.d.ts +9 -0
  13. package/packages/cli/dist/commands/list.d.ts.map +1 -0
  14. package/packages/cli/dist/commands/list.js +70 -0
  15. package/packages/cli/dist/commands/list.js.map +1 -0
  16. package/packages/cli/dist/commands/search.d.ts +2 -0
  17. package/packages/cli/dist/commands/search.d.ts.map +1 -0
  18. package/packages/cli/dist/commands/search.js +148 -0
  19. package/packages/cli/dist/commands/search.js.map +1 -0
  20. package/packages/core/dist/src/auth/oauth2-config.d.ts.map +1 -0
  21. package/packages/core/dist/src/auth/oauth2-config.js.map +1 -0
  22. package/packages/core/dist/src/auth/oauth2-handler.d.ts.map +1 -0
  23. package/packages/core/dist/src/auth/oauth2-handler.js.map +1 -0
  24. package/packages/core/dist/src/auth/oauth2-provider-loader.d.ts.map +1 -0
  25. package/packages/core/dist/src/auth/oauth2-provider-loader.js.map +1 -0
  26. package/{dist → packages/core/dist/src}/core/schema.d.ts +12 -2
  27. package/packages/core/dist/src/core/schema.d.ts.map +1 -0
  28. package/{dist → packages/core/dist/src}/core/schema.js +20 -6
  29. package/packages/core/dist/src/core/schema.js.map +1 -0
  30. package/{dist → packages/core/dist/src}/core/tool-loader.d.ts +16 -0
  31. package/packages/core/dist/src/core/tool-loader.d.ts.map +1 -0
  32. package/packages/core/dist/src/core/tool-loader.js +205 -0
  33. package/packages/core/dist/src/core/tool-loader.js.map +1 -0
  34. package/packages/core/dist/src/core/tool-registry.d.ts.map +1 -0
  35. package/{dist → packages/core/dist/src}/core/tool-registry.js +5 -1
  36. package/packages/core/dist/src/core/tool-registry.js.map +1 -0
  37. package/{dist → packages/core/dist/src}/core/types.d.ts +15 -1
  38. package/packages/core/dist/src/core/types.d.ts.map +1 -0
  39. package/{dist → packages/core/dist/src}/core/types.js.map +1 -1
  40. package/packages/core/dist/src/decorators/index.d.ts.map +1 -0
  41. package/packages/core/dist/src/decorators/index.js.map +1 -0
  42. package/packages/core/dist/src/decorators/tool-decorator.d.ts.map +1 -0
  43. package/{dist → packages/core/dist/src}/decorators/tool-decorator.js +7 -4
  44. package/packages/core/dist/src/decorators/tool-decorator.js.map +1 -0
  45. package/packages/core/dist/src/encodings/parameter-encoding.d.ts.map +1 -0
  46. package/{dist → packages/core/dist/src}/encodings/parameter-encoding.js +9 -2
  47. package/packages/core/dist/src/encodings/parameter-encoding.js.map +1 -0
  48. package/packages/core/dist/src/errors/matimo-error.d.ts.map +1 -0
  49. package/packages/core/dist/src/errors/matimo-error.js.map +1 -0
  50. package/packages/core/dist/src/executors/command-executor.d.ts.map +1 -0
  51. package/{dist → packages/core/dist/src}/executors/command-executor.js +5 -1
  52. package/packages/core/dist/src/executors/command-executor.js.map +1 -0
  53. package/packages/core/dist/src/executors/function-executor.d.ts +23 -0
  54. package/packages/core/dist/src/executors/function-executor.d.ts.map +1 -0
  55. package/packages/core/dist/src/executors/function-executor.js +164 -0
  56. package/packages/core/dist/src/executors/function-executor.js.map +1 -0
  57. package/packages/core/dist/src/executors/http-executor.d.ts.map +1 -0
  58. package/{dist → packages/core/dist/src}/executors/http-executor.js +5 -1
  59. package/packages/core/dist/src/executors/http-executor.js.map +1 -0
  60. package/{dist → packages/core/dist/src}/index.d.ts +5 -1
  61. package/packages/core/dist/src/index.d.ts.map +1 -0
  62. package/{dist → packages/core/dist/src}/index.js +3 -0
  63. package/packages/core/dist/src/index.js.map +1 -0
  64. package/packages/core/dist/src/integrations/langchain.d.ts +46 -0
  65. package/packages/core/dist/src/integrations/langchain.d.ts.map +1 -0
  66. package/packages/core/dist/src/integrations/langchain.js +197 -0
  67. package/packages/core/dist/src/integrations/langchain.js.map +1 -0
  68. package/{dist → packages/core/dist/src}/matimo-instance.d.ts +30 -4
  69. package/packages/core/dist/src/matimo-instance.d.ts.map +1 -0
  70. package/{dist → packages/core/dist/src}/matimo-instance.js +63 -10
  71. package/packages/core/dist/src/matimo-instance.js.map +1 -0
  72. package/packages/core/dist/tools/calculator/calculator.d.ts +26 -0
  73. package/packages/core/dist/tools/calculator/calculator.d.ts.map +1 -0
  74. package/packages/core/dist/tools/calculator/calculator.js +104 -0
  75. package/packages/core/dist/tools/calculator/calculator.js.map +1 -0
  76. package/packages/core/dist/tsconfig.tsbuildinfo +1 -0
  77. package/dist/auth/oauth2-config.d.ts.map +0 -1
  78. package/dist/auth/oauth2-config.js.map +0 -1
  79. package/dist/auth/oauth2-handler.d.ts.map +0 -1
  80. package/dist/auth/oauth2-handler.js.map +0 -1
  81. package/dist/auth/oauth2-provider-loader.d.ts.map +0 -1
  82. package/dist/auth/oauth2-provider-loader.js.map +0 -1
  83. package/dist/core/schema.d.ts.map +0 -1
  84. package/dist/core/schema.js.map +0 -1
  85. package/dist/core/tool-loader.d.ts.map +0 -1
  86. package/dist/core/tool-loader.js +0 -98
  87. package/dist/core/tool-loader.js.map +0 -1
  88. package/dist/core/tool-registry.d.ts.map +0 -1
  89. package/dist/core/tool-registry.js.map +0 -1
  90. package/dist/core/types.d.ts.map +0 -1
  91. package/dist/decorators/index.d.ts.map +0 -1
  92. package/dist/decorators/index.js.map +0 -1
  93. package/dist/decorators/tool-decorator.d.ts.map +0 -1
  94. package/dist/decorators/tool-decorator.js.map +0 -1
  95. package/dist/encodings/parameter-encoding.d.ts.map +0 -1
  96. package/dist/encodings/parameter-encoding.js.map +0 -1
  97. package/dist/errors/matimo-error.d.ts.map +0 -1
  98. package/dist/errors/matimo-error.js.map +0 -1
  99. package/dist/executors/command-executor.d.ts.map +0 -1
  100. package/dist/executors/command-executor.js.map +0 -1
  101. package/dist/executors/http-executor.d.ts.map +0 -1
  102. package/dist/executors/http-executor.js.map +0 -1
  103. package/dist/index.d.ts.map +0 -1
  104. package/dist/index.js.map +0 -1
  105. package/dist/matimo-instance.d.ts.map +0 -1
  106. package/dist/matimo-instance.js.map +0 -1
  107. package/docs/Gemfile +0 -5
  108. package/docs/RELEASES.md +0 -90
  109. package/docs/ROADMAP.md +0 -138
  110. package/docs/_config.yml +0 -27
  111. package/docs/api-reference/ERRORS.md +0 -445
  112. package/docs/api-reference/SDK.md +0 -582
  113. package/docs/api-reference/TYPES.md +0 -415
  114. package/docs/architecture/OAUTH.md +0 -1366
  115. package/docs/architecture/OVERVIEW.md +0 -564
  116. package/docs/assets/logo.png +0 -0
  117. package/docs/community/COMMIT_GUIDELINES.md +0 -552
  118. package/docs/framework-integrations/LANGCHAIN.md +0 -286
  119. package/docs/getting-started/QUICK_START.md +0 -212
  120. package/docs/getting-started/YOUR_FIRST_TOOL.md +0 -217
  121. package/docs/getting-started/installation.md +0 -124
  122. package/docs/index.md +0 -289
  123. package/docs/tool-development/DECORATOR_GUIDE.md +0 -633
  124. package/docs/tool-development/OAUTH_LINK.md +0 -5
  125. package/docs/tool-development/PROVIDER_CONFIGURATION.md +0 -458
  126. package/docs/tool-development/TESTING.md +0 -412
  127. package/docs/tool-development/TOOL_SPECIFICATION.md +0 -793
  128. package/docs/tool-development/YAML_TOOLS.md +0 -65
  129. package/docs/troubleshooting/FAQ.md +0 -391
  130. package/docs/user-guide/AUTHENTICATION.md +0 -255
  131. package/docs/user-guide/DEVELOPMENT_STANDARDS.md +0 -698
  132. package/docs/user-guide/SDK_PATTERNS.md +0 -316
  133. package/docs/user-guide/TOOL_DISCOVERY.md +0 -209
  134. /package/{dist → packages/core/dist/src}/auth/oauth2-config.d.ts +0 -0
  135. /package/{dist → packages/core/dist/src}/auth/oauth2-config.js +0 -0
  136. /package/{dist → packages/core/dist/src}/auth/oauth2-handler.d.ts +0 -0
  137. /package/{dist → packages/core/dist/src}/auth/oauth2-handler.js +0 -0
  138. /package/{dist → packages/core/dist/src}/auth/oauth2-provider-loader.d.ts +0 -0
  139. /package/{dist → packages/core/dist/src}/auth/oauth2-provider-loader.js +0 -0
  140. /package/{dist → packages/core/dist/src}/core/tool-registry.d.ts +0 -0
  141. /package/{dist → packages/core/dist/src}/core/types.js +0 -0
  142. /package/{dist → packages/core/dist/src}/decorators/index.d.ts +0 -0
  143. /package/{dist → packages/core/dist/src}/decorators/index.js +0 -0
  144. /package/{dist → packages/core/dist/src}/decorators/tool-decorator.d.ts +0 -0
  145. /package/{dist → packages/core/dist/src}/encodings/parameter-encoding.d.ts +0 -0
  146. /package/{dist → packages/core/dist/src}/errors/matimo-error.d.ts +0 -0
  147. /package/{dist → packages/core/dist/src}/errors/matimo-error.js +0 -0
  148. /package/{dist → packages/core/dist/src}/executors/command-executor.d.ts +0 -0
  149. /package/{dist → packages/core/dist/src}/executors/http-executor.d.ts +0 -0
@@ -1,412 +0,0 @@
1
- # Testing Tools
2
-
3
- Write and validate tests for Matimo tools.
4
-
5
- ## Tool Validation
6
-
7
- ### Validate All Tools
8
-
9
- ```bash
10
- # Validate tool definitions (YAML syntax and schema)
11
- pnpm validate-tools
12
-
13
- # Output:
14
- # ✅ tools/calculator/definition.yaml - Valid
15
- # ✅ tools/gmail/send-email/definition.yaml - Valid
16
- # ✅ tools/gmail/list-messages/definition.yaml - Valid
17
- ```
18
-
19
- This validates:
20
- - YAML syntax is correct
21
- - All required fields present
22
- - Parameter types are valid
23
- - Execution config is complete
24
- - Output schema is valid
25
-
26
- ---
27
-
28
- ## Unit Tests
29
-
30
- ### Test Tool Definition
31
-
32
- ```typescript
33
- import { describe, it, expect } from 'vitest';
34
- import { ToolLoader } from 'matimo';
35
-
36
- describe('Tool Definition', () => {
37
- it('should load calculator tool', async () => {
38
- const loader = new ToolLoader('./tools');
39
- const tool = await loader.loadToolFromFile(
40
- './tools/calculator/definition.yaml'
41
- );
42
-
43
- expect(tool.name).toBe('calculator');
44
- expect(tool.description).toBe('Perform basic math operations');
45
- expect(tool.version).toBe('1.0.0');
46
- });
47
-
48
- it('should have required parameters', async () => {
49
- const loader = new ToolLoader('./tools');
50
- const tool = await loader.loadToolFromFile(
51
- './tools/calculator/definition.yaml'
52
- );
53
-
54
- expect(tool.parameters).toHaveProperty('operation');
55
- expect(tool.parameters).toHaveProperty('a');
56
- expect(tool.parameters).toHaveProperty('b');
57
- });
58
-
59
- it('should validate parameter types', async () => {
60
- const loader = new ToolLoader('./tools');
61
- const tool = await loader.loadToolFromFile(
62
- './tools/calculator/definition.yaml'
63
- );
64
-
65
- expect(tool.parameters!.operation.type).toBe('string');
66
- expect(tool.parameters!.a.type).toBe('number');
67
- expect(tool.parameters!.b.type).toBe('number');
68
- });
69
-
70
- it('should have execution config', async () => {
71
- const loader = new ToolLoader('./tools');
72
- const tool = await loader.loadToolFromFile(
73
- './tools/calculator/definition.yaml'
74
- );
75
-
76
- expect(tool.execution).toBeDefined();
77
- expect(tool.execution.type).toMatch(/command|http/);
78
- });
79
- });
80
- ```
81
-
82
- ---
83
-
84
- ## Integration Tests
85
-
86
- ### Test Tool Execution
87
-
88
- ```typescript
89
- import { describe, it, expect, beforeAll } from 'vitest';
90
- import { matimo } from 'matimo';
91
-
92
- describe('Calculator Tool Execution', () => {
93
- let m: Awaited<ReturnType<typeof matimo.init>>;
94
-
95
- beforeAll(async () => {
96
- m = await matimo.init('./tools');
97
- });
98
-
99
- it('should execute add operation', async () => {
100
- const result = await m.execute('calculator', {
101
- operation: 'add',
102
- a: 5,
103
- b: 3
104
- });
105
-
106
- expect(result.result).toBe(8);
107
- });
108
-
109
- it('should execute subtract operation', async () => {
110
- const result = await m.execute('calculator', {
111
- operation: 'subtract',
112
- a: 10,
113
- b: 4
114
- });
115
-
116
- expect(result.result).toBe(6);
117
- });
118
-
119
- it('should execute multiply operation', async () => {
120
- const result = await m.execute('calculator', {
121
- operation: 'multiply',
122
- a: 5,
123
- b: 3
124
- });
125
-
126
- expect(result.result).toBe(15);
127
- });
128
-
129
- it('should execute divide operation', async () => {
130
- const result = await m.execute('calculator', {
131
- operation: 'divide',
132
- a: 10,
133
- b: 2
134
- });
135
-
136
- expect(result.result).toBe(5);
137
- });
138
- });
139
- ```
140
-
141
- ---
142
-
143
- ## Parameter Validation Tests
144
-
145
- ### Test Parameter Constraints
146
-
147
- ```typescript
148
- import { describe, it, expect } from 'vitest';
149
- import { matimo } from 'matimo';
150
-
151
- describe('Calculator Parameter Validation', () => {
152
- let m: Awaited<ReturnType<typeof matimo.init>>;
153
-
154
- beforeAll(async () => {
155
- m = await matimo.init('./tools');
156
- });
157
-
158
- it('should reject invalid operation', async () => {
159
- expect(async () => {
160
- await m.execute('calculator', {
161
- operation: 'invalid', // Not in enum
162
- a: 5,
163
- b: 3
164
- });
165
- }).rejects.toThrow('INVALID_PARAMETERS');
166
- });
167
-
168
- it('should require all parameters', async () => {
169
- expect(async () => {
170
- await m.execute('calculator', {
171
- operation: 'add'
172
- // Missing: a, b
173
- });
174
- }).rejects.toThrow('INVALID_PARAMETERS');
175
- });
176
-
177
- it('should validate parameter types', async () => {
178
- expect(async () => {
179
- await m.execute('calculator', {
180
- operation: 'add',
181
- a: 'five', // Should be number
182
- b: 3
183
- });
184
- }).rejects.toThrow('INVALID_PARAMETERS');
185
- });
186
- });
187
- ```
188
-
189
- ---
190
-
191
- ## OAuth2 Tool Tests
192
-
193
- ### Test OAuth2 Tools
194
-
195
- ```typescript
196
- import { describe, it, expect, beforeAll } from 'vitest';
197
- import { matimo } from 'matimo';
198
-
199
- describe('Gmail Tool Execution', () => {
200
- let m: Awaited<ReturnType<typeof matimo.init>>;
201
-
202
- beforeAll(async () => {
203
- // Ensure GMAIL_ACCESS_TOKEN is set in environment
204
- if (!process.env.GMAIL_ACCESS_TOKEN) {
205
- console.warn('⚠️ Skipping Gmail tests: GMAIL_ACCESS_TOKEN not set');
206
- return;
207
- }
208
-
209
- m = await matimo.init('./tools');
210
- });
211
-
212
- it('should send email', async () => {
213
- if (!m) {
214
- console.warn('Skipping: no Matimo instance');
215
- return;
216
- }
217
-
218
- const result = await m.execute('gmail-send-email', {
219
- to: 'test@example.com',
220
- subject: 'Test Email',
221
- body: 'This is a test email'
222
- });
223
-
224
- expect(result.messageId).toBeDefined();
225
- });
226
-
227
- it('should list messages', async () => {
228
- if (!m) return;
229
-
230
- const result = await m.execute('gmail-list-messages', {
231
- maxResults: 10
232
- });
233
-
234
- expect(result.messages).toBeDefined();
235
- expect(Array.isArray(result.messages)).toBe(true);
236
- });
237
-
238
- it('should handle missing auth token', async () => {
239
- // Clear token temporarily
240
- const saved = process.env.GMAIL_ACCESS_TOKEN;
241
- delete process.env.GMAIL_ACCESS_TOKEN;
242
-
243
- const m2 = await matimo.init('./tools');
244
-
245
- expect(async () => {
246
- await m2.execute('gmail-send-email', {
247
- to: 'test@example.com',
248
- subject: 'Test',
249
- body: 'Test'
250
- });
251
- }).rejects.toThrow('AUTH_FAILED');
252
-
253
- // Restore token
254
- if (saved) {
255
- process.env.GMAIL_ACCESS_TOKEN = saved;
256
- }
257
- });
258
- });
259
- ```
260
-
261
- ---
262
-
263
- ## Error Handling Tests
264
-
265
- ### Test Error Conditions
266
-
267
- ```typescript
268
- import { describe, it, expect } from 'vitest';
269
- import { matimo } from 'matimo';
270
-
271
- describe('Error Handling', () => {
272
- let m: Awaited<ReturnType<typeof matimo.init>>;
273
-
274
- beforeAll(async () => {
275
- m = await matimo.init('./tools');
276
- });
277
-
278
- it('should throw TOOL_NOT_FOUND', async () => {
279
- expect(async () => {
280
- await m.execute('unknown-tool', {});
281
- }).rejects.toThrow('TOOL_NOT_FOUND');
282
- });
283
-
284
- it('should throw INVALID_PARAMETERS', async () => {
285
- expect(async () => {
286
- await m.execute('calculator', {
287
- operation: 'add'
288
- // Missing: a, b
289
- });
290
- }).rejects.toThrow('INVALID_PARAMETERS');
291
- });
292
-
293
- it('should include error details', async () => {
294
- try {
295
- await m.execute('calculator', {
296
- operation: 'invalid',
297
- a: 5,
298
- b: 3
299
- });
300
- expect.fail('Should throw error');
301
- } catch (error) {
302
- expect(error.code).toBe('INVALID_PARAMETERS');
303
- expect(error.details).toBeDefined();
304
- }
305
- });
306
- });
307
- ```
308
-
309
- ---
310
-
311
- ## Running Tests
312
-
313
- ```bash
314
- # Run all tests
315
- pnpm test
316
-
317
- # Run with coverage
318
- pnpm test:coverage
319
-
320
- # Run in watch mode (during development)
321
- pnpm test:watch
322
-
323
- # Run specific test file
324
- pnpm test -- tools.test.ts
325
-
326
- # Run tests matching pattern
327
- pnpm test -- --grep "Calculator"
328
- ```
329
-
330
- ---
331
-
332
- ## Test Coverage
333
-
334
- ### View Coverage Report
335
-
336
- ```bash
337
- pnpm test:coverage
338
-
339
- # Output:
340
- # ✅ 100% Statements
341
- # ✅ 100% Branches
342
- # ✅ 100% Functions
343
- # ✅ 100% Lines
344
- ```
345
-
346
- ---
347
-
348
- ## Best Practices
349
-
350
- ### 1. Test YAML Syntax First
351
-
352
- Always validate YAML before testing execution:
353
-
354
- ```bash
355
- pnpm validate-tools
356
- ```
357
-
358
- ### 2. Test Parameters Before Execution
359
-
360
- ```typescript
361
- // First: validate tool definition
362
- const tool = m.getTool('calculator');
363
- expect(tool.parameters).toBeDefined();
364
-
365
- // Then: test execution
366
- const result = await m.execute('calculator', params);
367
- ```
368
-
369
- ### 3. Mock External Calls (for unit tests)
370
-
371
- ```typescript
372
- import { describe, it, expect, vi } from 'vitest';
373
-
374
- describe('Gmail Tool (Mocked)', () => {
375
- it('should call Gmail API', async () => {
376
- const mockExecute = vi.fn().mockResolvedValue({
377
- messageId: 'msg_123'
378
- });
379
-
380
- const result = await mockExecute({
381
- to: 'test@example.com',
382
- subject: 'Test',
383
- body: 'Test'
384
- });
385
-
386
- expect(result.messageId).toBe('msg_123');
387
- });
388
- });
389
- ```
390
-
391
- ### 4. Test Error Cases
392
-
393
- ```typescript
394
- it('should handle execution errors', async () => {
395
- expect(async () => {
396
- await m.execute('calculator', {
397
- operation: 'divide',
398
- a: 10,
399
- b: 0 // Division by zero
400
- });
401
- }).rejects.toThrow();
402
- });
403
- ```
404
-
405
- ---
406
-
407
- ## Next Steps
408
-
409
- - **Tool Development**: [YAML Tool Specification](./YAML_TOOLS.md)
410
- - **Error Codes**: [Error Reference](../api-reference/ERRORS.md)
411
- - **Examples**: [Code Examples](../../examples/)
412
-