matimo 0.1.0-alpha.8 → 0.1.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/package.json +10 -8
- package/packages/cli/dist/bin.d.ts +3 -0
- package/packages/cli/dist/bin.d.ts.map +1 -0
- package/packages/cli/dist/bin.js +50 -0
- package/packages/cli/dist/bin.js.map +1 -0
- package/packages/cli/dist/cli.d.ts.map +1 -1
- package/packages/cli/dist/cli.js +64 -2
- package/packages/cli/dist/cli.js.map +1 -1
- package/packages/cli/dist/commands/doctor.d.ts +2 -0
- package/packages/cli/dist/commands/doctor.d.ts.map +1 -0
- package/packages/cli/dist/commands/doctor.js +174 -0
- package/packages/cli/dist/commands/doctor.js.map +1 -0
- package/packages/cli/dist/commands/mcp-setup.d.ts +9 -0
- package/packages/cli/dist/commands/mcp-setup.d.ts.map +1 -0
- package/packages/cli/dist/commands/mcp-setup.js +106 -0
- package/packages/cli/dist/commands/mcp-setup.js.map +1 -0
- package/packages/cli/dist/commands/mcp.d.ts +17 -0
- package/packages/cli/dist/commands/mcp.d.ts.map +1 -0
- package/packages/cli/dist/commands/mcp.js +228 -0
- package/packages/cli/dist/commands/mcp.js.map +1 -0
- package/packages/cli/dist/commands/review.d.ts +10 -0
- package/packages/cli/dist/commands/review.d.ts.map +1 -0
- package/packages/cli/dist/commands/review.js +176 -0
- package/packages/cli/dist/commands/review.js.map +1 -0
- package/packages/core/dist/approval/approval-handler.d.ts +5 -1
- package/packages/core/dist/approval/approval-handler.d.ts.map +1 -1
- package/packages/core/dist/approval/approval-handler.js +6 -0
- package/packages/core/dist/approval/approval-handler.js.map +1 -1
- package/packages/core/dist/core/schema.d.ts +41 -10
- package/packages/core/dist/core/schema.d.ts.map +1 -1
- package/packages/core/dist/core/schema.js +40 -4
- package/packages/core/dist/core/schema.js.map +1 -1
- package/packages/core/dist/core/skill-content-parser.d.ts +91 -0
- package/packages/core/dist/core/skill-content-parser.d.ts.map +1 -0
- package/packages/core/dist/core/skill-content-parser.js +248 -0
- package/packages/core/dist/core/skill-content-parser.js.map +1 -0
- package/packages/core/dist/core/skill-loader.d.ts +46 -0
- package/packages/core/dist/core/skill-loader.d.ts.map +1 -0
- package/packages/core/dist/core/skill-loader.js +310 -0
- package/packages/core/dist/core/skill-loader.js.map +1 -0
- package/packages/core/dist/core/skill-registry.d.ts +131 -0
- package/packages/core/dist/core/skill-registry.d.ts.map +1 -0
- package/packages/core/dist/core/skill-registry.js +316 -0
- package/packages/core/dist/core/skill-registry.js.map +1 -0
- package/packages/core/dist/core/tfidf-embedding.d.ts +45 -0
- package/packages/core/dist/core/tfidf-embedding.d.ts.map +1 -0
- package/packages/core/dist/core/tfidf-embedding.js +199 -0
- package/packages/core/dist/core/tfidf-embedding.js.map +1 -0
- package/packages/core/dist/core/tool-loader.d.ts +3 -1
- package/packages/core/dist/core/tool-loader.d.ts.map +1 -1
- package/packages/core/dist/core/tool-loader.js +33 -10
- package/packages/core/dist/core/tool-loader.js.map +1 -1
- package/packages/core/dist/core/types.d.ts +203 -6
- package/packages/core/dist/core/types.d.ts.map +1 -1
- package/packages/core/dist/encodings/parameter-encoding.d.ts +1 -1
- package/packages/core/dist/encodings/parameter-encoding.d.ts.map +1 -1
- package/packages/core/dist/encodings/parameter-encoding.js +9 -4
- package/packages/core/dist/encodings/parameter-encoding.js.map +1 -1
- package/packages/core/dist/errors/matimo-error.d.ts +11 -2
- package/packages/core/dist/errors/matimo-error.d.ts.map +1 -1
- package/packages/core/dist/errors/matimo-error.js +25 -1
- package/packages/core/dist/errors/matimo-error.js.map +1 -1
- package/packages/core/dist/executors/command-executor.d.ts +9 -2
- package/packages/core/dist/executors/command-executor.d.ts.map +1 -1
- package/packages/core/dist/executors/command-executor.js +29 -5
- package/packages/core/dist/executors/command-executor.js.map +1 -1
- package/packages/core/dist/executors/function-executor.d.ts +10 -3
- package/packages/core/dist/executors/function-executor.d.ts.map +1 -1
- package/packages/core/dist/executors/function-executor.js +44 -24
- package/packages/core/dist/executors/function-executor.js.map +1 -1
- package/packages/core/dist/executors/http-executor.d.ts +79 -4
- package/packages/core/dist/executors/http-executor.d.ts.map +1 -1
- package/packages/core/dist/executors/http-executor.js +232 -28
- package/packages/core/dist/executors/http-executor.js.map +1 -1
- package/packages/core/dist/index.d.ts +25 -3
- package/packages/core/dist/index.d.ts.map +1 -1
- package/packages/core/dist/index.js +19 -1
- package/packages/core/dist/index.js.map +1 -1
- package/packages/core/dist/integrations/langchain.d.ts +55 -0
- package/packages/core/dist/integrations/langchain.d.ts.map +1 -1
- package/packages/core/dist/integrations/langchain.js +71 -4
- package/packages/core/dist/integrations/langchain.js.map +1 -1
- package/packages/core/dist/logging/logger.d.ts +8 -2
- package/packages/core/dist/logging/logger.d.ts.map +1 -1
- package/packages/core/dist/logging/logger.js.map +1 -1
- package/packages/core/dist/logging/winston-logger.d.ts.map +1 -1
- package/packages/core/dist/logging/winston-logger.js +9 -1
- package/packages/core/dist/logging/winston-logger.js.map +1 -1
- package/packages/core/dist/matimo-instance.d.ts +230 -18
- package/packages/core/dist/matimo-instance.d.ts.map +1 -1
- package/packages/core/dist/matimo-instance.js +739 -40
- package/packages/core/dist/matimo-instance.js.map +1 -1
- package/packages/core/dist/mcp/index.d.ts +18 -0
- package/packages/core/dist/mcp/index.d.ts.map +1 -0
- package/packages/core/dist/mcp/index.js +24 -0
- package/packages/core/dist/mcp/index.js.map +1 -0
- package/packages/core/dist/mcp/mcp-server.d.ts +141 -0
- package/packages/core/dist/mcp/mcp-server.d.ts.map +1 -0
- package/packages/core/dist/mcp/mcp-server.js +754 -0
- package/packages/core/dist/mcp/mcp-server.js.map +1 -0
- package/packages/core/dist/mcp/secrets/aws-resolver.d.ts +41 -0
- package/packages/core/dist/mcp/secrets/aws-resolver.d.ts.map +1 -0
- package/packages/core/dist/mcp/secrets/aws-resolver.js +141 -0
- package/packages/core/dist/mcp/secrets/aws-resolver.js.map +1 -0
- package/packages/core/dist/mcp/secrets/dotenv-resolver.d.ts +23 -0
- package/packages/core/dist/mcp/secrets/dotenv-resolver.d.ts.map +1 -0
- package/packages/core/dist/mcp/secrets/dotenv-resolver.js +94 -0
- package/packages/core/dist/mcp/secrets/dotenv-resolver.js.map +1 -0
- package/packages/core/dist/mcp/secrets/env-resolver.d.ts +14 -0
- package/packages/core/dist/mcp/secrets/env-resolver.d.ts.map +1 -0
- package/packages/core/dist/mcp/secrets/env-resolver.js +27 -0
- package/packages/core/dist/mcp/secrets/env-resolver.js.map +1 -0
- package/packages/core/dist/mcp/secrets/index.d.ts +14 -0
- package/packages/core/dist/mcp/secrets/index.d.ts.map +1 -0
- package/packages/core/dist/mcp/secrets/index.js +13 -0
- package/packages/core/dist/mcp/secrets/index.js.map +1 -0
- package/packages/core/dist/mcp/secrets/resolver-chain.d.ts +34 -0
- package/packages/core/dist/mcp/secrets/resolver-chain.d.ts.map +1 -0
- package/packages/core/dist/mcp/secrets/resolver-chain.js +141 -0
- package/packages/core/dist/mcp/secrets/resolver-chain.js.map +1 -0
- package/packages/core/dist/mcp/secrets/types.d.ts +73 -0
- package/packages/core/dist/mcp/secrets/types.d.ts.map +1 -0
- package/packages/core/dist/mcp/secrets/types.js +8 -0
- package/packages/core/dist/mcp/secrets/types.js.map +1 -0
- package/packages/core/dist/mcp/secrets/vault-resolver.d.ts +43 -0
- package/packages/core/dist/mcp/secrets/vault-resolver.d.ts.map +1 -0
- package/packages/core/dist/mcp/secrets/vault-resolver.js +127 -0
- package/packages/core/dist/mcp/secrets/vault-resolver.js.map +1 -0
- package/packages/core/dist/mcp/tool-converter.d.ts +40 -0
- package/packages/core/dist/mcp/tool-converter.d.ts.map +1 -0
- package/packages/core/dist/mcp/tool-converter.js +185 -0
- package/packages/core/dist/mcp/tool-converter.js.map +1 -0
- package/packages/core/dist/policy/approval-manifest.d.ts +76 -0
- package/packages/core/dist/policy/approval-manifest.d.ts.map +1 -0
- package/packages/core/dist/policy/approval-manifest.js +197 -0
- package/packages/core/dist/policy/approval-manifest.js.map +1 -0
- package/packages/core/dist/policy/content-validator.d.ts +19 -0
- package/packages/core/dist/policy/content-validator.d.ts.map +1 -0
- package/packages/core/dist/policy/content-validator.js +196 -0
- package/packages/core/dist/policy/content-validator.js.map +1 -0
- package/packages/core/dist/policy/default-policy.d.ts +46 -0
- package/packages/core/dist/policy/default-policy.d.ts.map +1 -0
- package/packages/core/dist/policy/default-policy.js +241 -0
- package/packages/core/dist/policy/default-policy.js.map +1 -0
- package/packages/core/dist/policy/events.d.ts +71 -0
- package/packages/core/dist/policy/events.d.ts.map +1 -0
- package/packages/core/dist/policy/events.js +8 -0
- package/packages/core/dist/policy/events.js.map +1 -0
- package/packages/core/dist/policy/index.d.ts +13 -0
- package/packages/core/dist/policy/index.d.ts.map +1 -0
- package/packages/core/dist/policy/index.js +9 -0
- package/packages/core/dist/policy/index.js.map +1 -0
- package/packages/core/dist/policy/integrity-tracker.d.ts +62 -0
- package/packages/core/dist/policy/integrity-tracker.d.ts.map +1 -0
- package/packages/core/dist/policy/integrity-tracker.js +79 -0
- package/packages/core/dist/policy/integrity-tracker.js.map +1 -0
- package/packages/core/dist/policy/policy-loader.d.ts +58 -0
- package/packages/core/dist/policy/policy-loader.d.ts.map +1 -0
- package/packages/core/dist/policy/policy-loader.js +156 -0
- package/packages/core/dist/policy/policy-loader.js.map +1 -0
- package/packages/core/dist/policy/risk-classifier.d.ts +18 -0
- package/packages/core/dist/policy/risk-classifier.d.ts.map +1 -0
- package/packages/core/dist/policy/risk-classifier.js +47 -0
- package/packages/core/dist/policy/risk-classifier.js.map +1 -0
- package/packages/core/dist/policy/types.d.ts +131 -0
- package/packages/core/dist/policy/types.d.ts.map +1 -0
- package/packages/core/dist/policy/types.js +8 -0
- package/packages/core/dist/policy/types.js.map +1 -0
- package/LICENSE +0 -21
- package/README.md +0 -243
- package/packages/cli/bin/matimo.cjs +0 -26
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy-as-YAML loader for Matimo.
|
|
3
|
+
*
|
|
4
|
+
* Allows the developer to configure the policy engine through a YAML file
|
|
5
|
+
* instead of inline TypeScript, making it easy to adjust policy across
|
|
6
|
+
* environments without rebuilding.
|
|
7
|
+
*
|
|
8
|
+
* Schema for policy.yaml:
|
|
9
|
+
*
|
|
10
|
+
* ```yaml
|
|
11
|
+
* allowedDomains:
|
|
12
|
+
* - api.slack.com
|
|
13
|
+
* - slack.com
|
|
14
|
+
*
|
|
15
|
+
* allowedCredentials:
|
|
16
|
+
* - SLACK_BOT_TOKEN
|
|
17
|
+
* - OPENAI_API_KEY
|
|
18
|
+
*
|
|
19
|
+
* allowedHttpMethods:
|
|
20
|
+
* - GET
|
|
21
|
+
* - POST
|
|
22
|
+
*
|
|
23
|
+
* allowCommandTools: false
|
|
24
|
+
* allowFunctionTools: false
|
|
25
|
+
*
|
|
26
|
+
* protectedNamespaces:
|
|
27
|
+
* - matimo_
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Usage:
|
|
31
|
+
* const matimo = await MatimoInstance.init({ policyFile: './policy.yaml' });
|
|
32
|
+
*/
|
|
33
|
+
import fs from 'fs';
|
|
34
|
+
import yaml from 'js-yaml';
|
|
35
|
+
import { z } from 'zod';
|
|
36
|
+
import { DefaultPolicyEngine } from './default-policy';
|
|
37
|
+
import { MatimoError, ErrorCode } from '../errors/matimo-error';
|
|
38
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
39
|
+
// Zod schema — validates the YAML before constructing PolicyConfig
|
|
40
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
41
|
+
// Valid HTTP methods supported by the policy engine
|
|
42
|
+
const VALID_HTTP_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'];
|
|
43
|
+
const ValidHttpMethodEnum = z.enum(VALID_HTTP_METHODS);
|
|
44
|
+
const PolicyFileSchema = z.object({
|
|
45
|
+
allowedDomains: z.array(z.string()).optional(),
|
|
46
|
+
allowedCredentials: z.array(z.string()).optional(),
|
|
47
|
+
allowedHttpMethods: z
|
|
48
|
+
.array(z
|
|
49
|
+
.string()
|
|
50
|
+
.transform((val) => val.toUpperCase())
|
|
51
|
+
.pipe(ValidHttpMethodEnum))
|
|
52
|
+
.optional(),
|
|
53
|
+
allowCommandTools: z.boolean().optional(),
|
|
54
|
+
allowFunctionTools: z.boolean().optional(),
|
|
55
|
+
protectedNamespaces: z.array(z.string()).optional(),
|
|
56
|
+
enableHITL: z.boolean().optional(),
|
|
57
|
+
quarantineRiskLevels: z.array(z.enum(['low', 'medium', 'high', 'critical'])).optional(),
|
|
58
|
+
approvalTtlSeconds: z.number().int().positive().optional(),
|
|
59
|
+
});
|
|
60
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
61
|
+
// Public API
|
|
62
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
63
|
+
/**
|
|
64
|
+
* Parse a YAML policy file and return a PolicyEngine configured from it.
|
|
65
|
+
*
|
|
66
|
+
* Throws `MatimoError(INVALID_SCHEMA)` if the file cannot be read or fails validation.
|
|
67
|
+
*
|
|
68
|
+
* @param filePath - Absolute or cwd-relative path to the policy YAML file
|
|
69
|
+
* @returns A frozen `DefaultPolicyEngine` built from the parsed config
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* // Direct usage
|
|
74
|
+
* const engine = loadPolicyFromFile('./policy.yaml');
|
|
75
|
+
* const matimo = await MatimoInstance.init({ policy: engine });
|
|
76
|
+
*
|
|
77
|
+
* // Or use the shorthand InitOption (preferred)
|
|
78
|
+
* const matimo = await MatimoInstance.init({ policyFile: './policy.yaml' });
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export function loadPolicyFromFile(filePath) {
|
|
82
|
+
let raw;
|
|
83
|
+
try {
|
|
84
|
+
raw = fs.readFileSync(filePath, 'utf-8');
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
throw new MatimoError(`Cannot read policy file "${filePath}": ${err.message}`, ErrorCode.INVALID_SCHEMA, { filePath });
|
|
88
|
+
}
|
|
89
|
+
let parsed;
|
|
90
|
+
try {
|
|
91
|
+
parsed = yaml.load(raw);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
throw new MatimoError(`Policy file "${filePath}" contains invalid YAML: ${err.message}`, ErrorCode.INVALID_SCHEMA, { filePath });
|
|
95
|
+
}
|
|
96
|
+
const result = PolicyFileSchema.safeParse(parsed ?? {});
|
|
97
|
+
if (!result.success) {
|
|
98
|
+
const issues = result.error.issues
|
|
99
|
+
.map((i) => ` • ${i.path.join('.')}: ${i.message}`)
|
|
100
|
+
.join('\n');
|
|
101
|
+
throw new MatimoError(`Policy file "${filePath}" is invalid:\n${issues}`, ErrorCode.INVALID_SCHEMA, { filePath, issues: result.error.issues });
|
|
102
|
+
}
|
|
103
|
+
const policyConfig = buildPolicyConfig(result.data);
|
|
104
|
+
return new DefaultPolicyEngine(policyConfig);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Parse a YAML policy file into a PolicyConfig (without creating an engine).
|
|
108
|
+
* Useful for hot-reload: parse the new file, then call engine.updateConfig().
|
|
109
|
+
*/
|
|
110
|
+
export function parsePolicyFile(filePath) {
|
|
111
|
+
let raw;
|
|
112
|
+
try {
|
|
113
|
+
raw = fs.readFileSync(filePath, 'utf-8');
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
throw new MatimoError(`Cannot read policy file "${filePath}": ${err.message}`, ErrorCode.INVALID_SCHEMA, { filePath });
|
|
117
|
+
}
|
|
118
|
+
let parsed;
|
|
119
|
+
try {
|
|
120
|
+
parsed = yaml.load(raw);
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
throw new MatimoError(`Policy file "${filePath}" contains invalid YAML: ${err.message}`, ErrorCode.INVALID_SCHEMA, { filePath });
|
|
124
|
+
}
|
|
125
|
+
const result = PolicyFileSchema.safeParse(parsed ?? {});
|
|
126
|
+
if (!result.success) {
|
|
127
|
+
const issues = result.error.issues
|
|
128
|
+
.map((i) => ` \u2022 ${i.path.join('.')}: ${i.message}`)
|
|
129
|
+
.join('\n');
|
|
130
|
+
throw new MatimoError(`Policy file "${filePath}" is invalid:\n${issues}`, ErrorCode.INVALID_SCHEMA, { filePath, issues: result.error.issues });
|
|
131
|
+
}
|
|
132
|
+
return buildPolicyConfig(result.data);
|
|
133
|
+
}
|
|
134
|
+
function buildPolicyConfig(data) {
|
|
135
|
+
const config = {};
|
|
136
|
+
if (data.allowedDomains !== undefined)
|
|
137
|
+
config.allowedDomains = data.allowedDomains;
|
|
138
|
+
if (data.allowedCredentials !== undefined)
|
|
139
|
+
config.allowedCredentials = data.allowedCredentials;
|
|
140
|
+
if (data.allowedHttpMethods !== undefined)
|
|
141
|
+
config.allowedHttpMethods = data.allowedHttpMethods;
|
|
142
|
+
if (data.allowCommandTools !== undefined)
|
|
143
|
+
config.allowCommandTools = data.allowCommandTools;
|
|
144
|
+
if (data.allowFunctionTools !== undefined)
|
|
145
|
+
config.allowFunctionTools = data.allowFunctionTools;
|
|
146
|
+
if (data.protectedNamespaces !== undefined)
|
|
147
|
+
config.protectedNamespaces = data.protectedNamespaces;
|
|
148
|
+
if (data.enableHITL !== undefined)
|
|
149
|
+
config.enableHITL = data.enableHITL;
|
|
150
|
+
if (data.quarantineRiskLevels !== undefined)
|
|
151
|
+
config.quarantineRiskLevels = data.quarantineRiskLevels;
|
|
152
|
+
if (data.approvalTtlSeconds !== undefined)
|
|
153
|
+
config.approvalTtlSeconds = data.approvalTtlSeconds;
|
|
154
|
+
return config;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=policy-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-loader.js","sourceRoot":"","sources":["../../src/policy/policy-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAA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I,CAAC,oBAAoB,KAAK,SAAS;QACzC,MAAM,CAAC,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,CAAC;IAC1D,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS;QAAE,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC;IAC/F,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Risk Classifier for Matimo tools.
|
|
3
|
+
*
|
|
4
|
+
* Pure function that classifies a tool's risk level based on its execution
|
|
5
|
+
* type, HTTP method, and approval requirements. No schema changes needed.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolDefinition } from '../core/schema';
|
|
8
|
+
import type { RiskLevel } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Classify the risk level of a tool based on its definition.
|
|
11
|
+
*
|
|
12
|
+
* - critical: arbitrary code execution (type: function)
|
|
13
|
+
* - high: shell execution (type: command), HTTP DELETE, or explicit requires_approval
|
|
14
|
+
* - medium: HTTP POST/PUT/PATCH (write operations)
|
|
15
|
+
* - low: HTTP GET, read-only tools
|
|
16
|
+
*/
|
|
17
|
+
export declare function classifyRisk(tool: ToolDefinition): RiskLevel;
|
|
18
|
+
//# sourceMappingURL=risk-classifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"risk-classifier.d.ts","sourceRoot":"","sources":["../../src/policy/risk-classifier.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,CAoC5D"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Risk Classifier for Matimo tools.
|
|
3
|
+
*
|
|
4
|
+
* Pure function that classifies a tool's risk level based on its execution
|
|
5
|
+
* type, HTTP method, and approval requirements. No schema changes needed.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Classify the risk level of a tool based on its definition.
|
|
9
|
+
*
|
|
10
|
+
* - critical: arbitrary code execution (type: function)
|
|
11
|
+
* - high: shell execution (type: command), HTTP DELETE, or explicit requires_approval
|
|
12
|
+
* - medium: HTTP POST/PUT/PATCH (write operations)
|
|
13
|
+
* - low: HTTP GET, read-only tools
|
|
14
|
+
*/
|
|
15
|
+
export function classifyRisk(tool) {
|
|
16
|
+
// Explicit override declared in the tool YAML takes precedence
|
|
17
|
+
if (tool.risk) {
|
|
18
|
+
return tool.risk;
|
|
19
|
+
}
|
|
20
|
+
const exec = tool.execution;
|
|
21
|
+
// Arbitrary code execution is always critical risk
|
|
22
|
+
if (exec.type === 'function') {
|
|
23
|
+
return 'critical';
|
|
24
|
+
}
|
|
25
|
+
// Shell commands are high risk (injection vectors)
|
|
26
|
+
if (exec.type === 'command') {
|
|
27
|
+
return 'high';
|
|
28
|
+
}
|
|
29
|
+
// HTTP tools: risk depends on method
|
|
30
|
+
if (exec.type === 'http') {
|
|
31
|
+
if (tool.requires_approval === true) {
|
|
32
|
+
return 'high';
|
|
33
|
+
}
|
|
34
|
+
const method = exec.method.toUpperCase();
|
|
35
|
+
if (method === 'DELETE') {
|
|
36
|
+
return 'high';
|
|
37
|
+
}
|
|
38
|
+
if (method === 'POST' || method === 'PUT' || method === 'PATCH') {
|
|
39
|
+
return 'medium';
|
|
40
|
+
}
|
|
41
|
+
// GET is low risk
|
|
42
|
+
return 'low';
|
|
43
|
+
}
|
|
44
|
+
// Unknown execution type — treat as high
|
|
45
|
+
return 'high';
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=risk-classifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"risk-classifier.js","sourceRoot":"","sources":["../../src/policy/risk-classifier.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,IAAoB;IAC/C,+DAA+D;IAC/D,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,IAAI,CAAC,IAAiB,CAAC;IAChC,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;IAE5B,mDAAmD;IACnD,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,mDAAmD;IACnD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,qCAAqC;IACrC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,iBAAiB,KAAK,IAAI,EAAE,CAAC;YACpC,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;YACxB,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;YAChE,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,kBAAkB;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,yCAAyC;IACzC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy Engine types for Matimo Agent-Native SDK.
|
|
3
|
+
*
|
|
4
|
+
* The policy engine governs what tools agents can create, execute, and discover.
|
|
5
|
+
* Agents cannot mutate policy at runtime; the host configures it and may hot-reload via `updateConfig()`.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolDefinition } from '../core/schema';
|
|
8
|
+
export type RiskLevel = 'low' | 'medium' | 'high' | 'critical';
|
|
9
|
+
/**
|
|
10
|
+
* Three-tier classification for agent-created tool proposals.
|
|
11
|
+
*
|
|
12
|
+
* - `auto`: Can be created and used immediately (low-risk GET tools, no auth).
|
|
13
|
+
* - `approval-required`: Allowed but must be approved before execution
|
|
14
|
+
* (tools with auth, POST/PUT/DELETE, external data writes).
|
|
15
|
+
* - `blocked`: Can never be created regardless of policy config
|
|
16
|
+
* (reserved namespaces, function/command execution, SSRF targets,
|
|
17
|
+
* tools referencing policy internals).
|
|
18
|
+
*/
|
|
19
|
+
export type PolicyTier = 'auto' | 'approval-required' | 'blocked';
|
|
20
|
+
/**
|
|
21
|
+
* Identity and environment context passed by the host application.
|
|
22
|
+
* Matimo does not authenticate — this is whatever the caller provides.
|
|
23
|
+
*/
|
|
24
|
+
export interface PolicyContext {
|
|
25
|
+
/** Identifier for the calling agent (optional — SDK doesn't mandate identity) */
|
|
26
|
+
agentId?: string;
|
|
27
|
+
/** Deployment environment (e.g. 'dev', 'staging', 'prod') */
|
|
28
|
+
environment?: string;
|
|
29
|
+
/** Roles assigned to the caller (e.g. ['reader', 'writer', 'admin']) */
|
|
30
|
+
roles?: string[];
|
|
31
|
+
/** Extensible metadata for custom policy rules */
|
|
32
|
+
metadata?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export type PolicyDecision = {
|
|
35
|
+
allowed: true;
|
|
36
|
+
} | {
|
|
37
|
+
allowed: false;
|
|
38
|
+
reason: string;
|
|
39
|
+
riskLevel?: RiskLevel;
|
|
40
|
+
} | {
|
|
41
|
+
allowed: 'pending_approval';
|
|
42
|
+
reason: string;
|
|
43
|
+
riskLevel: RiskLevel;
|
|
44
|
+
/** Tool name for the approval flow to reference */
|
|
45
|
+
toolName?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Async callback invoked when a tool enters the quarantine/HITL state.
|
|
49
|
+
* Returns `true` if the admin approves, `false` if rejected.
|
|
50
|
+
* Integrators wire this to a UI, Slack message, or approval queue.
|
|
51
|
+
*/
|
|
52
|
+
export type HITLCallback = (request: HITLRequest) => Promise<boolean>;
|
|
53
|
+
export interface HITLRequest {
|
|
54
|
+
toolName: string;
|
|
55
|
+
riskLevel: RiskLevel;
|
|
56
|
+
reason: string;
|
|
57
|
+
environment?: string;
|
|
58
|
+
agentId?: string;
|
|
59
|
+
/** Full tool definition for admin review */
|
|
60
|
+
toolDefinition?: unknown;
|
|
61
|
+
}
|
|
62
|
+
export interface Violation {
|
|
63
|
+
/** Machine-readable rule identifier (e.g. 'no-ssrf', 'reserved-namespace') */
|
|
64
|
+
rule: string;
|
|
65
|
+
/** Severity of the violation */
|
|
66
|
+
severity: RiskLevel;
|
|
67
|
+
/** Human-readable explanation */
|
|
68
|
+
message: string;
|
|
69
|
+
}
|
|
70
|
+
export interface ValidationResult {
|
|
71
|
+
valid: boolean;
|
|
72
|
+
violations: Violation[];
|
|
73
|
+
}
|
|
74
|
+
export interface ValidationContext {
|
|
75
|
+
/** Whether the tool comes from a trusted or untrusted path */
|
|
76
|
+
source: 'trusted' | 'untrusted';
|
|
77
|
+
/** Active policy configuration (defaults to empty/permissive) */
|
|
78
|
+
policy?: PolicyConfig;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Developer-configurable policy rules. All fields optional with conservative defaults.
|
|
82
|
+
*/
|
|
83
|
+
export interface PolicyConfig {
|
|
84
|
+
/** HTTP tool URL domain allowlist. If set, only these domains are permitted. */
|
|
85
|
+
allowedDomains?: string[];
|
|
86
|
+
/** Env var names that agent-created tools may reference for auth. */
|
|
87
|
+
allowedCredentials?: string[];
|
|
88
|
+
/** HTTP methods allowed for agent-created tools (default: ['GET', 'POST']). */
|
|
89
|
+
allowedHttpMethods?: string[];
|
|
90
|
+
/** Allow agent-created tools with execution type 'command' (default: false). */
|
|
91
|
+
allowCommandTools?: boolean;
|
|
92
|
+
/** Allow agent-created tools with execution type 'function' (default: false — always false for untrusted). */
|
|
93
|
+
allowFunctionTools?: boolean;
|
|
94
|
+
/** Tool name prefixes reserved for built-in tools (default: ['matimo_']). */
|
|
95
|
+
protectedNamespaces?: string[];
|
|
96
|
+
/**
|
|
97
|
+
* Enable quarantine/HITL for medium-risk tools in production.
|
|
98
|
+
* When true, `canCreate()` returns `pending_approval` instead of `allowed: false`
|
|
99
|
+
* for medium-risk tools, allowing a human reviewer to approve or reject.
|
|
100
|
+
* Default: false (original binary behavior preserved).
|
|
101
|
+
*/
|
|
102
|
+
enableHITL?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Risk levels eligible for HITL quarantine instead of outright rejection.
|
|
105
|
+
* Default: ['medium'] — critical/high are always blocked, low is always auto.
|
|
106
|
+
*/
|
|
107
|
+
quarantineRiskLevels?: RiskLevel[];
|
|
108
|
+
/**
|
|
109
|
+
* Number of seconds after which an approval expires and the tool must be re-approved.
|
|
110
|
+
* If not set, approvals never expire.
|
|
111
|
+
*/
|
|
112
|
+
approvalTtlSeconds?: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The PolicyEngine interface. Implementations are frozen at boot time and
|
|
116
|
+
* cannot be mutated by agents at runtime.
|
|
117
|
+
*/
|
|
118
|
+
export interface PolicyEngine {
|
|
119
|
+
/** Check whether this agent is allowed to execute a given tool. */
|
|
120
|
+
canExecute(context: PolicyContext, tool: ToolDefinition): PolicyDecision;
|
|
121
|
+
/** Check whether this agent is allowed to create/propose a tool definition. */
|
|
122
|
+
canCreate(context: PolicyContext, toolDef: ToolDefinition): PolicyDecision;
|
|
123
|
+
/**
|
|
124
|
+
* Update the policy configuration at runtime (hot-reload).
|
|
125
|
+
* Implementations should validate the new config before applying.
|
|
126
|
+
*/
|
|
127
|
+
updateConfig?(config: PolicyConfig): void;
|
|
128
|
+
/** Filter a list of tools to only those this agent is allowed to see/use. */
|
|
129
|
+
filterForAgent(context: PolicyContext, tools: ToolDefinition[]): ToolDefinition[];
|
|
130
|
+
}
|
|
131
|
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OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,GAAG,cAAc,CAAC;IAE3E;;;OAGG;IACH,YAAY,CAAC,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAE1C,6EAA6E;IAC7E,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAAC;CACnF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy Engine types for Matimo Agent-Native SDK.
|
|
3
|
+
*
|
|
4
|
+
* The policy engine governs what tools agents can create, execute, and discover.
|
|
5
|
+
* Agents cannot mutate policy at runtime; the host configures it and may hot-reload via `updateConfig()`.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/policy/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 tallclub
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
# Matimo — Toolbox For AI Agents
|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<img src="./docs/assets/logo.png" alt="Matimo Logo" width="300" />
|
|
5
|
-
</p>
|
|
6
|
-
<p align="center">
|
|
7
|
-
<strong>Matimo - "to be powerful"</strong>
|
|
8
|
-
</p>
|
|
9
|
-
|
|
10
|
-
<p align="center">
|
|
11
|
-
<a href="https://github.com/tallclub/matimo/actions/workflows/ci.yml?branch=main"><img src="https://img.shields.io/github/actions/workflow/status/tallclub/matimo/ci.yml?branch=main&style=for-the-badge" alt="CI status"></a>
|
|
12
|
-
<a href="https://www.npmjs.com/package/matimo"><img src="https://img.shields.io/npm/v/matimo.svg?style=for-the-badge" alt="npm version"></a>
|
|
13
|
-
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge" alt="MIT License"></a>
|
|
14
|
-
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.9+-blue?style=for-the-badge" alt="TypeScript"></a>
|
|
15
|
-
<a href="https://nodejs.org/"><img src="https://img.shields.io/badge/Node.js-18+-green?style=for-the-badge" alt="Node.js"></a>
|
|
16
|
-
</p>
|
|
17
|
-
|
|
18
|
-
<p align="center">
|
|
19
|
-
<a href="https://discord.gg/3JPt4mxWDV"><img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Discord"></a>
|
|
20
|
-
</p>
|
|
21
|
-
|
|
22
|
-
**Matimo** is a universal, configuration‑driven AI tools ecosystem. Define tools **once in YAML** and reuse them across the SDK, LangChain, custom agents, and a single MCP server, without re‑implementing schemas or fragmenting integration logic.
|
|
23
|
-
|
|
24
|
-
**Define once → Plug into any agent ecosystem.**
|
|
25
|
-
|
|
26
|
-
[📖 Documentation](./docs) · [🚀 Quick Start](./docs/getting-started/QUICK_START.md) · [📚 API Reference](./docs/api-reference/SDK.md) · [🛠️ Add Tools](./docs/tool-development/ADDING_TOOLS.md) · [🤖 Examples](./examples)
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Quick Start
|
|
31
|
-
|
|
32
|
-
### Installation
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
npm install matimo
|
|
36
|
-
# OR auto-discover tools from node_modules/@matimo/*
|
|
37
|
-
npm install matimo @matimo/slack @matimo/gmail
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Minimal Example (TypeScript)
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
import { MatimoInstance } from '@matimo/core';
|
|
44
|
-
|
|
45
|
-
const matimo = await MatimoInstance.init({
|
|
46
|
-
autoDiscover: true,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const result = await matimo.execute('slack-send-message', {
|
|
50
|
-
channel: '#general',
|
|
51
|
-
text: 'Hello from Matimo!',
|
|
52
|
-
});
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
See [Three Integration Patterns](#three-integration-patterns) and [examples/](./examples) for more.
|
|
56
|
-
|
|
57
|
-
## What's Included
|
|
58
|
-
|
|
59
|
-
Matimo ships with built-in support for:
|
|
60
|
-
|
|
61
|
-
- **Core Tools**: File I/O, Web fetch, Command execution, Code search
|
|
62
|
-
- **Slack Integration**: Send messages, manage channels, read threads
|
|
63
|
-
- **Gmail Integration**: Send/read email, manage threads
|
|
64
|
-
- **GitHub Integration**: Issues, pull requests, releases
|
|
65
|
-
- **Postgres Tools**: Query/modify data with safety checks
|
|
66
|
-
- **Auto-Discovery**: Automatic detection of @matimo/\* providers from npm
|
|
67
|
-
- **Matimo CLI**: Tool discovery, installation, and management
|
|
68
|
-
- **OAuth2 Support**: Provider-agnostic authorization for Slack, Gmail, GitHub, etc.
|
|
69
|
-
- **Framework Support**: Factory pattern, Decorator pattern, LangChain, CrewAI
|
|
70
|
-
- **TypeScript SDK**: Full type safety and IDE support
|
|
71
|
-
|
|
72
|
-
## Why Matimo?
|
|
73
|
-
|
|
74
|
-
**The Problem:** Every AI framework (LangChain, CrewAI, custom agents, etc.) defines tools differently. You duplicate tool logic across frameworks.
|
|
75
|
-
|
|
76
|
-
**The Solution:** Define tools **once** in clean YAML, use them **everywhere** — with built-in:
|
|
77
|
-
|
|
78
|
-
- TypeScript SDK (factory & decorator patterns)
|
|
79
|
-
- LangChain integration (with examples)
|
|
80
|
-
- Matimo CLI (tool discovery & management)
|
|
81
|
-
- Auto-discovery from npm packages
|
|
82
|
-
- OAuth2 support + parameter validation
|
|
83
|
-
|
|
84
|
-
See [Contributing](./CONTRIBUTING.md) for details.
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
## Three Integration Patterns
|
|
89
|
-
|
|
90
|
-
### 1️⃣ Factory Pattern (Simplest)
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
const matimo = await MatimoInstance.init({ autoDiscover: true });
|
|
94
|
-
const result = await matimo.execute('calculator', { operation: 'add', a: 5, b: 3 });
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### 2️⃣ Decorator Pattern (Class-Based)
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
@tool('slack-send-message')
|
|
101
|
-
async sendMessage(channel: string, text: string) { /* Auto-executed */ }
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### 3️⃣ LangChain Integration
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
const tools = matimo.listTools().map(tool => ({
|
|
108
|
-
type: 'function',
|
|
109
|
-
function: { name: tool.name, description: tool.description, ... }
|
|
110
|
-
}));
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
See [SDK Usage Patterns](./docs/user-guide/SDK_PATTERNS.md) and [LangChain Integration](./docs/framework-integrations/LANGCHAIN.md) for details.
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## Installation
|
|
118
|
-
|
|
119
|
-
### From npm (Recommended)
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
npm install matimo
|
|
123
|
-
|
|
124
|
-
# Install tool providers
|
|
125
|
-
npm install @matimo/slack @matimo/gmail
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
Then use with auto-discovery:
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
const matimo = await MatimoInstance.init({ autoDiscover: true });
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### Matimo CLI (Tool Management)
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
npm install -g @matimo/cli
|
|
138
|
-
|
|
139
|
-
matimo list # Show installed packages
|
|
140
|
-
matimo search email # Find tools
|
|
141
|
-
matimo install slack # Install tools
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
See [CLI Docs](./packages/cli/README.md) for full reference.
|
|
145
|
-
|
|
146
|
-
### From Source (Contributors)
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
git clone https://github.com/tallclub/matimo
|
|
150
|
-
cd matimo && pnpm install && pnpm build
|
|
151
|
-
pnpm test
|
|
152
|
-
cd examples/tools && pnpm install && pnpm agent:factory
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
## Features **Coming Soon:**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
- More tool providers (Stripe, Twilio, Notion, etc.)
|
|
161
|
-
- Python SDK
|
|
162
|
-
- Custom Tool Marketplace
|
|
163
|
-
- MCP Server support
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## Adding Tools to Matimo
|
|
168
|
-
|
|
169
|
-
If you build @matimo/<provider> following this pattern, we’ll list it in the official docs and README with you as maintainer.
|
|
170
|
-
|
|
171
|
-
Create tool providers as independent npm packages:
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
mkdir packages/github
|
|
175
|
-
cd packages/github && cat > package.json << 'EOF'
|
|
176
|
-
{ "name": "@matimo/github", "type": "module", ... }
|
|
177
|
-
EOF
|
|
178
|
-
|
|
179
|
-
mkdir tools/github-create-issue
|
|
180
|
-
cat > tools/github-create-issue/definition.yaml << 'EOF'
|
|
181
|
-
name: github-create-issue
|
|
182
|
-
parameters:
|
|
183
|
-
owner: { type: string, required: true }
|
|
184
|
-
repo: { type: string, required: true }
|
|
185
|
-
title: { type: string, required: true }
|
|
186
|
-
execution:
|
|
187
|
-
type: http
|
|
188
|
-
method: POST
|
|
189
|
-
url: https://api.github.com/repos/{owner}/{repo}/issues
|
|
190
|
-
headers:
|
|
191
|
-
Authorization: "Bearer {GITHUB_TOKEN}"
|
|
192
|
-
EOF
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
Then publish to npm as `@matimo/github`. Users install and auto-discover:
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
npm install @matimo/github
|
|
199
|
-
# New tools automatically available!
|
|
200
|
-
const matimo = await MatimoInstance.init({ autoDiscover: true });
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
See [Adding Tools to Matimo](./docs/tool-development/ADDING_TOOLS.md) for the complete 6-step guide.
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
## Documentation
|
|
208
|
-
|
|
209
|
-
- [Getting Started](./docs/getting-started/)
|
|
210
|
-
- [API Reference](./docs/api-reference/SDK.md)
|
|
211
|
-
- [Tool Development](./docs/tool-development/ADDING_TOOLS.md)
|
|
212
|
-
- [Architecture Overview](./docs/architecture/OVERVIEW.md)
|
|
213
|
-
- [Contributing](./CONTRIBUTING.md)
|
|
214
|
-
|
|
215
|
-
---
|
|
216
|
-
|
|
217
|
-
## License
|
|
218
|
-
|
|
219
|
-
MIT © 2026 Matimo Contributors
|
|
220
|
-
|
|
221
|
-
---
|
|
222
|
-
|
|
223
|
-
## Support the Project
|
|
224
|
-
|
|
225
|
-
- ⭐ Star the repo
|
|
226
|
-
- 🐛 Open issues for bugs or features
|
|
227
|
-
- 🔀 Submit PRs (see [Contributing](./CONTRIBUTING.md))
|
|
228
|
-
Best way to help: add a new provider (Notion, Jira, Stripe, Twilio…) or expand existing toolsets.
|
|
229
|
-
- 📢 Share on Twitter, Reddit, Discord
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
## Contributors
|
|
234
|
-
|
|
235
|
-
<a href="https://github.com/tallclub/matimo/graphs/contributors">
|
|
236
|
-
<img src="https://contrib.rocks/image?repo=tallclub/matimo" />
|
|
237
|
-
</a>
|
|
238
|
-
|
|
239
|
-
---
|
|
240
|
-
|
|
241
|
-
## Star History
|
|
242
|
-
|
|
243
|
-
[](https://star-history.com/#tallclub/matimo&Date)
|