matimo 0.1.0-alpha.2 → 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 +80 -26
  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 -8
  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 -90
  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 -212
  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 -289
  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,458 +0,0 @@
1
- # Provider Configuration Guide
2
-
3
- ## Overview
4
-
5
- Matimo uses a **configuration-driven** approach to OAuth2 provider endpoints. Instead of hardcoding provider information into the application, all provider definitions are stored in **YAML files**. This enables:
6
-
7
- - ✅ Support for **infinite providers** without code changes
8
- - ✅ **Configuration-driven design** - no coupling between code and provider endpoints
9
- - ✅ **Easy customization** - override endpoints via environment variables or runtime config
10
- - ✅ **Zero code modifications** - users can add new providers just by creating YAML files
11
-
12
- ## Provider Definition Structure
13
-
14
- Each OAuth2 provider must have a `definition.yaml` file in its provider folder:
15
-
16
- ```
17
- tools/
18
- ├── gmail/
19
- │ └── definition.yaml ← Provider definition
20
- ├── github/
21
- │ └── definition.yaml
22
- ├── slack/
23
- │ └── definition.yaml
24
- └── [your-provider]/
25
- └── definition.yaml
26
- ```
27
-
28
- ### Provider Definition Format
29
-
30
- ```yaml
31
- name: google-provider # Unique name for this provider definition
32
- type: provider # MUST be "provider" to indicate this is an OAuth2 config
33
- version: '1.0.0' # Semantic version of the provider config
34
- description: Google OAuth2 provider # Optional description
35
-
36
- provider:
37
- name: google # Provider identifier (used in code)
38
- displayName: Google # Human-readable name
39
-
40
- endpoints:
41
- authorizationUrl: https://accounts.google.com/o/oauth2/v2/auth
42
- tokenUrl: https://oauth2.googleapis.com/token
43
- revokeUrl: https://oauth2.googleapis.com/revoke # Optional
44
-
45
- defaultScopes: # Optional default scopes
46
- - https://www.googleapis.com/auth/gmail.send
47
- - https://www.googleapis.com/auth/gmail.readonly
48
-
49
- documentation: https://developers.google.com/identity/protocols/oauth2
50
- ```
51
-
52
- ## Configuration Priority
53
-
54
- Matimo resolves OAuth2 endpoints using a **3-tier priority system**:
55
-
56
- ### 1. Runtime Configuration (Highest Priority)
57
- User provides endpoints directly in code:
58
-
59
- ```typescript
60
- const oauth2 = new OAuth2Handler({
61
- provider: 'google',
62
- clientId: '...',
63
- clientSecret: '...',
64
- redirectUri: '...',
65
- endpoints: { // ← These override everything else
66
- authorizationUrl: 'https://custom.company.com/auth',
67
- tokenUrl: 'https://custom.company.com/token',
68
- }
69
- });
70
- ```
71
-
72
- **Use case:** Custom or internal OAuth2 servers
73
-
74
- ### 2. Environment Variables (Medium Priority)
75
- Deploy-time configuration via environment variables:
76
-
77
- ```bash
78
- export OAUTH_GOOGLE_AUTH_URL=https://custom.company.com/auth
79
- export OAUTH_GOOGLE_TOKEN_URL=https://custom.company.com/token
80
- export OAUTH_GOOGLE_REVOKE_URL=https://custom.company.com/revoke
81
- ```
82
-
83
- **Use case:** Different endpoints per deployment (dev, staging, prod)
84
-
85
- ### 3. YAML Configuration (Default)
86
- Default endpoints defined in `tools/[provider]/definition.yaml`:
87
-
88
- ```yaml
89
- provider:
90
- endpoints:
91
- authorizationUrl: https://accounts.google.com/o/oauth2/v2/auth
92
- tokenUrl: https://oauth2.googleapis.com/token
93
- ```
94
-
95
- **Use case:** Standard provider defaults
96
-
97
- ### Resolution Example
98
-
99
- ```typescript
100
- // If config.endpoints is provided → Use that (Priority 1)
101
- const handler = new OAuth2Handler({
102
- provider: 'google',
103
- clientId: '...',
104
- endpoints: { authorizationUrl: 'https://custom/auth', ... } // ← Used
105
- });
106
-
107
- // Else if OAUTH_GOOGLE_AUTH_URL env var is set → Use that (Priority 2)
108
- process.env.OAUTH_GOOGLE_AUTH_URL = 'https://custom/auth';
109
- const handler = new OAuth2Handler({
110
- provider: 'google',
111
- clientId: '...',
112
- // No endpoints provided, env var checked
113
- });
114
-
115
- // Else use tools/google/definition.yaml (Priority 3)
116
- const handler = new OAuth2Handler({
117
- provider: 'google',
118
- clientId: '...',
119
- // No endpoints or env vars, loads from YAML
120
- });
121
- ```
122
-
123
- ## Adding a New Provider
124
-
125
- ### Step 1: Create Provider Definition File
126
-
127
- Create `tools/[provider-name]/definition.yaml`:
128
-
129
- ```yaml
130
- name: microsoft-provider
131
- type: provider
132
- version: '1.0.0'
133
- description: Microsoft Azure AD OAuth2 provider
134
-
135
- provider:
136
- name: microsoft
137
- displayName: Microsoft
138
-
139
- endpoints:
140
- authorizationUrl: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
141
- tokenUrl: https://login.microsoftonline.com/common/oauth2/v2.0/token
142
- revokeUrl: https://login.microsoftonline.com/common/oauth2/v2.0/token/revoke
143
-
144
- defaultScopes:
145
- - https://graph.microsoft.com/Mail.Send
146
- - https://graph.microsoft.com/user.read
147
-
148
- documentation: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
149
- ```
150
-
151
- ### Step 2: Use in Code
152
-
153
- The provider loader automatically discovers the provider:
154
-
155
- ```typescript
156
- import { OAuth2Handler } from '@matimo/oauth2';
157
-
158
- const oauth2 = new OAuth2Handler({
159
- provider: 'microsoft', // Provider name from definition.yaml
160
- clientId: process.env.MICROSOFT_CLIENT_ID,
161
- clientSecret: process.env.MICROSOFT_CLIENT_SECRET,
162
- redirectUri: 'http://localhost:3000/callback',
163
- });
164
-
165
- // Get authorization URL
166
- const authUrl = oauth2.getAuthorizationUrl({
167
- scopes: ['https://graph.microsoft.com/Mail.Send'],
168
- userId: 'user-123',
169
- });
170
- ```
171
-
172
- ### Step 3: (Optional) Override with Environment Variables
173
-
174
- For deployment-specific endpoints:
175
-
176
- ```bash
177
- export OAUTH_MICROSOFT_AUTH_URL=https://custom-idp.company.com/authorize
178
- export OAUTH_MICROSOFT_TOKEN_URL=https://custom-idp.company.com/token
179
- export OAUTH_MICROSOFT_REVOKE_URL=https://custom-idp.company.com/revoke
180
- ```
181
-
182
- ## Built-in Provider Examples
183
-
184
- ### Google (Gmail)
185
-
186
- **File:** `tools/gmail/definition.yaml`
187
-
188
- ```yaml
189
- name: google-provider
190
- type: provider
191
- version: '1.0.0'
192
-
193
- provider:
194
- name: google
195
- displayName: Google
196
-
197
- endpoints:
198
- authorizationUrl: https://accounts.google.com/o/oauth2/v2/auth
199
- tokenUrl: https://oauth2.googleapis.com/token
200
- revokeUrl: https://oauth2.googleapis.com/revoke
201
-
202
- defaultScopes:
203
- - https://www.googleapis.com/auth/gmail.send
204
- - https://www.googleapis.com/auth/gmail.readonly
205
- - https://www.googleapis.com/auth/gmail.compose
206
-
207
- documentation: https://developers.google.com/identity/protocols/oauth2
208
- ```
209
-
210
- ### GitHub
211
-
212
- **File:** `tools/github/definition.yaml`
213
-
214
- ```yaml
215
- name: github-provider
216
- type: provider
217
- version: '1.0.0'
218
-
219
- provider:
220
- name: github
221
- displayName: GitHub
222
-
223
- endpoints:
224
- authorizationUrl: https://github.com/login/oauth/authorize
225
- tokenUrl: https://github.com/login/oauth/access_token
226
-
227
- defaultScopes:
228
- - user:email
229
- - repo
230
- - gist
231
-
232
- documentation: https://docs.github.com/en/developers/apps/building-oauth-apps
233
- ```
234
-
235
- ### Slack
236
-
237
- **File:** `tools/slack/definition.yaml`
238
-
239
- ```yaml
240
- name: slack-provider
241
- type: provider
242
- version: '1.0.0'
243
-
244
- provider:
245
- name: slack
246
- displayName: Slack
247
-
248
- endpoints:
249
- authorizationUrl: https://slack.com/oauth/v2/authorize
250
- tokenUrl: https://slack.com/api/oauth.v2.access
251
-
252
- defaultScopes:
253
- - chat:write
254
- - channels:read
255
- - users:read
256
-
257
- documentation: https://api.slack.com/authentication/oauth-v2
258
- ```
259
-
260
- ## Token Management
261
-
262
- Matimo handles OAuth2 flows but **does NOT store tokens**. Token storage is your responsibility:
263
-
264
- ```typescript
265
- import { OAuth2Handler } from '@matimo/oauth2';
266
-
267
- // 1. Initialize handler
268
- const oauth2 = new OAuth2Handler({
269
- provider: 'google',
270
- clientId: '...',
271
- clientSecret: '...',
272
- redirectUri: 'http://localhost:3000/callback',
273
- });
274
-
275
- // 2. Generate auth URL
276
- const authUrl = oauth2.getAuthorizationUrl({
277
- scopes: ['https://www.googleapis.com/auth/gmail.send'],
278
- userId: 'user-123',
279
- });
280
- // → Redirect user to authUrl
281
-
282
- // 3. Exchange code for token
283
- const token = await oauth2.exchangeCodeForToken('user-123', authCode);
284
- // Result: { accessToken, refreshToken, expiresAt, ... }
285
-
286
- // 4. YOU store the token (database, Redis, file, etc.)
287
- await database.saveToken('user-123', token);
288
-
289
- // 5. Later, retrieve and use the token with Matimo tools
290
- const stored = await database.getToken('user-123');
291
- await matimo.execute('gmail-send-email', {
292
- to: 'recipient@example.com',
293
- GMAIL_ACCESS_TOKEN: stored.accessToken, // ← Pass token here
294
- });
295
- ```
296
-
297
- ## Dynamic Provider Discovery
298
-
299
- The provider loader automatically discovers all providers from YAML files:
300
-
301
- ```typescript
302
- import { OAuth2ProviderLoader } from '@matimo/auth';
303
-
304
- const loader = new OAuth2ProviderLoader('./tools');
305
- const providers = await loader.loadProviders();
306
-
307
- // List all discovered providers
308
- const providerNames = providers.keys();
309
- // Output: ['google', 'github', 'slack', 'microsoft', ...]
310
-
311
- // Get endpoints for specific provider
312
- const googleEndpoints = providers.get('google');
313
- console.log(googleEndpoints);
314
- // Output: {
315
- // authorizationUrl: 'https://accounts.google.com/...',
316
- // tokenUrl: 'https://oauth2.googleapis.com/token',
317
- // revokeUrl: '...'
318
- // }
319
- ```
320
-
321
- ## Custom OAuth2 Server
322
-
323
- Use runtime configuration to connect to a custom OAuth2 server:
324
-
325
- ```typescript
326
- const oauth2 = new OAuth2Handler({
327
- provider: 'internal-oauth', // Any name
328
- clientId: 'internal-client',
329
- clientSecret: 'internal-secret',
330
- redirectUri: 'http://localhost:3000/callback',
331
- endpoints: {
332
- authorizationUrl: 'https://oauth.company.internal/authorize',
333
- tokenUrl: 'https://oauth.company.internal/token',
334
- revokeUrl: 'https://oauth.company.internal/revoke',
335
- }
336
- });
337
- ```
338
-
339
- Or use environment variables:
340
-
341
- ```bash
342
- export OAUTH_INTERNAL_AUTH_URL=https://oauth.company.internal/authorize
343
- export OAUTH_INTERNAL_TOKEN_URL=https://oauth.company.internal/token
344
- export OAUTH_INTERNAL_REVOKE_URL=https://oauth.company.internal/revoke
345
- ```
346
-
347
- ```typescript
348
- const oauth2 = new OAuth2Handler({
349
- provider: 'internal',
350
- clientId: '...',
351
- clientSecret: '...',
352
- redirectUri: '...',
353
- // Endpoints loaded from env vars automatically
354
- });
355
- ```
356
-
357
- ## Best Practices
358
-
359
- ### 1. Use Configuration-Driven Approach
360
- ❌ Don't hardcode endpoints:
361
- ```typescript
362
- const oauth2 = new OAuth2Handler({
363
- provider: 'custom',
364
- clientId: '...',
365
- endpoints: {
366
- authorizationUrl: 'https://hardcoded.example.com/auth', // ❌ Bad
367
- }
368
- });
369
- ```
370
-
371
- ✅ Use YAML or environment variables:
372
- ```yaml
373
- # tools/custom/definition.yaml
374
- provider:
375
- endpoints:
376
- authorizationUrl: https://custom.example.com/auth
377
- ```
378
-
379
- ### 2. Document Provider Requirements
380
- Include setup instructions in provider definition:
381
-
382
- ```yaml
383
- provider:
384
- documentation: https://docs.example.com/oauth2-setup
385
- # Include links to:
386
- # - How to register OAuth app
387
- # - Where to get client ID/secret
388
- # - Required scopes for different use cases
389
- ```
390
-
391
- ### 3. Use Semantic Versioning
392
- Update version when endpoints change:
393
-
394
- ```yaml
395
- version: '1.1.0' # Increment for breaking changes
396
- ```
397
-
398
- ### 4. Never Hardcode Secrets
399
- Always use environment variables:
400
-
401
- ```typescript
402
- const oauth2 = new OAuth2Handler({
403
- provider: 'google',
404
- clientId: process.env.GOOGLE_CLIENT_ID, // ✅ From env vars
405
- clientSecret: process.env.GOOGLE_CLIENT_SECRET, // ✅ From env vars
406
- redirectUri: process.env.GOOGLE_REDIRECT_URI, // ✅ From env vars
407
- });
408
- ```
409
-
410
- ### 5. Validate Provider Definition
411
- Matimo automatically validates YAML structure:
412
-
413
- ```typescript
414
- // This throws MatimoError if definition is invalid
415
- const loader = new OAuth2ProviderLoader('./tools');
416
- await loader.loadProviders();
417
- ```
418
-
419
- ## Troubleshooting
420
-
421
- ### Provider Not Found
422
- ```
423
- MatimoError: Unsupported OAuth2 provider: custom. Provide endpoints via:
424
- 1. config.endpoints (runtime override)
425
- 2. OAUTH_CUSTOM_AUTH_URL env var (deployment config)
426
- 3. tools/custom/definition.yaml (YAML configuration)
427
- ```
428
-
429
- **Solution:** Create `tools/custom/definition.yaml` with provider definition
430
-
431
- ### Invalid Provider Definition
432
- ```
433
- MatimoError: Invalid provider definition: Missing required field 'endpoints'
434
- ```
435
-
436
- **Solution:** Ensure YAML has required fields:
437
- - `name`
438
- - `type: provider`
439
- - `provider.endpoints.authorizationUrl`
440
- - `provider.endpoints.tokenUrl`
441
-
442
- ### Environment Variable Not Read
443
- Make sure env var name matches the pattern:
444
- ```bash
445
- # For provider: 'google'
446
- export OAUTH_GOOGLE_AUTH_URL=...
447
- export OAUTH_GOOGLE_TOKEN_URL=...
448
- export OAUTH_GOOGLE_REVOKE_URL=... # Optional
449
-
450
- # For provider: 'microsoft'
451
- export OAUTH_MICROSOFT_AUTH_URL=...
452
- ```
453
-
454
- ## See Also
455
-
456
- - [OAuth2Handler API](./src/auth/oauth2-handler.ts)
457
- - [Provider Loader Implementation](./src/auth/oauth2-provider-loader.ts)
458
- - [Integration Examples](./test/integration/)