@omote/core 0.7.1 → 0.9.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,145 @@
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
+ /** Trace ID from active telemetry span (log-to-span correlation) */
34
+ traceId?: string;
35
+ /** Span ID from active telemetry span (log-to-span correlation) */
36
+ spanId?: string;
37
+ }
38
+ /**
39
+ * Log output sink interface
40
+ */
41
+ interface LogSink {
42
+ (entry: LogEntry): void;
43
+ }
44
+ /**
45
+ * Log formatter interface
46
+ */
47
+ interface LogFormatter {
48
+ (entry: LogEntry): string;
49
+ }
50
+ /**
51
+ * Global logging configuration
52
+ */
53
+ interface LoggingConfig {
54
+ /** Minimum log level to output (default: 'info') */
55
+ level: LogLevel;
56
+ /** Enable/disable logging globally (default: true) */
57
+ enabled: boolean;
58
+ /** Output format: 'json' for structured, 'pretty' for human-readable */
59
+ format: 'json' | 'pretty';
60
+ /** Custom output sink (default: console) */
61
+ sink?: LogSink;
62
+ /** Include timestamps in output (default: true) */
63
+ timestamps?: boolean;
64
+ /** Include module name in output (default: true) */
65
+ includeModule?: boolean;
66
+ }
67
+ /**
68
+ * Logger interface for module-specific logging
69
+ */
70
+ interface ILogger {
71
+ error(message: string, data?: Record<string, unknown>): void;
72
+ warn(message: string, data?: Record<string, unknown>): void;
73
+ info(message: string, data?: Record<string, unknown>): void;
74
+ debug(message: string, data?: Record<string, unknown>): void;
75
+ trace(message: string, data?: Record<string, unknown>): void;
76
+ verbose(message: string, data?: Record<string, unknown>): void;
77
+ /** Create a child logger with a sub-module name */
78
+ child(subModule: string): ILogger;
79
+ /** Get the module name for this logger */
80
+ readonly module: string;
81
+ }
82
+ /**
83
+ * Default configuration
84
+ */
85
+ declare const DEFAULT_LOGGING_CONFIG: LoggingConfig;
86
+
87
+ /**
88
+ * Omote SDK Logger
89
+ *
90
+ * Unified logging system with:
91
+ * - 6 log levels (error, warn, info, debug, trace, verbose)
92
+ * - Structured JSON output for machine parsing
93
+ * - Pretty output for human readability
94
+ * - Module-based child loggers
95
+ * - Runtime configuration
96
+ * - Browser and Node.js compatible
97
+ */
98
+
99
+ /**
100
+ * Configure global logging settings
101
+ */
102
+ declare function configureLogging(config: Partial<LoggingConfig>): void;
103
+ /**
104
+ * Get current logging configuration
105
+ */
106
+ declare function getLoggingConfig(): LoggingConfig;
107
+ /**
108
+ * Reset logging configuration to defaults
109
+ */
110
+ declare function resetLoggingConfig(): void;
111
+ /**
112
+ * Set log level at runtime
113
+ */
114
+ declare function setLogLevel(level: LogLevel): void;
115
+ /**
116
+ * Enable or disable logging
117
+ */
118
+ declare function setLoggingEnabled(enabled: boolean): void;
119
+ /**
120
+ * Create a logger for a specific module
121
+ *
122
+ * @param module - Module name (e.g., 'LocalInference', 'ModelCache')
123
+ * @returns Logger instance
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const logger = createLogger('LocalInference');
128
+ * logger.info('Model loaded', { backend: 'webgpu', loadTimeMs: 1234 });
129
+ * ```
130
+ */
131
+ declare function createLogger(module: string): ILogger;
132
+ /**
133
+ * Clear logger cache (useful for testing)
134
+ */
135
+ declare function clearLoggerCache(): void;
136
+ /**
137
+ * No-op logger for when logging is completely disabled
138
+ */
139
+ declare const noopLogger: ILogger;
140
+ /**
141
+ * Get a no-op logger (for production builds that tree-shake logging)
142
+ */
143
+ declare function getNoopLogger(): ILogger;
144
+
145
+ export { DEFAULT_LOGGING_CONFIG as D, type ILogger as I, type LogFormatter as L, LOG_LEVEL_PRIORITY as a, type LogEntry as b, type LogLevel as c, type LogSink as d, type LoggingConfig as e, clearLoggerCache as f, configureLogging as g, createLogger as h, getLoggingConfig as i, getNoopLogger as j, setLoggingEnabled as k, noopLogger as n, resetLoggingConfig as r, setLogLevel as s };
@@ -0,0 +1,145 @@
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
+ /** Trace ID from active telemetry span (log-to-span correlation) */
34
+ traceId?: string;
35
+ /** Span ID from active telemetry span (log-to-span correlation) */
36
+ spanId?: string;
37
+ }
38
+ /**
39
+ * Log output sink interface
40
+ */
41
+ interface LogSink {
42
+ (entry: LogEntry): void;
43
+ }
44
+ /**
45
+ * Log formatter interface
46
+ */
47
+ interface LogFormatter {
48
+ (entry: LogEntry): string;
49
+ }
50
+ /**
51
+ * Global logging configuration
52
+ */
53
+ interface LoggingConfig {
54
+ /** Minimum log level to output (default: 'info') */
55
+ level: LogLevel;
56
+ /** Enable/disable logging globally (default: true) */
57
+ enabled: boolean;
58
+ /** Output format: 'json' for structured, 'pretty' for human-readable */
59
+ format: 'json' | 'pretty';
60
+ /** Custom output sink (default: console) */
61
+ sink?: LogSink;
62
+ /** Include timestamps in output (default: true) */
63
+ timestamps?: boolean;
64
+ /** Include module name in output (default: true) */
65
+ includeModule?: boolean;
66
+ }
67
+ /**
68
+ * Logger interface for module-specific logging
69
+ */
70
+ interface ILogger {
71
+ error(message: string, data?: Record<string, unknown>): void;
72
+ warn(message: string, data?: Record<string, unknown>): void;
73
+ info(message: string, data?: Record<string, unknown>): void;
74
+ debug(message: string, data?: Record<string, unknown>): void;
75
+ trace(message: string, data?: Record<string, unknown>): void;
76
+ verbose(message: string, data?: Record<string, unknown>): void;
77
+ /** Create a child logger with a sub-module name */
78
+ child(subModule: string): ILogger;
79
+ /** Get the module name for this logger */
80
+ readonly module: string;
81
+ }
82
+ /**
83
+ * Default configuration
84
+ */
85
+ declare const DEFAULT_LOGGING_CONFIG: LoggingConfig;
86
+
87
+ /**
88
+ * Omote SDK Logger
89
+ *
90
+ * Unified logging system with:
91
+ * - 6 log levels (error, warn, info, debug, trace, verbose)
92
+ * - Structured JSON output for machine parsing
93
+ * - Pretty output for human readability
94
+ * - Module-based child loggers
95
+ * - Runtime configuration
96
+ * - Browser and Node.js compatible
97
+ */
98
+
99
+ /**
100
+ * Configure global logging settings
101
+ */
102
+ declare function configureLogging(config: Partial<LoggingConfig>): void;
103
+ /**
104
+ * Get current logging configuration
105
+ */
106
+ declare function getLoggingConfig(): LoggingConfig;
107
+ /**
108
+ * Reset logging configuration to defaults
109
+ */
110
+ declare function resetLoggingConfig(): void;
111
+ /**
112
+ * Set log level at runtime
113
+ */
114
+ declare function setLogLevel(level: LogLevel): void;
115
+ /**
116
+ * Enable or disable logging
117
+ */
118
+ declare function setLoggingEnabled(enabled: boolean): void;
119
+ /**
120
+ * Create a logger for a specific module
121
+ *
122
+ * @param module - Module name (e.g., 'LocalInference', 'ModelCache')
123
+ * @returns Logger instance
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const logger = createLogger('LocalInference');
128
+ * logger.info('Model loaded', { backend: 'webgpu', loadTimeMs: 1234 });
129
+ * ```
130
+ */
131
+ declare function createLogger(module: string): ILogger;
132
+ /**
133
+ * Clear logger cache (useful for testing)
134
+ */
135
+ declare function clearLoggerCache(): void;
136
+ /**
137
+ * No-op logger for when logging is completely disabled
138
+ */
139
+ declare const noopLogger: ILogger;
140
+ /**
141
+ * Get a no-op logger (for production builds that tree-shake logging)
142
+ */
143
+ declare function getNoopLogger(): ILogger;
144
+
145
+ export { DEFAULT_LOGGING_CONFIG as D, type ILogger as I, type LogFormatter as L, LOG_LEVEL_PRIORITY as a, type LogEntry as b, type LogLevel as c, type LogSink as d, type LoggingConfig as e, clearLoggerCache as f, configureLogging as g, createLogger as h, getLoggingConfig as i, getNoopLogger as j, setLoggingEnabled as k, noopLogger as n, resetLoggingConfig as r, setLogLevel as s };