@matimo/core 0.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +252 -0
  3. package/destructive-keywords.yaml +70 -0
  4. package/dist/approval/approval-handler.d.ts +74 -0
  5. package/dist/approval/approval-handler.d.ts.map +1 -0
  6. package/dist/approval/approval-handler.js +210 -0
  7. package/dist/approval/approval-handler.js.map +1 -0
  8. package/dist/auth/oauth2-config.d.ts +104 -0
  9. package/dist/auth/oauth2-config.d.ts.map +1 -0
  10. package/dist/auth/oauth2-config.js +38 -0
  11. package/dist/auth/oauth2-config.js.map +1 -0
  12. package/dist/auth/oauth2-handler.d.ts +130 -0
  13. package/dist/auth/oauth2-handler.d.ts.map +1 -0
  14. package/dist/auth/oauth2-handler.js +265 -0
  15. package/dist/auth/oauth2-handler.js.map +1 -0
  16. package/dist/auth/oauth2-provider-loader.d.ts +68 -0
  17. package/dist/auth/oauth2-provider-loader.d.ts.map +1 -0
  18. package/dist/auth/oauth2-provider-loader.js +120 -0
  19. package/dist/auth/oauth2-provider-loader.js.map +1 -0
  20. package/dist/core/schema.d.ts +259 -0
  21. package/dist/core/schema.d.ts.map +1 -0
  22. package/dist/core/schema.js +187 -0
  23. package/dist/core/schema.js.map +1 -0
  24. package/dist/core/tool-loader.d.ts +57 -0
  25. package/dist/core/tool-loader.d.ts.map +1 -0
  26. package/dist/core/tool-loader.js +250 -0
  27. package/dist/core/tool-loader.js.map +1 -0
  28. package/dist/core/tool-registry.d.ts +48 -0
  29. package/dist/core/tool-registry.d.ts.map +1 -0
  30. package/dist/core/tool-registry.js +93 -0
  31. package/dist/core/tool-registry.js.map +1 -0
  32. package/dist/core/types.d.ts +162 -0
  33. package/dist/core/types.d.ts.map +1 -0
  34. package/dist/core/types.js +5 -0
  35. package/dist/core/types.js.map +1 -0
  36. package/dist/decorators/index.d.ts +2 -0
  37. package/dist/decorators/index.d.ts.map +1 -0
  38. package/dist/decorators/index.js +2 -0
  39. package/dist/decorators/index.js.map +1 -0
  40. package/dist/decorators/tool-decorator.d.ts +97 -0
  41. package/dist/decorators/tool-decorator.d.ts.map +1 -0
  42. package/dist/decorators/tool-decorator.js +157 -0
  43. package/dist/decorators/tool-decorator.js.map +1 -0
  44. package/dist/encodings/parameter-encoding.d.ts +51 -0
  45. package/dist/encodings/parameter-encoding.d.ts.map +1 -0
  46. package/dist/encodings/parameter-encoding.js +124 -0
  47. package/dist/encodings/parameter-encoding.js.map +1 -0
  48. package/dist/errors/matimo-error.d.ts +41 -0
  49. package/dist/errors/matimo-error.d.ts.map +1 -0
  50. package/dist/errors/matimo-error.js +71 -0
  51. package/dist/errors/matimo-error.js.map +1 -0
  52. package/dist/executors/command-executor.d.ts +19 -0
  53. package/dist/executors/command-executor.d.ts.map +1 -0
  54. package/dist/executors/command-executor.js +98 -0
  55. package/dist/executors/command-executor.js.map +1 -0
  56. package/dist/executors/function-executor.d.ts +23 -0
  57. package/dist/executors/function-executor.d.ts.map +1 -0
  58. package/dist/executors/function-executor.js +181 -0
  59. package/dist/executors/function-executor.js.map +1 -0
  60. package/dist/executors/http-executor.d.ts +78 -0
  61. package/dist/executors/http-executor.d.ts.map +1 -0
  62. package/dist/executors/http-executor.js +279 -0
  63. package/dist/executors/http-executor.js.map +1 -0
  64. package/dist/index.d.ts +30 -0
  65. package/dist/index.d.ts.map +1 -0
  66. package/dist/index.js +33 -0
  67. package/dist/index.js.map +1 -0
  68. package/dist/integrations/langchain.d.ts +46 -0
  69. package/dist/integrations/langchain.d.ts.map +1 -0
  70. package/dist/integrations/langchain.js +197 -0
  71. package/dist/integrations/langchain.js.map +1 -0
  72. package/dist/logging/index.d.ts +3 -0
  73. package/dist/logging/index.d.ts.map +1 -0
  74. package/dist/logging/index.js +3 -0
  75. package/dist/logging/index.js.map +1 -0
  76. package/dist/logging/logger.d.ts +96 -0
  77. package/dist/logging/logger.d.ts.map +1 -0
  78. package/dist/logging/logger.js +53 -0
  79. package/dist/logging/logger.js.map +1 -0
  80. package/dist/logging/winston-logger.d.ts +29 -0
  81. package/dist/logging/winston-logger.d.ts.map +1 -0
  82. package/dist/logging/winston-logger.js +73 -0
  83. package/dist/logging/winston-logger.js.map +1 -0
  84. package/dist/matimo-instance.d.ts +140 -0
  85. package/dist/matimo-instance.d.ts.map +1 -0
  86. package/dist/matimo-instance.js +412 -0
  87. package/dist/matimo-instance.js.map +1 -0
  88. package/package.json +96 -0
  89. package/tools/calculator/calculator.ts +145 -0
  90. package/tools/calculator/definition.yaml +70 -0
  91. package/tools/edit/definition.yaml +115 -0
  92. package/tools/edit/edit.ts +187 -0
  93. package/tools/execute/definition.yaml +90 -0
  94. package/tools/execute/execute.ts +207 -0
  95. package/tools/read/definition.yaml +106 -0
  96. package/tools/read/read.ts +118 -0
  97. package/tools/search/definition.yaml +148 -0
  98. package/tools/search/search.ts +192 -0
  99. package/tools/web/definition.yaml +132 -0
  100. package/tools/web/web.ts +134 -0
