matimo 0.1.0-alpha.1
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/LICENSE +21 -0
- package/README.md +651 -0
- package/dist/auth/oauth2-config.d.ts +104 -0
- package/dist/auth/oauth2-config.d.ts.map +1 -0
- package/dist/auth/oauth2-config.js +38 -0
- package/dist/auth/oauth2-config.js.map +1 -0
- package/dist/auth/oauth2-handler.d.ts +130 -0
- package/dist/auth/oauth2-handler.d.ts.map +1 -0
- package/dist/auth/oauth2-handler.js +265 -0
- package/dist/auth/oauth2-handler.js.map +1 -0
- package/dist/auth/oauth2-provider-loader.d.ts +68 -0
- package/dist/auth/oauth2-provider-loader.d.ts.map +1 -0
- package/dist/auth/oauth2-provider-loader.js +120 -0
- package/dist/auth/oauth2-provider-loader.js.map +1 -0
- package/dist/core/schema.d.ts +238 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +168 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/tool-loader.d.ts +29 -0
- package/dist/core/tool-loader.d.ts.map +1 -0
- package/dist/core/tool-loader.js +98 -0
- package/dist/core/tool-loader.js.map +1 -0
- package/dist/core/tool-registry.d.ts +48 -0
- package/dist/core/tool-registry.d.ts.map +1 -0
- package/dist/core/tool-registry.js +89 -0
- package/dist/core/tool-registry.js.map +1 -0
- package/dist/core/types.d.ts +143 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +2 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/tool-decorator.d.ts +97 -0
- package/dist/decorators/tool-decorator.d.ts.map +1 -0
- package/dist/decorators/tool-decorator.js +154 -0
- package/dist/decorators/tool-decorator.js.map +1 -0
- package/dist/encodings/parameter-encoding.d.ts +51 -0
- package/dist/encodings/parameter-encoding.d.ts.map +1 -0
- package/dist/encodings/parameter-encoding.js +116 -0
- package/dist/encodings/parameter-encoding.js.map +1 -0
- package/dist/errors/matimo-error.d.ts +34 -0
- package/dist/errors/matimo-error.d.ts.map +1 -0
- package/dist/errors/matimo-error.js +49 -0
- package/dist/errors/matimo-error.js.map +1 -0
- package/dist/executors/command-executor.d.ts +19 -0
- package/dist/executors/command-executor.d.ts.map +1 -0
- package/dist/executors/command-executor.js +94 -0
- package/dist/executors/command-executor.js.map +1 -0
- package/dist/executors/http-executor.d.ts +26 -0
- package/dist/executors/http-executor.d.ts.map +1 -0
- package/dist/executors/http-executor.js +133 -0
- package/dist/executors/http-executor.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/matimo-instance.d.ts +98 -0
- package/dist/matimo-instance.d.ts.map +1 -0
- package/dist/matimo-instance.js +260 -0
- package/dist/matimo-instance.js.map +1 -0
- package/docs/Gemfile +5 -0
- package/docs/RELEASES.md +69 -0
- package/docs/ROADMAP.md +138 -0
- package/docs/_config.yml +27 -0
- package/docs/api-reference/ERRORS.md +445 -0
- package/docs/api-reference/SDK.md +582 -0
- package/docs/api-reference/TYPES.md +415 -0
- package/docs/architecture/OAUTH.md +1366 -0
- package/docs/architecture/OVERVIEW.md +564 -0
- package/docs/assets/logo.png +0 -0
- package/docs/community/COMMIT_GUIDELINES.md +552 -0
- package/docs/framework-integrations/LANGCHAIN.md +286 -0
- package/docs/getting-started/QUICK_START.md +211 -0
- package/docs/getting-started/YOUR_FIRST_TOOL.md +217 -0
- package/docs/getting-started/installation.md +124 -0
- package/docs/index.md +288 -0
- package/docs/tool-development/DECORATOR_GUIDE.md +633 -0
- package/docs/tool-development/OAUTH_LINK.md +5 -0
- package/docs/tool-development/PROVIDER_CONFIGURATION.md +458 -0
- package/docs/tool-development/TESTING.md +412 -0
- package/docs/tool-development/TOOL_SPECIFICATION.md +793 -0
- package/docs/tool-development/YAML_TOOLS.md +65 -0
- package/docs/troubleshooting/FAQ.md +391 -0
- package/docs/user-guide/AUTHENTICATION.md +255 -0
- package/docs/user-guide/DEVELOPMENT_STANDARDS.md +698 -0
- package/docs/user-guide/SDK_PATTERNS.md +316 -0
- package/docs/user-guide/TOOL_DISCOVERY.md +209 -0
- package/package.json +96 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { applyParameterEncodings } from '../encodings/parameter-encoding';
|
|
3
|
+
/**
|
|
4
|
+
* HttpExecutor - Executes HTTP requests
|
|
5
|
+
* Handles authentication, retries, and response validation
|
|
6
|
+
*/
|
|
7
|
+
export class HttpExecutor {
|
|
8
|
+
/**
|
|
9
|
+
* Execute a tool that makes an HTTP request
|
|
10
|
+
*/
|
|
11
|
+
async execute(tool, params) {
|
|
12
|
+
if (tool.execution.type !== 'http') {
|
|
13
|
+
throw new Error('Tool execution type is not http');
|
|
14
|
+
}
|
|
15
|
+
const { method, url, headers = {}, body, timeout, query_params, parameter_encoding, } = tool.execution;
|
|
16
|
+
const queryParams = query_params;
|
|
17
|
+
const parameterEncodings = parameter_encoding;
|
|
18
|
+
// Apply parameter encodings (e.g., MIME encoding for email parameters)
|
|
19
|
+
let finalParams = params;
|
|
20
|
+
if (parameterEncodings && parameterEncodings.length > 0) {
|
|
21
|
+
finalParams = applyParameterEncodings(params, parameterEncodings);
|
|
22
|
+
}
|
|
23
|
+
// Implement parameter templating
|
|
24
|
+
let finalUrl = this.templateString(url, finalParams);
|
|
25
|
+
// Handle query parameters - only include non-empty ones
|
|
26
|
+
if (queryParams) {
|
|
27
|
+
const queryString = this.buildQueryString(queryParams, finalParams);
|
|
28
|
+
if (queryString) {
|
|
29
|
+
finalUrl += '?' + queryString;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const templatedHeaders = this.templateObject(headers, finalParams);
|
|
33
|
+
const templatedBody = body && typeof body === 'object'
|
|
34
|
+
? this.templateObject(body, finalParams)
|
|
35
|
+
: body;
|
|
36
|
+
// Build request config
|
|
37
|
+
const requestConfig = {
|
|
38
|
+
method,
|
|
39
|
+
url: finalUrl,
|
|
40
|
+
};
|
|
41
|
+
if (Object.keys(templatedHeaders).length > 0) {
|
|
42
|
+
requestConfig.headers = templatedHeaders;
|
|
43
|
+
}
|
|
44
|
+
if (templatedBody !== undefined) {
|
|
45
|
+
requestConfig.data = templatedBody;
|
|
46
|
+
}
|
|
47
|
+
if (timeout !== undefined) {
|
|
48
|
+
requestConfig.timeout = timeout;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const response = await axios.request(requestConfig);
|
|
52
|
+
const success = response.status >= 200 && response.status < 300;
|
|
53
|
+
return {
|
|
54
|
+
success,
|
|
55
|
+
data: response.data,
|
|
56
|
+
statusCode: response.status,
|
|
57
|
+
headers: response.headers,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const axiosError = error;
|
|
62
|
+
const status = axiosError.response?.status || 500;
|
|
63
|
+
const details = axiosError.response?.data || {};
|
|
64
|
+
return {
|
|
65
|
+
success: false,
|
|
66
|
+
error: axiosError.message || String(error),
|
|
67
|
+
statusCode: status,
|
|
68
|
+
details,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Replace parameter placeholders in a string
|
|
74
|
+
*/
|
|
75
|
+
templateString(str, params) {
|
|
76
|
+
let result = str;
|
|
77
|
+
for (const [key, value] of Object.entries(params)) {
|
|
78
|
+
const placeholder = `{${key}}`;
|
|
79
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
80
|
+
result = result.replace(new RegExp(placeholder, 'g'), String(value));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Build query string from query_params, only including provided values
|
|
87
|
+
*/
|
|
88
|
+
buildQueryString(queryParams, params) {
|
|
89
|
+
const parts = [];
|
|
90
|
+
for (const [key, template] of Object.entries(queryParams)) {
|
|
91
|
+
const value = this.templateString(template, params);
|
|
92
|
+
// Only include if not empty and didn't result in "{param}" (unfilled placeholder)
|
|
93
|
+
if (value && !value.startsWith('{')) {
|
|
94
|
+
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return parts.join('&');
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Replace parameter placeholders in an object (headers, body)
|
|
101
|
+
* Recursively handles nested objects
|
|
102
|
+
*/
|
|
103
|
+
templateObject(obj, params) {
|
|
104
|
+
const result = {};
|
|
105
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
106
|
+
if (typeof value === 'string') {
|
|
107
|
+
result[key] = this.templateString(value, params);
|
|
108
|
+
}
|
|
109
|
+
else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
110
|
+
// Recursively template nested objects
|
|
111
|
+
result[key] = this.templateObject(value, params);
|
|
112
|
+
}
|
|
113
|
+
else if (Array.isArray(value)) {
|
|
114
|
+
// Handle arrays of objects
|
|
115
|
+
result[key] = value.map((item) => {
|
|
116
|
+
if (typeof item === 'string') {
|
|
117
|
+
return this.templateString(item, params);
|
|
118
|
+
}
|
|
119
|
+
else if (typeof item === 'object' && item !== null && !Array.isArray(item)) {
|
|
120
|
+
return this.templateObject(item, params);
|
|
121
|
+
}
|
|
122
|
+
return item;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
result[key] = value;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export default HttpExecutor;
|
|
133
|
+
//# sourceMappingURL=http-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-executor.js","sourceRoot":"","sources":["../../src/executors/http-executor.ts"],"names":[],"mappings":"AAAA,OA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agent Tools Ecosystem
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic SDK that enables any developer to integrate 1000+ tools
|
|
5
|
+
* across any AI framework (LangChain, CrewAI, Anthropic SDK, etc.).
|
|
6
|
+
*/
|
|
7
|
+
export type { Parameter, AuthConfig, HttpExecution, CommandExecution, OutputSchema, RateLimitConfig, ErrorHandlingConfig, } from './core/types';
|
|
8
|
+
export { ParameterSchema, AuthConfigSchema, ExecutionConfigSchema } from './core/schema';
|
|
9
|
+
export { ToolLoader } from './core/tool-loader';
|
|
10
|
+
export { ToolRegistry } from './core/tool-registry';
|
|
11
|
+
export { CommandExecutor } from './executors/command-executor';
|
|
12
|
+
export { HttpExecutor } from './executors/http-executor';
|
|
13
|
+
export { applyParameterEncodings } from './encodings/parameter-encoding';
|
|
14
|
+
export type { ParameterEncodingConfig } from './encodings/parameter-encoding';
|
|
15
|
+
export { tool, setGlobalMatimoInstance, getGlobalMatimoInstance, } from './decorators/tool-decorator';
|
|
16
|
+
export { MatimoError, ErrorCode, createValidationError, createExecutionError, } from './errors/matimo-error';
|
|
17
|
+
export { MatimoInstance, matimo } from './matimo-instance';
|
|
18
|
+
export type { OAuth2Provider, OAuth2Token, OAuth2Config, AuthorizationOptions, TokenResponse, OAuth2Endpoints, } from './auth/oauth2-config';
|
|
19
|
+
export type { ProviderDefinition } from './core/schema';
|
|
20
|
+
export { OAuth2ProviderLoader } from './auth/oauth2-provider-loader';
|
|
21
|
+
export { OAuth2Handler } from './auth/oauth2-handler';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACV,SAAS,EACT,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,YAAY,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAG9E,OAAO,EACL,IAAI,EACJ,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,WAAW,EACX,SAAS,EACT,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3D,YAAY,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matimo - Universal AI Agent Tools Ecosystem
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic SDK that enables any developer to integrate 1000+ tools
|
|
5
|
+
* across any AI framework (LangChain, CrewAI, Anthropic SDK, etc.).
|
|
6
|
+
*/
|
|
7
|
+
export { ParameterSchema, AuthConfigSchema, ExecutionConfigSchema } from './core/schema';
|
|
8
|
+
export { ToolLoader } from './core/tool-loader';
|
|
9
|
+
export { ToolRegistry } from './core/tool-registry';
|
|
10
|
+
// Executors
|
|
11
|
+
export { CommandExecutor } from './executors/command-executor';
|
|
12
|
+
export { HttpExecutor } from './executors/http-executor';
|
|
13
|
+
// Parameter Encoding
|
|
14
|
+
export { applyParameterEncodings } from './encodings/parameter-encoding';
|
|
15
|
+
// Decorators
|
|
16
|
+
export { tool, setGlobalMatimoInstance, getGlobalMatimoInstance, } from './decorators/tool-decorator';
|
|
17
|
+
// Error handling
|
|
18
|
+
export { MatimoError, ErrorCode, createValidationError, createExecutionError, } from './errors/matimo-error';
|
|
19
|
+
// Matimo instance and namespace
|
|
20
|
+
export { MatimoInstance, matimo } from './matimo-instance';
|
|
21
|
+
export { OAuth2ProviderLoader } from './auth/oauth2-provider-loader';
|
|
22
|
+
export { OAuth2Handler } from './auth/oauth2-handler';
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,YAAY;AACZ,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,qBAAqB;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,aAAa;AACb,OAAO,EACL,IAAI,EACJ,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AAErC,iBAAiB;AACjB,OAAO,EACL,WAAW,EACX,SAAS,EACT,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAE/B,gCAAgC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAY3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ToolDefinition } from './core/schema';
|
|
2
|
+
/**
|
|
3
|
+
* Matimo Instance - Single initialization point for tool execution
|
|
4
|
+
* Combines loader, registry, and executors into one interface
|
|
5
|
+
*/
|
|
6
|
+
export declare class MatimoInstance {
|
|
7
|
+
private toolsPath;
|
|
8
|
+
private loader;
|
|
9
|
+
private registry;
|
|
10
|
+
private commandExecutor;
|
|
11
|
+
private httpExecutor;
|
|
12
|
+
private constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Initialize Matimo with tools from a directory
|
|
15
|
+
* @param toolsPath - Path to tools directory
|
|
16
|
+
* @returns MatimoInstance ready to execute tools
|
|
17
|
+
*/
|
|
18
|
+
static init(toolsPath: string): Promise<MatimoInstance>;
|
|
19
|
+
/**
|
|
20
|
+
* Execute a tool by name with parameters
|
|
21
|
+
* @param toolName - Name of the tool to execute
|
|
22
|
+
* @param params - Tool parameters
|
|
23
|
+
* @returns Tool execution result
|
|
24
|
+
*/
|
|
25
|
+
execute(toolName: string, params: Record<string, unknown>): Promise<unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a tool definition by name
|
|
28
|
+
* @param toolName - Name of the tool
|
|
29
|
+
* @returns Tool definition or undefined
|
|
30
|
+
*/
|
|
31
|
+
getTool(toolName: string): ToolDefinition | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* List all available tools
|
|
34
|
+
* @returns Array of tool definitions
|
|
35
|
+
*/
|
|
36
|
+
listTools(): ToolDefinition[];
|
|
37
|
+
/**
|
|
38
|
+
* Get all available tools (alias for listTools)
|
|
39
|
+
* @returns Array of tool definitions
|
|
40
|
+
*/
|
|
41
|
+
getAllTools(): ToolDefinition[];
|
|
42
|
+
/**
|
|
43
|
+
* Search tools by name or description
|
|
44
|
+
* @param query - Search query
|
|
45
|
+
* @returns Matching tools
|
|
46
|
+
*/
|
|
47
|
+
searchTools(query: string): ToolDefinition[];
|
|
48
|
+
/**
|
|
49
|
+
* Get tools by tag
|
|
50
|
+
* @param tag - Tag to search for
|
|
51
|
+
* @returns Tools with the given tag
|
|
52
|
+
*/
|
|
53
|
+
getToolsByTag(tag: string): ToolDefinition[];
|
|
54
|
+
/**
|
|
55
|
+
* Automatically inject parameters from environment variables
|
|
56
|
+
* Uses a YAML-native, scale-friendly approach:
|
|
57
|
+
*
|
|
58
|
+
* 1. Scans the execution config for all parameter placeholders
|
|
59
|
+
* 2. For each parameter not provided by user, checks if it looks like auth (TOKEN, KEY, SECRET, etc.)
|
|
60
|
+
* 3. If yes, attempts to load from environment: MATIMO_<PARAM_NAME> or <PARAM_NAME>
|
|
61
|
+
*
|
|
62
|
+
* This works for ANY tool with ANY auth parameter name - no hardcoding needed.
|
|
63
|
+
* Scales to unlimited tools - contributors just submit YAML.
|
|
64
|
+
*
|
|
65
|
+
* Examples:
|
|
66
|
+
* - GMAIL_ACCESS_TOKEN → looks in env vars
|
|
67
|
+
* - GITHUB_TOKEN → looks in env vars
|
|
68
|
+
* - SLACK_BOT_TOKEN → looks in env vars
|
|
69
|
+
* - MY_CUSTOM_API_KEY → looks in env vars
|
|
70
|
+
* - ANY_SECRET → looks in env vars
|
|
71
|
+
*/
|
|
72
|
+
private injectAuthParameters;
|
|
73
|
+
/**
|
|
74
|
+
* Extract all parameter placeholders from execution config
|
|
75
|
+
* Scans headers, body, URL, and query_params for {paramName} patterns
|
|
76
|
+
*/
|
|
77
|
+
private extractParameterPlaceholders;
|
|
78
|
+
/**
|
|
79
|
+
* Recursively scan object for parameter placeholders
|
|
80
|
+
*/
|
|
81
|
+
private scanObjectForParams;
|
|
82
|
+
/**
|
|
83
|
+
* Get the appropriate executor for a tool
|
|
84
|
+
*/
|
|
85
|
+
private getExecutor;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Matimo namespace - Entry point for the SDK
|
|
89
|
+
*/
|
|
90
|
+
export declare const matimo: {
|
|
91
|
+
/**
|
|
92
|
+
* Initialize Matimo with a tools directory
|
|
93
|
+
* @param toolsPath - Path to tools directory
|
|
94
|
+
* @returns MatimoInstance ready to use
|
|
95
|
+
*/
|
|
96
|
+
init(toolsPath: string): Promise<MatimoInstance>;
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=matimo-instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matimo-instance.d.ts","sourceRoot":"","sources":["../src/matimo-instance.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,QAAQ,CAAe;IAC/B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,YAAY,CAAe;IAEnC,OAAO;IAUP;;;;OAIG;WACU,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAO7D;;;;;OAKG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBlF;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIrD;;;OAGG;IACH,SAAS,IAAI,cAAc,EAAE;IAI7B;;;OAGG;IACH,WAAW,IAAI,cAAc,EAAE;IAI/B;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE;IAI5C;;;;OAIG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,EAAE;IAI5C;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,oBAAoB;IAoD5B;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAkDpC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA0C3B;;OAEG;IACH,OAAO,CAAC,WAAW;CAepB;AAED;;GAEG;AACH,eAAO,MAAM,MAAM;IACjB;;;;OAIG;oBACmB,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CAGvD,CAAC"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { ToolLoader } from './core/tool-loader';
|
|
3
|
+
import { ToolRegistry } from './core/tool-registry';
|
|
4
|
+
import { CommandExecutor } from './executors/command-executor';
|
|
5
|
+
import { HttpExecutor } from './executors/http-executor';
|
|
6
|
+
import { MatimoError, ErrorCode } from './errors/matimo-error';
|
|
7
|
+
/**
|
|
8
|
+
* Matimo Instance - Single initialization point for tool execution
|
|
9
|
+
* Combines loader, registry, and executors into one interface
|
|
10
|
+
*/
|
|
11
|
+
export class MatimoInstance {
|
|
12
|
+
constructor(toolsPath) {
|
|
13
|
+
this.toolsPath = toolsPath;
|
|
14
|
+
this.loader = new ToolLoader();
|
|
15
|
+
this.registry = new ToolRegistry();
|
|
16
|
+
// Use dirname to get parent directory reliably - works regardless of directory name
|
|
17
|
+
const workingDir = path.dirname(toolsPath);
|
|
18
|
+
this.commandExecutor = new CommandExecutor(workingDir);
|
|
19
|
+
this.httpExecutor = new HttpExecutor();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Initialize Matimo with tools from a directory
|
|
23
|
+
* @param toolsPath - Path to tools directory
|
|
24
|
+
* @returns MatimoInstance ready to execute tools
|
|
25
|
+
*/
|
|
26
|
+
static async init(toolsPath) {
|
|
27
|
+
const instance = new MatimoInstance(toolsPath);
|
|
28
|
+
const tools = await instance.loader.loadToolsFromDirectory(toolsPath);
|
|
29
|
+
instance.registry.registerAll(Array.from(tools.values()));
|
|
30
|
+
return instance;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Execute a tool by name with parameters
|
|
34
|
+
* @param toolName - Name of the tool to execute
|
|
35
|
+
* @param params - Tool parameters
|
|
36
|
+
* @returns Tool execution result
|
|
37
|
+
*/
|
|
38
|
+
async execute(toolName, params) {
|
|
39
|
+
const tool = this.registry.get(toolName);
|
|
40
|
+
if (!tool) {
|
|
41
|
+
throw new MatimoError(`Tool '${toolName}' not found in registry`, ErrorCode.TOOL_NOT_FOUND, {
|
|
42
|
+
toolName,
|
|
43
|
+
availableTools: this.registry.getAll().map((t) => t.name),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// Auto-inject authentication parameters from environment variables
|
|
47
|
+
const finalParams = this.injectAuthParameters(tool, params);
|
|
48
|
+
const executor = this.getExecutor(tool);
|
|
49
|
+
return executor.execute(tool, finalParams);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get a tool definition by name
|
|
53
|
+
* @param toolName - Name of the tool
|
|
54
|
+
* @returns Tool definition or undefined
|
|
55
|
+
*/
|
|
56
|
+
getTool(toolName) {
|
|
57
|
+
return this.registry.get(toolName);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* List all available tools
|
|
61
|
+
* @returns Array of tool definitions
|
|
62
|
+
*/
|
|
63
|
+
listTools() {
|
|
64
|
+
return this.registry.getAll();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get all available tools (alias for listTools)
|
|
68
|
+
* @returns Array of tool definitions
|
|
69
|
+
*/
|
|
70
|
+
getAllTools() {
|
|
71
|
+
return this.registry.getAll();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Search tools by name or description
|
|
75
|
+
* @param query - Search query
|
|
76
|
+
* @returns Matching tools
|
|
77
|
+
*/
|
|
78
|
+
searchTools(query) {
|
|
79
|
+
return this.registry.search(query);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get tools by tag
|
|
83
|
+
* @param tag - Tag to search for
|
|
84
|
+
* @returns Tools with the given tag
|
|
85
|
+
*/
|
|
86
|
+
getToolsByTag(tag) {
|
|
87
|
+
return this.registry.getByTag(tag);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Automatically inject parameters from environment variables
|
|
91
|
+
* Uses a YAML-native, scale-friendly approach:
|
|
92
|
+
*
|
|
93
|
+
* 1. Scans the execution config for all parameter placeholders
|
|
94
|
+
* 2. For each parameter not provided by user, checks if it looks like auth (TOKEN, KEY, SECRET, etc.)
|
|
95
|
+
* 3. If yes, attempts to load from environment: MATIMO_<PARAM_NAME> or <PARAM_NAME>
|
|
96
|
+
*
|
|
97
|
+
* This works for ANY tool with ANY auth parameter name - no hardcoding needed.
|
|
98
|
+
* Scales to unlimited tools - contributors just submit YAML.
|
|
99
|
+
*
|
|
100
|
+
* Examples:
|
|
101
|
+
* - GMAIL_ACCESS_TOKEN → looks in env vars
|
|
102
|
+
* - GITHUB_TOKEN → looks in env vars
|
|
103
|
+
* - SLACK_BOT_TOKEN → looks in env vars
|
|
104
|
+
* - MY_CUSTOM_API_KEY → looks in env vars
|
|
105
|
+
* - ANY_SECRET → looks in env vars
|
|
106
|
+
*/
|
|
107
|
+
injectAuthParameters(tool, params) {
|
|
108
|
+
const result = { ...params };
|
|
109
|
+
// Collect all parameter names referenced in the execution config
|
|
110
|
+
const referencedParams = this.extractParameterPlaceholders(tool);
|
|
111
|
+
// Auth-related parameter name patterns (case-insensitive)
|
|
112
|
+
const authPatterns = [
|
|
113
|
+
'token',
|
|
114
|
+
'key',
|
|
115
|
+
'secret',
|
|
116
|
+
'password',
|
|
117
|
+
'credential',
|
|
118
|
+
'auth',
|
|
119
|
+
'bearer',
|
|
120
|
+
'api_key',
|
|
121
|
+
];
|
|
122
|
+
// Check each referenced parameter
|
|
123
|
+
for (const paramName of referencedParams) {
|
|
124
|
+
// Skip if user already provided it
|
|
125
|
+
if (paramName in result) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
// Check if parameter name looks like auth
|
|
129
|
+
const lowerName = paramName.toLowerCase();
|
|
130
|
+
const isAuthParam = authPatterns.some((pattern) => lowerName.includes(pattern));
|
|
131
|
+
if (isAuthParam) {
|
|
132
|
+
// Try to load from environment
|
|
133
|
+
// First try MATIMO_ prefixed version for organization
|
|
134
|
+
let envValue = process.env[`MATIMO_${paramName}`];
|
|
135
|
+
// If not found, try the parameter name directly
|
|
136
|
+
if (!envValue) {
|
|
137
|
+
envValue = process.env[paramName];
|
|
138
|
+
}
|
|
139
|
+
// If found, inject it
|
|
140
|
+
if (envValue) {
|
|
141
|
+
result[paramName] = envValue;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Extract all parameter placeholders from execution config
|
|
149
|
+
* Scans headers, body, URL, and query_params for {paramName} patterns
|
|
150
|
+
*/
|
|
151
|
+
extractParameterPlaceholders(tool) {
|
|
152
|
+
const params = new Set();
|
|
153
|
+
const placeholderRegex = /\{([^}]+)\}/g;
|
|
154
|
+
const execution = tool.execution;
|
|
155
|
+
// Scan URL
|
|
156
|
+
if ('url' in execution && execution.url) {
|
|
157
|
+
let match;
|
|
158
|
+
while ((match = placeholderRegex.exec(execution.url)) !== null) {
|
|
159
|
+
params.add(match[1]);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Scan headers
|
|
163
|
+
if ('headers' in execution && execution.headers && typeof execution.headers === 'object') {
|
|
164
|
+
for (const value of Object.values(execution.headers)) {
|
|
165
|
+
if (typeof value === 'string') {
|
|
166
|
+
let match;
|
|
167
|
+
while ((match = placeholderRegex.exec(value)) !== null) {
|
|
168
|
+
params.add(match[1]);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Scan body (recursively for nested objects)
|
|
174
|
+
if ('body' in execution && execution.body) {
|
|
175
|
+
this.scanObjectForParams(execution.body, params);
|
|
176
|
+
}
|
|
177
|
+
// Scan query_params
|
|
178
|
+
if ('query_params' in execution &&
|
|
179
|
+
execution.query_params &&
|
|
180
|
+
typeof execution.query_params === 'object') {
|
|
181
|
+
for (const value of Object.values(execution.query_params)) {
|
|
182
|
+
if (typeof value === 'string') {
|
|
183
|
+
let match;
|
|
184
|
+
while ((match = placeholderRegex.exec(value)) !== null) {
|
|
185
|
+
params.add(match[1]);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return params;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Recursively scan object for parameter placeholders
|
|
194
|
+
*/
|
|
195
|
+
scanObjectForParams(obj, params, visited = new WeakSet()) {
|
|
196
|
+
if (!obj || typeof obj !== 'object') {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
// Prevent infinite loops
|
|
200
|
+
if (visited.has(obj)) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
visited.add(obj);
|
|
204
|
+
const placeholderRegex = /\{([^}]+)\}/g;
|
|
205
|
+
if (Array.isArray(obj)) {
|
|
206
|
+
for (const item of obj) {
|
|
207
|
+
if (typeof item === 'string') {
|
|
208
|
+
let match;
|
|
209
|
+
while ((match = placeholderRegex.exec(item)) !== null) {
|
|
210
|
+
params.add(match[1]);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else if (item && typeof item === 'object') {
|
|
214
|
+
this.scanObjectForParams(item, params, visited);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
for (const value of Object.values(obj)) {
|
|
220
|
+
if (typeof value === 'string') {
|
|
221
|
+
let match;
|
|
222
|
+
while ((match = placeholderRegex.exec(value)) !== null) {
|
|
223
|
+
params.add(match[1]);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else if (value && typeof value === 'object') {
|
|
227
|
+
this.scanObjectForParams(value, params, visited);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Get the appropriate executor for a tool
|
|
234
|
+
*/
|
|
235
|
+
getExecutor(tool) {
|
|
236
|
+
const executionType = tool.execution.type;
|
|
237
|
+
switch (executionType) {
|
|
238
|
+
case 'command':
|
|
239
|
+
return this.commandExecutor;
|
|
240
|
+
case 'http':
|
|
241
|
+
return this.httpExecutor;
|
|
242
|
+
default:
|
|
243
|
+
throw new MatimoError(`Unsupported execution type: ${executionType}`, ErrorCode.EXECUTION_FAILED, { executionType });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Matimo namespace - Entry point for the SDK
|
|
249
|
+
*/
|
|
250
|
+
export const matimo = {
|
|
251
|
+
/**
|
|
252
|
+
* Initialize Matimo with a tools directory
|
|
253
|
+
* @param toolsPath - Path to tools directory
|
|
254
|
+
* @returns MatimoInstance ready to use
|
|
255
|
+
*/
|
|
256
|
+
async init(toolsPath) {
|
|
257
|
+
return MatimoInstance.init(toolsPath);
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
//# sourceMappingURL=matimo-instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matimo-instance.js","sourceRoot":"","sources":["../src/matimo-instance.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;GAGG;AACH,MAAM,OAAO,cAAc;IAOzB,YAAoB,SAAiB;QACnC,IAAI,CAAC,SAAS,GAAG,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,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,IAAoB;QACtC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAc,CAAC;QACpD,QAAQ,aAAa,EAAE,CAAC;YACtB,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAC,eAAe,CAAC;YAC9B,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC,YAAY,CAAC;YAC3B;gBACE,MAAM,IAAI,WAAW,CACnB,+BAA+B,aAAa,EAAE,EAC9C,SAAS,CAAC,gBAAgB,EAC1B,EAAE,aAAa,EAAE,CAClB,CAAC;QACN,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,SAAiB;QAC1B,OAAO,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF,CAAC"}
|
package/docs/Gemfile
ADDED
package/docs/RELEASES.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# v0.1.0-alpha.1
|
|
2
|
+
|
|
3
|
+
> First alpha release - Core OAuth2, tool execution, and SDK patterns
|
|
4
|
+
|
|
5
|
+
**Released**: February 3, 2026
|
|
6
|
+
|
|
7
|
+
## What's New
|
|
8
|
+
|
|
9
|
+
### OAuth2 Multi-Provider Support
|
|
10
|
+
- OAuth2 handler with token injection
|
|
11
|
+
- Providers: Google (Gmail), GitHub, Slack
|
|
12
|
+
- Provider YAML configuration
|
|
13
|
+
- Automatic token injection into requests
|
|
14
|
+
|
|
15
|
+
### Tool System
|
|
16
|
+
- YAML/JSON tool definitions with Zod validation
|
|
17
|
+
- Command executor (shell commands with templating)
|
|
18
|
+
- HTTP executor (REST APIs with OAuth2)
|
|
19
|
+
- Provider definition system
|
|
20
|
+
- Tool discovery and filtering
|
|
21
|
+
|
|
22
|
+
### SDK Patterns
|
|
23
|
+
- **Factory pattern**: `const m = await matimo.init('./tools'); m.execute(toolName, params)`
|
|
24
|
+
- **Decorator pattern**: `@tool('calculator')` for class-based usage
|
|
25
|
+
- Tool discovery, filtering, and search
|
|
26
|
+
- Full TypeScript support with strict types
|
|
27
|
+
|
|
28
|
+
### Tools Included
|
|
29
|
+
- **Gmail** (5 tools): send, list, get, draft, delete
|
|
30
|
+
- **Utilities**: calculator, echo, HTTP client
|
|
31
|
+
- **Provider configs**: Google, GitHub, Slack
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install matimo@0.1.0-alpha.1
|
|
37
|
+
pnpm add matimo@0.1.0-alpha.1
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { matimo } from 'matimo';
|
|
44
|
+
|
|
45
|
+
const m = await matimo.init('./tools');
|
|
46
|
+
const result = await m.execute('calculator', {
|
|
47
|
+
operation: 'add', a: 5, b: 3
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Documentation
|
|
52
|
+
|
|
53
|
+
- [Installation & Setup](./getting-started/installation.md)
|
|
54
|
+
- [Quick Start](./getting-started/QUICK_START.md)
|
|
55
|
+
- [SDK Patterns](./user-guide/SDK_PATTERNS.md)
|
|
56
|
+
- [OAuth2 Guide](./architecture/OAUTH.md)
|
|
57
|
+
- [API Reference](./api-reference/SDK.md)
|
|
58
|
+
- [Examples](../examples/)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## Known Limitations
|
|
62
|
+
|
|
63
|
+
This is an **alpha release**. Not recommended for production without thorough testing.
|
|
64
|
+
|
|
65
|
+
See [Roadmap](./ROADMAP.md) for future features.
|
|
66
|
+
|
|
67
|
+
## Contributing
|
|
68
|
+
|
|
69
|
+
[Contributing Guide](../CONTRIBUTING.md) | [Report Issues](https://github.com/tallclub/matimo/issues)
|