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,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
|
package/docs/assets/logo.png
DELETED
|
Binary file
|