@runanywhere/web 0.1.0-beta.3 → 0.1.0-beta.5
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/Foundation/StructOffsets.d.ts +34 -5
- package/dist/Foundation/StructOffsets.d.ts.map +1 -1
- package/dist/Foundation/StructOffsets.js +128 -93
- package/dist/Foundation/StructOffsets.js.map +1 -1
- package/dist/Infrastructure/ExtensionPoint.d.ts +78 -0
- package/dist/Infrastructure/ExtensionPoint.d.ts.map +1 -0
- package/dist/Infrastructure/ExtensionPoint.js +118 -0
- package/dist/Infrastructure/ExtensionPoint.js.map +1 -0
- package/dist/Infrastructure/LocalFileStorage.d.ts +116 -0
- package/dist/Infrastructure/LocalFileStorage.d.ts.map +1 -0
- package/dist/Infrastructure/LocalFileStorage.js +368 -0
- package/dist/Infrastructure/LocalFileStorage.js.map +1 -0
- package/dist/Infrastructure/ModelDownloader.d.ts +16 -5
- package/dist/Infrastructure/ModelDownloader.d.ts.map +1 -1
- package/dist/Infrastructure/ModelDownloader.js +54 -7
- package/dist/Infrastructure/ModelDownloader.js.map +1 -1
- package/dist/Infrastructure/ModelFileInference.d.ts +39 -0
- package/dist/Infrastructure/ModelFileInference.d.ts.map +1 -0
- package/dist/Infrastructure/ModelFileInference.js +110 -0
- package/dist/Infrastructure/ModelFileInference.js.map +1 -0
- package/dist/Infrastructure/ModelLoaderTypes.d.ts +76 -11
- package/dist/Infrastructure/ModelLoaderTypes.d.ts.map +1 -1
- package/dist/Infrastructure/ModelLoaderTypes.js +7 -1
- package/dist/Infrastructure/ModelLoaderTypes.js.map +1 -1
- package/dist/Infrastructure/ModelManager.d.ts +30 -104
- package/dist/Infrastructure/ModelManager.d.ts.map +1 -1
- package/dist/Infrastructure/ModelManager.js +209 -544
- package/dist/Infrastructure/ModelManager.js.map +1 -1
- package/dist/Infrastructure/ModelRegistry.d.ts +6 -0
- package/dist/Infrastructure/ModelRegistry.d.ts.map +1 -1
- package/dist/Infrastructure/ModelRegistry.js +11 -0
- package/dist/Infrastructure/ModelRegistry.js.map +1 -1
- package/dist/Public/Extensions/RunAnywhere+VoicePipeline.d.ts +3 -29
- package/dist/Public/Extensions/RunAnywhere+VoicePipeline.d.ts.map +1 -1
- package/dist/Public/Extensions/RunAnywhere+VoicePipeline.js +48 -44
- package/dist/Public/Extensions/RunAnywhere+VoicePipeline.js.map +1 -1
- package/dist/Public/Extensions/VoicePipelineTypes.d.ts +28 -37
- package/dist/Public/Extensions/VoicePipelineTypes.d.ts.map +1 -1
- package/dist/Public/Extensions/VoicePipelineTypes.js +4 -1
- package/dist/Public/Extensions/VoicePipelineTypes.js.map +1 -1
- package/dist/Public/RunAnywhere.d.ts +65 -61
- package/dist/Public/RunAnywhere.d.ts.map +1 -1
- package/dist/Public/RunAnywhere.js +193 -141
- package/dist/Public/RunAnywhere.js.map +1 -1
- package/dist/index.d.ts +23 -39
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -31
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -5
- package/wasm/racommons.js +91 -91
- package/wasm/racommons.wasm +0 -0
- package/dist/Foundation/SherpaONNXBridge.d.ts +0 -147
- package/dist/Foundation/SherpaONNXBridge.d.ts.map +0 -1
- package/dist/Foundation/SherpaONNXBridge.js +0 -345
- package/dist/Foundation/SherpaONNXBridge.js.map +0 -1
- package/dist/Infrastructure/AudioCapture.d.ts +0 -87
- package/dist/Infrastructure/AudioCapture.d.ts.map +0 -1
- package/dist/Infrastructure/AudioCapture.js +0 -231
- package/dist/Infrastructure/AudioCapture.js.map +0 -1
- package/dist/Infrastructure/AudioPlayback.d.ts +0 -53
- package/dist/Infrastructure/AudioPlayback.d.ts.map +0 -1
- package/dist/Infrastructure/AudioPlayback.js +0 -117
- package/dist/Infrastructure/AudioPlayback.js.map +0 -1
- package/dist/Infrastructure/VLMWorkerBridge.d.ts +0 -211
- package/dist/Infrastructure/VLMWorkerBridge.d.ts.map +0 -1
- package/dist/Infrastructure/VLMWorkerBridge.js +0 -264
- package/dist/Infrastructure/VLMWorkerBridge.js.map +0 -1
- package/dist/Infrastructure/VLMWorkerRuntime.d.ts +0 -38
- package/dist/Infrastructure/VLMWorkerRuntime.d.ts.map +0 -1
- package/dist/Infrastructure/VLMWorkerRuntime.js +0 -503
- package/dist/Infrastructure/VLMWorkerRuntime.js.map +0 -1
- package/dist/Infrastructure/VideoCapture.d.ts +0 -118
- package/dist/Infrastructure/VideoCapture.d.ts.map +0 -1
- package/dist/Infrastructure/VideoCapture.js +0 -207
- package/dist/Infrastructure/VideoCapture.js.map +0 -1
- package/dist/Public/Extensions/DiffusionTypes.d.ts +0 -64
- package/dist/Public/Extensions/DiffusionTypes.d.ts.map +0 -1
- package/dist/Public/Extensions/DiffusionTypes.js +0 -28
- package/dist/Public/Extensions/DiffusionTypes.js.map +0 -1
- package/dist/Public/Extensions/EmbeddingsTypes.d.ts +0 -33
- package/dist/Public/Extensions/EmbeddingsTypes.d.ts.map +0 -1
- package/dist/Public/Extensions/EmbeddingsTypes.js +0 -13
- package/dist/Public/Extensions/EmbeddingsTypes.js.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+Diffusion.d.ts +0 -44
- package/dist/Public/Extensions/RunAnywhere+Diffusion.d.ts.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+Diffusion.js +0 -189
- package/dist/Public/Extensions/RunAnywhere+Diffusion.js.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+Embeddings.d.ts +0 -56
- package/dist/Public/Extensions/RunAnywhere+Embeddings.d.ts.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+Embeddings.js +0 -240
- package/dist/Public/Extensions/RunAnywhere+Embeddings.js.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+STT.d.ts +0 -95
- package/dist/Public/Extensions/RunAnywhere+STT.d.ts.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+STT.js +0 -417
- package/dist/Public/Extensions/RunAnywhere+STT.js.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+StructuredOutput.d.ts +0 -69
- package/dist/Public/Extensions/RunAnywhere+StructuredOutput.d.ts.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+StructuredOutput.js +0 -196
- package/dist/Public/Extensions/RunAnywhere+StructuredOutput.js.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+TTS.d.ts +0 -55
- package/dist/Public/Extensions/RunAnywhere+TTS.d.ts.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+TTS.js +0 -253
- package/dist/Public/Extensions/RunAnywhere+TTS.js.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+TextGeneration.d.ts +0 -80
- package/dist/Public/Extensions/RunAnywhere+TextGeneration.d.ts.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+TextGeneration.js +0 -436
- package/dist/Public/Extensions/RunAnywhere+TextGeneration.js.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+ToolCalling.d.ts +0 -82
- package/dist/Public/Extensions/RunAnywhere+ToolCalling.d.ts.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+ToolCalling.js +0 -576
- package/dist/Public/Extensions/RunAnywhere+ToolCalling.js.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+VAD.d.ts +0 -70
- package/dist/Public/Extensions/RunAnywhere+VAD.d.ts.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+VAD.js +0 -231
- package/dist/Public/Extensions/RunAnywhere+VAD.js.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+VLM.d.ts +0 -58
- package/dist/Public/Extensions/RunAnywhere+VLM.d.ts.map +0 -1
- package/dist/Public/Extensions/RunAnywhere+VLM.js +0 -262
- package/dist/Public/Extensions/RunAnywhere+VLM.js.map +0 -1
- package/dist/Public/Extensions/STTTypes.d.ts +0 -53
- package/dist/Public/Extensions/STTTypes.d.ts.map +0 -1
- package/dist/Public/Extensions/STTTypes.js +0 -16
- package/dist/Public/Extensions/STTTypes.js.map +0 -1
- package/dist/Public/Extensions/TTSTypes.d.ts +0 -31
- package/dist/Public/Extensions/TTSTypes.d.ts.map +0 -1
- package/dist/Public/Extensions/TTSTypes.js +0 -3
- package/dist/Public/Extensions/TTSTypes.js.map +0 -1
- package/dist/Public/Extensions/ToolCallingTypes.d.ts +0 -78
- package/dist/Public/Extensions/ToolCallingTypes.d.ts.map +0 -1
- package/dist/Public/Extensions/ToolCallingTypes.js +0 -8
- package/dist/Public/Extensions/ToolCallingTypes.js.map +0 -1
- package/dist/Public/Extensions/VADTypes.d.ts +0 -30
- package/dist/Public/Extensions/VADTypes.d.ts.map +0 -1
- package/dist/Public/Extensions/VADTypes.js +0 -8
- package/dist/Public/Extensions/VADTypes.js.map +0 -1
- package/dist/Public/Extensions/VLMTypes.d.ts +0 -56
- package/dist/Public/Extensions/VLMTypes.d.ts.map +0 -1
- package/dist/Public/Extensions/VLMTypes.js +0 -24
- package/dist/Public/Extensions/VLMTypes.js.map +0 -1
- package/dist/types/LLMTypes.d.ts +0 -48
- package/dist/types/LLMTypes.d.ts.map +0 -1
- package/dist/types/LLMTypes.js +0 -8
- package/dist/types/LLMTypes.js.map +0 -1
- package/dist/workers/vlm-worker.d.ts +0 -9
- package/dist/workers/vlm-worker.d.ts.map +0 -1
- package/dist/workers/vlm-worker.js +0 -10
- package/dist/workers/vlm-worker.js.map +0 -1
- package/wasm/racommons-webgpu.js +0 -156
- package/wasm/racommons-webgpu.wasm +0 -0
- package/wasm/sherpa/sherpa-onnx-asr.js +0 -1538
- package/wasm/sherpa/sherpa-onnx-glue-original.js +0 -19
- package/wasm/sherpa/sherpa-onnx-glue.js +0 -17
- package/wasm/sherpa/sherpa-onnx-tts.js +0 -657
- package/wasm/sherpa/sherpa-onnx-vad.js +0 -337
- package/wasm/sherpa/sherpa-onnx-wave.js +0 -88
- package/wasm/sherpa/sherpa-onnx.wasm +0 -0
|
@@ -6,36 +6,32 @@
|
|
|
6
6
|
* - RunAnywhere.swift (iOS) - enum with static methods
|
|
7
7
|
* - RunAnywhere.kt (Kotlin) - object/class
|
|
8
8
|
* - RunAnywhere.ts (React Native) - object literal
|
|
9
|
-
* - RunAnywhere.dart (Flutter) - class
|
|
10
9
|
*
|
|
11
10
|
* All operations flow through the WASM bridge to RACommons C++.
|
|
11
|
+
* Backend packages (@runanywhere/web-llamacpp, @runanywhere/web-onnx)
|
|
12
|
+
* register themselves via the ExtensionPoint API.
|
|
12
13
|
*
|
|
13
14
|
* Usage:
|
|
14
15
|
* import { RunAnywhere } from '@runanywhere/web';
|
|
16
|
+
* import { LlamaCPP } from '@runanywhere/web-llamacpp';
|
|
17
|
+
* import { ONNX } from '@runanywhere/web-onnx';
|
|
15
18
|
*
|
|
16
19
|
* await RunAnywhere.initialize({ environment: 'development' });
|
|
17
|
-
*
|
|
20
|
+
* await LlamaCPP.register();
|
|
21
|
+
* await ONNX.register();
|
|
18
22
|
*/
|
|
19
23
|
import { SDKEnvironment, SDKEventType, AccelerationPreference } from '../types/enums';
|
|
20
24
|
import { SDKError, SDKErrorCode } from '../Foundation/ErrorTypes';
|
|
21
25
|
import { EventBus } from '../Foundation/EventBus';
|
|
22
26
|
import { SDKLogger, LogLevel } from '../Foundation/SDKLogger';
|
|
23
27
|
import { WASMBridge } from '../Foundation/WASMBridge';
|
|
24
|
-
import { SherpaONNXBridge } from '../Foundation/SherpaONNXBridge';
|
|
25
28
|
import { PlatformAdapter } from '../Foundation/PlatformAdapter';
|
|
26
29
|
import { loadOffsets } from '../Foundation/StructOffsets';
|
|
27
30
|
import { Offsets } from '../Foundation/StructOffsets';
|
|
28
31
|
import { ModelManager } from '../Infrastructure/ModelManager';
|
|
29
32
|
import { ExtensionRegistry } from '../Infrastructure/ExtensionRegistry';
|
|
30
|
-
|
|
31
|
-
import {
|
|
32
|
-
import { VLM } from './Extensions/RunAnywhere+VLM';
|
|
33
|
-
import { STT } from './Extensions/RunAnywhere+STT';
|
|
34
|
-
import { TTS } from './Extensions/RunAnywhere+TTS';
|
|
35
|
-
import { VAD } from './Extensions/RunAnywhere+VAD';
|
|
36
|
-
import { Embeddings } from './Extensions/RunAnywhere+Embeddings';
|
|
37
|
-
import { Diffusion } from './Extensions/RunAnywhere+Diffusion';
|
|
38
|
-
import { ToolCalling } from './Extensions/RunAnywhere+ToolCalling';
|
|
33
|
+
import { ExtensionPoint } from '../Infrastructure/ExtensionPoint';
|
|
34
|
+
import { LocalFileStorage } from '../Infrastructure/LocalFileStorage';
|
|
39
35
|
const logger = new SDKLogger('RunAnywhere');
|
|
40
36
|
// ---------------------------------------------------------------------------
|
|
41
37
|
// Internal State
|
|
@@ -44,8 +40,8 @@ let _isInitialized = false;
|
|
|
44
40
|
let _hasCompletedServicesInit = false;
|
|
45
41
|
let _platformAdapter = null;
|
|
46
42
|
let _initOptions = null;
|
|
47
|
-
/** Guard against concurrent initialize() calls */
|
|
48
43
|
let _initializingPromise = null;
|
|
44
|
+
let _localFileStorage = null;
|
|
49
45
|
// ---------------------------------------------------------------------------
|
|
50
46
|
// RunAnywhere Public API
|
|
51
47
|
// ---------------------------------------------------------------------------
|
|
@@ -53,31 +49,24 @@ export const RunAnywhere = {
|
|
|
53
49
|
// =========================================================================
|
|
54
50
|
// SDK State
|
|
55
51
|
// =========================================================================
|
|
56
|
-
/** Whether the SDK is initialized (Phase 1 complete) */
|
|
57
52
|
get isInitialized() {
|
|
58
53
|
return _isInitialized;
|
|
59
54
|
},
|
|
60
|
-
/** Whether services are fully ready (Phase 2 complete) */
|
|
61
55
|
get areServicesReady() {
|
|
62
56
|
return _hasCompletedServicesInit;
|
|
63
57
|
},
|
|
64
|
-
/** Current SDK version */
|
|
65
58
|
get version() {
|
|
66
59
|
return '0.1.0';
|
|
67
60
|
},
|
|
68
|
-
/** Current environment */
|
|
69
61
|
get environment() {
|
|
70
62
|
return _initOptions?.environment ?? null;
|
|
71
63
|
},
|
|
72
|
-
/** Access to the event bus */
|
|
73
64
|
get events() {
|
|
74
65
|
return EventBus.shared;
|
|
75
66
|
},
|
|
76
|
-
/** Whether the WASM module is loaded */
|
|
77
67
|
get isWASMLoaded() {
|
|
78
68
|
return WASMBridge.shared.isLoaded;
|
|
79
69
|
},
|
|
80
|
-
/** The active hardware acceleration mode ('webgpu' or 'cpu'). */
|
|
81
70
|
get accelerationMode() {
|
|
82
71
|
return WASMBridge.shared.accelerationMode;
|
|
83
72
|
},
|
|
@@ -93,29 +82,15 @@ export const RunAnywhere = {
|
|
|
93
82
|
* 3. Call rac_init() (same C function as iOS/Android)
|
|
94
83
|
* 4. Mark SDK as initialized
|
|
95
84
|
*
|
|
96
|
-
*
|
|
97
|
-
* @
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```typescript
|
|
101
|
-
* // Development mode (default)
|
|
102
|
-
* await RunAnywhere.initialize();
|
|
103
|
-
*
|
|
104
|
-
* // Production mode
|
|
105
|
-
* await RunAnywhere.initialize({
|
|
106
|
-
* apiKey: 'your-key',
|
|
107
|
-
* baseURL: 'https://api.runanywhere.ai',
|
|
108
|
-
* environment: 'production',
|
|
109
|
-
* });
|
|
110
|
-
* ```
|
|
85
|
+
* After initialization, register backend packages:
|
|
86
|
+
* await LlamaCPP.register(); // @runanywhere/web-llamacpp
|
|
87
|
+
* await ONNX.register(); // @runanywhere/web-onnx
|
|
111
88
|
*/
|
|
112
89
|
async initialize(options = {}, wasmUrl) {
|
|
113
|
-
// Guard: already done
|
|
114
90
|
if (_isInitialized) {
|
|
115
91
|
logger.debug('Already initialized');
|
|
116
92
|
return;
|
|
117
93
|
}
|
|
118
|
-
// Guard: another call is already in flight – wait for it instead of racing
|
|
119
94
|
if (_initializingPromise) {
|
|
120
95
|
logger.debug('Initialization already in progress, awaiting...');
|
|
121
96
|
return _initializingPromise;
|
|
@@ -124,75 +99,41 @@ export const RunAnywhere = {
|
|
|
124
99
|
try {
|
|
125
100
|
const env = options.environment ?? SDKEnvironment.Development;
|
|
126
101
|
_initOptions = { ...options, environment: env };
|
|
127
|
-
// Configure logging
|
|
128
102
|
if (options.debug) {
|
|
129
103
|
SDKLogger.level = LogLevel.Debug;
|
|
130
104
|
}
|
|
131
105
|
logger.info(`Initializing RunAnywhere Web SDK (${env})...`);
|
|
132
|
-
// Phase 1: Load WASM module
|
|
106
|
+
// Phase 1: Load WASM module
|
|
133
107
|
const bridge = WASMBridge.shared;
|
|
134
108
|
const acceleration = options.acceleration ?? AccelerationPreference.Auto;
|
|
135
109
|
await bridge.load(wasmUrl, options.webgpuWasmUrl, acceleration);
|
|
136
110
|
logger.info(`Hardware acceleration: ${bridge.accelerationMode}`);
|
|
137
|
-
// Emit acceleration mode event so app UIs can show a badge
|
|
138
111
|
EventBus.shared.emit('sdk.accelerationMode', SDKEventType.Device, {
|
|
139
112
|
mode: bridge.accelerationMode,
|
|
140
113
|
});
|
|
141
|
-
// Phase
|
|
142
|
-
// This must happen before any struct read/write in the SDK.
|
|
114
|
+
// Phase 2: Load core struct offsets
|
|
143
115
|
loadOffsets(bridge.module);
|
|
144
|
-
// Phase
|
|
116
|
+
// Phase 3: Register platform adapter
|
|
145
117
|
_platformAdapter = new PlatformAdapter();
|
|
146
118
|
_platformAdapter.register();
|
|
147
|
-
// Phase
|
|
119
|
+
// Phase 4: Initialize RACommons core
|
|
148
120
|
const m = bridge.module;
|
|
149
|
-
// Create rac_config_t in WASM memory
|
|
150
121
|
const configSize = m._rac_wasm_sizeof_config();
|
|
151
122
|
const configPtr = m._malloc(configSize);
|
|
152
|
-
// Zero-initialize
|
|
153
123
|
for (let i = 0; i < configSize; i++) {
|
|
154
124
|
m.setValue(configPtr + i, 0, 'i8');
|
|
155
125
|
}
|
|
156
|
-
// Set platform_adapter pointer (offset 0) -- always first field
|
|
157
126
|
m.setValue(configPtr, _platformAdapter.getAdapterPtr(), '*');
|
|
158
|
-
|
|
159
|
-
const logLevel = options.debug ? 1 : 2; // DEBUG=1, INFO=2
|
|
127
|
+
const logLevel = options.debug ? 1 : 2;
|
|
160
128
|
m.setValue(configPtr + Offsets.config.logLevel, logLevel, 'i32');
|
|
161
|
-
// {async: true} lets JSPI suspend during WebGPU adapter/device init.
|
|
162
129
|
const result = await bridge.callFunction('rac_init', 'number', ['number'], [configPtr], { async: true });
|
|
163
130
|
m._free(configPtr);
|
|
164
131
|
if (result !== 0) {
|
|
165
132
|
const errMsg = bridge.getErrorMessage(result);
|
|
166
133
|
throw new SDKError(SDKErrorCode.InitializationFailed, `rac_init failed: ${errMsg}`);
|
|
167
134
|
}
|
|
168
|
-
// Phase
|
|
169
|
-
//
|
|
170
|
-
// Check if the function exists (only present when built with --llamacpp).
|
|
171
|
-
if (typeof m['_rac_backend_llamacpp_register'] === 'function') {
|
|
172
|
-
const regResult = await bridge.callFunction('rac_backend_llamacpp_register', 'number', [], [], { async: true });
|
|
173
|
-
if (regResult === 0) {
|
|
174
|
-
logger.info('llama.cpp LLM backend registered');
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
logger.warning(`llama.cpp backend registration returned: ${regResult}`);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
// Phase 5: Register model loaders with ModelManager.
|
|
181
|
-
// This keeps the dependency flow correct: Public -> Infrastructure.
|
|
182
|
-
ModelManager.setLLMLoader(TextGeneration);
|
|
183
|
-
ModelManager.setSTTLoader(STT);
|
|
184
|
-
ModelManager.setTTSLoader(TTS);
|
|
185
|
-
ModelManager.setVADLoader(VAD);
|
|
186
|
-
// Phase 6: Register extensions with the lifecycle registry.
|
|
187
|
-
// Order matters: low-level components first (cleaned up last).
|
|
188
|
-
ExtensionRegistry.register(TextGeneration);
|
|
189
|
-
ExtensionRegistry.register(STT);
|
|
190
|
-
ExtensionRegistry.register(TTS);
|
|
191
|
-
ExtensionRegistry.register(VAD);
|
|
192
|
-
ExtensionRegistry.register(VLM);
|
|
193
|
-
ExtensionRegistry.register(Embeddings);
|
|
194
|
-
ExtensionRegistry.register(Diffusion);
|
|
195
|
-
ExtensionRegistry.register(ToolCalling);
|
|
135
|
+
// Phase 5: SDK ready — backend packages register themselves
|
|
136
|
+
// via LlamaCPP.register() / ONNX.register() after this returns.
|
|
196
137
|
_isInitialized = true;
|
|
197
138
|
_hasCompletedServicesInit = true;
|
|
198
139
|
logger.info('RunAnywhere Web SDK initialized successfully');
|
|
@@ -208,123 +149,234 @@ export const RunAnywhere = {
|
|
|
208
149
|
return _initializingPromise;
|
|
209
150
|
},
|
|
210
151
|
// =========================================================================
|
|
211
|
-
// Model Management
|
|
152
|
+
// Model Management
|
|
212
153
|
// =========================================================================
|
|
213
|
-
/**
|
|
214
|
-
* Register a catalog of models for download and loading.
|
|
215
|
-
* @param models - Compact model definitions to register
|
|
216
|
-
*/
|
|
217
154
|
registerModels(models) {
|
|
218
155
|
ModelManager.registerModels(models);
|
|
219
156
|
},
|
|
220
|
-
/**
|
|
221
|
-
* Set the VLM (vision-language model) loader implementation.
|
|
222
|
-
* The app provides an implementation (typically backed by a Web Worker).
|
|
223
|
-
*/
|
|
224
157
|
setVLMLoader(loader) {
|
|
225
158
|
ModelManager.setVLMLoader(loader);
|
|
226
159
|
},
|
|
227
|
-
/**
|
|
228
|
-
* Download a model (and any companion files) to persistent OPFS storage.
|
|
229
|
-
* @param modelId - The model ID to download
|
|
230
|
-
*/
|
|
231
160
|
async downloadModel(modelId) {
|
|
232
161
|
return ModelManager.downloadModel(modelId);
|
|
233
162
|
},
|
|
234
|
-
/**
|
|
235
|
-
* Load a downloaded model into the inference engine.
|
|
236
|
-
* @param modelId - The model ID to load
|
|
237
|
-
* @returns true if loaded successfully
|
|
238
|
-
*/
|
|
239
163
|
async loadModel(modelId) {
|
|
240
164
|
return ModelManager.loadModel(modelId);
|
|
241
165
|
},
|
|
242
|
-
/**
|
|
243
|
-
* Get all registered models with their current status.
|
|
244
|
-
*/
|
|
245
166
|
availableModels() {
|
|
246
167
|
return ModelManager.getModels();
|
|
247
168
|
},
|
|
248
|
-
/**
|
|
249
|
-
* Get the currently loaded model for a given category.
|
|
250
|
-
* @param category - Optional model category filter
|
|
251
|
-
*/
|
|
252
169
|
getLoadedModel(category) {
|
|
253
170
|
return ModelManager.getLoadedModel(category);
|
|
254
171
|
},
|
|
172
|
+
async unloadAll() {
|
|
173
|
+
return ModelManager.unloadAll();
|
|
174
|
+
},
|
|
175
|
+
async deleteModel(modelId) {
|
|
176
|
+
return ModelManager.deleteModel(modelId);
|
|
177
|
+
},
|
|
178
|
+
// =========================================================================
|
|
179
|
+
// Model Import (file picker / drag-and-drop)
|
|
180
|
+
// =========================================================================
|
|
255
181
|
/**
|
|
256
|
-
*
|
|
182
|
+
* Open a file picker to import a model file.
|
|
183
|
+
*
|
|
184
|
+
* Progressive enhancement:
|
|
185
|
+
* - Chrome/Edge: Uses showOpenFilePicker() (modern File System Access API)
|
|
186
|
+
* - Safari/Firefox/mobile: Falls back to hidden <input type="file">
|
|
257
187
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
188
|
+
* Works on ALL browsers and platforms (desktop + mobile).
|
|
189
|
+
*
|
|
190
|
+
* @param options.modelId - Optional: associate with an existing registered model
|
|
191
|
+
* @param options.accept - File extensions to accept (default: .gguf, .onnx, .bin)
|
|
192
|
+
* @returns The model ID, or null if the user cancelled
|
|
261
193
|
*/
|
|
262
|
-
async
|
|
263
|
-
|
|
194
|
+
async importModelFromPicker(options) {
|
|
195
|
+
const acceptExts = options?.accept ?? ['.gguf', '.onnx', '.bin'];
|
|
196
|
+
// Try modern File System Access API (Chrome/Edge desktop + Android 144+)
|
|
197
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
198
|
+
if ('showOpenFilePicker' in window) {
|
|
199
|
+
try {
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
201
|
+
const [handle] = await window.showOpenFilePicker({
|
|
202
|
+
types: [{
|
|
203
|
+
description: 'AI Model Files',
|
|
204
|
+
accept: { 'application/octet-stream': acceptExts },
|
|
205
|
+
}],
|
|
206
|
+
multiple: false,
|
|
207
|
+
});
|
|
208
|
+
const file = await handle.getFile();
|
|
209
|
+
return this.importModelFromFile(file, options);
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
if (err instanceof Error && err.name === 'AbortError')
|
|
213
|
+
return null;
|
|
214
|
+
// Fall through to <input> fallback
|
|
215
|
+
logger.debug('showOpenFilePicker failed, using input fallback');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Fallback: hidden <input type="file"> (Safari, Firefox, iOS, all mobile)
|
|
219
|
+
return new Promise((resolve) => {
|
|
220
|
+
const input = document.createElement('input');
|
|
221
|
+
input.type = 'file';
|
|
222
|
+
input.accept = acceptExts.join(',');
|
|
223
|
+
input.style.display = 'none';
|
|
224
|
+
input.onchange = async () => {
|
|
225
|
+
const file = input.files?.[0];
|
|
226
|
+
document.body.removeChild(input);
|
|
227
|
+
if (!file) {
|
|
228
|
+
resolve(null);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
const id = await this.importModelFromFile(file, options);
|
|
233
|
+
resolve(id);
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
236
|
+
logger.error(`Import failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
237
|
+
resolve(null);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
// Handle cancel (input doesn't fire change on cancel in all browsers)
|
|
241
|
+
input.addEventListener('cancel', () => {
|
|
242
|
+
document.body.removeChild(input);
|
|
243
|
+
resolve(null);
|
|
244
|
+
});
|
|
245
|
+
document.body.appendChild(input);
|
|
246
|
+
input.click();
|
|
247
|
+
});
|
|
264
248
|
},
|
|
265
249
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
250
|
+
* Import a model from a File object.
|
|
251
|
+
*
|
|
252
|
+
* Use this for drag-and-drop, programmatic imports, or any case where
|
|
253
|
+
* you already have a File/Blob reference.
|
|
254
|
+
*
|
|
255
|
+
* Works on ALL browsers and platforms.
|
|
256
|
+
*
|
|
257
|
+
* @param file - The File object to import
|
|
258
|
+
* @param options.modelId - Optional: associate with an existing registered model
|
|
259
|
+
* @returns The model ID (existing or auto-generated from filename)
|
|
268
260
|
*/
|
|
269
|
-
async
|
|
270
|
-
|
|
261
|
+
async importModelFromFile(file, options) {
|
|
262
|
+
logger.info(`Importing model from file: ${file.name} (${(file.size / 1024 / 1024).toFixed(1)} MB)`);
|
|
263
|
+
return ModelManager.importModel(file, options?.modelId);
|
|
271
264
|
},
|
|
272
265
|
// =========================================================================
|
|
273
|
-
//
|
|
266
|
+
// Local File Storage (persistent model storage)
|
|
274
267
|
// =========================================================================
|
|
268
|
+
/** Whether the File System Access API is available in this browser. */
|
|
269
|
+
get isLocalStorageSupported() {
|
|
270
|
+
return LocalFileStorage.isSupported;
|
|
271
|
+
},
|
|
272
|
+
/** Whether a local storage directory is currently configured and authorized. */
|
|
273
|
+
get isLocalStorageReady() {
|
|
274
|
+
return _localFileStorage?.isReady ?? false;
|
|
275
|
+
},
|
|
276
|
+
/** Whether a directory handle exists in IndexedDB (may need re-authorization). */
|
|
277
|
+
get hasLocalStorageHandle() {
|
|
278
|
+
return _localFileStorage?.hasStoredHandle ?? false;
|
|
279
|
+
},
|
|
280
|
+
/** The name of the currently configured local storage directory (for UI display). */
|
|
281
|
+
get localStorageDirectoryName() {
|
|
282
|
+
return _localFileStorage?.directoryName ?? null;
|
|
283
|
+
},
|
|
275
284
|
/**
|
|
276
|
-
*
|
|
285
|
+
* Prompt the user to choose a local directory for model storage.
|
|
286
|
+
* Opens the OS folder picker dialog.
|
|
287
|
+
* Must be called from a user gesture (button click).
|
|
277
288
|
*
|
|
278
|
-
*
|
|
279
|
-
* higher-level components (e.g. VoiceAgent pipeline) are torn
|
|
280
|
-
* down before the lower-level ones they depend on.
|
|
289
|
+
* @returns true if a directory was selected
|
|
281
290
|
*/
|
|
291
|
+
async chooseLocalStorageDirectory() {
|
|
292
|
+
if (!LocalFileStorage.isSupported) {
|
|
293
|
+
logger.warning('File System Access API not supported — using browser storage (OPFS)');
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
if (!_localFileStorage) {
|
|
297
|
+
_localFileStorage = new LocalFileStorage();
|
|
298
|
+
}
|
|
299
|
+
const success = await _localFileStorage.chooseDirectory();
|
|
300
|
+
if (success) {
|
|
301
|
+
ModelManager.setLocalFileStorage(_localFileStorage);
|
|
302
|
+
EventBus.shared.emit('storage.localDirectorySelected', SDKEventType.Storage, {
|
|
303
|
+
directoryName: _localFileStorage.directoryName,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
return success;
|
|
307
|
+
},
|
|
308
|
+
/**
|
|
309
|
+
* Attempt to restore a previously chosen local storage directory.
|
|
310
|
+
* Call on app startup — if permission is still granted (Chrome 122+),
|
|
311
|
+
* models will be loaded from the local filesystem automatically.
|
|
312
|
+
*
|
|
313
|
+
* @returns true if directory was restored and permission is granted
|
|
314
|
+
*/
|
|
315
|
+
async restoreLocalStorage() {
|
|
316
|
+
if (!LocalFileStorage.isSupported)
|
|
317
|
+
return false;
|
|
318
|
+
if (!_localFileStorage) {
|
|
319
|
+
_localFileStorage = new LocalFileStorage();
|
|
320
|
+
}
|
|
321
|
+
const success = await _localFileStorage.restoreDirectory();
|
|
322
|
+
if (success) {
|
|
323
|
+
ModelManager.setLocalFileStorage(_localFileStorage);
|
|
324
|
+
logger.info(`Local storage restored: ${_localFileStorage.directoryName}`);
|
|
325
|
+
}
|
|
326
|
+
return success;
|
|
327
|
+
},
|
|
328
|
+
/**
|
|
329
|
+
* Request re-authorization for a previously chosen directory.
|
|
330
|
+
* Must be called from a user gesture (button click).
|
|
331
|
+
* Use when `hasLocalStorageHandle` is true but `isLocalStorageReady` is false.
|
|
332
|
+
*
|
|
333
|
+
* @returns true if permission was granted
|
|
334
|
+
*/
|
|
335
|
+
async requestLocalStorageAccess() {
|
|
336
|
+
if (!_localFileStorage)
|
|
337
|
+
return false;
|
|
338
|
+
const success = await _localFileStorage.requestAccess();
|
|
339
|
+
if (success) {
|
|
340
|
+
ModelManager.setLocalFileStorage(_localFileStorage);
|
|
341
|
+
}
|
|
342
|
+
return success;
|
|
343
|
+
},
|
|
344
|
+
// =========================================================================
|
|
345
|
+
// Shutdown
|
|
346
|
+
// =========================================================================
|
|
282
347
|
shutdown() {
|
|
283
348
|
logger.info('Shutting down RunAnywhere Web SDK...');
|
|
284
|
-
//
|
|
285
|
-
// 1. Clean up all registered extensions in reverse dependency order.
|
|
286
|
-
// Extensions were registered low-level first, so reverse cleanup
|
|
287
|
-
// tears down high-level orchestrations before their dependencies.
|
|
288
|
-
// ------------------------------------------------------------------
|
|
349
|
+
// 1. Clean up all registered extensions (reverse dependency order)
|
|
289
350
|
ExtensionRegistry.cleanupAll();
|
|
290
|
-
//
|
|
291
|
-
|
|
292
|
-
//
|
|
293
|
-
// SherpaONNXBridge (STT/TTS/VAD WASM module)
|
|
294
|
-
try {
|
|
295
|
-
SherpaONNXBridge.shared.shutdown();
|
|
296
|
-
}
|
|
297
|
-
catch { /* ignore during shutdown */ }
|
|
298
|
-
// Platform adapter
|
|
351
|
+
// 2. Clean up all registered backends (includes sherpa-onnx shutdown)
|
|
352
|
+
ExtensionPoint.cleanupAll();
|
|
353
|
+
// 3. Platform adapter
|
|
299
354
|
if (_platformAdapter) {
|
|
300
355
|
try {
|
|
301
356
|
_platformAdapter.cleanup();
|
|
302
357
|
}
|
|
303
|
-
catch { /* ignore
|
|
358
|
+
catch { /* ignore */ }
|
|
304
359
|
_platformAdapter = null;
|
|
305
360
|
}
|
|
306
|
-
// RACommons WASM bridge
|
|
361
|
+
// 4. RACommons WASM bridge
|
|
307
362
|
try {
|
|
308
363
|
WASMBridge.shared.shutdown();
|
|
309
364
|
}
|
|
310
|
-
catch { /* ignore
|
|
311
|
-
//
|
|
312
|
-
// 3. Reset SDK state
|
|
313
|
-
// ------------------------------------------------------------------
|
|
365
|
+
catch { /* ignore */ }
|
|
366
|
+
// 5. Reset state
|
|
314
367
|
EventBus.reset();
|
|
315
368
|
ExtensionRegistry.reset();
|
|
369
|
+
ExtensionPoint.reset();
|
|
316
370
|
_isInitialized = false;
|
|
317
371
|
_hasCompletedServicesInit = false;
|
|
318
372
|
_initOptions = null;
|
|
319
373
|
_initializingPromise = null;
|
|
374
|
+
_localFileStorage = null;
|
|
320
375
|
logger.info('RunAnywhere Web SDK shut down');
|
|
321
376
|
},
|
|
322
377
|
// =========================================================================
|
|
323
378
|
// Reset (testing)
|
|
324
379
|
// =========================================================================
|
|
325
|
-
/**
|
|
326
|
-
* Reset SDK state (for testing purposes).
|
|
327
|
-
*/
|
|
328
380
|
reset() {
|
|
329
381
|
RunAnywhere.shutdown();
|
|
330
382
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunAnywhere.js","sourceRoot":"","sources":["../../src/Public/RunAnywhere.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"RunAnywhere.js","sourceRoot":"","sources":["../../src/Public/RunAnywhere.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAiB,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAErG,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,OAAO,EAAE,iBAAi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BAAyB,GAAG,KAAK,CAAC;QAClC,YAAY,GAAG,IAAI,CAAC;QACpB,oBAAoB,GAAG,IAAI,CAAC;QAC5B,iBAAiB,GAAG,IAAI,CAAC;QAEzB,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IAC/C,CAAC;IAED,4EAA4E;IAC5E,kBAAkB;IAClB,4EAA4E;IAE5E,KAAK;QACH,WAAW,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,70 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* RunAnywhere Web SDK
|
|
2
|
+
* RunAnywhere Web SDK - Core Package
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Foundation, infrastructure, and orchestration for on-device AI
|
|
5
|
+
* inference in the browser via RACommons WebAssembly.
|
|
6
|
+
*
|
|
7
|
+
* Backend packages provide the actual inference capabilities:
|
|
8
|
+
* - @runanywhere/web-llamacpp — LLM, VLM, embeddings, diffusion
|
|
9
|
+
* - @runanywhere/web-onnx — STT, TTS, VAD
|
|
5
10
|
*
|
|
6
11
|
* @packageDocumentation
|
|
7
12
|
*
|
|
8
13
|
* @example
|
|
9
14
|
* ```typescript
|
|
10
15
|
* import { RunAnywhere } from '@runanywhere/web';
|
|
16
|
+
* import { LlamaCPP } from '@runanywhere/web-llamacpp';
|
|
17
|
+
* import { ONNX } from '@runanywhere/web-onnx';
|
|
11
18
|
*
|
|
12
|
-
* // Initialize
|
|
13
19
|
* await RunAnywhere.initialize({ environment: 'development' });
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* console.log('WebGPU:', RunAnywhere.isWASMLoaded);
|
|
17
|
-
*
|
|
18
|
-
* // Future: Generate text
|
|
19
|
-
* // const result = await RunAnywhere.generate('Hello!', { maxTokens: 100 });
|
|
20
|
+
* await LlamaCPP.register();
|
|
21
|
+
* await ONNX.register();
|
|
20
22
|
* ```
|
|
21
23
|
*/
|
|
22
24
|
export { RunAnywhere } from './Public/RunAnywhere';
|
|
23
|
-
export { TextGeneration } from './Public/Extensions/RunAnywhere+TextGeneration';
|
|
24
|
-
export { STT, STTModelType } from './Public/Extensions/RunAnywhere+STT';
|
|
25
|
-
export type { STTModelConfig, STTWhisperFiles, STTZipformerFiles, STTParaformerFiles, STTTranscriptionResult, STTWord, STTTranscribeOptions, STTStreamCallback, STTStreamingSession, } from './Public/Extensions/RunAnywhere+STT';
|
|
26
|
-
export { TTS } from './Public/Extensions/RunAnywhere+TTS';
|
|
27
|
-
export type { TTSVoiceConfig, TTSSynthesisResult, TTSSynthesizeOptions } from './Public/Extensions/RunAnywhere+TTS';
|
|
28
|
-
export { VAD, SpeechActivity } from './Public/Extensions/RunAnywhere+VAD';
|
|
29
|
-
export type { SpeechActivityCallback, VADModelConfig, SpeechSegment } from './Public/Extensions/RunAnywhere+VAD';
|
|
30
25
|
export { VoiceAgent, VoiceAgentSession, PipelineState } from './Public/Extensions/RunAnywhere+VoiceAgent';
|
|
31
26
|
export type { VoiceAgentModels, VoiceTurnResult, VoiceAgentEventData, VoiceAgentEventCallback } from './Public/Extensions/RunAnywhere+VoiceAgent';
|
|
32
27
|
export { VoicePipeline } from './Public/Extensions/RunAnywhere+VoicePipeline';
|
|
33
28
|
export type { VoicePipelineCallbacks, VoicePipelineOptions, VoicePipelineTurnResult } from './Public/Extensions/VoicePipelineTypes';
|
|
34
|
-
export { VLM, VLMImageFormat, VLMModelFamily } from './Public/Extensions/RunAnywhere+VLM';
|
|
35
|
-
export type { VLMImage, VLMGenerationOptions, VLMGenerationResult, VLMStreamingResult } from './Public/Extensions/RunAnywhere+VLM';
|
|
36
|
-
export { ToolCalling, ToolCallFormat, toToolValue, fromToolValue, getStringArg, getNumberArg } from './Public/Extensions/RunAnywhere+ToolCalling';
|
|
37
|
-
export type { ToolValue, ToolParameterType, ToolParameter, ToolDefinition, ToolCall, ToolResult, ToolCallingOptions, ToolCallingResult, ToolExecutor, } from './Public/Extensions/RunAnywhere+ToolCalling';
|
|
38
|
-
export { StructuredOutput } from './Public/Extensions/RunAnywhere+StructuredOutput';
|
|
39
|
-
export type { StructuredOutputConfig, StructuredOutputValidation } from './Public/Extensions/RunAnywhere+StructuredOutput';
|
|
40
|
-
export { Diffusion } from './Public/Extensions/RunAnywhere+Diffusion';
|
|
41
|
-
export { DiffusionScheduler, DiffusionModelVariant, DiffusionMode } from './Public/Extensions/RunAnywhere+Diffusion';
|
|
42
|
-
export type { DiffusionGenerationOptions, DiffusionGenerationResult, DiffusionProgressCallback } from './Public/Extensions/RunAnywhere+Diffusion';
|
|
43
|
-
export { Embeddings } from './Public/Extensions/RunAnywhere+Embeddings';
|
|
44
|
-
export { EmbeddingsNormalize, EmbeddingsPooling } from './Public/Extensions/RunAnywhere+Embeddings';
|
|
45
|
-
export type { EmbeddingVector, EmbeddingsResult, EmbeddingsOptions } from './Public/Extensions/RunAnywhere+Embeddings';
|
|
46
29
|
export * from './types';
|
|
47
30
|
export { SDKError, SDKErrorCode } from './Foundation/ErrorTypes';
|
|
48
31
|
export { SDKLogger, LogLevel } from './Foundation/SDKLogger';
|
|
49
32
|
export { EventBus } from './Foundation/EventBus';
|
|
50
33
|
export type { EventListener, Unsubscribe, SDKEventEnvelope } from './Foundation/EventBus';
|
|
34
|
+
export { WASMBridge } from './Foundation/WASMBridge';
|
|
51
35
|
export type { AccelerationMode } from './Foundation/WASMBridge';
|
|
52
|
-
export {
|
|
36
|
+
export { Offsets, loadOffsets, mergeOffsets, loadOffsetsFromModule, loadLlamaCppOffsetsInto, wasmOffsetOf, wasmSizeOf } from './Foundation/StructOffsets';
|
|
37
|
+
export type { ConfigOffsets, LLMOptionsOffsets, LLMResultOffsets, VLMImageOffsets, VLMOptionsOffsets, VLMResultOffsets, StructuredOutputConfigOffsets, StructuredOutputValidationOffsets, EmbeddingsOptionsOffsets, EmbeddingsResultOffsets, EmbeddingVectorOffsets, DiffusionOptionsOffsets, DiffusionResultOffsets, AllOffsets, } from './Foundation/StructOffsets';
|
|
53
38
|
export { detectCapabilities, getDeviceInfo } from './Infrastructure/DeviceCapabilities';
|
|
54
39
|
export type { WebCapabilities } from './Infrastructure/DeviceCapabilities';
|
|
55
|
-
export { AudioCapture } from './Infrastructure/AudioCapture';
|
|
56
|
-
export type { AudioChunkCallback, AudioLevelCallback, AudioCaptureConfig } from './Infrastructure/AudioCapture';
|
|
57
|
-
export { VideoCapture } from './Infrastructure/VideoCapture';
|
|
58
|
-
export type { VideoCaptureConfig, CapturedFrame } from './Infrastructure/VideoCapture';
|
|
59
|
-
export { AudioPlayback } from './Infrastructure/AudioPlayback';
|
|
60
|
-
export type { PlaybackCompleteCallback, PlaybackConfig } from './Infrastructure/AudioPlayback';
|
|
61
|
-
/** @advanced — Most consumers should use `RunAnywhere.downloadModel / loadModel / registerModels` instead. */
|
|
62
40
|
export { ModelManager } from './Infrastructure/ModelManager';
|
|
63
41
|
export type { ManagedModel, CompactModelDef, DownloadProgress, ModelFileDescriptor, ArtifactType, VLMLoader, VLMLoadParams, } from './Infrastructure/ModelManager';
|
|
64
42
|
export type { QuotaCheckResult, EvictionCandidateInfo } from './Infrastructure/ModelDownloader';
|
|
65
43
|
export { OPFSStorage } from './Infrastructure/OPFSStorage';
|
|
66
44
|
export type { StoredModelInfo, MetadataMap, ModelMetadata } from './Infrastructure/OPFSStorage';
|
|
67
|
-
export {
|
|
68
|
-
export type {
|
|
69
|
-
export {
|
|
45
|
+
export { ExtensionRegistry } from './Infrastructure/ExtensionRegistry';
|
|
46
|
+
export type { SDKExtension } from './Infrastructure/ExtensionRegistry';
|
|
47
|
+
export { ExtensionPoint, BackendCapability } from './Infrastructure/ExtensionPoint';
|
|
48
|
+
export type { BackendExtension } from './Infrastructure/ExtensionPoint';
|
|
49
|
+
export type { ModelLoadContext, LLMModelLoader, STTModelLoader, TTSModelLoader, VADModelLoader } from './Infrastructure/ModelLoaderTypes';
|
|
50
|
+
export { extractTarGz } from './Infrastructure/ArchiveUtility';
|
|
51
|
+
export { LocalFileStorage } from './Infrastructure/LocalFileStorage';
|
|
52
|
+
export { inferModelFromFilename, sanitizeId } from './Infrastructure/ModelFileInference';
|
|
53
|
+
export type { InferredModelMeta } from './Infrastructure/ModelFileInference';
|
|
70
54
|
//# sourceMappingURL=index.d.ts.map
|