@@ -0,0 +1,97 @@
1
+ import { ToolDefinition } from '../core/types.js';
2
+ import type { MatimoInstance } from '../matimo-instance.js';
3
+ /**
4
+ * Set the global Matimo instance for decorator usage
5
+ *
6
+ * Must be called before any @tool decorated methods are invoked
7
+ *
8
+ * @param instance - The MatimoInstance to use globally
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const matimo = await MatimoInstance.init('./tools');
13
+ * setGlobalMatimoInstance(matimo);
14
+ *
15
+ * class MyAgent {
16
+ * @tool('calculator')
17
+ * async calculate(operation: string, a: number, b: number) { }
18
+ * }
19
+ *
20
+ * const agent = new MyAgent();
21
+ * await agent.calculate('add', 5, 3);
22
+ * ```
23
+ */
24
+ export declare function setGlobalMatimoInstance(instance: MatimoInstance | null): void;
25
+ /**
26
+ * Get the global Matimo instance
27
+ *
28
+ * @throws {Error} If no global instance is set
29
+ */
30
+ export declare function getGlobalMatimoInstance(): MatimoInstance;
31
+ /**
32
+ * Tool decorator - transforms a method into a tool executor
33
+ *
34
+ * Automatically calls matimo.execute() with the method's arguments mapped to tool parameters.
35
+ * Must be used in a class that has a `matimo` property or after setGlobalMatimoInstance() is called.
36
+ *
37
+ * Works with both traditional and modern TypeScript decorator syntax.
38
+ *
39
+ * @param toolName - Name of the tool to execute (e.g., 'calculator', 'github-get-repo')
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // Using global instance
44
+ * const matimo = await MatimoInstance.init('./tools');
45
+ * setGlobalMatimoInstance(matimo);
46
+ *
47
+ * class MyAgent {
48
+ * @tool('calculator')
49
+ * async calculate(operation: string, a: number, b: number) {
50
+ * // Automatically executes: matimo.execute('calculator', { operation, a, b })
51
+ * }
52
+ *
53
+ * @tool('github-get-repo')
54
+ * async getRepo(owner: string, repo: string) {
55
+ * // Automatically executes: matimo.execute('github-get-repo', { owner, repo })
56
+ * }
57
+ * }
58
+ *
59
+ * const agent = new MyAgent();
60
+ * const result = await agent.calculate('add', 5, 3);
61
+ * ```
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Using instance property
66
+ * class MyAgent {
67
+ * constructor(public matimo: MatimoInstance) {}
68
+ *
69
+ * @tool('calculator')
70
+ * async calculate(operation: string, a: number, b: number) { }
71
+ * }
72
+ *
73
+ * const matimo = await MatimoInstance.init('./tools');
74
+ * const agent = new MyAgent(matimo);
75
+ * const result = await agent.calculate('add', 5, 3);
76
+ * ```
77
+ */
78
+ export declare function tool(toolName: string): <This, Args extends unknown[], Return>(_target: (this: This, ...args: Args) => Return, _context: any) => (this: any, ...args: Args) => Promise<unknown>;
79
+ /**
80
+ * Execute tool via decorator - shared logic for both decorator syntaxes
81
+ * Exported for testing purposes
82
+ */
83
+ export declare function executeToolViaDecorator(toolName: string, thisArg: unknown, args: any[]): Promise<unknown>;
84
+ /**
85
+ * Convert positional arguments to named parameters object
86
+ * Maps function arguments to tool parameter names in order
87
+ * Exported for testing purposes
88
+ *
89
+ * @example
90
+ * ```
91
+ * Tool has parameters: { operation, a, b }
92
+ * Args: ['add', 5, 3]
93
+ * Result: { operation: 'add', a: 5, b: 3 }
94
+ * ```
95
+ */
96
+ export declare function convertArgsToParams(args: unknown[], toolDef: ToolDefinition): Record<string, unknown>;
97
+ //# sourceMappingURL=tool-decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/tool-decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAS5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,cAAc,CAQxD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,IAClB,IAAI,EAAE,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EACnD,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,EAE9C,UAAU,GAAG,MAOU,MAAM,GAAG,EAAE,GAAG,MAAM,IAAI,KAAG,OAAO,CAAC,OAAO,CAAC,CAIrE;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAEhB,IAAI,EAAE,GAAG,EAAE,GACV,OAAO,CAAC,OAAO,CAAC,CAuClB;AACD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,OAAO,EAAE,EACf,OAAO,EAAE,cAAc,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAczB"}
@@ -0,0 +1,157 @@
1
+ import { MatimoError, ErrorCode } from '../errors/matimo-error';
2
+ /**
3
+ * Global Matimo instance for decorator usage
4
+ * Set via setGlobalMatimoInstance() before using @tool decorators
5
+ */
6
+ let globalMatimoInstance = null;
7
+ /**
8
+ * Set the global Matimo instance for decorator usage
9
+ *
10
+ * Must be called before any @tool decorated methods are invoked
11
+ *
12
+ * @param instance - The MatimoInstance to use globally
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const matimo = await MatimoInstance.init('./tools');
17
+ * setGlobalMatimoInstance(matimo);
18
+ *
19
+ * class MyAgent {
20
+ * @tool('calculator')
21
+ * async calculate(operation: string, a: number, b: number) { }
22
+ * }
23
+ *
24
+ * const agent = new MyAgent();
25
+ * await agent.calculate('add', 5, 3);
26
+ * ```
27
+ */
28
+ export function setGlobalMatimoInstance(instance) {
29
+ globalMatimoInstance = instance;
30
+ }
31
+ /**
32
+ * Get the global Matimo instance
33
+ *
34
+ * @throws {Error} If no global instance is set
35
+ */
36
+ export function getGlobalMatimoInstance() {
37
+ if (!globalMatimoInstance) {
38
+ throw new MatimoError('Global MatimoInstance not set. Call setGlobalMatimoInstance() before using @tool decorator.', ErrorCode.TOOL_NOT_FOUND);
39
+ }
40
+ return globalMatimoInstance;
41
+ }
42
+ /**
43
+ * Tool decorator - transforms a method into a tool executor
44
+ *
45
+ * Automatically calls matimo.execute() with the method's arguments mapped to tool parameters.
46
+ * Must be used in a class that has a `matimo` property or after setGlobalMatimoInstance() is called.
47
+ *
48
+ * Works with both traditional and modern TypeScript decorator syntax.
49
+ *
50
+ * @param toolName - Name of the tool to execute (e.g., 'calculator', 'github-get-repo')
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // Using global instance
55
+ * const matimo = await MatimoInstance.init('./tools');
56
+ * setGlobalMatimoInstance(matimo);
57
+ *
58
+ * class MyAgent {
59
+ * @tool('calculator')
60
+ * async calculate(operation: string, a: number, b: number) {
61
+ * // Automatically executes: matimo.execute('calculator', { operation, a, b })
62
+ * }
63
+ *
64
+ * @tool('github-get-repo')
65
+ * async getRepo(owner: string, repo: string) {
66
+ * // Automatically executes: matimo.execute('github-get-repo', { owner, repo })
67
+ * }
68
+ * }
69
+ *
70
+ * const agent = new MyAgent();
71
+ * const result = await agent.calculate('add', 5, 3);
72
+ * ```
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * // Using instance property
77
+ * class MyAgent {
78
+ * constructor(public matimo: MatimoInstance) {}
79
+ *
80
+ * @tool('calculator')
81
+ * async calculate(operation: string, a: number, b: number) { }
82
+ * }
83
+ *
84
+ * const matimo = await MatimoInstance.init('./tools');
85
+ * const agent = new MyAgent(matimo);
86
+ * const result = await agent.calculate('add', 5, 3);
87
+ * ```
88
+ */
89
+ export function tool(toolName) {
90
+ return function (_target,
91
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
+ _context) {
93
+ // Handle modern experimental decorator API
94
+ // The decorator can be used on methods and will receive the method and context
95
+ // Return a new function that intercepts the call
96
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
+ return async function (...args) {
98
+ return executeToolViaDecorator(toolName, this, args);
99
+ };
100
+ };
101
+ }
102
+ /**
103
+ * Execute tool via decorator - shared logic for both decorator syntaxes
104
+ * Exported for testing purposes
105
+ */
106
+ export async function executeToolViaDecorator(toolName, thisArg,
107
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
108
+ args) {
109
+ // Get Matimo instance (from class property or global)
110
+ let matimoInstance = null;
111
+ if (thisArg && typeof thisArg === 'object' && 'matimo' in thisArg) {
112
+ matimoInstance = thisArg.matimo || null;
113
+ }
114
+ if (!matimoInstance) {
115
+ matimoInstance = globalMatimoInstance;
116
+ }
117
+ if (!matimoInstance) {
118
+ throw new MatimoError(`Matimo instance not found for @tool('${toolName}') decorator. ` +
119
+ `Either add matimo property to class or call setGlobalMatimoInstance() first.`, ErrorCode.TOOL_NOT_FOUND, { toolName });
120
+ }
121
+ // Get tool definition
122
+ const toolDef = matimoInstance.getTool(toolName);
123
+ if (!toolDef) {
124
+ throw new MatimoError(`Tool '${toolName}' not found in Matimo registry`, ErrorCode.TOOL_NOT_FOUND, {
125
+ toolName,
126
+ });
127
+ }
128
+ // Convert positional arguments to parameters object
129
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
130
+ const params = convertArgsToParams(args, toolDef);
131
+ // Execute tool via Matimo
132
+ return matimoInstance.execute(toolName, params);
133
+ }
134
+ /**
135
+ * Convert positional arguments to named parameters object
136
+ * Maps function arguments to tool parameter names in order
137
+ * Exported for testing purposes
138
+ *
139
+ * @example
140
+ * ```
141
+ * Tool has parameters: { operation, a, b }
142
+ * Args: ['add', 5, 3]
143
+ * Result: { operation: 'add', a: 5, b: 3 }
144
+ * ```
145
+ */
146
+ export function convertArgsToParams(args, toolDef) {
147
+ const params = {};
148
+ if (!toolDef.parameters) {
149
+ return params;
150
+ }
151
+ const paramNames = Object.keys(toolDef.parameters);
152
+ for (let i = 0; i < args.length && i < paramNames.length; i++) {
153
+ params[paramNames[i]] = args[i];
154
+ }
155
+ return params;
156
+ }
157
+ //# sourceMappingURL=tool-decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-decorator.js","sourceRoot":"","sources":["../../src/decorators/tool-decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;GAGG;AACH,IAAI,oBAAoB,GAA0B,IAAI,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAA+B;IACrE,oBAAoB,GAAG,QAAQ,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB;IACrC,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,MAAM,IAAI,WAAW,CACnB,6FAA6F,EAC7F,SAAS,CAAC,cAAc,CACzB,CAAC;IACJ,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC;IAEzD,0BAA0B;IAC1B,OAAO,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC;AACD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAe,EACf,OAAuB;IAEvB,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAEnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9D,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Generic parameter encoding system for transforming input parameters
3
+ * Used to convert structured parameters into API-specific formats (MIME, JSON, etc.)
4
+ *
5
+ * This is YAML-driven via the parameter_encoding directive in tool definitions.
6
+ * No tool-specific code needed - keeps Matimo universal.
7
+ */
8
+ /**
9
+ * Encoding configuration from YAML
10
+ */
11
+ export interface ParameterEncodingConfig {
12
+ source: string[];
13
+ target: string;
14
+ encoding: string;
15
+ options?: Record<string, unknown>;
16
+ }
17
+ /**
18
+ * Apply parameter encodings to transform input parameters
19
+ * @param params - User-provided parameters
20
+ * @param encodings - List of encoding configurations from tool YAML
21
+ * @returns Parameters with encoded values added
22
+ */
23
+ export declare function applyParameterEncodings(params: Record<string, unknown>, encodings: ParameterEncodingConfig[]): Record<string, unknown>;
24
+ /**
25
+ * Example usage in YAML:
26
+ *
27
+ * execution:
28
+ * type: http
29
+ * method: POST
30
+ * url: 'https://www.googleapis.com/gmail/v1/users/me/messages/send'
31
+ * headers:
32
+ * Content-Type: 'application/json'
33
+ * Authorization: 'Bearer {GMAIL_ACCESS_TOKEN}'
34
+ *
35
+ * parameter_encoding:
36
+ * - source: [to, subject, body, cc, bcc, isHtml]
37
+ * target: raw
38
+ * encoding: mime_rfc2822_base64url
39
+ *
40
+ * body:
41
+ * raw: '{raw}'
42
+ *
43
+ * Then users call:
44
+ * matimo.execute('gmail-send-email', {
45
+ * to: 'user@example.com',
46
+ * subject: 'Hello',
47
+ * body: 'Hi there',
48
+ * GMAIL_ACCESS_TOKEN: token
49
+ * });
50
+ */
51
+ //# sourceMappingURL=parameter-encoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameter-encoding.d.ts","sourceRoot":"","sources":["../../src/encodings/parameter-encoding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,SAAS,EAAE,uBAAuB,EAAE,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoBzB;AAmFD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Generic parameter encoding system for transforming input parameters
3
+ * Used to convert structured parameters into API-specific formats (MIME, JSON, etc.)
4
+ *
5
+ * This is YAML-driven via the parameter_encoding directive in tool definitions.
6
+ * No tool-specific code needed - keeps Matimo universal.
7
+ */
8
+ import { MatimoError, ErrorCode } from '../errors/matimo-error';
9
+ /**
10
+ * Apply parameter encodings to transform input parameters
11
+ * @param params - User-provided parameters
12
+ * @param encodings - List of encoding configurations from tool YAML
13
+ * @returns Parameters with encoded values added
14
+ */
15
+ export function applyParameterEncodings(params, encodings) {
16
+ const result = { ...params };
17
+ for (const config of encodings) {
18
+ // Extract source parameters
19
+ const sourceValues = {};
20
+ for (const key of config.source) {
21
+ if (key in params) {
22
+ sourceValues[key] = params[key];
23
+ }
24
+ }
25
+ // Apply encoding function
26
+ const encodedValue = encodeParameters(sourceValues, config.encoding, config.options);
27
+ // Store in target parameter
28
+ result[config.target] = encodedValue;
29
+ }
30
+ return result;
31
+ }
32
+ /**
33
+ * Route to specific encoding function based on type
34
+ */
35
+ function encodeParameters(sourceValues, encoding, _options) {
36
+ switch (encoding) {
37
+ case 'mime_rfc2822_base64url':
38
+ return encodeMimeRfc2822(sourceValues);
39
+ case 'json_compact':
40
+ return JSON.stringify(sourceValues);
41
+ case 'url_encoded':
42
+ return encodeUrlParams(sourceValues);
43
+ default:
44
+ throw new MatimoError(`Unknown parameter encoding type: ${encoding}`, ErrorCode.INVALID_PARAMETER, {
45
+ encodingType: encoding,
46
+ supportedTypes: ['mime_rfc2822_base64url', 'json_compact', 'url_encoded'],
47
+ });
48
+ }
49
+ }
50
+ /**
51
+ * Encode parameters as RFC 2822 MIME message with base64url encoding
52
+ * Used for Gmail and other email APIs that accept raw MIME format
53
+ */
54
+ function encodeMimeRfc2822(sourceValues) {
55
+ const to = sourceValues.to;
56
+ const subject = sourceValues.subject;
57
+ const body = sourceValues.body;
58
+ const cc = sourceValues.cc;
59
+ const bcc = sourceValues.bcc;
60
+ // Accept both camelCase (`isHtml`) and snake_case (`is_html`) for backward compatibility
61
+ const isHtml = (sourceValues.isHtml ?? sourceValues.is_html) || false;
62
+ if (!to || !subject || !body) {
63
+ throw new MatimoError('MIME encoding requires: to, subject, body parameters', ErrorCode.INVALID_PARAMETER, {
64
+ requiredFields: ['to', 'subject', 'body'],
65
+ providedFields: Object.keys(sourceValues),
66
+ });
67
+ }
68
+ // Build RFC 2822 MIME message
69
+ let message = '';
70
+ message += `To: ${to}\r\n`;
71
+ message += `Subject: ${subject}\r\n`;
72
+ if (cc)
73
+ message += `Cc: ${cc}\r\n`;
74
+ if (bcc)
75
+ message += `Bcc: ${bcc}\r\n`;
76
+ message += `Content-Type: ${isHtml ? 'text/html' : 'text/plain'}; charset="UTF-8"\r\n`;
77
+ message += 'Content-Transfer-Encoding: 7bit\r\n';
78
+ message += '\r\n'; // Empty line separates headers from body
79
+ message += body;
80
+ // Convert to base64url
81
+ const base64 = Buffer.from(message).toString('base64');
82
+ // Replace standard base64 characters with URL-safe variants
83
+ return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
84
+ }
85
+ /**
86
+ * Encode parameters as URL-encoded form data
87
+ */
88
+ function encodeUrlParams(sourceValues) {
89
+ const params = new URLSearchParams();
90
+ for (const [key, value] of Object.entries(sourceValues)) {
91
+ if (value !== undefined && value !== null) {
92
+ params.append(key, String(value));
93
+ }
94
+ }
95
+ return params.toString();
96
+ }
97
+ /**
98
+ * Example usage in YAML:
99
+ *
100
+ * execution:
101
+ * type: http
102
+ * method: POST
103
+ * url: 'https://www.googleapis.com/gmail/v1/users/me/messages/send'
104
+ * headers:
105
+ * Content-Type: 'application/json'
106
+ * Authorization: 'Bearer {GMAIL_ACCESS_TOKEN}'
107
+ *
108
+ * parameter_encoding:
109
+ * - source: [to, subject, body, cc, bcc, isHtml]
110
+ * target: raw
111
+ * encoding: mime_rfc2822_base64url
112
+ *
113
+ * body:
114
+ * raw: '{raw}'
115
+ *
116
+ * Then users call:
117
+ * matimo.execute('gmail-send-email', {
118
+ * to: 'user@example.com',
119
+ * subject: 'Hello',
120
+ * body: 'Hi there',
121
+ * GMAIL_ACCESS_TOKEN: token
122
+ * });
123
+ */
124
+ //# sourceMappingURL=parameter-encoding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameter-encoding.js","sourceRoot":"","sources":["../../src/encodings/parameter-encoding.ts"],"names":[],"mappings":"A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M,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvD,4DAA4D;IAC5D,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,YAAqC;IAC5D,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACxD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Error codes and custom error class for Matimo
3
+ */
4
+ export declare enum ErrorCode {
5
+ INVALID_SCHEMA = "INVALID_SCHEMA",
6
+ EXECUTION_FAILED = "EXECUTION_FAILED",
7
+ AUTH_FAILED = "AUTH_FAILED",
8
+ TOOL_NOT_FOUND = "TOOL_NOT_FOUND",
9
+ FILE_NOT_FOUND = "FILE_NOT_FOUND",
10
+ VALIDATION_FAILED = "VALIDATION_FAILED",
11
+ RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED",
12
+ TIMEOUT = "TIMEOUT",
13
+ NETWORK_ERROR = "NETWORK_ERROR",
14
+ INVALID_PARAMETER = "INVALID_PARAMETER",
15
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
16
+ }
17
+ /**
18
+ * Custom error class for Matimo
19
+ */
20
+ export declare class MatimoError extends Error {
21
+ code: ErrorCode;
22
+ details?: Record<string, unknown> | undefined;
23
+ cause?: Error | unknown;
24
+ constructor(message: string, code: ErrorCode, details?: Record<string, unknown> | undefined, cause?: Error | unknown);
25
+ toJSON(): Record<string, unknown>;
26
+ }
27
+ /**
28
+ * Normalize an HTTP/Axios-style error into a MatimoError preserving useful metadata.
29
+ * This avoids importing axios in the errors module and works with any object
30
+ * that follows the common `error.response` shape.
31
+ */
32
+ export declare function fromHttpError(error: unknown, message?: string): MatimoError;
33
+ /**
34
+ * Create a validation error with context
35
+ */
36
+ export declare function createValidationError(message: string, details?: Record<string, unknown>): MatimoError;
37
+ /**
38
+ * Create an execution error with context
39
+ */
40
+ export declare function createExecutionError(message: string, details?: Record<string, unknown>): MatimoError;
41
+ //# sourceMappingURL=matimo-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matimo-error.d.ts","sourceRoot":"","sources":["../../src/errors/matimo-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAY,SAAS;IACnB,cAAc,mBAAmB;IACjC,gBAAgB,qBAAqB;IACrC,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,iBAAiB,sBAAsB;IACvC,mBAAmB,wBAAwB;IAC3C,OAAO,YAAY;IACnB,aAAa,kBAAkB;IAC/B,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;CAChC;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IAK3B,IAAI,EAAE,SAAS;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IALnC,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;gBAG7B,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,SAAS,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA,EACxC,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO;IAOzB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAYlC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,SAAwB,eAW5E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,WAAW,CAEb;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,WAAW,CAEb"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Error codes and custom error class for Matimo
3
+ */
4
+ export var ErrorCode;
5
+ (function (ErrorCode) {
6
+ ErrorCode["INVALID_SCHEMA"] = "INVALID_SCHEMA";
7
+ ErrorCode["EXECUTION_FAILED"] = "EXECUTION_FAILED";
8
+ ErrorCode["AUTH_FAILED"] = "AUTH_FAILED";
9
+ ErrorCode["TOOL_NOT_FOUND"] = "TOOL_NOT_FOUND";
10
+ ErrorCode["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
11
+ ErrorCode["VALIDATION_FAILED"] = "VALIDATION_FAILED";
12
+ ErrorCode["RATE_LIMIT_EXCEEDED"] = "RATE_LIMIT_EXCEEDED";
13
+ ErrorCode["TIMEOUT"] = "TIMEOUT";
14
+ ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
15
+ ErrorCode["INVALID_PARAMETER"] = "INVALID_PARAMETER";
16
+ ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
17
+ })(ErrorCode || (ErrorCode = {}));
18
+ /**
19
+ * Custom error class for Matimo
20
+ */
21
+ export class MatimoError extends Error {
22
+ constructor(message, code, details, cause) {
23
+ super(message);
24
+ this.code = code;
25
+ this.details = details;
26
+ this.name = 'MatimoError';
27
+ this.cause = cause;
28
+ }
29
+ toJSON() {
30
+ return {
31
+ name: this.name,
32
+ message: this.message,
33
+ code: this.code,
34
+ details: this.details,
35
+ cause: this.cause instanceof Error
36
+ ? { message: this.cause.message, name: this.cause.name }
37
+ : this.cause,
38
+ };
39
+ }
40
+ }
41
+ /**
42
+ * Normalize an HTTP/Axios-style error into a MatimoError preserving useful metadata.
43
+ * This avoids importing axios in the errors module and works with any object
44
+ * that follows the common `error.response` shape.
45
+ */
46
+ export function fromHttpError(error, message = 'HTTP request failed') {
47
+ // Attempt to extract common HTTP error fields
48
+ const asAny = error;
49
+ const response = asAny?.response;
50
+ const statusCode = response?.status ?? 500;
51
+ const details = response?.data;
52
+ const meta = { statusCode };
53
+ if (details !== undefined)
54
+ meta.details = details;
55
+ // Preserve original error message/cause for debugging (redaction handled elsewhere)
56
+ meta.originalError = asAny?.message ?? String(error ?? '');
57
+ return new MatimoError(message, ErrorCode.EXECUTION_FAILED, meta, error);
58
+ }
59
+ /**
60
+ * Create a validation error with context
61
+ */
62
+ export function createValidationError(message, details) {
63
+ return new MatimoError(message, ErrorCode.VALIDATION_FAILED, details);
64
+ }
65
+ /**
66
+ * Create an execution error with context
67
+ */
68
+ export function createExecutionError(message, details) {
69
+ return new MatimoError(message, ErrorCode.EXECUTION_FAILED, details);
70
+ }
71
+ //# sourceMappingURL=matimo-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matimo-error.js","sourceRoot":"","sources":["../../src/errors/matimo-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAN,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,8CAAiC,CAAA;IACjC,kDAAqC,CAAA;IACrC,wCAA2B,CAAA;IAC3B,8CAAiC,CAAA;IACjC,8CAAiC,CAAA;IACjC,oDAAuC,CAAA;IACvC,wDAA2C,CAAA;IAC3C,gCAAmB,CAAA;IACnB,4CAA+B,CAAA;IAC/B,oDAAuC,CAAA;IACvC,4CAA+B,CAAA;AACjC,CAAC,EAZW,SAAS,KAAT,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CAAC;IAC3D,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAe,EACf,OAAiC;IAEjC,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,OAAiC;IAEjC,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { ToolDefinition } from '../core/schema';
2
+ /**
3
+ * CommandExecutor - Executes shell commands
4
+ * Handles parameter templating, timeouts, and error capture
5
+ */
6
+ export declare class CommandExecutor {
7
+ private cwd?;
8
+ constructor(cwd?: string);
9
+ /**
10
+ * Execute a tool that runs a shell command
11
+ */
12
+ execute(tool: ToolDefinition, params: Record<string, unknown>): Promise<unknown>;
13
+ /**
14
+ * Replace parameter placeholders in a string
15
+ */
16
+ private templateString;
17
+ }
18
+ export default CommandExecutor;
19
+ //# sourceMappingURL=command-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-executor.d.ts","sourceRoot":"","sources":["../../src/executors/command-executor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;GAGG;AAEH,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAC,CAAS;gBAET,GAAG,CAAC,EAAE,MAAM;IAIxB;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAqFtF;;OAEG;IACH,OAAO,CAAC,cAAc;CAQvB;AAED,eAAe,eAAe,CAAC"}