@matimo/core 0.1.0-alpha.9 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +341 -14
- package/dist/approval/approval-handler.d.ts +5 -1
- package/dist/approval/approval-handler.d.ts.map +1 -1
- package/dist/approval/approval-handler.js +7 -1
- package/dist/approval/approval-handler.js.map +1 -1
- package/dist/auth/oauth2-handler.d.ts +2 -2
- package/dist/auth/oauth2-handler.d.ts.map +1 -1
- package/dist/auth/oauth2-handler.js +2 -2
- package/dist/auth/oauth2-handler.js.map +1 -1
- package/dist/auth/oauth2-provider-loader.d.ts +2 -2
- package/dist/auth/oauth2-provider-loader.d.ts.map +1 -1
- package/dist/auth/oauth2-provider-loader.js +2 -2
- package/dist/auth/oauth2-provider-loader.js.map +1 -1
- package/dist/core/schema.d.ts +42 -11
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +42 -6
- package/dist/core/schema.js.map +1 -1
- package/dist/core/skill-content-parser.d.ts +91 -0
- package/dist/core/skill-content-parser.d.ts.map +1 -0
- package/dist/core/skill-content-parser.js +248 -0
- package/dist/core/skill-content-parser.js.map +1 -0
- package/dist/core/skill-loader.d.ts +46 -0
- package/dist/core/skill-loader.d.ts.map +1 -0
- package/dist/core/skill-loader.js +311 -0
- package/dist/core/skill-loader.js.map +1 -0
- package/dist/core/skill-registry.d.ts +131 -0
- package/dist/core/skill-registry.d.ts.map +1 -0
- package/dist/core/skill-registry.js +316 -0
- package/dist/core/skill-registry.js.map +1 -0
- package/dist/core/tfidf-embedding.d.ts +45 -0
- package/dist/core/tfidf-embedding.d.ts.map +1 -0
- package/dist/core/tfidf-embedding.js +199 -0
- package/dist/core/tfidf-embedding.js.map +1 -0
- package/dist/core/tool-loader.d.ts +4 -2
- package/dist/core/tool-loader.d.ts.map +1 -1
- package/dist/core/tool-loader.js +35 -12
- package/dist/core/tool-loader.js.map +1 -1
- package/dist/core/tool-registry.d.ts +1 -1
- package/dist/core/tool-registry.d.ts.map +1 -1
- package/dist/core/tool-registry.js +1 -1
- package/dist/core/tool-registry.js.map +1 -1
- package/dist/core/types.d.ts +204 -7
- package/dist/core/types.d.ts.map +1 -1
- package/dist/decorators/index.d.ts +1 -1
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +1 -1
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/tool-decorator.js +1 -1
- package/dist/decorators/tool-decorator.js.map +1 -1
- package/dist/encodings/parameter-encoding.d.ts +1 -1
- package/dist/encodings/parameter-encoding.d.ts.map +1 -1
- package/dist/encodings/parameter-encoding.js +10 -5
- package/dist/encodings/parameter-encoding.js.map +1 -1
- package/dist/errors/matimo-error.d.ts +11 -2
- package/dist/errors/matimo-error.d.ts.map +1 -1
- package/dist/errors/matimo-error.js +25 -1
- package/dist/errors/matimo-error.js.map +1 -1
- package/dist/executors/command-executor.d.ts +10 -3
- package/dist/executors/command-executor.d.ts.map +1 -1
- package/dist/executors/command-executor.js +30 -6
- package/dist/executors/command-executor.js.map +1 -1
- package/dist/executors/function-executor.d.ts +11 -4
- package/dist/executors/function-executor.d.ts.map +1 -1
- package/dist/executors/function-executor.js +46 -26
- package/dist/executors/function-executor.js.map +1 -1
- package/dist/executors/http-executor.d.ts +80 -5
- package/dist/executors/http-executor.d.ts.map +1 -1
- package/dist/executors/http-executor.js +233 -29
- package/dist/executors/http-executor.js.map +1 -1
- package/dist/index.d.ts +45 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -16
- package/dist/index.js.map +1 -1
- package/dist/integrations/langchain.d.ts +57 -2
- package/dist/integrations/langchain.d.ts.map +1 -1
- package/dist/integrations/langchain.js +71 -4
- package/dist/integrations/langchain.js.map +1 -1
- package/dist/logging/winston-logger.d.ts.map +1 -1
- package/dist/logging/winston-logger.js +9 -1
- package/dist/logging/winston-logger.js.map +1 -1
- package/dist/matimo-instance.d.ts +231 -19
- package/dist/matimo-instance.d.ts.map +1 -1
- package/dist/matimo-instance.js +747 -48
- package/dist/matimo-instance.js.map +1 -1
- package/dist/mcp/index.d.ts +18 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +24 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcp-server.d.ts +141 -0
- package/dist/mcp/mcp-server.d.ts.map +1 -0
- package/dist/mcp/mcp-server.js +754 -0
- package/dist/mcp/mcp-server.js.map +1 -0
- package/dist/mcp/secrets/aws-resolver.d.ts +41 -0
- package/dist/mcp/secrets/aws-resolver.d.ts.map +1 -0
- package/dist/mcp/secrets/aws-resolver.js +141 -0
- package/dist/mcp/secrets/aws-resolver.js.map +1 -0
- package/dist/mcp/secrets/dotenv-resolver.d.ts +23 -0
- package/dist/mcp/secrets/dotenv-resolver.d.ts.map +1 -0
- package/dist/mcp/secrets/dotenv-resolver.js +94 -0
- package/dist/mcp/secrets/dotenv-resolver.js.map +1 -0
- package/dist/mcp/secrets/env-resolver.d.ts +14 -0
- package/dist/mcp/secrets/env-resolver.d.ts.map +1 -0
- package/dist/mcp/secrets/env-resolver.js +27 -0
- package/dist/mcp/secrets/env-resolver.js.map +1 -0
- package/dist/mcp/secrets/index.d.ts +14 -0
- package/dist/mcp/secrets/index.d.ts.map +1 -0
- package/dist/mcp/secrets/index.js +13 -0
- package/dist/mcp/secrets/index.js.map +1 -0
- package/dist/mcp/secrets/resolver-chain.d.ts +34 -0
- package/dist/mcp/secrets/resolver-chain.d.ts.map +1 -0
- package/dist/mcp/secrets/resolver-chain.js +141 -0
- package/dist/mcp/secrets/resolver-chain.js.map +1 -0
- package/dist/mcp/secrets/types.d.ts +73 -0
- package/dist/mcp/secrets/types.d.ts.map +1 -0
- package/dist/mcp/secrets/types.js +8 -0
- package/dist/mcp/secrets/types.js.map +1 -0
- package/dist/mcp/secrets/vault-resolver.d.ts +43 -0
- package/dist/mcp/secrets/vault-resolver.d.ts.map +1 -0
- package/dist/mcp/secrets/vault-resolver.js +127 -0
- package/dist/mcp/secrets/vault-resolver.js.map +1 -0
- package/dist/mcp/tool-converter.d.ts +40 -0
- package/dist/mcp/tool-converter.d.ts.map +1 -0
- package/dist/mcp/tool-converter.js +185 -0
- package/dist/mcp/tool-converter.js.map +1 -0
- package/dist/policy/approval-manifest.d.ts +76 -0
- package/dist/policy/approval-manifest.d.ts.map +1 -0
- package/dist/policy/approval-manifest.js +197 -0
- package/dist/policy/approval-manifest.js.map +1 -0
- package/dist/policy/content-validator.d.ts +19 -0
- package/dist/policy/content-validator.d.ts.map +1 -0
- package/dist/policy/content-validator.js +196 -0
- package/dist/policy/content-validator.js.map +1 -0
- package/dist/policy/default-policy.d.ts +46 -0
- package/dist/policy/default-policy.d.ts.map +1 -0
- package/dist/policy/default-policy.js +241 -0
- package/dist/policy/default-policy.js.map +1 -0
- package/dist/policy/events.d.ts +71 -0
- package/dist/policy/events.d.ts.map +1 -0
- package/dist/policy/events.js +8 -0
- package/dist/policy/events.js.map +1 -0
- package/dist/policy/index.d.ts +13 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +9 -0
- package/dist/policy/index.js.map +1 -0
- package/dist/policy/integrity-tracker.d.ts +62 -0
- package/dist/policy/integrity-tracker.d.ts.map +1 -0
- package/dist/policy/integrity-tracker.js +79 -0
- package/dist/policy/integrity-tracker.js.map +1 -0
- package/dist/policy/policy-loader.d.ts +58 -0
- package/dist/policy/policy-loader.d.ts.map +1 -0
- package/dist/policy/policy-loader.js +156 -0
- package/dist/policy/policy-loader.js.map +1 -0
- package/dist/policy/risk-classifier.d.ts +18 -0
- package/dist/policy/risk-classifier.d.ts.map +1 -0
- package/dist/policy/risk-classifier.js +47 -0
- package/dist/policy/risk-classifier.js.map +1 -0
- package/dist/policy/types.d.ts +131 -0
- package/dist/policy/types.d.ts.map +1 -0
- package/dist/policy/types.js +8 -0
- package/dist/policy/types.js.map +1 -0
- package/package.json +22 -6
- package/tools/matimo_approve_tool/definition.yaml +36 -0
- package/tools/matimo_approve_tool/matimo_approve_tool.ts +90 -0
- package/tools/matimo_create_skill/definition.yaml +46 -0
- package/tools/matimo_create_skill/matimo_create_skill.ts +75 -0
- package/tools/matimo_create_tool/definition.yaml +48 -0
- package/tools/matimo_create_tool/matimo_create_tool.ts +137 -0
- package/tools/matimo_get_skill/definition.yaml +60 -0
- package/tools/matimo_get_skill/matimo_get_skill.ts +182 -0
- package/tools/matimo_get_tool/definition.yaml +36 -0
- package/tools/matimo_get_tool/matimo_get_tool.ts +56 -0
- package/tools/matimo_get_tool_status/definition.yaml +42 -0
- package/tools/matimo_get_tool_status/matimo_get_tool_status.ts +101 -0
- package/tools/matimo_list_skills/definition.yaml +52 -0
- package/tools/matimo_list_skills/matimo_list_skills.ts +138 -0
- package/tools/matimo_list_user_tools/definition.yaml +32 -0
- package/tools/matimo_list_user_tools/matimo_list_user_tools.ts +74 -0
- package/tools/matimo_reload_tools/definition.yaml +35 -0
- package/tools/matimo_reload_tools/matimo_reload_tools.ts +29 -0
- package/tools/matimo_search_tools/definition.yaml +32 -0
- package/tools/matimo_search_tools/matimo_search_tools.ts +82 -0
- package/tools/matimo_validate_skill/definition.yaml +43 -0
- package/tools/matimo_validate_skill/matimo_validate_skill.ts +137 -0
- package/tools/matimo_validate_tool/definition.yaml +34 -0
- package/tools/matimo_validate_tool/matimo_validate_tool.ts +168 -0
- package/tools/shared/skill-validation.ts +335 -0
- package/LICENSE +0 -21
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import { applyParameterEncodings } from '../encodings/parameter-encoding';
|
|
3
|
-
import { MatimoError, ErrorCode } from '../errors/matimo-error';
|
|
2
|
+
import { applyParameterEncodings } from '../encodings/parameter-encoding.js';
|
|
3
|
+
import { MatimoError, ErrorCode, fromHttpError } from '../errors/matimo-error.js';
|
|
4
4
|
/**
|
|
5
5
|
* HttpExecutor - Executes HTTP requests
|
|
6
6
|
* Handles authentication, retries, and response validation
|
|
7
7
|
*/
|
|
8
8
|
export class HttpExecutor {
|
|
9
9
|
/**
|
|
10
|
-
* Execute a tool that makes an HTTP request
|
|
10
|
+
* Execute a tool that makes an HTTP request.
|
|
11
|
+
*
|
|
12
|
+
* @param tool - Tool definition
|
|
13
|
+
* @param params - Tool parameters (already env-injected by MatimoInstance)
|
|
14
|
+
* @param credentials - Optional per-call credential overrides. Used for
|
|
15
|
+
* `authentication.type: basic` (username_env / password_env keys) instead of
|
|
16
|
+
* reading from `process.env`. Other auth schemes (bearer, api_key) are handled
|
|
17
|
+
* upstream via parameter templating in MatimoInstance.injectAuthParameters().
|
|
18
|
+
* Values are never logged.
|
|
11
19
|
*/
|
|
12
|
-
async execute(tool, params) {
|
|
20
|
+
async execute(tool, params, credentials) {
|
|
13
21
|
if (tool.execution.type !== 'http') {
|
|
14
22
|
throw new MatimoError('Tool execution type is not http', ErrorCode.EXECUTION_FAILED, {
|
|
15
23
|
expectedType: 'http',
|
|
@@ -24,6 +32,8 @@ export class HttpExecutor {
|
|
|
24
32
|
if (parameterEncodings && parameterEncodings.length > 0) {
|
|
25
33
|
finalParams = applyParameterEncodings(params, parameterEncodings);
|
|
26
34
|
}
|
|
35
|
+
// Validate URL parameters are provided
|
|
36
|
+
this.validateUrlParameters(url, finalParams);
|
|
27
37
|
// Implement parameter templating
|
|
28
38
|
let finalUrl = this.templateString(url, finalParams);
|
|
29
39
|
// Handle query parameters - only include non-empty ones
|
|
@@ -33,10 +43,17 @@ export class HttpExecutor {
|
|
|
33
43
|
finalUrl += '?' + queryString;
|
|
34
44
|
}
|
|
35
45
|
}
|
|
36
|
-
const templatedHeaders = this.templateObject(headers, finalParams);
|
|
46
|
+
const templatedHeaders = this.templateObject(headers, finalParams, tool.parameters);
|
|
47
|
+
// Natively handle HTTP Basic Auth when authentication.type === 'basic' and
|
|
48
|
+
// username_env/password_env are declared. This eliminates the need for
|
|
49
|
+
// developers to pre-compute base64 credentials as a separate env var step.
|
|
50
|
+
// Credentials override takes precedence over process.env when provided.
|
|
51
|
+
this.applyBasicAuth(tool, templatedHeaders, credentials);
|
|
37
52
|
const templatedBody = body && typeof body === 'object'
|
|
38
|
-
? this.templateObject(body, finalParams)
|
|
39
|
-
: body
|
|
53
|
+
? this.templateObject(body, finalParams, tool.parameters)
|
|
54
|
+
: typeof body === 'string'
|
|
55
|
+
? this.templateString(body, finalParams)
|
|
56
|
+
: body;
|
|
40
57
|
// Build request config
|
|
41
58
|
const requestConfig = {
|
|
42
59
|
method,
|
|
@@ -46,7 +63,25 @@ export class HttpExecutor {
|
|
|
46
63
|
requestConfig.headers = templatedHeaders;
|
|
47
64
|
}
|
|
48
65
|
if (templatedBody !== undefined) {
|
|
49
|
-
|
|
66
|
+
// If Content-Type is application/x-www-form-urlencoded and body is an object,
|
|
67
|
+
// convert to URLSearchParams for proper form encoding by axios
|
|
68
|
+
const contentType = templatedHeaders['Content-Type'] ||
|
|
69
|
+
templatedHeaders['content-type'];
|
|
70
|
+
if (contentType?.includes('application/x-www-form-urlencoded') &&
|
|
71
|
+
typeof templatedBody === 'object' &&
|
|
72
|
+
templatedBody !== null &&
|
|
73
|
+
!(templatedBody instanceof FormData)) {
|
|
74
|
+
const params = new URLSearchParams();
|
|
75
|
+
for (const [key, value] of Object.entries(templatedBody)) {
|
|
76
|
+
if (value !== undefined && value !== null) {
|
|
77
|
+
params.append(key, String(value));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
requestConfig.data = params;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
requestConfig.data = templatedBody;
|
|
84
|
+
}
|
|
50
85
|
}
|
|
51
86
|
if (timeout !== undefined) {
|
|
52
87
|
requestConfig.timeout = timeout;
|
|
@@ -62,17 +97,43 @@ export class HttpExecutor {
|
|
|
62
97
|
};
|
|
63
98
|
}
|
|
64
99
|
catch (error) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
details,
|
|
73
|
-
};
|
|
100
|
+
// If this is already a MatimoError, rethrow to preserve semantics
|
|
101
|
+
if (error instanceof MatimoError) {
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
// Normalize any HTTP/axios-like or generic errors into MatimoError.
|
|
105
|
+
// This keeps callers consistent and preserves original cause via details.cause.
|
|
106
|
+
throw fromHttpError(error, 'HTTP request failed');
|
|
74
107
|
}
|
|
75
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Automatically inject `Authorization: Basic <base64(username:password)>` when
|
|
111
|
+
* the tool declares `authentication.type: basic` with `username_env` and `password_env`.
|
|
112
|
+
*
|
|
113
|
+
* This is a zero-friction pattern: developers only set two natural env vars
|
|
114
|
+
* (e.g. TWILIO_ACCOUNT_SID + TWILIO_AUTH_TOKEN) and Matimo handles encoding.
|
|
115
|
+
* No pre-computed base64 credential string required.
|
|
116
|
+
*
|
|
117
|
+
* When `credentials` is provided the lookup order is:
|
|
118
|
+
* 1. `credentials[envVarName]` (per-call override — multi-tenant use)
|
|
119
|
+
* 2. `process.env[envVarName]` (singleton / single-tenant fallback)
|
|
120
|
+
*
|
|
121
|
+
* Credential values are never logged or included in error details.
|
|
122
|
+
*/
|
|
123
|
+
applyBasicAuth(tool, headers, credentials) {
|
|
124
|
+
const auth = tool.authentication;
|
|
125
|
+
if (auth?.type !== 'basic' || !auth.username_env || !auth.password_env) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
// Prefer per-call credentials, fall back to process.env
|
|
129
|
+
const username = (credentials && credentials[auth.username_env]) ?? process.env[auth.username_env];
|
|
130
|
+
const password = (credentials && credentials[auth.password_env]) ?? process.env[auth.password_env];
|
|
131
|
+
if (!username || !password) {
|
|
132
|
+
throw new MatimoError(`Basic Auth requires env vars '${auth.username_env}' and '${auth.password_env}' to be set`, ErrorCode.AUTH_FAILED, { toolName: tool.name, username_env: auth.username_env, password_env: auth.password_env });
|
|
133
|
+
}
|
|
134
|
+
const encoded = Buffer.from(`${username}:${password}`).toString('base64');
|
|
135
|
+
headers['Authorization'] = `Basic ${encoded}`;
|
|
136
|
+
}
|
|
76
137
|
/**
|
|
77
138
|
* Replace parameter placeholders in a string
|
|
78
139
|
*/
|
|
@@ -80,12 +141,42 @@ export class HttpExecutor {
|
|
|
80
141
|
let result = str;
|
|
81
142
|
for (const [key, value] of Object.entries(params)) {
|
|
82
143
|
const placeholder = `{${key}}`;
|
|
83
|
-
|
|
84
|
-
|
|
144
|
+
// Allow empty-string values to be substituted (validation allows empty strings)
|
|
145
|
+
if (value !== undefined && value !== null) {
|
|
146
|
+
const replacement = String(value);
|
|
147
|
+
result = result.replace(new RegExp(placeholder, 'g'), () => replacement);
|
|
85
148
|
}
|
|
86
149
|
}
|
|
87
150
|
return result;
|
|
88
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Check if a string is an unfilled placeholder
|
|
154
|
+
* Only matches single placeholders like "{param}", not "{...}" or embedded placeholders
|
|
155
|
+
*/
|
|
156
|
+
isUnfilledPlaceholder(str) {
|
|
157
|
+
// Match exactly "{word}" where word is a valid identifier
|
|
158
|
+
return /^\{[a-zA-Z_][a-zA-Z0-9_]*\}$/.test(str);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Validate that all URL parameters are provided
|
|
162
|
+
*/
|
|
163
|
+
validateUrlParameters(url, params) {
|
|
164
|
+
// Extract all placeholders from URL like {param_name}
|
|
165
|
+
const urlParamMatches = url.match(/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g);
|
|
166
|
+
if (!urlParamMatches) {
|
|
167
|
+
return; // No parameters in URL
|
|
168
|
+
}
|
|
169
|
+
for (const match of urlParamMatches) {
|
|
170
|
+
const paramName = match.slice(1, -1); // Remove { }
|
|
171
|
+
const paramValue = params[paramName];
|
|
172
|
+
// Check if parameter is missing or undefined
|
|
173
|
+
if (paramValue === undefined) {
|
|
174
|
+
throw new MatimoError(`Required URL parameter '${paramName}' is missing`, ErrorCode.INVALID_SCHEMA, { url, missingParam: paramName });
|
|
175
|
+
}
|
|
176
|
+
// Allow null, empty string, 0, false, etc. as valid values
|
|
177
|
+
// Just ensure the parameter is defined
|
|
178
|
+
}
|
|
179
|
+
}
|
|
89
180
|
/**
|
|
90
181
|
* Build query string from query_params, only including provided values
|
|
91
182
|
*/
|
|
@@ -101,32 +192,145 @@ export class HttpExecutor {
|
|
|
101
192
|
return parts.join('&');
|
|
102
193
|
}
|
|
103
194
|
/**
|
|
104
|
-
* Replace parameter placeholders in an object (headers, body)
|
|
105
|
-
*
|
|
195
|
+
* Replace parameter placeholders in an object (headers, body, query params)
|
|
196
|
+
*
|
|
197
|
+
* CORE PRINCIPLE: "Define once in YAML, embed correctly at execution time"
|
|
198
|
+
*
|
|
199
|
+
* This method intelligently handles different parameter types:
|
|
200
|
+
* - STRING placeholders like "{title}": Always templated as strings
|
|
201
|
+
* - OBJECT placeholders like "{parent}": Embedded directly as JSON objects (not stringified) if paramDefinitions specifies type:object
|
|
202
|
+
* - ARRAY placeholders like "{items}": Embedded directly as JSON arrays (not stringified) if paramDefinitions specifies type:array
|
|
203
|
+
*
|
|
204
|
+
* Key behaviors:
|
|
205
|
+
* - Recursively processes nested objects
|
|
206
|
+
* - Skips keys with unfilled placeholders (e.g., "{sort_by}" when sort_by not provided)
|
|
207
|
+
* - Uses parameter schema type from YAML to determine how to embed values
|
|
208
|
+
* - Preserves JSON structure for complex types (objects/arrays) sent to APIs
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```
|
|
212
|
+
* // YAML definition:
|
|
213
|
+
* parameters:
|
|
214
|
+
* parent:
|
|
215
|
+
* type: object // <-- Tells executor to embed as-is, not stringify
|
|
216
|
+
* items:
|
|
217
|
+
* type: array // <-- Tells executor to embed as-is, not stringify
|
|
218
|
+
* title:
|
|
219
|
+
* type: string // <-- String templating applies
|
|
220
|
+
*
|
|
221
|
+
* body:
|
|
222
|
+
* parent: "{parent}" // Object embedded as {"id": "123", ...}
|
|
223
|
+
* items: "{items}" // Array embedded as [{"name": "a"}, ...]
|
|
224
|
+
* title: "{title}" // String embedded as "My Title"
|
|
225
|
+
*
|
|
226
|
+
* // JavaScript call:
|
|
227
|
+
* const result = await matimo.execute('notion_create_page', {
|
|
228
|
+
* parent: { database_id: 'abc123' }, // JavaScript object
|
|
229
|
+
* items: [{ type: 'text' }], // JavaScript array
|
|
230
|
+
* title: 'Create This Page' // String
|
|
231
|
+
* });
|
|
232
|
+
*
|
|
233
|
+
* // HTTP body sent to API:
|
|
234
|
+
* {
|
|
235
|
+
* "parent": {"database_id": "abc123"}, // Proper JSON object
|
|
236
|
+
* "items": [{"type": "text"}], // Proper JSON array
|
|
237
|
+
* "title": "Create This Page" // String
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
106
240
|
*/
|
|
107
|
-
templateObject(obj, params) {
|
|
241
|
+
templateObject(obj, params, paramDefinitions) {
|
|
108
242
|
const result = {};
|
|
109
243
|
for (const [key, value] of Object.entries(obj)) {
|
|
110
244
|
if (typeof value === 'string') {
|
|
111
|
-
|
|
245
|
+
// Check if this is exactly a placeholder like "{parent}"
|
|
246
|
+
const paramNameMatch = value.match(/^\{([a-zA-Z_][a-zA-Z0-9_]*)\}$/);
|
|
247
|
+
if (paramNameMatch) {
|
|
248
|
+
const paramName = paramNameMatch[1];
|
|
249
|
+
const paramValue = params[paramName];
|
|
250
|
+
// If parameter is defined in schema with type object or array,
|
|
251
|
+
// embed the value directly instead of stringifying
|
|
252
|
+
if (paramValue !== undefined && paramDefinitions?.[paramName]) {
|
|
253
|
+
const paramType = paramDefinitions[paramName].type;
|
|
254
|
+
if ((paramType === 'object' || paramType === 'array') && paramValue !== null) {
|
|
255
|
+
result[key] = paramValue;
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Otherwise, do normal string templating
|
|
261
|
+
const templated = this.templateString(value, params);
|
|
262
|
+
if (templated !== undefined &&
|
|
263
|
+
templated !== null &&
|
|
264
|
+
!this.isUnfilledPlaceholder(templated)) {
|
|
265
|
+
// Extract parameter name from template (e.g., "{page_size}" → "page_size")
|
|
266
|
+
const paramName = paramNameMatch ? paramNameMatch[1] : null;
|
|
267
|
+
// If this is a single parameter placeholder, use the parameter's defined type
|
|
268
|
+
if (paramName && paramDefinitions?.[paramName]) {
|
|
269
|
+
const paramType = paramDefinitions[paramName].type;
|
|
270
|
+
if (paramType === 'number' && !isNaN(Number(templated))) {
|
|
271
|
+
result[key] = Number(templated);
|
|
272
|
+
}
|
|
273
|
+
else if (paramType === 'boolean') {
|
|
274
|
+
result[key] = templated === 'true' || templated === '1' || templated === 'yes';
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
result[key] = templated;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
result[key] = templated;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
112
284
|
}
|
|
113
285
|
else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
114
286
|
// Recursively template nested objects
|
|
115
|
-
|
|
287
|
+
const nestedResult = this.templateObject(value, params, paramDefinitions);
|
|
288
|
+
// Only include nested object if it has content
|
|
289
|
+
if (Object.keys(nestedResult).length > 0) {
|
|
290
|
+
result[key] = nestedResult;
|
|
291
|
+
}
|
|
116
292
|
}
|
|
117
293
|
else if (Array.isArray(value)) {
|
|
118
294
|
// Handle arrays of objects
|
|
119
|
-
|
|
295
|
+
const templatedArray = value
|
|
296
|
+
.map((item) => {
|
|
120
297
|
if (typeof item === 'string') {
|
|
121
|
-
|
|
298
|
+
const templated = this.templateString(item, params);
|
|
299
|
+
// Skip unfilled placeholders; allow empty strings
|
|
300
|
+
if (templated !== undefined &&
|
|
301
|
+
templated !== null &&
|
|
302
|
+
!this.isUnfilledPlaceholder(templated)) {
|
|
303
|
+
// Extract parameter name from template
|
|
304
|
+
const paramNameMatch = item.match(/^\{([a-zA-Z_][a-zA-Z0-9_]*)\}$/);
|
|
305
|
+
const paramName = paramNameMatch ? paramNameMatch[1] : null;
|
|
306
|
+
// If this is a single parameter placeholder, use the parameter's defined type
|
|
307
|
+
if (paramName && paramDefinitions?.[paramName]) {
|
|
308
|
+
const paramType = paramDefinitions[paramName].type;
|
|
309
|
+
if (paramType === 'number' && !isNaN(Number(templated))) {
|
|
310
|
+
return Number(templated);
|
|
311
|
+
}
|
|
312
|
+
else if (paramType === 'boolean') {
|
|
313
|
+
return templated === 'true' || templated === '1' || templated === 'yes';
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return templated;
|
|
317
|
+
}
|
|
318
|
+
return null;
|
|
122
319
|
}
|
|
123
320
|
else if (typeof item === 'object' && item !== null && !Array.isArray(item)) {
|
|
124
|
-
|
|
321
|
+
const templated = this.templateObject(item, params, paramDefinitions);
|
|
322
|
+
// Only include if has content
|
|
323
|
+
return Object.keys(templated).length > 0 ? templated : null;
|
|
125
324
|
}
|
|
126
325
|
return item;
|
|
127
|
-
})
|
|
326
|
+
})
|
|
327
|
+
.filter((item) => item !== null);
|
|
328
|
+
// Only include array if it has items
|
|
329
|
+
if (templatedArray.length > 0) {
|
|
330
|
+
result[key] = templatedArray;
|
|
331
|
+
}
|
|
128
332
|
}
|
|
129
|
-
else {
|
|
333
|
+
else if (value !== undefined && value !== null) {
|
|
130
334
|
result[key] = value;
|
|
131
335
|
}
|
|
132
336
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-executor.js","sourceRoot":"","sources":["../../src/executors/http-executor.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"http-executor.js","sourceRoot":"","sources":["../../src/executors/http-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAElF;;;GAGG;AAEH,MAAM,OAAO,YAAY;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AO,IAAI,CAAC;oBACd,CAAC;yBAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC7E,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CACnC,IAA+B,EAC/B,MAAM,EACN,gBAAgB,CACjB,CAAC;wBACF,8BAA8B;wBAC9B,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;oBAC9D,CAAC;oBACD,OAAO,IAAI,CAAC;gBACd,CAAC,CAAC;qBACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;gBACnC,qCAAqC;gBACrC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC9B,MAAM,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC;gBAC/B,CAAC;YACH,CAAC;iBAAM,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACjD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACtB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,eAAe,YAAY,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,27 +4,49 @@
|
|
|
4
4
|
* Framework-agnostic SDK that enables any developer to integrate 1000+ tools
|
|
5
5
|
* across any AI framework (LangChain, CrewAI, Anthropic SDK, etc.).
|
|
6
6
|
*/
|
|
7
|
-
export type { Parameter, AuthConfig, HttpExecution, CommandExecution, FunctionExecution, OutputSchema, RateLimitConfig, ErrorHandlingConfig, ToolDefinition, } 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 {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export
|
|
22
|
-
export type {
|
|
23
|
-
export
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export
|
|
28
|
-
export {
|
|
29
|
-
export type {
|
|
7
|
+
export type { Parameter, AuthConfig, HttpExecution, CommandExecution, FunctionExecution, OutputSchema, RateLimitConfig, ErrorHandlingConfig, ToolDefinition, ExecuteOptions, SkillDefinition, SkillFrontmatter, ParsedSkill, SkillSummary, SearchSkillsOptions, BundledResources, SkillCatalogInfo, SkillSection, SkillContentOptions, EmbeddingProvider, } from './core/types.js';
|
|
8
|
+
export { ParameterSchema, AuthConfigSchema, ExecutionConfigSchema } from './core/schema.js';
|
|
9
|
+
export { ToolLoader } from './core/tool-loader.js';
|
|
10
|
+
export { ToolRegistry } from './core/tool-registry.js';
|
|
11
|
+
export { SkillLoader } from './core/skill-loader.js';
|
|
12
|
+
export { SkillRegistry } from './core/skill-registry.js';
|
|
13
|
+
export type { SemanticSearchResult } from './core/skill-registry.js';
|
|
14
|
+
export { parseSkillSections, extractSkillContent, listSkillSections, } from './core/skill-content-parser.js';
|
|
15
|
+
export { extractSkillMetadata } from './core/skill-loader.js';
|
|
16
|
+
export type { ParsedSkillContent } from './core/skill-content-parser.js';
|
|
17
|
+
export { TfIdfEmbeddingProvider, cosineSimilarity } from './core/tfidf-embedding.js';
|
|
18
|
+
export { CommandExecutor } from './executors/command-executor.js';
|
|
19
|
+
export { HttpExecutor } from './executors/http-executor.js';
|
|
20
|
+
export { FunctionExecutor } from './executors/function-executor.js';
|
|
21
|
+
export { applyParameterEncodings } from './encodings/parameter-encoding.js';
|
|
22
|
+
export type { ParameterEncodingConfig } from './encodings/parameter-encoding.js';
|
|
23
|
+
export { tool, setGlobalMatimoInstance, getGlobalMatimoInstance, } from './decorators/tool-decorator.js';
|
|
24
|
+
export { MatimoError, ErrorCode, createValidationError, createExecutionError, } from './errors/matimo-error.js';
|
|
25
|
+
export { MatimoLogger, LogLevel, LoggerConfig, getLoggerConfig, setGlobalMatimoLogger, getGlobalMatimoLogger, } from './logging/index.js';
|
|
26
|
+
export { WinstonMatimoLogger, createLogger } from './logging/winston-logger.js';
|
|
27
|
+
export { MatimoInstance, matimo } from './matimo-instance.js';
|
|
28
|
+
export type { InitOptions } from './matimo-instance.js';
|
|
29
|
+
export type { OAuth2Provider, OAuth2Token, OAuth2Config, AuthorizationOptions, TokenResponse, OAuth2Endpoints, } from './auth/oauth2-config.js';
|
|
30
|
+
export type { ProviderDefinition } from './core/schema.js';
|
|
31
|
+
export { OAuth2ProviderLoader } from './auth/oauth2-provider-loader.js';
|
|
32
|
+
export { OAuth2Handler } from './auth/oauth2-handler.js';
|
|
33
|
+
export { convertToolsToLangChain, getSkillsMetadata, buildRelevantSkillPrompt, } from './integrations/langchain.js';
|
|
34
|
+
export type { LangChainTool, SkillContext } from './integrations/langchain.js';
|
|
35
|
+
export type { PolicyEngine, PolicyContext, PolicyDecision, PolicyConfig, PolicyTier, RiskLevel, Violation, ValidationResult, ValidationContext, HITLCallback, HITLRequest, } from './policy/types.js';
|
|
36
|
+
export { DefaultPolicyEngine, getTierForTool } from './policy/default-policy.js';
|
|
37
|
+
export { validateToolContent, isSSRFTarget } from './policy/content-validator.js';
|
|
38
|
+
export { classifyRisk } from './policy/risk-classifier.js';
|
|
39
|
+
export { ToolIntegrityTracker } from './policy/integrity-tracker.js';
|
|
40
|
+
export { ApprovalManifest } from './policy/approval-manifest.js';
|
|
41
|
+
export { loadPolicyFromFile, parsePolicyFile } from './policy/policy-loader.js';
|
|
42
|
+
export type { MatimoEvent, MatimoEventHandler } from './policy/events.js';
|
|
43
|
+
export { ToolDefinitionSchema, validateToolDefinition } from './core/schema.js';
|
|
44
|
+
export type { ReloadResult } from './matimo-instance.js';
|
|
45
|
+
export { ApprovalHandler, getGlobalApprovalHandler } from './approval/approval-handler.js';
|
|
46
|
+
export type { ApprovalRequest, ApprovalCallback } from './approval/approval-handler.js';
|
|
47
|
+
export { MCPServer, createMCPServer } from './mcp/index.js';
|
|
48
|
+
export type { MCPServerOptions } from './mcp/index.js';
|
|
49
|
+
export type { SecretResolver, SecretResolverConfig, SecretResolverChainConfig, } from './mcp/index.js';
|
|
50
|
+
export { EnvSecretResolver, DotenvSecretResolver, SecretResolverChain, createResolverChain, } from './mcp/index.js';
|
|
51
|
+
export { convertParametersToMcpSchema, toolToMcpRegistration, extractAuthPlaceholders, } from './mcp/index.js';
|
|
30
52
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,cAAc,
|
|
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,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC5F,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,MAAM,gCAAgC,CAAC;AAIxF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,30 +4,48 @@
|
|
|
4
4
|
* Framework-agnostic SDK that enables any developer to integrate 1000+ tools
|
|
5
5
|
* across any AI framework (LangChain, CrewAI, Anthropic SDK, etc.).
|
|
6
6
|
*/
|
|
7
|
-
export { ParameterSchema, AuthConfigSchema, ExecutionConfigSchema } from './core/schema';
|
|
8
|
-
export { ToolLoader } from './core/tool-loader';
|
|
9
|
-
export { ToolRegistry } from './core/tool-registry';
|
|
7
|
+
export { ParameterSchema, AuthConfigSchema, ExecutionConfigSchema } from './core/schema.js';
|
|
8
|
+
export { ToolLoader } from './core/tool-loader.js';
|
|
9
|
+
export { ToolRegistry } from './core/tool-registry.js';
|
|
10
|
+
export { SkillLoader } from './core/skill-loader.js';
|
|
11
|
+
export { SkillRegistry } from './core/skill-registry.js';
|
|
12
|
+
export { parseSkillSections, extractSkillContent, listSkillSections, } from './core/skill-content-parser.js';
|
|
13
|
+
export { extractSkillMetadata } from './core/skill-loader.js';
|
|
14
|
+
export { TfIdfEmbeddingProvider, cosineSimilarity } from './core/tfidf-embedding.js';
|
|
10
15
|
// Executors
|
|
11
|
-
export { CommandExecutor } from './executors/command-executor';
|
|
12
|
-
export { HttpExecutor } from './executors/http-executor';
|
|
13
|
-
export { FunctionExecutor } from './executors/function-executor';
|
|
16
|
+
export { CommandExecutor } from './executors/command-executor.js';
|
|
17
|
+
export { HttpExecutor } from './executors/http-executor.js';
|
|
18
|
+
export { FunctionExecutor } from './executors/function-executor.js';
|
|
14
19
|
// Parameter Encoding
|
|
15
|
-
export { applyParameterEncodings } from './encodings/parameter-encoding';
|
|
20
|
+
export { applyParameterEncodings } from './encodings/parameter-encoding.js';
|
|
16
21
|
// Decorators
|
|
17
|
-
export { tool, setGlobalMatimoInstance, getGlobalMatimoInstance, } from './decorators/tool-decorator';
|
|
22
|
+
export { tool, setGlobalMatimoInstance, getGlobalMatimoInstance, } from './decorators/tool-decorator.js';
|
|
18
23
|
// Error handling
|
|
19
|
-
export { MatimoError, ErrorCode, createValidationError, createExecutionError, } from './errors/matimo-error';
|
|
24
|
+
export { MatimoError, ErrorCode, createValidationError, createExecutionError, } from './errors/matimo-error.js';
|
|
20
25
|
// Logging
|
|
21
|
-
export { getLoggerConfig, setGlobalMatimoLogger, getGlobalMatimoLogger, } from './logging';
|
|
22
|
-
export { WinstonMatimoLogger, createLogger } from './logging/winston-logger';
|
|
26
|
+
export { getLoggerConfig, setGlobalMatimoLogger, getGlobalMatimoLogger, } from './logging/index.js';
|
|
27
|
+
export { WinstonMatimoLogger, createLogger } from './logging/winston-logger.js';
|
|
23
28
|
// Matimo instance and namespace
|
|
24
|
-
export { MatimoInstance, matimo } from './matimo-instance';
|
|
25
|
-
export { OAuth2ProviderLoader } from './auth/oauth2-provider-loader';
|
|
26
|
-
export { OAuth2Handler } from './auth/oauth2-handler';
|
|
29
|
+
export { MatimoInstance, matimo } from './matimo-instance.js';
|
|
30
|
+
export { OAuth2ProviderLoader } from './auth/oauth2-provider-loader.js';
|
|
31
|
+
export { OAuth2Handler } from './auth/oauth2-handler.js';
|
|
27
32
|
// LangChain integration
|
|
28
|
-
export { convertToolsToLangChain } from './integrations/langchain';
|
|
33
|
+
export { convertToolsToLangChain, getSkillsMetadata, buildRelevantSkillPrompt, } from './integrations/langchain.js';
|
|
34
|
+
export { DefaultPolicyEngine, getTierForTool } from './policy/default-policy.js';
|
|
35
|
+
export { validateToolContent, isSSRFTarget } from './policy/content-validator.js';
|
|
36
|
+
export { classifyRisk } from './policy/risk-classifier.js';
|
|
37
|
+
export { ToolIntegrityTracker } from './policy/integrity-tracker.js';
|
|
38
|
+
export { ApprovalManifest } from './policy/approval-manifest.js';
|
|
39
|
+
export { loadPolicyFromFile, parsePolicyFile } from './policy/policy-loader.js';
|
|
40
|
+
// Schema validation
|
|
41
|
+
export { ToolDefinitionSchema, validateToolDefinition } from './core/schema.js';
|
|
29
42
|
// Generic Approval System - Simple, scalable flow for any tool
|
|
30
43
|
// Tools declare requires_approval in YAML, or system detects destructive keywords
|
|
31
44
|
// Single approval callback handles all tools - no per-provider logic needed
|
|
32
|
-
export { ApprovalHandler, getGlobalApprovalHandler } from './approval/approval-handler';
|
|
45
|
+
export { ApprovalHandler, getGlobalApprovalHandler } from './approval/approval-handler.js';
|
|
46
|
+
// MCP Server - Model Context Protocol integration
|
|
47
|
+
// Exposes all Matimo tools via MCP for Claude Desktop, Cursor, etc.
|
|
48
|
+
export { MCPServer, createMCPServer } from './mcp/index.js';
|
|
49
|
+
export { EnvSecretResolver, DotenvSecretResolver, SecretResolverChain, createResolverChain, } from './mcp/index.js';
|
|
50
|
+
export { convertParametersToMcpSchema, toolToMcpRegistration, extractAuthPlaceholders, } from './mcp/index.js';
|
|
33
51
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,O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BAAmB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAGhF,oBAAoB;AACpB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAKhF,+DAA+D;AAC/D,kFAAkF;AAClF,4EAA4E;AAC5E,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAG3F,kDAAkD;AAClD,oEAAoE;AACpE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAS5D,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC"}
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
* );
|
|
17
17
|
*/
|
|
18
18
|
import { z } from 'zod';
|
|
19
|
-
import type { ToolDefinition } from '../core/types';
|
|
20
|
-
import type { MatimoInstance } from '../matimo-instance';
|
|
19
|
+
import type { ToolDefinition } from '../core/types.js';
|
|
20
|
+
import type { MatimoInstance } from '../matimo-instance.js';
|
|
21
21
|
export interface LangChainTool {
|
|
22
22
|
name: string;
|
|
23
23
|
description: string;
|
|
@@ -43,4 +43,59 @@ export interface LangChainTool {
|
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
45
|
export declare function convertToolsToLangChain(tools: ToolDefinition[], matimo: MatimoInstance, secrets?: Record<string, string>, secretParamNames?: Set<string>): Promise<LangChainTool[]>;
|
|
46
|
+
export interface SkillContext {
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
content: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Return Level 1 metadata (name + description) for all available skills.
|
|
53
|
+
*
|
|
54
|
+
* Token-safe — only a few lines per skill. Include this in the system prompt
|
|
55
|
+
* so the agent knows what skills exist and can request them by name, mirroring
|
|
56
|
+
* what `matimo_list_skills` does in the tool-based flow.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const meta = getSkillsMetadata(matimo);
|
|
61
|
+
* // → [{ name: 'code-review', description: 'Code review checklist' }, ...]
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function getSkillsMetadata(matimo: MatimoInstance): Array<{
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Build a per-request system prompt snippet from semantically relevant skills.
|
|
70
|
+
*
|
|
71
|
+
* Uses TF-IDF semantic search (built-in, zero dependencies) to rank all skills
|
|
72
|
+
* against the user's query and loads full content only for the top matches.
|
|
73
|
+
* This preserves the progressive disclosure model without MCP:
|
|
74
|
+
*
|
|
75
|
+
* Level 1 at startup → Level 2 per-request (only relevant skills)
|
|
76
|
+
*
|
|
77
|
+
* @param matimo - Initialised MatimoInstance
|
|
78
|
+
* @param query - The user's current message/query; drives semantic ranking
|
|
79
|
+
* @param options.topK - Max skills to load (default 3); keeps token cost bounded
|
|
80
|
+
* @param options.minScore - Minimum cosine similarity to include (default 0.3)
|
|
81
|
+
* @param options.header - Custom header text (optional)
|
|
82
|
+
* @returns Formatted string ready to inject as a context block, or empty string
|
|
83
|
+
* when no skills score above `minScore`.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* // In your ReAct loop, per message:
|
|
88
|
+
* const skillContext = await buildRelevantSkillPrompt(matimo, userMessage, { topK: 2 });
|
|
89
|
+
* const messages = [
|
|
90
|
+
* new SystemMessage(baseSystemPrompt),
|
|
91
|
+
* ...(skillContext ? [new SystemMessage(skillContext)] : []),
|
|
92
|
+
* new HumanMessage(userMessage),
|
|
93
|
+
* ];
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function buildRelevantSkillPrompt(matimo: MatimoInstance, query: string, options?: {
|
|
97
|
+
topK?: number;
|
|
98
|
+
minScore?: number;
|
|
99
|
+
header?: string;
|
|
100
|
+
}): Promise<string>;
|
|
46
101
|
//# sourceMappingURL=langchain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../src/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../src/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC;IACpB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D;AAiMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,E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