@omote/core 0.9.1 → 0.9.3
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/dist/ErrorCodes-AX3ADZri.d.mts +266 -0
- package/dist/ErrorCodes-AX3ADZri.d.ts +266 -0
- package/dist/chunk-CYBTTLG7.mjs +927 -0
- package/dist/chunk-CYBTTLG7.mjs.map +1 -0
- package/dist/chunk-X5OTUOE6.mjs +927 -0
- package/dist/chunk-X5OTUOE6.mjs.map +1 -0
- package/dist/chunk-Y3DTP5P3.mjs +927 -0
- package/dist/chunk-Y3DTP5P3.mjs.map +1 -0
- package/dist/index.d.mts +214 -3
- package/dist/index.d.ts +214 -3
- package/dist/index.js +713 -233
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +638 -225
- package/dist/index.mjs.map +1 -1
- package/dist/logging/index.d.mts +2 -2
- package/dist/logging/index.d.ts +2 -2
- package/dist/logging/index.js +75 -1
- package/dist/logging/index.js.map +1 -1
- package/dist/logging/index.mjs +9 -1
- package/package.json +3 -1
|
@@ -0,0 +1,266 @@
|
|
|
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 error code from ErrorCodes (e.g., 'OMOTE_INF_001') */
|
|
30
|
+
code?: string;
|
|
31
|
+
/** Optional structured data */
|
|
32
|
+
data?: Record<string, unknown>;
|
|
33
|
+
/** Optional error object */
|
|
34
|
+
error?: Error;
|
|
35
|
+
/** Trace ID from active telemetry span (log-to-span correlation) */
|
|
36
|
+
traceId?: string;
|
|
37
|
+
/** Span ID from active telemetry span (log-to-span correlation) */
|
|
38
|
+
spanId?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Log output sink interface.
|
|
42
|
+
*
|
|
43
|
+
* **Portability contract**: Replace the default console sink to route logs to
|
|
44
|
+
* any backend — Node.js winston/pino, Unreal UE_LOG, Unity Debug.Log, or a
|
|
45
|
+
* remote telemetry service. Register via `configureLogging({ sink: mySink })`.
|
|
46
|
+
*/
|
|
47
|
+
interface LogSink {
|
|
48
|
+
(entry: LogEntry): void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Log formatter interface
|
|
52
|
+
*/
|
|
53
|
+
interface LogFormatter {
|
|
54
|
+
(entry: LogEntry): string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Global logging configuration
|
|
58
|
+
*/
|
|
59
|
+
interface LoggingConfig {
|
|
60
|
+
/** Minimum log level to output (default: 'info') */
|
|
61
|
+
level: LogLevel;
|
|
62
|
+
/** Enable/disable logging globally (default: true) */
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
/** Output format: 'json' for structured, 'pretty' for human-readable */
|
|
65
|
+
format: 'json' | 'pretty';
|
|
66
|
+
/** Custom output sink (default: console) */
|
|
67
|
+
sink?: LogSink;
|
|
68
|
+
/** Include timestamps in output (default: true) */
|
|
69
|
+
timestamps?: boolean;
|
|
70
|
+
/** Include module name in output (default: true) */
|
|
71
|
+
includeModule?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Logger interface for module-specific logging.
|
|
75
|
+
*
|
|
76
|
+
* **Portability contract**: All SDK modules depend only on this interface.
|
|
77
|
+
* To integrate with a non-browser runtime (Node.js, Unreal, Unity), either:
|
|
78
|
+
* 1. Use the built-in Logger with a custom `LogSink`, or
|
|
79
|
+
* 2. Provide your own `ILogger` implementation that bridges to the host
|
|
80
|
+
* runtime's logging system (e.g., `console.log`, `UE_LOG`, `Debug.Log`).
|
|
81
|
+
*/
|
|
82
|
+
interface ILogger {
|
|
83
|
+
error(message: string, data?: Record<string, unknown>): void;
|
|
84
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
85
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
86
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
87
|
+
trace(message: string, data?: Record<string, unknown>): void;
|
|
88
|
+
verbose(message: string, data?: Record<string, unknown>): void;
|
|
89
|
+
/** Create a child logger with a sub-module name */
|
|
90
|
+
child(subModule: string): ILogger;
|
|
91
|
+
/** Get the module name for this logger */
|
|
92
|
+
readonly module: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Default configuration
|
|
96
|
+
*/
|
|
97
|
+
declare const DEFAULT_LOGGING_CONFIG: LoggingConfig;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Omote SDK Logger
|
|
101
|
+
*
|
|
102
|
+
* Unified logging system with:
|
|
103
|
+
* - 6 log levels (error, warn, info, debug, trace, verbose)
|
|
104
|
+
* - Structured JSON output for machine parsing
|
|
105
|
+
* - Pretty output for human readability
|
|
106
|
+
* - Module-based child loggers
|
|
107
|
+
* - Runtime configuration
|
|
108
|
+
* - Browser and Node.js compatible
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Configure global logging settings
|
|
113
|
+
*/
|
|
114
|
+
declare function configureLogging(config: Partial<LoggingConfig>): void;
|
|
115
|
+
/**
|
|
116
|
+
* Get current logging configuration
|
|
117
|
+
*/
|
|
118
|
+
declare function getLoggingConfig(): LoggingConfig;
|
|
119
|
+
/**
|
|
120
|
+
* Reset logging configuration to defaults
|
|
121
|
+
*/
|
|
122
|
+
declare function resetLoggingConfig(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Set log level at runtime
|
|
125
|
+
*/
|
|
126
|
+
declare function setLogLevel(level: LogLevel): void;
|
|
127
|
+
/**
|
|
128
|
+
* Enable or disable logging
|
|
129
|
+
*/
|
|
130
|
+
declare function setLoggingEnabled(enabled: boolean): void;
|
|
131
|
+
/**
|
|
132
|
+
* Create a logger for a specific module
|
|
133
|
+
*
|
|
134
|
+
* @param module - Module name (e.g., 'LocalInference', 'ModelCache')
|
|
135
|
+
* @returns Logger instance
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const logger = createLogger('LocalInference');
|
|
140
|
+
* logger.info('Model loaded', { backend: 'webgpu', loadTimeMs: 1234 });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
declare function createLogger(module: string): ILogger;
|
|
144
|
+
/**
|
|
145
|
+
* Clear logger cache (useful for testing)
|
|
146
|
+
*/
|
|
147
|
+
declare function clearLoggerCache(): void;
|
|
148
|
+
/**
|
|
149
|
+
* No-op logger for when logging is completely disabled
|
|
150
|
+
*/
|
|
151
|
+
declare const noopLogger: ILogger;
|
|
152
|
+
/**
|
|
153
|
+
* Get a no-op logger (for production builds that tree-shake logging)
|
|
154
|
+
*/
|
|
155
|
+
declare function getNoopLogger(): ILogger;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Abstract monotonic clock for runtime-agnostic timing.
|
|
159
|
+
*
|
|
160
|
+
* **Portability contract**: To port the SDK to Node.js, Python, Unreal, or Unity,
|
|
161
|
+
* implement this interface with your runtime's high-resolution timer and call
|
|
162
|
+
* `configureClock()` at startup.
|
|
163
|
+
*
|
|
164
|
+
* @example Node.js
|
|
165
|
+
* ```typescript
|
|
166
|
+
* import { configureClock } from '@omote/core';
|
|
167
|
+
* configureClock({
|
|
168
|
+
* now: () => Number(process.hrtime.bigint() / 1_000_000n),
|
|
169
|
+
* timestamp: () => Date.now(),
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @example Unreal Engine (via wasm-bindgen)
|
|
174
|
+
* ```typescript
|
|
175
|
+
* configureClock({
|
|
176
|
+
* now: () => FPlatformTime.Seconds() * 1000,
|
|
177
|
+
* timestamp: () => FDateTime.UtcNow().ToUnixTimestamp() * 1000,
|
|
178
|
+
* });
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @example Unity (via jslib bridge)
|
|
182
|
+
* ```typescript
|
|
183
|
+
* configureClock({
|
|
184
|
+
* now: () => Time.realtimeSinceStartup * 1000,
|
|
185
|
+
* timestamp: () => Date.now(),
|
|
186
|
+
* });
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
interface Clock {
|
|
190
|
+
/** Monotonic high-resolution milliseconds (for durations, telemetry spans) */
|
|
191
|
+
now(): number;
|
|
192
|
+
/** Wall-clock milliseconds since epoch (for log timestamps) */
|
|
193
|
+
timestamp(): number;
|
|
194
|
+
}
|
|
195
|
+
declare const defaultClock: Clock;
|
|
196
|
+
/** Replace the default browser clock with a custom implementation. */
|
|
197
|
+
declare function configureClock(clock: Clock): void;
|
|
198
|
+
/** Get the active clock instance. */
|
|
199
|
+
declare function getClock(): Clock;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Structured error codes for the Omote SDK.
|
|
203
|
+
*
|
|
204
|
+
* Codes follow the pattern `OMOTE_{CATEGORY}_{SEQ}` where:
|
|
205
|
+
* - **INF** = Inference (model loading, session, OOM)
|
|
206
|
+
* - **AUD** = Audio (AudioContext, scheduling, decoding)
|
|
207
|
+
* - **SPH** = Speech (VAD, ASR, microphone)
|
|
208
|
+
* - **TTS** = Text-to-Speech (synthesis, streaming, phonemizer)
|
|
209
|
+
* - **PIP** = Pipeline (state machine, abort)
|
|
210
|
+
* - **CAC** = Cache (IndexedDB quota, eviction, staleness)
|
|
211
|
+
* - **NET** = Network (fetch, timeout, WebSocket)
|
|
212
|
+
*
|
|
213
|
+
* Exported as a const object (not enum) for tree-shaking.
|
|
214
|
+
*/
|
|
215
|
+
declare const ErrorCodes: {
|
|
216
|
+
/** Model failed to load (file not found, corrupted, unsupported format) */
|
|
217
|
+
readonly INF_LOAD_FAILED: "OMOTE_INF_001";
|
|
218
|
+
/** ORT session poisoned after WebGPU device loss — must reload tab */
|
|
219
|
+
readonly INF_SESSION_POISON: "OMOTE_INF_002";
|
|
220
|
+
/** Inference exceeded timeout threshold */
|
|
221
|
+
readonly INF_TIMEOUT: "OMOTE_INF_003";
|
|
222
|
+
/** Out-of-memory during inference or model loading */
|
|
223
|
+
readonly INF_OOM: "OMOTE_INF_004";
|
|
224
|
+
/** WebGPU unavailable, fell back to WASM */
|
|
225
|
+
readonly INF_WEBGPU_FALLBACK: "OMOTE_INF_005";
|
|
226
|
+
/** Input tensor shape does not match model expectations */
|
|
227
|
+
readonly INF_SHAPE_MISMATCH: "OMOTE_INF_006";
|
|
228
|
+
/** AudioContext creation or resume failed */
|
|
229
|
+
readonly AUD_CONTEXT_FAILED: "OMOTE_AUD_001";
|
|
230
|
+
/** Gap detected in audio scheduling (buffer underrun) */
|
|
231
|
+
readonly AUD_SCHEDULE_GAP: "OMOTE_AUD_002";
|
|
232
|
+
/** Audio buffer decoding failed */
|
|
233
|
+
readonly AUD_DECODE_FAILED: "OMOTE_AUD_003";
|
|
234
|
+
/** Voice activity detection error */
|
|
235
|
+
readonly SPH_VAD_ERROR: "OMOTE_SPH_001";
|
|
236
|
+
/** Automatic speech recognition error */
|
|
237
|
+
readonly SPH_ASR_ERROR: "OMOTE_SPH_002";
|
|
238
|
+
/** Microphone access denied or unavailable */
|
|
239
|
+
readonly SPH_MIC_DENIED: "OMOTE_SPH_003";
|
|
240
|
+
/** TTS synthesis failed */
|
|
241
|
+
readonly TTS_SYNTH_FAILED: "OMOTE_TTS_001";
|
|
242
|
+
/** TTS streaming error (chunk delivery failure) */
|
|
243
|
+
readonly TTS_STREAM_ERROR: "OMOTE_TTS_002";
|
|
244
|
+
/** Phonemizer (eSpeak-NG WASM) ran out of memory */
|
|
245
|
+
readonly TTS_PHONEMIZER_OOM: "OMOTE_TTS_003";
|
|
246
|
+
/** Invalid state transition in pipeline state machine */
|
|
247
|
+
readonly PIP_STATE_ERROR: "OMOTE_PIP_001";
|
|
248
|
+
/** Pipeline operation aborted (user interrupt or signal) */
|
|
249
|
+
readonly PIP_ABORT: "OMOTE_PIP_002";
|
|
250
|
+
/** IndexedDB storage quota exceeded */
|
|
251
|
+
readonly CAC_QUOTA_EXCEEDED: "OMOTE_CAC_001";
|
|
252
|
+
/** Cache entry evicted (LRU or manual) */
|
|
253
|
+
readonly CAC_EVICTION: "OMOTE_CAC_002";
|
|
254
|
+
/** Cached model is stale (version mismatch) */
|
|
255
|
+
readonly CAC_STALE: "OMOTE_CAC_003";
|
|
256
|
+
/** HTTP fetch failed (model download, CDN) */
|
|
257
|
+
readonly NET_FETCH_FAILED: "OMOTE_NET_001";
|
|
258
|
+
/** Network request timed out */
|
|
259
|
+
readonly NET_TIMEOUT: "OMOTE_NET_002";
|
|
260
|
+
/** WebSocket connection error */
|
|
261
|
+
readonly NET_WEBSOCKET_ERROR: "OMOTE_NET_003";
|
|
262
|
+
};
|
|
263
|
+
/** Union type of all error code string values. */
|
|
264
|
+
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
265
|
+
|
|
266
|
+
export { type Clock as C, DEFAULT_LOGGING_CONFIG as D, type ErrorCode as E, type ILogger as I, type LogFormatter as L, ErrorCodes as a, LOG_LEVEL_PRIORITY as b, type LogEntry as c, type LogLevel as d, type LogSink as e, type LoggingConfig as f, clearLoggerCache as g, configureClock as h, configureLogging as i, createLogger as j, defaultClock as k, getClock as l, getLoggingConfig as m, getNoopLogger as n, noopLogger as o, setLoggingEnabled as p, resetLoggingConfig as r, setLogLevel as s };
|
|
@@ -0,0 +1,266 @@
|
|
|
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 error code from ErrorCodes (e.g., 'OMOTE_INF_001') */
|
|
30
|
+
code?: string;
|
|
31
|
+
/** Optional structured data */
|
|
32
|
+
data?: Record<string, unknown>;
|
|
33
|
+
/** Optional error object */
|
|
34
|
+
error?: Error;
|
|
35
|
+
/** Trace ID from active telemetry span (log-to-span correlation) */
|
|
36
|
+
traceId?: string;
|
|
37
|
+
/** Span ID from active telemetry span (log-to-span correlation) */
|
|
38
|
+
spanId?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Log output sink interface.
|
|
42
|
+
*
|
|
43
|
+
* **Portability contract**: Replace the default console sink to route logs to
|
|
44
|
+
* any backend — Node.js winston/pino, Unreal UE_LOG, Unity Debug.Log, or a
|
|
45
|
+
* remote telemetry service. Register via `configureLogging({ sink: mySink })`.
|
|
46
|
+
*/
|
|
47
|
+
interface LogSink {
|
|
48
|
+
(entry: LogEntry): void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Log formatter interface
|
|
52
|
+
*/
|
|
53
|
+
interface LogFormatter {
|
|
54
|
+
(entry: LogEntry): string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Global logging configuration
|
|
58
|
+
*/
|
|
59
|
+
interface LoggingConfig {
|
|
60
|
+
/** Minimum log level to output (default: 'info') */
|
|
61
|
+
level: LogLevel;
|
|
62
|
+
/** Enable/disable logging globally (default: true) */
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
/** Output format: 'json' for structured, 'pretty' for human-readable */
|
|
65
|
+
format: 'json' | 'pretty';
|
|
66
|
+
/** Custom output sink (default: console) */
|
|
67
|
+
sink?: LogSink;
|
|
68
|
+
/** Include timestamps in output (default: true) */
|
|
69
|
+
timestamps?: boolean;
|
|
70
|
+
/** Include module name in output (default: true) */
|
|
71
|
+
includeModule?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Logger interface for module-specific logging.
|
|
75
|
+
*
|
|
76
|
+
* **Portability contract**: All SDK modules depend only on this interface.
|
|
77
|
+
* To integrate with a non-browser runtime (Node.js, Unreal, Unity), either:
|
|
78
|
+
* 1. Use the built-in Logger with a custom `LogSink`, or
|
|
79
|
+
* 2. Provide your own `ILogger` implementation that bridges to the host
|
|
80
|
+
* runtime's logging system (e.g., `console.log`, `UE_LOG`, `Debug.Log`).
|
|
81
|
+
*/
|
|
82
|
+
interface ILogger {
|
|
83
|
+
error(message: string, data?: Record<string, unknown>): void;
|
|
84
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
85
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
86
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
87
|
+
trace(message: string, data?: Record<string, unknown>): void;
|
|
88
|
+
verbose(message: string, data?: Record<string, unknown>): void;
|
|
89
|
+
/** Create a child logger with a sub-module name */
|
|
90
|
+
child(subModule: string): ILogger;
|
|
91
|
+
/** Get the module name for this logger */
|
|
92
|
+
readonly module: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Default configuration
|
|
96
|
+
*/
|
|
97
|
+
declare const DEFAULT_LOGGING_CONFIG: LoggingConfig;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Omote SDK Logger
|
|
101
|
+
*
|
|
102
|
+
* Unified logging system with:
|
|
103
|
+
* - 6 log levels (error, warn, info, debug, trace, verbose)
|
|
104
|
+
* - Structured JSON output for machine parsing
|
|
105
|
+
* - Pretty output for human readability
|
|
106
|
+
* - Module-based child loggers
|
|
107
|
+
* - Runtime configuration
|
|
108
|
+
* - Browser and Node.js compatible
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Configure global logging settings
|
|
113
|
+
*/
|
|
114
|
+
declare function configureLogging(config: Partial<LoggingConfig>): void;
|
|
115
|
+
/**
|
|
116
|
+
* Get current logging configuration
|
|
117
|
+
*/
|
|
118
|
+
declare function getLoggingConfig(): LoggingConfig;
|
|
119
|
+
/**
|
|
120
|
+
* Reset logging configuration to defaults
|
|
121
|
+
*/
|
|
122
|
+
declare function resetLoggingConfig(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Set log level at runtime
|
|
125
|
+
*/
|
|
126
|
+
declare function setLogLevel(level: LogLevel): void;
|
|
127
|
+
/**
|
|
128
|
+
* Enable or disable logging
|
|
129
|
+
*/
|
|
130
|
+
declare function setLoggingEnabled(enabled: boolean): void;
|
|
131
|
+
/**
|
|
132
|
+
* Create a logger for a specific module
|
|
133
|
+
*
|
|
134
|
+
* @param module - Module name (e.g., 'LocalInference', 'ModelCache')
|
|
135
|
+
* @returns Logger instance
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const logger = createLogger('LocalInference');
|
|
140
|
+
* logger.info('Model loaded', { backend: 'webgpu', loadTimeMs: 1234 });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
declare function createLogger(module: string): ILogger;
|
|
144
|
+
/**
|
|
145
|
+
* Clear logger cache (useful for testing)
|
|
146
|
+
*/
|
|
147
|
+
declare function clearLoggerCache(): void;
|
|
148
|
+
/**
|
|
149
|
+
* No-op logger for when logging is completely disabled
|
|
150
|
+
*/
|
|
151
|
+
declare const noopLogger: ILogger;
|
|
152
|
+
/**
|
|
153
|
+
* Get a no-op logger (for production builds that tree-shake logging)
|
|
154
|
+
*/
|
|
155
|
+
declare function getNoopLogger(): ILogger;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Abstract monotonic clock for runtime-agnostic timing.
|
|
159
|
+
*
|
|
160
|
+
* **Portability contract**: To port the SDK to Node.js, Python, Unreal, or Unity,
|
|
161
|
+
* implement this interface with your runtime's high-resolution timer and call
|
|
162
|
+
* `configureClock()` at startup.
|
|
163
|
+
*
|
|
164
|
+
* @example Node.js
|
|
165
|
+
* ```typescript
|
|
166
|
+
* import { configureClock } from '@omote/core';
|
|
167
|
+
* configureClock({
|
|
168
|
+
* now: () => Number(process.hrtime.bigint() / 1_000_000n),
|
|
169
|
+
* timestamp: () => Date.now(),
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @example Unreal Engine (via wasm-bindgen)
|
|
174
|
+
* ```typescript
|
|
175
|
+
* configureClock({
|
|
176
|
+
* now: () => FPlatformTime.Seconds() * 1000,
|
|
177
|
+
* timestamp: () => FDateTime.UtcNow().ToUnixTimestamp() * 1000,
|
|
178
|
+
* });
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @example Unity (via jslib bridge)
|
|
182
|
+
* ```typescript
|
|
183
|
+
* configureClock({
|
|
184
|
+
* now: () => Time.realtimeSinceStartup * 1000,
|
|
185
|
+
* timestamp: () => Date.now(),
|
|
186
|
+
* });
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
interface Clock {
|
|
190
|
+
/** Monotonic high-resolution milliseconds (for durations, telemetry spans) */
|
|
191
|
+
now(): number;
|
|
192
|
+
/** Wall-clock milliseconds since epoch (for log timestamps) */
|
|
193
|
+
timestamp(): number;
|
|
194
|
+
}
|
|
195
|
+
declare const defaultClock: Clock;
|
|
196
|
+
/** Replace the default browser clock with a custom implementation. */
|
|
197
|
+
declare function configureClock(clock: Clock): void;
|
|
198
|
+
/** Get the active clock instance. */
|
|
199
|
+
declare function getClock(): Clock;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Structured error codes for the Omote SDK.
|
|
203
|
+
*
|
|
204
|
+
* Codes follow the pattern `OMOTE_{CATEGORY}_{SEQ}` where:
|
|
205
|
+
* - **INF** = Inference (model loading, session, OOM)
|
|
206
|
+
* - **AUD** = Audio (AudioContext, scheduling, decoding)
|
|
207
|
+
* - **SPH** = Speech (VAD, ASR, microphone)
|
|
208
|
+
* - **TTS** = Text-to-Speech (synthesis, streaming, phonemizer)
|
|
209
|
+
* - **PIP** = Pipeline (state machine, abort)
|
|
210
|
+
* - **CAC** = Cache (IndexedDB quota, eviction, staleness)
|
|
211
|
+
* - **NET** = Network (fetch, timeout, WebSocket)
|
|
212
|
+
*
|
|
213
|
+
* Exported as a const object (not enum) for tree-shaking.
|
|
214
|
+
*/
|
|
215
|
+
declare const ErrorCodes: {
|
|
216
|
+
/** Model failed to load (file not found, corrupted, unsupported format) */
|
|
217
|
+
readonly INF_LOAD_FAILED: "OMOTE_INF_001";
|
|
218
|
+
/** ORT session poisoned after WebGPU device loss — must reload tab */
|
|
219
|
+
readonly INF_SESSION_POISON: "OMOTE_INF_002";
|
|
220
|
+
/** Inference exceeded timeout threshold */
|
|
221
|
+
readonly INF_TIMEOUT: "OMOTE_INF_003";
|
|
222
|
+
/** Out-of-memory during inference or model loading */
|
|
223
|
+
readonly INF_OOM: "OMOTE_INF_004";
|
|
224
|
+
/** WebGPU unavailable, fell back to WASM */
|
|
225
|
+
readonly INF_WEBGPU_FALLBACK: "OMOTE_INF_005";
|
|
226
|
+
/** Input tensor shape does not match model expectations */
|
|
227
|
+
readonly INF_SHAPE_MISMATCH: "OMOTE_INF_006";
|
|
228
|
+
/** AudioContext creation or resume failed */
|
|
229
|
+
readonly AUD_CONTEXT_FAILED: "OMOTE_AUD_001";
|
|
230
|
+
/** Gap detected in audio scheduling (buffer underrun) */
|
|
231
|
+
readonly AUD_SCHEDULE_GAP: "OMOTE_AUD_002";
|
|
232
|
+
/** Audio buffer decoding failed */
|
|
233
|
+
readonly AUD_DECODE_FAILED: "OMOTE_AUD_003";
|
|
234
|
+
/** Voice activity detection error */
|
|
235
|
+
readonly SPH_VAD_ERROR: "OMOTE_SPH_001";
|
|
236
|
+
/** Automatic speech recognition error */
|
|
237
|
+
readonly SPH_ASR_ERROR: "OMOTE_SPH_002";
|
|
238
|
+
/** Microphone access denied or unavailable */
|
|
239
|
+
readonly SPH_MIC_DENIED: "OMOTE_SPH_003";
|
|
240
|
+
/** TTS synthesis failed */
|
|
241
|
+
readonly TTS_SYNTH_FAILED: "OMOTE_TTS_001";
|
|
242
|
+
/** TTS streaming error (chunk delivery failure) */
|
|
243
|
+
readonly TTS_STREAM_ERROR: "OMOTE_TTS_002";
|
|
244
|
+
/** Phonemizer (eSpeak-NG WASM) ran out of memory */
|
|
245
|
+
readonly TTS_PHONEMIZER_OOM: "OMOTE_TTS_003";
|
|
246
|
+
/** Invalid state transition in pipeline state machine */
|
|
247
|
+
readonly PIP_STATE_ERROR: "OMOTE_PIP_001";
|
|
248
|
+
/** Pipeline operation aborted (user interrupt or signal) */
|
|
249
|
+
readonly PIP_ABORT: "OMOTE_PIP_002";
|
|
250
|
+
/** IndexedDB storage quota exceeded */
|
|
251
|
+
readonly CAC_QUOTA_EXCEEDED: "OMOTE_CAC_001";
|
|
252
|
+
/** Cache entry evicted (LRU or manual) */
|
|
253
|
+
readonly CAC_EVICTION: "OMOTE_CAC_002";
|
|
254
|
+
/** Cached model is stale (version mismatch) */
|
|
255
|
+
readonly CAC_STALE: "OMOTE_CAC_003";
|
|
256
|
+
/** HTTP fetch failed (model download, CDN) */
|
|
257
|
+
readonly NET_FETCH_FAILED: "OMOTE_NET_001";
|
|
258
|
+
/** Network request timed out */
|
|
259
|
+
readonly NET_TIMEOUT: "OMOTE_NET_002";
|
|
260
|
+
/** WebSocket connection error */
|
|
261
|
+
readonly NET_WEBSOCKET_ERROR: "OMOTE_NET_003";
|
|
262
|
+
};
|
|
263
|
+
/** Union type of all error code string values. */
|
|
264
|
+
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
265
|
+
|
|
266
|
+
export { type Clock as C, DEFAULT_LOGGING_CONFIG as D, type ErrorCode as E, type ILogger as I, type LogFormatter as L, ErrorCodes as a, LOG_LEVEL_PRIORITY as b, type LogEntry as c, type LogLevel as d, type LogSink as e, type LoggingConfig as f, clearLoggerCache as g, configureClock as h, configureLogging as i, createLogger as j, defaultClock as k, getClock as l, getLoggingConfig as m, getNoopLogger as n, noopLogger as o, setLoggingEnabled as p, resetLoggingConfig as r, setLogLevel as s };
|