@omote/core 0.1.0 → 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.
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Logging types for Omote SDK
3
+ *
4
+ * 6-level logging system with structured output:
5
+ * - error: Critical failures that prevent operation
6
+ * - warn: Recoverable issues or degraded performance
7
+ * - info: Key lifecycle events (model loaded, inference complete)
8
+ * - debug: Detailed operational info for development
9
+ * - trace: Fine-grained tracing for performance analysis
10
+ * - verbose: Extremely detailed output (tensor shapes, intermediate values)
11
+ */
12
+ type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'verbose';
13
+ /**
14
+ * Numeric priority for log levels (lower = more severe)
15
+ */
16
+ declare const LOG_LEVEL_PRIORITY: Record<LogLevel, number>;
17
+ /**
18
+ * Structured log entry
19
+ */
20
+ interface LogEntry {
21
+ /** Unix timestamp in milliseconds */
22
+ timestamp: number;
23
+ /** Log level */
24
+ level: LogLevel;
25
+ /** Module name (e.g., 'LocalInference', 'ModelCache') */
26
+ module: string;
27
+ /** Human-readable message */
28
+ message: string;
29
+ /** Optional structured data */
30
+ data?: Record<string, unknown>;
31
+ /** Optional error object */
32
+ error?: Error;
33
+ }
34
+ /**
35
+ * Log output sink interface
36
+ */
37
+ interface LogSink {
38
+ (entry: LogEntry): void;
39
+ }
40
+ /**
41
+ * Log formatter interface
42
+ */
43
+ interface LogFormatter {
44
+ (entry: LogEntry): string;
45
+ }
46
+ /**
47
+ * Global logging configuration
48
+ */
49
+ interface LoggingConfig {
50
+ /** Minimum log level to output (default: 'info') */
51
+ level: LogLevel;
52
+ /** Enable/disable logging globally (default: true) */
53
+ enabled: boolean;
54
+ /** Output format: 'json' for structured, 'pretty' for human-readable */
55
+ format: 'json' | 'pretty';
56
+ /** Custom output sink (default: console) */
57
+ sink?: LogSink;
58
+ /** Include timestamps in output (default: true) */
59
+ timestamps?: boolean;
60
+ /** Include module name in output (default: true) */
61
+ includeModule?: boolean;
62
+ }
63
+ /**
64
+ * Logger interface for module-specific logging
65
+ */
66
+ interface ILogger {
67
+ error(message: string, data?: Record<string, unknown>): void;
68
+ warn(message: string, data?: Record<string, unknown>): void;
69
+ info(message: string, data?: Record<string, unknown>): void;
70
+ debug(message: string, data?: Record<string, unknown>): void;
71
+ trace(message: string, data?: Record<string, unknown>): void;
72
+ verbose(message: string, data?: Record<string, unknown>): void;
73
+ /** Create a child logger with a sub-module name */
74
+ child(subModule: string): ILogger;
75
+ /** Get the module name for this logger */
76
+ readonly module: string;
77
+ }
78
+ /**
79
+ * Default configuration
80
+ */
81
+ declare const DEFAULT_LOGGING_CONFIG: LoggingConfig;
82
+
83
+ /**
84
+ * Omote SDK Logger
85
+ *
86
+ * Unified logging system with:
87
+ * - 6 log levels (error, warn, info, debug, trace, verbose)
88
+ * - Structured JSON output for machine parsing
89
+ * - Pretty output for human readability
90
+ * - Module-based child loggers
91
+ * - Runtime configuration
92
+ * - Browser and Node.js compatible
93
+ */
94
+
95
+ /**
96
+ * Configure global logging settings
97
+ */
98
+ declare function configureLogging(config: Partial<LoggingConfig>): void;
99
+ /**
100
+ * Get current logging configuration
101
+ */
102
+ declare function getLoggingConfig(): LoggingConfig;
103
+ /**
104
+ * Reset logging configuration to defaults
105
+ */
106
+ declare function resetLoggingConfig(): void;
107
+ /**
108
+ * Set log level at runtime
109
+ */
110
+ declare function setLogLevel(level: LogLevel): void;
111
+ /**
112
+ * Enable or disable logging
113
+ */
114
+ declare function setLoggingEnabled(enabled: boolean): void;
115
+ /**
116
+ * Create a logger for a specific module
117
+ *
118
+ * @param module - Module name (e.g., 'LocalInference', 'ModelCache')
119
+ * @returns Logger instance
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const logger = createLogger('LocalInference');
124
+ * logger.info('Model loaded', { backend: 'webgpu', loadTimeMs: 1234 });
125
+ * ```
126
+ */
127
+ declare function createLogger(module: string): ILogger;
128
+ /**
129
+ * Clear logger cache (useful for testing)
130
+ */
131
+ declare function clearLoggerCache(): void;
132
+ /**
133
+ * No-op logger for when logging is completely disabled
134
+ */
135
+ declare const noopLogger: ILogger;
136
+ /**
137
+ * Get a no-op logger (for production builds that tree-shake logging)
138
+ */
139
+ declare function getNoopLogger(): ILogger;
140
+
141
+ export { DEFAULT_LOGGING_CONFIG as D, type ILogger as I, type LogFormatter as L, type LogLevel as a, type LogEntry as b, type LogSink as c, type LoggingConfig as d, LOG_LEVEL_PRIORITY as e, configureLogging as f, getLoggingConfig as g, setLoggingEnabled as h, createLogger as i, clearLoggerCache as j, getNoopLogger as k, noopLogger as n, resetLoggingConfig as r, setLogLevel as s };
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Logging types for Omote SDK
3
+ *
4
+ * 6-level logging system with structured output:
5
+ * - error: Critical failures that prevent operation
6
+ * - warn: Recoverable issues or degraded performance
7
+ * - info: Key lifecycle events (model loaded, inference complete)
8
+ * - debug: Detailed operational info for development
9
+ * - trace: Fine-grained tracing for performance analysis
10
+ * - verbose: Extremely detailed output (tensor shapes, intermediate values)
11
+ */
12
+ type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'verbose';
13
+ /**
14
+ * Numeric priority for log levels (lower = more severe)
15
+ */
16
+ declare const LOG_LEVEL_PRIORITY: Record<LogLevel, number>;
17
+ /**
18
+ * Structured log entry
19
+ */
20
+ interface LogEntry {
21
+ /** Unix timestamp in milliseconds */
22
+ timestamp: number;
23
+ /** Log level */
24
+ level: LogLevel;
25
+ /** Module name (e.g., 'LocalInference', 'ModelCache') */
26
+ module: string;
27
+ /** Human-readable message */
28
+ message: string;
29
+ /** Optional structured data */
30
+ data?: Record<string, unknown>;
31
+ /** Optional error object */
32
+ error?: Error;
33
+ }
34
+ /**
35
+ * Log output sink interface
36
+ */
37
+ interface LogSink {
38
+ (entry: LogEntry): void;
39
+ }
40
+ /**
41
+ * Log formatter interface
42
+ */
43
+ interface LogFormatter {
44
+ (entry: LogEntry): string;
45
+ }
46
+ /**
47
+ * Global logging configuration
48
+ */
49
+ interface LoggingConfig {
50
+ /** Minimum log level to output (default: 'info') */
51
+ level: LogLevel;
52
+ /** Enable/disable logging globally (default: true) */
53
+ enabled: boolean;
54
+ /** Output format: 'json' for structured, 'pretty' for human-readable */
55
+ format: 'json' | 'pretty';
56
+ /** Custom output sink (default: console) */
57
+ sink?: LogSink;
58
+ /** Include timestamps in output (default: true) */
59
+ timestamps?: boolean;
60
+ /** Include module name in output (default: true) */
61
+ includeModule?: boolean;
62
+ }
63
+ /**
64
+ * Logger interface for module-specific logging
65
+ */
66
+ interface ILogger {
67
+ error(message: string, data?: Record<string, unknown>): void;
68
+ warn(message: string, data?: Record<string, unknown>): void;
69
+ info(message: string, data?: Record<string, unknown>): void;
70
+ debug(message: string, data?: Record<string, unknown>): void;
71
+ trace(message: string, data?: Record<string, unknown>): void;
72
+ verbose(message: string, data?: Record<string, unknown>): void;
73
+ /** Create a child logger with a sub-module name */
74
+ child(subModule: string): ILogger;
75
+ /** Get the module name for this logger */
76
+ readonly module: string;
77
+ }
78
+ /**
79
+ * Default configuration
80
+ */
81
+ declare const DEFAULT_LOGGING_CONFIG: LoggingConfig;
82
+
83
+ /**
84
+ * Omote SDK Logger
85
+ *
86
+ * Unified logging system with:
87
+ * - 6 log levels (error, warn, info, debug, trace, verbose)
88
+ * - Structured JSON output for machine parsing
89
+ * - Pretty output for human readability
90
+ * - Module-based child loggers
91
+ * - Runtime configuration
92
+ * - Browser and Node.js compatible
93
+ */
94
+
95
+ /**
96
+ * Configure global logging settings
97
+ */
98
+ declare function configureLogging(config: Partial<LoggingConfig>): void;
99
+ /**
100
+ * Get current logging configuration
101
+ */
102
+ declare function getLoggingConfig(): LoggingConfig;
103
+ /**
104
+ * Reset logging configuration to defaults
105
+ */
106
+ declare function resetLoggingConfig(): void;
107
+ /**
108
+ * Set log level at runtime
109
+ */
110
+ declare function setLogLevel(level: LogLevel): void;
111
+ /**
112
+ * Enable or disable logging
113
+ */
114
+ declare function setLoggingEnabled(enabled: boolean): void;
115
+ /**
116
+ * Create a logger for a specific module
117
+ *
118
+ * @param module - Module name (e.g., 'LocalInference', 'ModelCache')
119
+ * @returns Logger instance
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const logger = createLogger('LocalInference');
124
+ * logger.info('Model loaded', { backend: 'webgpu', loadTimeMs: 1234 });
125
+ * ```
126
+ */
127
+ declare function createLogger(module: string): ILogger;
128
+ /**
129
+ * Clear logger cache (useful for testing)
130
+ */
131
+ declare function clearLoggerCache(): void;
132
+ /**
133
+ * No-op logger for when logging is completely disabled
134
+ */
135
+ declare const noopLogger: ILogger;
136
+ /**
137
+ * Get a no-op logger (for production builds that tree-shake logging)
138
+ */
139
+ declare function getNoopLogger(): ILogger;
140
+
141
+ export { DEFAULT_LOGGING_CONFIG as D, type ILogger as I, type LogFormatter as L, type LogLevel as a, type LogEntry as b, type LogSink as c, type LoggingConfig as d, LOG_LEVEL_PRIORITY as e, configureLogging as f, getLoggingConfig as g, setLoggingEnabled as h, createLogger as i, clearLoggerCache as j, getNoopLogger as k, noopLogger as n, resetLoggingConfig as r, setLogLevel as s };