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,564 +0,0 @@
1
- # System Architecture Overview
2
-
3
- Understand how Matimo is designed and how components interact.
4
-
5
- ## High-Level Architecture
6
-
7
- ```
8
- ┌──────────────────────────────────────────────────────────────────┐
9
- │ Application Layer │
10
- │ (Your code: Express, CLI, Scheduled Job, etc) │
11
- └───────────────────────────┬──────────────────────────────────────┘
12
-
13
- ┌───────────────────┴────────────────────┐
14
- │ │
15
- ▼ ▼
16
- ┌───────────────────────────┐ ┌──────────────────────────────┐
17
- │ Pure SDK Patterns │ │ Framework Integration Layer │
18
- │ (No Framework) │ │ (With AI Framework) │
19
- ├───────────────────────────┤ ├──────────────────────────────┤
20
- │ • Factory Pattern │ │ • LangChain Official API* │
21
- │ • Decorator Pattern │ │ (LLM-driven, automatic) │
22
- │ │ │ │
23
- │ For: CLI, backends, │ │ • Decorator + LangChain │
24
- │ APIs, simple logic │ │ (Class-based agents) │
25
- └─────────────┬─────────────┘ │ │
26
- │ │ • Factory + LangChain │
27
- │ │ (Manual routing) │
28
- │ │ │
29
- │ │ For: AI agents, │
30
- └──────────┬───────────┤ intelligent orchestration │
31
- │ └──────────┬───────────────────┘
32
- │ │
33
- └──────────┬───────────┘
34
-
35
- ┌───────────────────────▼────────────────────┐
36
- │ SDK Layer (Matimo Core) │
37
- │ │
38
- │ ┌──────────────────────────────────────┐ │
39
- │ │ MatimoInstance (Orchestrator) │ │
40
- │ │ • Tool registry • Executor coord │ │
41
- │ │ • Parameter validation │ │
42
- │ │ • Error handling │ │
43
- │ └──────────────────────────────────────┘ │
44
- └───────┬──────────────────────┬─────────────┘
45
- │ │
46
- ┌───────────▼──────┐ ┌──────────▼────────┐
47
- │ Command Executor │ │ HTTP Executor │
48
- │ │ │ │
49
- │ • Shell commands │ │ • REST APIs │
50
- │ • Param template │ │ • Auth injection │
51
- │ • Exit handling │ │ • Response valid │
52
- └───────┬──────────┘ └──────────┬────────┘
53
- │ │
54
- └────────┬─────────────────┘
55
-
56
- ┌────────────▼──────────────┐
57
- │ Tool Definitions (YAML) │
58
- │ │
59
- │ • calculator │
60
- │ • gmail-send-email │
61
- │ • github-create-issue │
62
- │ • 1000+ tools coming │
63
- └────────────┬───────────────┘
64
-
65
- ┌────────────▼──────────────┐
66
- │ External Services │
67
- │ │
68
- │ • Gmail API │
69
- │ • GitHub API │
70
- │ • Slack API │
71
- │ • Shell commands │
72
- │ • Custom HTTP APIs │
73
- └────────────────────────────┘
74
-
75
- * Recommended for AI agents with automatic tool selection
76
- ```
77
-
78
- ---
79
-
80
- ## Component Layers
81
-
82
- ### 1. Application Layer
83
-
84
- Your code that uses Matimo. Examples:
85
- - Express.js API endpoint
86
- - LangChain agent
87
- - CLI tool
88
- - Scheduled job
89
- - Discord bot
90
-
91
- ### 2. SDK Layer
92
-
93
- **Factory Pattern**:
94
- ```typescript
95
- const m = await matimo.init('./tools');
96
- const result = await m.execute('calculator', params);
97
- ```
98
-
99
- **Decorator Pattern**:
100
- ```typescript
101
- class Agent {
102
- @tool('calculator')
103
- async calculate(...) { }
104
- }
105
- ```
106
-
107
- ### 3. Core Orchestration
108
-
109
- **MatimoInstance**: Central orchestrator that:
110
- - Manages tool registry
111
- - Coordinates execution
112
- - Handles errors
113
- - Manages OAuth2 tokens
114
-
115
- ### 4. Tool Management
116
-
117
- **ToolRegistry**: In-memory index of all tools
118
- ```
119
- tools: Map<name, ToolDefinition>
120
- |
121
- ├── calculator
122
- ├── gmail-send-email
123
- ├── github-create-issue
124
- └── ...
125
- ```
126
-
127
- **ToolLoader**: Loads tools from YAML files
128
- - Reads from `./tools/**/*.yaml`
129
- - Validates against Zod schema
130
- - Returns `ToolDefinition[]`
131
-
132
- ### 5. Execution Layer
133
-
134
- **CommandExecutor**: Runs shell commands
135
- ```
136
- Input: { command: "node script.js", args: [...] }
137
- Process: Spawn child process
138
- Output: { stdout, stderr, exitCode }
139
- ```
140
-
141
- **HttpExecutor**: Makes HTTP requests
142
- ```
143
- Input: { method: "POST", url: "...", headers: {...} }
144
- Process: Send request + validate response
145
- Output: { status, data, headers }
146
- ```
147
-
148
- ### 6. Tool Definitions
149
-
150
- **YAML Format**:
151
- ```yaml
152
- name: calculator
153
- execution:
154
- type: command
155
- command: node calculator.js
156
- parameters: { ... }
157
- ```
158
-
159
- **Provider Definitions**:
160
- ```yaml
161
- type: provider
162
- provider:
163
- endpoints:
164
- authorizationUrl: https://...
165
- ```
166
-
167
- ### 7. External Services
168
-
169
- Tools interact with:
170
- - Google Gmail API
171
- - GitHub REST API
172
- - Slack Web API
173
- - Shell commands
174
- - Custom HTTP APIs
175
-
176
- ---
177
-
178
- ## Data Flow
179
-
180
- ### Tool Execution Flow
181
-
182
- ```
183
- 1. Application
184
-
185
- └─> matimo.execute('calculator', { operation: 'add', a: 5, b: 3 })
186
-
187
-
188
- 2. MatimoInstance
189
- └─> Validate parameters against schema
190
-
191
-
192
- 3. ToolRegistry
193
- └─> Lookup 'calculator' definition
194
-
195
- ├─ execution: { type: 'command', command: 'node calculator.js' }
196
- ├─ parameters: { operation, a, b }
197
-
198
-
199
- 4. CommandExecutor
200
- └─> Execute: 'node calculator.js --op add 5 3'
201
-
202
- ├─ Substitute {operation}, {a}, {b} with actual values
203
- ├─ Spawn child process
204
- ├─ Capture stdout/stderr
205
-
206
-
207
- 5. External Service (node script)
208
- └─> Run: node calculator.js --op add 5 3
209
-
210
- ├─ Calculate: 5 + 3 = 8
211
-
212
-
213
- 6. Result Validation
214
- └─> Validate against output_schema
215
-
216
- ├─ Check type matches
217
- ├─ Check required fields present
218
-
219
-
220
- 7. Return to Application
221
- └─> { result: 8 }
222
- ```
223
-
224
- ### OAuth2 Token Flow
225
-
226
- ```
227
- 1. Environment
228
-
229
- └─> process.env.GMAIL_ACCESS_TOKEN = "ya29.abc..."
230
-
231
-
232
- 2. HTTP Tool Execution
233
- └─> Tool requires OAuth2 token
234
-
235
- ├─ Check authentication config
236
- ├─ Find provider: google
237
-
238
-
239
- 3. Token Injection
240
- └─> Read from environment variable
241
-
242
- ├─ GMAIL_ACCESS_TOKEN → "ya29.abc..."
243
-
244
-
245
- 4. HTTP Request
246
- └─> Add to headers
247
-
248
- ├─ Authorization: "Bearer ya29.abc..."
249
-
250
-
251
- 5. External Service (Gmail API)
252
- └─> Verify token
253
-
254
- ├─ Token valid → Execute request
255
- ├─ Token invalid → 401 Unauthorized
256
-
257
-
258
- 6. Response
259
- └─> Return result or error
260
- ```
261
-
262
- ---
263
-
264
- ## Framework Integration Patterns
265
-
266
- Matimo supports 3 patterns for integrating with AI frameworks like LangChain, where the LLM automatically decides which tool to use:
267
-
268
- ### Pattern 1: LangChain Official API (⭐ Recommended)
269
-
270
- Uses LangChain's official `tool()` function with automatic schema generation:
271
-
272
- ```
273
- ┌──────────────────────────────────┐
274
- │ LangChain Agent │
275
- │ (with OpenAI GPT-4) │
276
- └────────────┬─────────────────────┘
277
-
278
-
279
- ┌──────────────────────────────────┐
280
- │ LangChain Official API │
281
- │ tool(async fn, schema) │
282
- │ ├─ Automatic schema generation │
283
- │ ├─ Type validation via Zod │
284
- │ └─ Best IDE support │
285
- └────────────┬─────────────────────┘
286
-
287
-
288
- ┌──────────────────────────────────┐
289
- │ Matimo SDK │
290
- │ m.execute(toolName, params) │
291
- └────────────┬─────────────────────┘
292
-
293
-
294
- ┌──────────────────────────────────┐
295
- │ Tool Executors │
296
- │ (Command/HTTP) │
297
- └──────────────────────────────────┘
298
- ```
299
-
300
- **When to use:** Default choice for AI agents with LangChain
301
-
302
- ### Pattern 2: Decorator Pattern with LangChain
303
-
304
- Uses Matimo's `@tool()` decorators for class-based agents:
305
-
306
- ```
307
- ┌──────────────────────────────────┐
308
- │ Class-Based Agent │
309
- │ │
310
- │ @tool('calculator') │
311
- │ async calculate(...) { } │
312
- │ │
313
- │ @tool('email-sender') │
314
- │ async sendEmail(...) { } │
315
- └────────────┬─────────────────────┘
316
-
317
-
318
- ┌──────────────────────────────────┐
319
- │ @tool Decorator │
320
- │ ├─ Intercepts method calls │
321
- │ ├─ Maps args to parameters │
322
- │ └─ Calls matimo.execute() │
323
- └────────────┬─────────────────────┘
324
-
325
-
326
- ┌──────────────────────────────────┐
327
- │ Matimo SDK │
328
- │ m.execute(toolName, params) │
329
- └────────────┬─────────────────────┘
330
-
331
-
332
- ┌──────────────────────────────────┐
333
- │ Tool Executors │
334
- │ (Command/HTTP) │
335
- └──────────────────────────────────┘
336
- ```
337
-
338
- **When to use:** Class-based agents, automatic tool binding
339
-
340
- ### Pattern 3: Factory Pattern with LangChain
341
-
342
- Direct `matimo.execute()` calls in agent logic:
343
-
344
- ```
345
- ┌──────────────────────────────────┐
346
- │ Agent with Custom Logic │
347
- │ │
348
- │ if (prompt.includes('calc')) │
349
- │ m.execute('calculator', ...) │
350
- │ │
351
- │ if (prompt.includes('email')) │
352
- │ m.execute('gmail-send', ...) │
353
- └────────────┬─────────────────────┘
354
-
355
-
356
- ┌──────────────────────────────────┐
357
- │ Matimo SDK │
358
- │ m.execute(toolName, params) │
359
- └────────────┬─────────────────────┘
360
-
361
-
362
- ┌──────────────────────────────────┐
363
- │ Tool Executors │
364
- │ (Command/HTTP) │
365
- └──────────────────────────────────┘
366
- ```
367
-
368
- **When to use:** Simple logic, manual tool routing
369
-
370
- ### Comparison Matrix
371
-
372
- | Aspect | Official API | Decorator | Factory |
373
- |--------|--------------|-----------|---------|
374
- | **LLM-Driven** | ✅ Yes (automatic) | ✅ Yes | ❌ Manual |
375
- | **Schema Gen** | ✅ Automatic | ✅ Manual | ✅ Manual |
376
- | **Type Safety** | Excellent | Excellent | Good |
377
- | **Framework** | LangChain+ | LangChain+ | Any |
378
- | **Best For** | AI agents | Class-based agents | Simple logic |
379
- | **Learning Curve** | Low | Medium | Low |
380
-
381
- For full details, see [Framework Integrations - LangChain](../framework-integrations/LANGCHAIN.md).
382
-
383
- ---
384
-
385
- ## Core Types
386
-
387
- ```typescript
388
- // Tool Definition
389
- interface ToolDefinition {
390
- name: string;
391
- description: string;
392
- version: string;
393
- parameters?: Record<string, Parameter>;
394
- execution: ExecutionConfig; // command or http
395
- authentication?: AuthConfig;
396
- output_schema?: OutputSchema;
397
- }
398
-
399
- // Execution Config (Command)
400
- interface CommandExecution {
401
- type: 'command';
402
- command: string;
403
- args?: string[];
404
- cwd?: string;
405
- timeout?: number;
406
- }
407
-
408
- // Execution Config (HTTP)
409
- interface HttpExecution {
410
- type: 'http';
411
- method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
412
- url: string;
413
- headers?: Record<string, string>;
414
- body?: unknown;
415
- query_params?: Record<string, string>;
416
- }
417
-
418
- // Provider Definition
419
- interface ProviderDefinition {
420
- type: 'provider';
421
- name: string;
422
- provider: {
423
- endpoints: OAuth2Endpoints;
424
- // ...
425
- };
426
- }
427
- ```
428
-
429
- ---
430
-
431
- ## Validation Pipeline
432
-
433
- Every tool goes through validation:
434
-
435
- ```
436
- YAML File
437
-
438
- ├─> Parse YAML
439
- ├─> Validate against Zod schema
440
- │ ├─ Check required fields
441
- │ ├─ Check types
442
- │ ├─ Check enums
443
- ├─> Validate authentication (if OAuth2)
444
- │ ├─ Check provider exists
445
- │ ├─ Check endpoints are URLs
446
- ├─> Validate execution
447
- │ ├─ Check type is 'command' or 'http'
448
- │ ├─ Check required fields for type
449
- ├─> Validate parameters
450
- │ ├─ Check types match
451
- │ ├─ Check required fields
452
-
453
-
454
- ToolDefinition (validated)
455
- ```
456
-
457
- ---
458
-
459
- ## Error Handling
460
-
461
- ```
462
- Error occurs
463
-
464
- ├─> Catch with try/catch
465
- ├─> Wrap in MatimoError
466
- │ ├─ code: ErrorCode
467
- │ ├─ message: string
468
- │ ├─ details?: object
469
-
470
-
471
- Application error handling
472
-
473
- ├─> Log error (never log secrets)
474
- ├─> Return structured error
475
- ├─> Notify user/system
476
-
477
-
478
- Application recovery
479
- ```
480
-
481
- ---
482
-
483
- ## Design Principles
484
-
485
- ### 1. Configuration-Driven
486
-
487
- Tools defined in YAML, not code:
488
- - ✅ Easy to update without redeploying
489
- - ✅ Non-technical users can add tools
490
- - ✅ Version control friendly
491
-
492
- ### 2. Stateless
493
-
494
- Matimo doesn't store anything:
495
- - ✅ No database required
496
- - ✅ Easy to scale
497
- - ✅ Simple to test
498
-
499
- ### 3. Multi-Provider
500
-
501
- Support any OAuth2 provider:
502
- - ✅ Google, GitHub, Slack out of box
503
- - ✅ Add new providers with YAML
504
- - ✅ No code changes needed
505
-
506
- ### 4. Type-Safe
507
-
508
- Full TypeScript + Zod validation:
509
- - ✅ Catch errors at load time
510
- - ✅ IDE autocomplete support
511
- - ✅ Zero `any` types
512
-
513
- ### 5. Framework-Agnostic
514
-
515
- Works with any framework:
516
- - ✅ Direct SDK usage
517
- - ✅ LangChain integration
518
- - ✅ Custom framework support
519
- - ✅ Coming: CrewAI, Vercel AI, etc.
520
-
521
- ---
522
-
523
- ## Extension Points
524
-
525
- ### Adding a New Tool
526
-
527
- 1. Create `tools/category/tool-name/definition.yaml`
528
- 2. Loader automatically discovers it
529
- 3. Validation confirms correctness
530
- 4. Ready to use
531
-
532
- ### Adding an Executor
533
-
534
- 1. Extend `Executor` base class
535
- 2. Implement `execute(tool, params)` method
536
- 3. Add to tool execution dispatch
537
- 4. Support new execution types
538
-
539
- ### Adding a Provider
540
-
541
- 1. Create `tools/provider-name/definition.yaml`
542
- 2. Set `type: provider`
543
- 3. Configure OAuth2 endpoints
544
- 4. Tools reference provider in authentication
545
-
546
- ---
547
-
548
- ## Performance Characteristics
549
-
550
- | Operation | Time | Notes |
551
- |-----------|------|-------|
552
- | Load tools | ~50ms | One-time, cached |
553
- | Validate schema | ~5ms | Per tool |
554
- | Execute command | Varies | Depends on command |
555
- | Execute HTTP | 100-500ms | Network dependent |
556
- | OAuth token inject | <1ms | Environment variable lookup |
557
-
558
- ---
559
-
560
- ## Next Steps
561
-
562
- - **[SDK Usage Patterns](../user-guide/SDK_PATTERNS.md)** — How to use Matimo
563
- - **[Tool Specification](../tool-development/YAML_TOOLS.md)** — How to build tools
564
- - **[Troubleshooting](../troubleshooting/FAQ.md)** — Common issues
Binary file