@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.
- package/LICENSE +21 -0
- package/README.md +252 -0
- package/destructive-keywords.yaml +70 -0
- package/dist/approval/approval-handler.d.ts +74 -0
- package/dist/approval/approval-handler.d.ts.map +1 -0
- package/dist/approval/approval-handler.js +210 -0
- package/dist/approval/approval-handler.js.map +1 -0
- package/dist/auth/oauth2-config.d.ts +104 -0
- package/dist/auth/oauth2-config.d.ts.map +1 -0
- package/dist/auth/oauth2-config.js +38 -0
- package/dist/auth/oauth2-config.js.map +1 -0
- package/dist/auth/oauth2-handler.d.ts +130 -0
- package/dist/auth/oauth2-handler.d.ts.map +1 -0
- package/dist/auth/oauth2-handler.js +265 -0
- package/dist/auth/oauth2-handler.js.map +1 -0
- package/dist/auth/oauth2-provider-loader.d.ts +68 -0
- package/dist/auth/oauth2-provider-loader.d.ts.map +1 -0
- package/dist/auth/oauth2-provider-loader.js +120 -0
- package/dist/auth/oauth2-provider-loader.js.map +1 -0
- package/dist/core/schema.d.ts +259 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +187 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/tool-loader.d.ts +57 -0
- package/dist/core/tool-loader.d.ts.map +1 -0
- package/dist/core/tool-loader.js +250 -0
- package/dist/core/tool-loader.js.map +1 -0
- package/dist/core/tool-registry.d.ts +48 -0
- package/dist/core/tool-registry.d.ts.map +1 -0
- package/dist/core/tool-registry.js +93 -0
- package/dist/core/tool-registry.js.map +1 -0
- package/dist/core/types.d.ts +162 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +2 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/tool-decorator.d.ts +97 -0
- package/dist/decorators/tool-decorator.d.ts.map +1 -0
- package/dist/decorators/tool-decorator.js +157 -0
- package/dist/decorators/tool-decorator.js.map +1 -0
- package/dist/encodings/parameter-encoding.d.ts +51 -0
- package/dist/encodings/parameter-encoding.d.ts.map +1 -0
- package/dist/encodings/parameter-encoding.js +124 -0
- package/dist/encodings/parameter-encoding.js.map +1 -0
- package/dist/errors/matimo-error.d.ts +41 -0
- package/dist/errors/matimo-error.d.ts.map +1 -0
- package/dist/errors/matimo-error.js +71 -0
- package/dist/errors/matimo-error.js.map +1 -0
- package/dist/executors/command-executor.d.ts +19 -0
- package/dist/executors/command-executor.d.ts.map +1 -0
- package/dist/executors/command-executor.js +98 -0
- package/dist/executors/command-executor.js.map +1 -0
- package/dist/executors/function-executor.d.ts +23 -0
- package/dist/executors/function-executor.d.ts.map +1 -0
- package/dist/executors/function-executor.js +181 -0
- package/dist/executors/function-executor.js.map +1 -0
- package/dist/executors/http-executor.d.ts +78 -0
- package/dist/executors/http-executor.d.ts.map +1 -0
- package/dist/executors/http-executor.js +279 -0
- package/dist/executors/http-executor.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/langchain.d.ts +46 -0
- package/dist/integrations/langchain.d.ts.map +1 -0
- package/dist/integrations/langchain.js +197 -0
- package/dist/integrations/langchain.js.map +1 -0
- package/dist/logging/index.d.ts +3 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +3 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.d.ts +96 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +53 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/logging/winston-logger.d.ts +29 -0
- package/dist/logging/winston-logger.d.ts.map +1 -0
- package/dist/logging/winston-logger.js +73 -0
- package/dist/logging/winston-logger.js.map +1 -0
- package/dist/matimo-instance.d.ts +140 -0
- package/dist/matimo-instance.d.ts.map +1 -0
- package/dist/matimo-instance.js +412 -0
- package/dist/matimo-instance.js.map +1 -0
- package/package.json +96 -0
- package/tools/calculator/calculator.ts +145 -0
- package/tools/calculator/definition.yaml +70 -0
- package/tools/edit/definition.yaml +115 -0
- package/tools/edit/edit.ts +187 -0
- package/tools/execute/definition.yaml +90 -0
- package/tools/execute/execute.ts +207 -0
- package/tools/read/definition.yaml +106 -0
- package/tools/read/read.ts +118 -0
- package/tools/search/definition.yaml +148 -0
- package/tools/search/search.ts +192 -0
- package/tools/web/definition.yaml +132 -0
- package/tools/web/web.ts +134 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger interface for Matimo SDK
|
|
3
|
+
* Provides a contract for logging implementations allowing users to plug in
|
|
4
|
+
* their own loggers (Winston, Pino, custom) or use the default Winston logger.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // Use default Winston logger
|
|
9
|
+
* const matimo = await MatimoInstance.init({
|
|
10
|
+
* toolPaths: ['./tools'],
|
|
11
|
+
* logLevel: 'debug'
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* // Use custom logger
|
|
15
|
+
* const customLogger = { info: (...) => {}, warn: (...) => {}, ... };
|
|
16
|
+
* const matimo = await MatimoInstance.init({
|
|
17
|
+
* toolPaths: ['./tools'],
|
|
18
|
+
* logger: customLogger
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export interface MatimoLogger {
|
|
23
|
+
/**
|
|
24
|
+
* Log an informational message with optional metadata
|
|
25
|
+
*/
|
|
26
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
27
|
+
/**
|
|
28
|
+
* Log a warning message with optional metadata
|
|
29
|
+
*/
|
|
30
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
31
|
+
/**
|
|
32
|
+
* Log an error message with optional metadata
|
|
33
|
+
*/
|
|
34
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
35
|
+
/**
|
|
36
|
+
* Log a debug message with optional metadata
|
|
37
|
+
*/
|
|
38
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Log level for Matimo logger
|
|
42
|
+
* silent: No logs (useful for testing)
|
|
43
|
+
* error: Only errors
|
|
44
|
+
* warn: Warnings and errors
|
|
45
|
+
* info: Info, warnings, and errors
|
|
46
|
+
* debug: All logs including debug messages
|
|
47
|
+
*/
|
|
48
|
+
export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
|
|
49
|
+
/**
|
|
50
|
+
* Logger configuration options
|
|
51
|
+
*/
|
|
52
|
+
export interface LoggerConfig {
|
|
53
|
+
/**
|
|
54
|
+
* Log level for output (default: 'info')
|
|
55
|
+
* Environment variable: MATIMO_LOG_LEVEL
|
|
56
|
+
*/
|
|
57
|
+
logLevel?: LogLevel;
|
|
58
|
+
/**
|
|
59
|
+
* Log format: 'json' for structured logging, 'simple' for human-readable
|
|
60
|
+
* Default: 'json' in production, 'simple' in development
|
|
61
|
+
* Environment variable: MATIMO_LOG_FORMAT
|
|
62
|
+
*/
|
|
63
|
+
logFormat?: 'json' | 'simple';
|
|
64
|
+
/**
|
|
65
|
+
* Custom logger instance. If provided, overrides all other logger options.
|
|
66
|
+
* Allows users to plug in Winston, Pino, or any custom logger.
|
|
67
|
+
*/
|
|
68
|
+
logger?: MatimoLogger;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get logger configuration from environment variables and config object
|
|
72
|
+
* Environment variables take precedence over programmatic config.
|
|
73
|
+
* Supports:
|
|
74
|
+
* - MATIMO_LOG_LEVEL: 'silent' | 'error' | 'warn' | 'info' | 'debug'
|
|
75
|
+
* - MATIMO_LOG_FORMAT: 'json' | 'simple'
|
|
76
|
+
*/
|
|
77
|
+
export declare function getLoggerConfig(config?: LoggerConfig): {
|
|
78
|
+
logLevel: LogLevel;
|
|
79
|
+
logFormat: 'json' | 'simple';
|
|
80
|
+
logger?: MatimoLogger;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Set the global Matimo logger instance
|
|
84
|
+
* Called by MatimoInstance.init() during initialization
|
|
85
|
+
*
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
export declare function setGlobalMatimoLogger(logger: MatimoLogger): void;
|
|
89
|
+
/**
|
|
90
|
+
* Get the global Matimo logger instance
|
|
91
|
+
* Returns a no-op logger if not initialized (safe fallback)
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
export declare function getGlobalMatimoLogger(): MatimoLogger;
|
|
96
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logging/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE5D;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE5D;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE7D;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC9D;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAE9B;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG;IACtD,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC7B,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAYA;AAUD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,YAAY,CAWpD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get logger configuration from environment variables and config object
|
|
3
|
+
* Environment variables take precedence over programmatic config.
|
|
4
|
+
* Supports:
|
|
5
|
+
* - MATIMO_LOG_LEVEL: 'silent' | 'error' | 'warn' | 'info' | 'debug'
|
|
6
|
+
* - MATIMO_LOG_FORMAT: 'json' | 'simple'
|
|
7
|
+
*/
|
|
8
|
+
export function getLoggerConfig(config) {
|
|
9
|
+
const logLevel = process.env.MATIMO_LOG_LEVEL || config?.logLevel || 'info';
|
|
10
|
+
const logFormat = process.env.MATIMO_LOG_FORMAT ||
|
|
11
|
+
config?.logFormat ||
|
|
12
|
+
(process.env.NODE_ENV === 'production' ? 'json' : 'simple');
|
|
13
|
+
return {
|
|
14
|
+
logLevel,
|
|
15
|
+
logFormat,
|
|
16
|
+
logger: config?.logger,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Global logger instance used by Matimo modules
|
|
21
|
+
* Set via setGlobalMatimoLogger, accessed via getGlobalMatimoLogger
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
let globalMatimoLogger;
|
|
26
|
+
/**
|
|
27
|
+
* Set the global Matimo logger instance
|
|
28
|
+
* Called by MatimoInstance.init() during initialization
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export function setGlobalMatimoLogger(logger) {
|
|
33
|
+
globalMatimoLogger = logger;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the global Matimo logger instance
|
|
37
|
+
* Returns a no-op logger if not initialized (safe fallback)
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export function getGlobalMatimoLogger() {
|
|
42
|
+
if (!globalMatimoLogger) {
|
|
43
|
+
// Return no-op logger if not initialized (safe fallback for tests/edge cases)
|
|
44
|
+
return {
|
|
45
|
+
info: () => { },
|
|
46
|
+
warn: () => { },
|
|
47
|
+
error: () => { },
|
|
48
|
+
debug: () => { },
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return globalMatimoLogger;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logging/logger.ts"],"names":[],"mappings":"AA6EA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,MAAqB;IAKnD,MAAM,QAAQ,GAAI,OAAO,CAAC,GAAG,CAAC,gBAA6B,IAAI,MAAM,EAAE,QAAQ,IAAI,MAAM,CAAC;IAC1F,MAAM,SAAS,GACZ,OAAO,CAAC,GAAG,CAAC,iBAAuC;QACpD,MAAM,EAAE,SAAS;QACjB,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAE9D,OAAO;QACL,QAAQ;QACR,SAAS;QACT,MAAM,EAAE,MAAM,EAAE,MAAM;KACvB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,IAAI,kBAA4C,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAoB;IACxD,kBAAkB,GAAG,MAAM,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,8EAA8E;QAC9E,OAAO;YACL,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;YACd,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;YACd,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;YACf,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;SAChB,CAAC;IACJ,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MatimoLogger, LogLevel, LoggerConfig } from './logger.js';
|
|
2
|
+
/**
|
|
3
|
+
* Winston-based logger implementation for Matimo SDK
|
|
4
|
+
* Provides structured logging with optional JSON format for production use.
|
|
5
|
+
* Supports environment variable overrides for log level and format.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare class WinstonMatimoLogger implements MatimoLogger {
|
|
10
|
+
private winstonLogger;
|
|
11
|
+
constructor(config: {
|
|
12
|
+
logLevel: LogLevel;
|
|
13
|
+
logFormat: 'json' | 'simple';
|
|
14
|
+
});
|
|
15
|
+
private mapLogLevel;
|
|
16
|
+
private createFormat;
|
|
17
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
18
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
19
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
20
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a logger from config
|
|
24
|
+
* Uses Winston if no custom logger provided, otherwise returns the custom logger
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function createLogger(config: LoggerConfig): MatimoLogger;
|
|
29
|
+
//# sourceMappingURL=winston-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"winston-logger.d.ts","sourceRoot":"","sources":["../../src/logging/winston-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEnE;;;;;;GAMG;AACH,qBAAa,mBAAoB,YAAW,YAAY;IACtD,OAAO,CAAC,aAAa,CAAiB;gBAE1B,MAAM,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAE;IAkBxE,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,YAAY;IAsBpB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI3D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI3D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAG7D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAS/D"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import winston from 'winston';
|
|
2
|
+
/**
|
|
3
|
+
* Winston-based logger implementation for Matimo SDK
|
|
4
|
+
* Provides structured logging with optional JSON format for production use.
|
|
5
|
+
* Supports environment variable overrides for log level and format.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export class WinstonMatimoLogger {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
// Map Matimo log levels to Winston levels
|
|
12
|
+
const winstonLevel = this.mapLogLevel(config.logLevel);
|
|
13
|
+
// Create format based on config
|
|
14
|
+
const format = this.createFormat(config.logFormat);
|
|
15
|
+
this.winstonLogger = winston.createLogger({
|
|
16
|
+
level: winstonLevel,
|
|
17
|
+
format,
|
|
18
|
+
transports: [
|
|
19
|
+
new winston.transports.Console({
|
|
20
|
+
format: winston.format.combine(winston.format.colorize(), format),
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
mapLogLevel(level) {
|
|
26
|
+
const levelMap = {
|
|
27
|
+
silent: 'error', // Log errors even in silent mode (they'll be filtered at transport level)
|
|
28
|
+
error: 'error',
|
|
29
|
+
warn: 'warn',
|
|
30
|
+
info: 'info',
|
|
31
|
+
debug: 'debug',
|
|
32
|
+
};
|
|
33
|
+
return levelMap[level];
|
|
34
|
+
}
|
|
35
|
+
createFormat(format) {
|
|
36
|
+
if (format === 'json') {
|
|
37
|
+
return winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.errors({ stack: true }), winston.format.splat(), winston.format.json());
|
|
38
|
+
}
|
|
39
|
+
// Simple human-readable format
|
|
40
|
+
return winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.errors({ stack: true }), winston.format.splat(), winston.format.printf(({ timestamp, level, message, ...meta }) => {
|
|
41
|
+
const metaStr = Object.keys(meta).length > 0 ? JSON.stringify(meta, null, 2) : '';
|
|
42
|
+
return `[${timestamp}] [${level.toUpperCase()}] ${message}${metaStr ? '\n' + metaStr : ''}`;
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
info(message, meta) {
|
|
46
|
+
this.winstonLogger.info(message, meta);
|
|
47
|
+
}
|
|
48
|
+
warn(message, meta) {
|
|
49
|
+
this.winstonLogger.warn(message, meta);
|
|
50
|
+
}
|
|
51
|
+
error(message, meta) {
|
|
52
|
+
this.winstonLogger.error(message, meta);
|
|
53
|
+
}
|
|
54
|
+
debug(message, meta) {
|
|
55
|
+
this.winstonLogger.debug(message, meta);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a logger from config
|
|
60
|
+
* Uses Winston if no custom logger provided, otherwise returns the custom logger
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export function createLogger(config) {
|
|
65
|
+
if (config.logger) {
|
|
66
|
+
return config.logger;
|
|
67
|
+
}
|
|
68
|
+
return new WinstonMatimoLogger({
|
|
69
|
+
logLevel: config.logLevel || 'info',
|
|
70
|
+
logFormat: config.logFormat || (process.env.NODE_ENV === 'production' ? 'json' : 'simple'),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=winston-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"winston-logger.js","sourceRoot":"","sources":["../../src/logging/winston-logger.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B;;;;;;GAMG;AACH,MAAM,OAAO,mBAAmB;IAG9B,YAAY,MAA4D;QACtE,0CAA0C;QAC1C,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEvD,gCAAgC;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEnD,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;YACxC,KAAK,EAAE,YAAY;YACnB,MAAM;YACN,UAAU,EAAE;gBACV,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,C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,0 +1,140 @@
|
|
|
1
|
+
import { ToolDefinition } from './core/schema';
|
|
2
|
+
import { MatimoLogger, LoggerConfig } from './logging';
|
|
3
|
+
/**
|
|
4
|
+
* Options for MatimoInstance initialization
|
|
5
|
+
*/
|
|
6
|
+
export interface InitOptions extends LoggerConfig {
|
|
7
|
+
toolPaths?: string[];
|
|
8
|
+
autoDiscover?: boolean;
|
|
9
|
+
includeCore?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Matimo Instance - Single initialization point for tool execution
|
|
13
|
+
* Combines loader, registry, and executors into one interface
|
|
14
|
+
*/
|
|
15
|
+
export declare class MatimoInstance {
|
|
16
|
+
private toolPaths;
|
|
17
|
+
private loader;
|
|
18
|
+
private registry;
|
|
19
|
+
private commandExecutor;
|
|
20
|
+
private httpExecutor;
|
|
21
|
+
private functionExecutor;
|
|
22
|
+
private logger;
|
|
23
|
+
private approvalHandler;
|
|
24
|
+
private constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Initialize Matimo with tools from directory or auto-discovery
|
|
27
|
+
* @param options - Initialization options (string for backward compatibility)
|
|
28
|
+
* @returns MatimoInstance ready to execute tools
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Backward compatible - single path
|
|
32
|
+
* const matimo = await MatimoInstance.init('./tools');
|
|
33
|
+
*
|
|
34
|
+
* // New - auto-discovery
|
|
35
|
+
* const matimo = await MatimoInstance.init({ autoDiscover: true });
|
|
36
|
+
*
|
|
37
|
+
* // Explicit paths with logging config
|
|
38
|
+
* const matimo = await MatimoInstance.init({
|
|
39
|
+
* toolPaths: ['./tools'],
|
|
40
|
+
* logLevel: 'debug',
|
|
41
|
+
* logFormat: 'json'
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Custom logger
|
|
45
|
+
* const matimo = await MatimoInstance.init({
|
|
46
|
+
* toolPaths: ['./tools'],
|
|
47
|
+
* logger: myCustomLogger
|
|
48
|
+
* });
|
|
49
|
+
*/
|
|
50
|
+
static init(options?: InitOptions | string): Promise<MatimoInstance>;
|
|
51
|
+
/**
|
|
52
|
+
* Get tool paths
|
|
53
|
+
* @returns Array of tool paths
|
|
54
|
+
*/
|
|
55
|
+
getToolPaths(): string[];
|
|
56
|
+
/**
|
|
57
|
+
* Get the logger instance
|
|
58
|
+
* @returns MatimoLogger instance
|
|
59
|
+
*/
|
|
60
|
+
getLogger(): MatimoLogger;
|
|
61
|
+
/**
|
|
62
|
+
* Execute a tool by name with parameters
|
|
63
|
+
* @param toolName - Name of the tool to execute
|
|
64
|
+
* @param params - Tool parameters
|
|
65
|
+
* @returns Tool execution result
|
|
66
|
+
*/
|
|
67
|
+
execute(toolName: string, params: Record<string, unknown>): Promise<unknown>;
|
|
68
|
+
/**
|
|
69
|
+
* Get a tool definition by name
|
|
70
|
+
* @param toolName - Name of the tool
|
|
71
|
+
* @returns Tool definition or undefined
|
|
72
|
+
*/
|
|
73
|
+
getTool(toolName: string): ToolDefinition | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* List all available tools
|
|
76
|
+
* @returns Array of tool definitions
|
|
77
|
+
*/
|
|
78
|
+
listTools(): ToolDefinition[];
|
|
79
|
+
/**
|
|
80
|
+
* Get all available tools (alias for listTools)
|
|
81
|
+
* @returns Array of tool definitions
|
|
82
|
+
*/
|
|
83
|
+
getAllTools(): ToolDefinition[];
|
|
84
|
+
/**
|
|
85
|
+
* Search tools by name or description
|
|
86
|
+
* @param query - Search query
|
|
87
|
+
* @returns Matching tools
|
|
88
|
+
*/
|
|
89
|
+
searchTools(query: string): ToolDefinition[];
|
|
90
|
+
/**
|
|
91
|
+
* Get tools by tag
|
|
92
|
+
* @param tag - Tag to search for
|
|
93
|
+
* @returns Tools with the given tag
|
|
94
|
+
*/
|
|
95
|
+
getToolsByTag(tag: string): ToolDefinition[];
|
|
96
|
+
/**
|
|
97
|
+
* Automatically inject parameters from environment variables
|
|
98
|
+
* Uses a YAML-native, scale-friendly approach:
|
|
99
|
+
*
|
|
100
|
+
* 1. Scans the execution config for all parameter placeholders
|
|
101
|
+
* 2. For each parameter not provided by user, checks if it looks like auth (TOKEN, KEY, SECRET, etc.)
|
|
102
|
+
* 3. If yes, attempts to load from environment: MATIMO_<PARAM_NAME> or <PARAM_NAME>
|
|
103
|
+
*
|
|
104
|
+
* This works for ANY tool with ANY auth parameter name - no hardcoding needed.
|
|
105
|
+
* Scales to unlimited tools - contributors just submit YAML.
|
|
106
|
+
*
|
|
107
|
+
* Examples:
|
|
108
|
+
* - GMAIL_ACCESS_TOKEN → looks in env vars
|
|
109
|
+
* - GITHUB_TOKEN → looks in env vars
|
|
110
|
+
* - SLACK_BOT_TOKEN → looks in env vars
|
|
111
|
+
* - MY_CUSTOM_API_KEY → looks in env vars
|
|
112
|
+
* - ANY_SECRET → looks in env vars
|
|
113
|
+
*/
|
|
114
|
+
private injectAuthParameters;
|
|
115
|
+
/**
|
|
116
|
+
* Extract all parameter placeholders from execution config
|
|
117
|
+
* Scans headers, body, URL, and query_params for {paramName} patterns
|
|
118
|
+
*/
|
|
119
|
+
private extractParameterPlaceholders;
|
|
120
|
+
/**
|
|
121
|
+
* Recursively scan object for parameter placeholders
|
|
122
|
+
*/
|
|
123
|
+
private scanObjectForParams;
|
|
124
|
+
/**
|
|
125
|
+
* Get the appropriate executor for a tool
|
|
126
|
+
*/
|
|
127
|
+
private getExecutor;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Matimo namespace - Entry point for the SDK
|
|
131
|
+
*/
|
|
132
|
+
export declare const matimo: {
|
|
133
|
+
/**
|
|
134
|
+
* Initialize Matimo with a tools directory
|
|
135
|
+
* @param toolsPath - Path to tools directory
|
|
136
|
+
* @returns MatimoInstance ready to use
|
|
137
|
+
*/
|
|
138
|
+
init(toolsPath: string): Promise<MatimoInstance>;
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=matimo-instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mat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