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,286 +0,0 @@
1
- # LangChain Integration
2
-
3
- ## Overview
4
-
5
- Matimo tools integrate seamlessly with LangChain for AI-powered agents. This guide shows how to use Matimo tools in LangChain applications.
6
-
7
- ## v0.1.0-alpha.1 Status
8
-
9
- **✅ Implemented**: Direct SDK usage with LangChain tools interface
10
- **🔜 Future**: LangChain adapters and plugins
11
-
12
- ## Installation
13
-
14
- ```bash
15
- npm install matimo langchain @langchain/core
16
- # or
17
- pnpm add matimo langchain @langchain/core
18
- ```
19
-
20
- ## Basic Integration
21
-
22
- ### 1. Load Matimo Tools
23
-
24
- ```typescript
25
- import { matimo } from 'matimo';
26
-
27
- // Initialize Matimo with your tools
28
- const matimoInstance = await matimo.init('./tools');
29
-
30
- // Get available tools
31
- const allTools = matimoInstance.listTools();
32
- console.log('Available tools:', allTools.map(t => t.name));
33
- ```
34
-
35
- ### 2. Execute Tools Directly
36
-
37
- ```typescript
38
- import { matimo } from 'matimo';
39
-
40
- const m = await matimo.init('./tools');
41
-
42
- // Execute a tool
43
- const result = await m.execute('gmail-send-email', {
44
- to: 'user@example.com',
45
- subject: 'Hello',
46
- body: 'World'
47
- });
48
-
49
- console.log('Email sent:', result);
50
- ```
51
-
52
- ### 3. Using with LangChain Agents
53
-
54
- ```typescript
55
- import { matimo } from 'matimo';
56
- import { ChatOpenAI } from '@langchain/openai';
57
- import { AgentExecutor, createOpenAIFunctionsAgent } from 'langchain/agents';
58
- import { Tool } from '@langchain/core/tools';
59
-
60
- // Initialize Matimo
61
- const matimoInstance = await matimo.init('./tools');
62
-
63
- // Wrap Matimo tools for LangChain
64
- function createLangChainTool(matimoTool): Tool {
65
- return new Tool({
66
- name: matimoTool.name,
67
- description: matimoTool.description,
68
- func: async (input) => {
69
- // Parse input and execute
70
- const params = JSON.parse(input);
71
- const result = await matimoInstance.execute(
72
- matimoTool.name,
73
- params
74
- );
75
- return JSON.stringify(result);
76
- }
77
- });
78
- }
79
-
80
- // Create LangChain tools from Matimo
81
- const langchainTools = matimoInstance
82
- .listTools()
83
- .map(tool => createLangChainTool(tool));
84
-
85
- // Create LangChain agent
86
- const model = new ChatOpenAI({
87
- apiKey: process.env.OPENAI_API_KEY,
88
- temperature: 0
89
- });
90
-
91
- const agent = await createOpenAIFunctionsAgent({
92
- llm: model,
93
- tools: langchainTools,
94
- prompt: ChatPromptTemplate.fromMessages([
95
- ['system', 'You are a helpful assistant with access to various tools.'],
96
- ['human', '{input}'],
97
- new MessagesPlaceholder('agent_scratchpad')
98
- ])
99
- });
100
-
101
- const agentExecutor = new AgentExecutor({
102
- agent,
103
- tools: langchainTools,
104
- verbose: true
105
- });
106
-
107
- // Run agent
108
- const result = await agentExecutor.invoke({
109
- input: 'Send an email to john@example.com saying hello'
110
- });
111
-
112
- console.log('Agent response:', result.output);
113
- ```
114
-
115
- ## Decorator Pattern with LangChain
116
-
117
- For class-based agents using decorators:
118
-
119
- ```typescript
120
- import { tool, matimo } from 'matimo';
121
- import { BaseLanguageModel } from '@langchain/core/language_models';
122
-
123
- class EmailAgent {
124
- constructor(private matimoInstance: any) {}
125
-
126
- @tool('gmail-send-email')
127
- async sendEmail(to: string, subject: string, body: string) {
128
- // Decorator handles execution
129
- // Return type is inferred from tool definition
130
- }
131
-
132
- @tool('gmail-list-messages')
133
- async listEmails(maxResults?: number) {
134
- // Automatically calls Matimo executor
135
- }
136
- }
137
-
138
- // Usage with LangChain
139
- const m = await matimo.init('./tools');
140
- const agent = new EmailAgent(m);
141
-
142
- // Call decorated methods
143
- await agent.sendEmail(
144
- 'recipient@example.com',
145
- 'Test Subject',
146
- 'Test Body'
147
- );
148
- ```
149
-
150
- ## Working Examples
151
-
152
- See [examples/langchain/](../../examples/langchain/) for complete examples:
153
-
154
- - `gmail-langchain.ts` - Gmail tool integration with LangChain
155
- - `gmail-decorator.ts` - Decorator pattern example
156
- - `gmail-factory.ts` - Factory pattern example
157
-
158
- Run them:
159
-
160
- ```bash
161
- cd examples/langchain
162
- pnpm install
163
- pnpm gmail:langchain --email:your@email.com
164
- ```
165
-
166
- ## Tool Parameter Mapping
167
-
168
- Matimo parameters map directly to LangChain function calls:
169
-
170
- ```yaml
171
- # Matimo tool definition
172
- parameters:
173
- email:
174
- type: string
175
- required: true
176
- subject:
177
- type: string
178
- required: true
179
- body:
180
- type: string
181
- required: true
182
- ```
183
-
184
- Becomes in LangChain:
185
-
186
- ```json
187
- {
188
- "name": "gmail-send-email",
189
- "description": "Send an email",
190
- "parameters": {
191
- "type": "object",
192
- "properties": {
193
- "email": { "type": "string" },
194
- "subject": { "type": "string" },
195
- "body": { "type": "string" }
196
- },
197
- "required": ["email", "subject", "body"]
198
- }
199
- }
200
- ```
201
-
202
- ## OAuth2 with LangChain
203
-
204
- Tools requiring OAuth2 authentication:
205
-
206
- ```typescript
207
- // Set OAuth tokens as environment variables
208
- process.env.GMAIL_ACCESS_TOKEN = 'your-access-token';
209
- process.env.GITHUB_TOKEN = 'your-github-token';
210
-
211
- // Matimo automatically injects tokens into tools
212
- const result = await matimoInstance.execute('gmail-send-email', {
213
- to: 'user@example.com',
214
- subject: 'Hello',
215
- body: 'Message'
216
- // Token is automatically included from environment
217
- });
218
- ```
219
-
220
- ## Error Handling
221
-
222
- ```typescript
223
- try {
224
- const result = await agentExecutor.invoke({
225
- input: 'Send an email'
226
- });
227
- } catch (error) {
228
- if (error.code === 'TOOL_NOT_FOUND') {
229
- console.error('Tool not available:', error.message);
230
- } else if (error.code === 'INVALID_PARAMETERS') {
231
- console.error('Invalid parameters:', error.details);
232
- } else if (error.code === 'EXECUTION_FAILED') {
233
- console.error('Tool execution failed:', error.details);
234
- } else {
235
- console.error('Unexpected error:', error);
236
- }
237
- }
238
- ```
239
-
240
- ## Future Releases
241
-
242
- 🔜 **v0.2.0** will include:
243
- - Official LangChain adapter package
244
- - Automatic tool schema conversion
245
- - LangChain Tool subclass implementation
246
- - CrewAI integration examples
247
- - Vercel AI SDK integration
248
-
249
- ---
250
-
251
- ## Troubleshooting
252
-
253
- ### Tool Not Found Error
254
-
255
- ```
256
- Error: Tool not found: gmail-send-email
257
- ```
258
-
259
- **Solution**: Verify tools are loaded correctly
260
-
261
- ```typescript
262
- const tools = matimoInstance.listTools();
263
- console.log('Available tools:', tools.map(t => t.name));
264
- ```
265
-
266
- ### OAuth Token Missing
267
-
268
- ```
269
- Error: Missing OAuth token for provider: google
270
- ```
271
-
272
- **Solution**: Set environment variable
273
-
274
- ```bash
275
- export GMAIL_ACCESS_TOKEN=your_token_here
276
- ```
277
-
278
- ### Type Errors with LangChain Tools
279
-
280
- Ensure all Matimo tools are properly typed:
281
-
282
- ```bash
283
- pnpm validate-tools # Validates all YAML definitions
284
- ```
285
-
286
- See [Troubleshooting Guide](../troubleshooting/FAQ.md) for more help.
@@ -1,212 +0,0 @@
1
- # Quick Start — 5 Minutes
2
-
3
- Get Matimo up and running in 5 minutes.
4
-
5
- ## 1. Installation (1 min)
6
-
7
- ```bash
8
- npm install matimo
9
- # or with pnpm
10
- pnpm add matimo
11
- ```
12
-
13
- ## 2. Load Tools (2 min)
14
-
15
- Create a file `load-tools.ts`:
16
-
17
- ```typescript
18
- import { ToolLoader } from 'matimo';
19
-
20
- const loader = new ToolLoader('./tools');
21
- const tools = await loader.loadToolsFromDirectory();
22
-
23
- console.log(`Loaded ${tools.length} tools`);
24
- ```
25
-
26
- ## 3. Execute a Tool (1 min)
27
-
28
- ```typescript
29
- import { CommandExecutor } from 'matimo';
30
-
31
- const executor = new CommandExecutor();
32
- const result = await executor.execute(tools[0], {
33
- param1: 'value1',
34
- param2: 'value2'
35
- });
36
-
37
- console.log(result);
38
- ```
39
-
40
- ## 4. Use the SDK Factory (1 min)
41
-
42
- ```typescript
43
- import { MatimoFactory } from 'matimo';
44
-
45
- // Create instance with factory pattern
46
- const matimo = MatimoFactory.create({
47
- toolsPath: './tools'
48
- });
49
-
50
- // List all tools
51
- const allTools = matimo.getToolRegistry().listTools();
52
-
53
- // Execute a tool
54
- const result = await matimo.executeTool('calculator', {
55
- operation: 'add',
56
- a: 5,
57
- b: 3
58
- });
59
-
60
- console.log(result); // { result: 8 }
61
- ```
62
-
63
- ## Next Steps
64
-
65
- - **[API Reference](../api-reference/SDK.md)** — Full SDK documentation
66
- - **[Tool Specification](../tool-development/TOOL_SPECIFICATION.md)** — Write your own tools
67
- - **[Decorator Guide](../tool-development/DECORATOR_GUIDE.md)** — Use TypeScript decorators
68
- - **[Development Guide](../CONTRIBUTING.md)** — Contributing to Matimo
69
-
70
- ## Common Tasks
71
-
72
- ### List All Loaded Tools
73
-
74
- ```typescript
75
- const tools = matimo.getToolRegistry().listTools();
76
- tools.forEach(tool => {
77
- console.log(`${tool.name} - ${tool.description}`);
78
- });
79
- ```
80
-
81
- ### Get Tool by Name
82
-
83
- ```typescript
84
- const tool = matimo.getToolRegistry().getTool('calculator');
85
- if (tool) {
86
- console.log(tool.parameters);
87
- }
88
- ```
89
-
90
- ### Execute with Error Handling
91
-
92
- ```typescript
93
- try {
94
- const result = await matimo.executeTool('github-create-issue', {
95
- repo: 'owner/repo',
96
- title: 'Bug Report'
97
- });
98
- console.log('Success:', result);
99
- } catch (error) {
100
- if (error.code === 'VALIDATION_FAILED') {
101
- console.error('Invalid parameters:', error.message);
102
- } else if (error.code === 'EXECUTION_FAILED') {
103
- console.error('Tool execution failed:', error.message);
104
- } else {
105
- console.error('Unknown error:', error);
106
- }
107
- }
108
- ```
109
-
110
- ### Use with MCP Server
111
-
112
- ```typescript
113
- // MCP Server - Coming in Phase 2
114
- // import { MCPServer } from 'matimo/mcp';
115
-
116
- const server = new MCPServer({
117
- toolsPath: './tools',
118
- port: 3000
119
- });
120
-
121
- await server.start();
122
- console.log('MCP Server running on port 3000');
123
- // Claude can now discover and call all tools via MCP
124
- ```
125
-
126
- ## Example Directory Structure
127
-
128
- ```
129
- project/
130
- ├── tools/
131
- │ ├── calculator/
132
- │ │ └── defination.yaml
133
- │ └── github/
134
- | └── defination.yaml
135
- │ └── create-issue
136
- | └── defination.yaml
137
- ├── src/
138
- │ └── app.ts
139
- └── package.json
140
- ```
141
-
142
- ## Example Tool YAML
143
-
144
- Create `tools/calculator/tool.yaml`:
145
-
146
- ```yaml
147
- name: calculator
148
- description: Perform basic math operations
149
- version: "1.0.0"
150
-
151
- parameters:
152
- operation:
153
- type: string
154
- enum: [add, subtract, multiply, divide]
155
- required: true
156
- a:
157
- type: number
158
- required: true
159
- b:
160
- type: number
161
- required: true
162
-
163
- execution:
164
- type: command
165
- command: node
166
- args:
167
- - -e
168
- - "console.log(JSON.stringify({ result: eval(`${process.argv[1]} ${process.argv[2]} ${process.argv[3]}`) }))"
169
- - "{operation === 'add' ? '+' : operation === 'subtract' ? '-' : operation === 'multiply' ? '*' : '/'}"
170
- - "{a}"
171
- - "{b}"
172
-
173
- output_schema:
174
- type: object
175
- properties:
176
- result:
177
- type: number
178
- ```
179
-
180
- Load and execute:
181
-
182
- ```typescript
183
- const result = await matimo.executeTool('calculator', {
184
- operation: 'add',
185
- a: 10,
186
- b: 5
187
- });
188
- // result = { result: 15 }
189
- ```
190
-
191
- ## Troubleshooting
192
-
193
- **Tools not loading?**
194
- - Check that tool YAML files are in the correct path
195
- - Verify YAML syntax is valid
196
- - Run `pnpm lint` to check for errors
197
-
198
- **Execution failing?**
199
- - Check parameters match the tool's parameter schema
200
- - Verify required environment variables are set
201
- - Check error message for specific failure reason
202
-
203
- **Type errors?**
204
- - Ensure TypeScript strict mode is enabled
205
- - Check that tool definitions match expected types
206
- - Run `pnpm build` to catch compilation errors
207
-
208
- ## Support
209
-
210
- - **Questions?** Open a [GitHub Discussion](https://github.com/tallclub/matimo/discussions)
211
- - **Found a bug?** [Open an issue](https://github.com/tallclub/matimo/issues)
212
- - **Want to contribute?** See [CONTRIBUTING.md](../CONTRIBUTING.md)
@@ -1,217 +0,0 @@
1
- # Your First Tool — Step by Step
2
-
3
- Execute your first Matimo tool in 5 minutes.
4
-
5
- ## Prerequisites
6
-
7
- - ✅ Matimo installed (see [Installation](./installation.md))
8
- - ✅ Node.js v18+ and pnpm installed
9
- - ✅ `cd` into a Matimo project with tools loaded
10
-
11
- ## Step 1: Initialize Matimo
12
-
13
- Create `first-tool.ts`:
14
-
15
- ```typescript
16
- import { matimo } from 'matimo';
17
-
18
- async function main() {
19
- // Initialize Matimo with tools directory
20
- const m = await matimo.init('./tools');
21
-
22
- console.log(`✅ Loaded ${m.listTools().length} tools`);
23
- }
24
-
25
- main().catch(console.error);
26
- ```
27
-
28
- Run it:
29
-
30
- ```bash
31
- npx tsx first-tool.ts
32
- ```
33
-
34
- **Output:**
35
- ```
36
- ✅ Loaded 8 tools
37
- ```
38
-
39
- ---
40
-
41
- ## Step 2: List Available Tools
42
-
43
- Update `first-tool.ts`:
44
-
45
- ```typescript
46
- import { matimo } from 'matimo';
47
-
48
- async function main() {
49
- const m = await matimo.init('./tools');
50
-
51
- // List all tools
52
- const tools = m.listTools();
53
-
54
- console.log('\n📦 Available Tools:\n');
55
- tools.forEach(tool => {
56
- console.log(` • ${tool.name}`);
57
- console.log(` ${tool.description}\n`);
58
- });
59
- }
60
-
61
- main().catch(console.error);
62
- ```
63
-
64
- **Output:**
65
- ```
66
- 📦 Available Tools:
67
-
68
- • calculator
69
- Perform basic math operations
70
-
71
- • gmail-send-email
72
- Send an email via Gmail API
73
-
74
- ... (more tools)
75
- ```
76
-
77
- ---
78
-
79
- ## Step 3: Get Tool Details
80
-
81
- ```typescript
82
- const tool = m.getTool('calculator');
83
-
84
- console.log(`Tool: ${tool.name}`);
85
- console.log(`Description: ${tool.description}`);
86
- console.log(`Parameters:`, tool.parameters);
87
- ```
88
-
89
- **Output:**
90
- ```
91
- Tool: calculator
92
- Description: Perform basic math operations
93
- Parameters: {
94
- operation: { type: 'string', required: true, ... },
95
- a: { type: 'number', required: true, ... },
96
- b: { type: 'number', required: true, ... }
97
- }
98
- ```
99
-
100
- ---
101
-
102
- ## Step 4: Execute a Tool
103
-
104
- ```typescript
105
- const result = await m.execute('calculator', {
106
- operation: 'add',
107
- a: 5,
108
- b: 3
109
- });
110
-
111
- console.log('Result:', result);
112
- // Output: Result: { result: 8 }
113
- ```
114
-
115
- ### Execute Different Operations
116
-
117
- ```typescript
118
- // Add
119
- const add = await m.execute('calculator', { operation: 'add', a: 10, b: 5 });
120
- console.log('10 + 5 =', add.result); // 15
121
-
122
- // Subtract
123
- const sub = await m.execute('calculator', { operation: 'subtract', a: 10, b: 5 });
124
- console.log('10 - 5 =', sub.result); // 5
125
-
126
- // Multiply
127
- const mul = await m.execute('calculator', { operation: 'multiply', a: 10, b: 5 });
128
- console.log('10 * 5 =', mul.result); // 50
129
-
130
- // Divide
131
- const div = await m.execute('calculator', { operation: 'divide', a: 10, b: 5 });
132
- console.log('10 / 5 =', div.result); // 2
133
- ```
134
-
135
- ---
136
-
137
- ## Step 5: Handle Errors
138
-
139
- ```typescript
140
- try {
141
- const result = await m.execute('calculator', {
142
- operation: 'divide',
143
- a: 10,
144
- b: 0 // ⚠️ Invalid
145
- });
146
- } catch (error) {
147
- if (error.code === 'EXECUTION_FAILED') {
148
- console.error('Tool execution failed:', error.message);
149
- } else if (error.code === 'INVALID_PARAMETERS') {
150
- console.error('Invalid parameters:', error.details);
151
- } else {
152
- console.error('Error:', error.message);
153
- }
154
- }
155
- ```
156
-
157
- See [Error Codes](../api-reference/ERRORS.md) for all possible errors.
158
-
159
- ---
160
-
161
- ## Next Steps
162
-
163
- - **Learn SDK Patterns**: [Factory vs Decorator](../user-guide/SDK_PATTERNS.md)
164
- - **Find More Tools**: [Tool Discovery](../user-guide/TOOL_DISCOVERY.md)
165
- - **Use with LangChain**: [LangChain Integration](../framework-integrations/LANGCHAIN.md)
166
- - **Build Your Own Tools**: [YAML Tool Specification](../tool-development/YAML_TOOLS.md)
167
-
168
- ---
169
-
170
- ## Complete Example
171
-
172
- ```typescript
173
- import { matimo } from 'matimo';
174
-
175
- async function main() {
176
- // 1. Initialize
177
- const m = await matimo.init('./tools');
178
- console.log(`✅ Loaded ${m.listTools().length} tools\n`);
179
-
180
- // 2. List tools
181
- const tools = m.listTools();
182
- console.log('📦 Available tools:');
183
- tools.forEach(t => console.log(` - ${t.name}`));
184
-
185
- // 3. Get tool
186
- const calc = m.getTool('calculator');
187
- console.log(`\n🔧 Tool: ${calc.name}`);
188
-
189
- // 4. Execute
190
- console.log('\n⚙️ Executing calculator...');
191
- const result = await m.execute('calculator', {
192
- operation: 'add',
193
- a: 5,
194
- b: 3
195
- });
196
- console.log('✅ Result:', result.result);
197
- }
198
-
199
- main().catch(console.error);
200
- ```
201
-
202
- **Output:**
203
- ```
204
- ✅ Loaded 8 tools
205
-
206
- 📦 Available tools:
207
- - calculator
208
- - gmail-send-email
209
- - github-get-repo
210
- ... (more tools)
211
-
212
- 🔧 Tool: calculator
213
-
214
- ⚙️ Executing calculator...
215
- ✅ Result: 8
216
- ```
217
-