@qvac/sdk 0.6.1 → 0.7.0
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 +1 -24
- package/NOTICE +632 -0
- package/README.md +2 -1
- package/dist/client/api/embed.js +1 -4
- package/dist/client/api/get-model-info.d.ts +10 -3
- package/dist/client/api/index.d.ts +2 -0
- package/dist/client/api/index.js +2 -0
- package/dist/client/api/invoke-plugin.d.ts +14 -0
- package/dist/client/api/invoke-plugin.js +38 -0
- package/dist/client/api/registry.d.ts +14 -0
- package/dist/client/api/registry.js +37 -0
- package/dist/client/api/transcribe.js +0 -4
- package/dist/client/api/unload-model.js +1 -1
- package/dist/client/config-loader/resolve-config.node.d.ts +3 -2
- package/dist/client/config-loader/resolve-config.node.js +31 -4
- package/dist/client/init-hooks.js +2 -1
- package/dist/client/rpc/bare-client.d.ts +2 -0
- package/dist/client/rpc/bare-client.js +48 -7
- package/dist/client/rpc/expo-device-info.d.ts +6 -0
- package/dist/client/rpc/expo-device-info.js +32 -0
- package/dist/client/rpc/expo-rpc-client.js +9 -32
- package/dist/client/rpc/node-rpc-client.d.ts +1 -1
- package/dist/client/rpc/node-rpc-client.js +201 -28
- package/dist/client/rpc/rpc-client.d.ts +1 -1
- package/dist/client/rpc/rpc-client.js +2 -2
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/registry.d.ts +2 -0
- package/dist/constants/registry.js +1 -0
- package/dist/examples/cache-management.js +2 -2
- package/dist/examples/config/plugins/plugins.config.d.ts +5 -0
- package/dist/examples/config/plugins/plugins.config.js +4 -0
- package/dist/examples/download-with-blind-relays.js +1 -1
- package/dist/examples/llamacpp-multimodal.js +3 -3
- package/dist/examples/llamacpp-native-tools.js +2 -2
- package/dist/examples/mcp-websearch.js +2 -2
- package/dist/examples/multi-model-demo.js +2 -2
- package/dist/examples/ocr-fasttext.js +4 -4
- package/dist/examples/parallel-download.js +2 -2
- package/dist/examples/plugins.d.ts +14 -0
- package/dist/examples/plugins.js +129 -0
- package/dist/examples/registry-query.d.ts +2 -0
- package/dist/examples/registry-query.js +87 -0
- package/dist/examples/translation/translation-bergamot-batch.js +2 -2
- package/dist/examples/translation/translation-bergamot.js +4 -4
- package/dist/examples/translation/translation-opus.js +2 -2
- package/dist/examples/translation/translation-stream.js +2 -2
- package/dist/examples/tts/chatterbox.d.ts +2 -0
- package/dist/examples/tts/chatterbox.js +59 -0
- package/dist/examples/tts/supertonic.d.ts +2 -0
- package/dist/examples/tts/supertonic.js +51 -0
- package/dist/examples/tts/utils.d.ts +17 -0
- package/dist/examples/tts/utils.js +93 -0
- package/dist/examples/whispercpp-filesystem.js +2 -3
- package/dist/examples/whispercpp-microphone-record.js +1 -2
- package/dist/examples/whispercpp-prompt.js +2 -3
- package/dist/expo/plugins/index.d.ts +3 -0
- package/dist/expo/plugins/index.js +3 -0
- package/dist/expo/plugins/resolve-sdk-package-dir.d.ts +15 -0
- package/dist/expo/plugins/resolve-sdk-package-dir.js +31 -0
- package/dist/expo/plugins/withAndroidArchitecture.d.ts +8 -0
- package/dist/expo/plugins/withAndroidArchitecture.js +52 -0
- package/dist/expo/plugins/withAndroidNdkVersion.d.ts +8 -0
- package/dist/expo/plugins/withAndroidNdkVersion.js +31 -0
- package/dist/expo/plugins/withDeviceInfo.d.ts +10 -0
- package/dist/expo/plugins/withDeviceInfo.js +48 -0
- package/dist/expo/plugins/withMobileBundle.d.ts +5 -2
- package/dist/expo/plugins/withMobileBundle.js +121 -65
- package/dist/expo/plugins/withQvacSDK.d.ts +4 -0
- package/dist/expo/plugins/withQvacSDK.js +26 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/models/{hyperdrive → registry}/index.js +1 -1
- package/dist/models/registry/models.d.ts +9056 -0
- package/dist/models/registry/models.js +9351 -0
- package/dist/models/update-models/codegen.d.ts +3 -0
- package/dist/models/update-models/codegen.js +135 -0
- package/dist/models/update-models/history.d.ts +13 -0
- package/dist/models/update-models/history.js +88 -0
- package/dist/models/update-models/index.d.ts +2 -0
- package/dist/models/update-models/index.js +124 -0
- package/dist/models/update-models/naming.d.ts +4 -0
- package/dist/models/update-models/naming.js +314 -0
- package/dist/models/update-models/processing.d.ts +8 -0
- package/dist/models/update-models/processing.js +67 -0
- package/dist/models/update-models/registry.d.ts +4 -0
- package/dist/models/update-models/registry.js +67 -0
- package/dist/models/update-models/shards.d.ts +4 -0
- package/dist/models/update-models/shards.js +57 -0
- package/dist/models/update-models/types.d.ts +60 -0
- package/dist/models/update-models/types.js +1 -0
- package/dist/models/update-models/utils.d.ts +3 -0
- package/dist/models/update-models/utils.js +21 -0
- package/dist/pear/pre.d.ts +18 -0
- package/dist/pear/pre.js +433 -0
- package/dist/schemas/common.d.ts +286 -32
- package/dist/schemas/common.js +12 -0
- package/dist/schemas/download-asset.d.ts +35 -11
- package/dist/schemas/download-asset.js +5 -1
- package/dist/schemas/engine-addon-map.d.ts +5 -0
- package/dist/schemas/engine-addon-map.js +49 -0
- package/dist/schemas/get-model-info.d.ts +32 -16
- package/dist/schemas/get-model-info.js +17 -8
- package/dist/schemas/index.d.ts +4 -1
- package/dist/schemas/index.js +4 -4
- package/dist/schemas/load-model.d.ts +2224 -900
- package/dist/schemas/load-model.js +130 -25
- package/dist/schemas/model-src-utils.d.ts +30 -12
- package/dist/schemas/model-src-utils.js +5 -2
- package/dist/schemas/model-types.d.ts +15 -4
- package/dist/schemas/model-types.js +21 -4
- package/dist/schemas/path-validation.d.ts +10 -0
- package/dist/schemas/path-validation.js +22 -0
- package/dist/schemas/plugin.d.ts +180 -0
- package/dist/schemas/plugin.js +132 -0
- package/dist/schemas/rag.d.ts +2 -2
- package/dist/schemas/rag.js +7 -3
- package/dist/schemas/registry.d.ts +338 -0
- package/dist/schemas/registry.js +91 -0
- package/dist/schemas/sdk-errors-client.d.ts +6 -6
- package/dist/schemas/sdk-errors-client.js +15 -15
- package/dist/schemas/sdk-errors-registry.d.ts +6 -0
- package/dist/schemas/sdk-errors-registry.js +8 -0
- package/dist/schemas/sdk-errors-server.d.ts +16 -2
- package/dist/schemas/sdk-errors-server.js +90 -10
- package/dist/schemas/text-to-speech.d.ts +670 -1
- package/dist/schemas/text-to-speech.js +51 -2
- package/dist/schemas/translate.d.ts +2 -2
- package/dist/scripts/run-security-tests-bare.d.ts +2 -0
- package/dist/scripts/run-security-tests-bare.js +78 -0
- package/dist/scripts/run-security-tests.d.ts +2 -0
- package/dist/scripts/run-security-tests.js +22 -0
- package/dist/server/bare/delegate-rpc-client.d.ts +6 -0
- package/dist/server/bare/delegate-rpc-client.js +136 -56
- package/dist/server/bare/{addons/llamacpp-embedding/handlers → ops}/embed.d.ts +1 -1
- package/dist/server/bare/{addons/llamacpp-embedding/handlers → ops}/embed.js +3 -3
- package/dist/server/bare/{addons/llamacpp-completion → ops}/kv-cache-utils.js +6 -6
- package/dist/server/bare/{addons → ops}/load-model.js +32 -42
- package/dist/server/bare/{addons/nmtcpp-translation/handlers → ops}/translate.d.ts +1 -1
- package/dist/server/bare/{addons/nmtcpp-translation/handlers → ops}/translate.js +5 -4
- package/dist/server/bare/plugins/index.d.ts +7 -0
- package/dist/server/bare/plugins/index.js +6 -0
- package/dist/server/bare/{addons/llamacpp-completion → plugins/llamacpp-completion/ops}/cache-logger.js +1 -1
- package/dist/server/bare/{addons/llamacpp-completion/handlers → plugins/llamacpp-completion/ops}/completion-stream.d.ts +1 -1
- package/dist/server/bare/{addons/llamacpp-completion/handlers → plugins/llamacpp-completion/ops}/completion-stream.js +2 -3
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +115 -0
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +142 -0
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +24 -0
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +73 -0
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +45 -0
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +97 -0
- package/dist/server/bare/{addons/onnx-ocr/handlers → plugins/onnx-ocr/ops}/ocr-stream.js +2 -1
- package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +38 -0
- package/dist/server/bare/{addons/onnx-ocr/create-model.js → plugins/onnx-ocr/plugin.js} +39 -2
- package/dist/server/bare/{addons/onnx-tts/handlers → plugins/onnx-tts/ops}/text-to-speech.js +23 -1
- package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +26 -0
- package/dist/server/bare/plugins/onnx-tts/plugin.js +162 -0
- package/dist/server/bare/plugins/onnx-tts/wav-helper.d.ts +14 -0
- package/dist/server/bare/plugins/onnx-tts/wav-helper.js +107 -0
- package/dist/server/bare/plugins/whispercpp-transcription/ops/transcribe-stream.d.ts +3 -0
- package/dist/server/bare/{addons/whispercpp-transcription/handlers → plugins/whispercpp-transcription/ops}/transcribe-stream.js +1 -2
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +31 -0
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +74 -0
- package/dist/server/bare/rag-hyperdb/handlers/ingest.js +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/search.js +1 -1
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +2 -1
- package/dist/server/bare/registry/config-registry.js +1 -1
- package/dist/server/bare/registry/registry-client.d.ts +5 -0
- package/dist/server/bare/registry/registry-client.js +37 -0
- package/dist/server/env.d.ts +22 -0
- package/dist/server/env.js +57 -0
- package/dist/server/plugins/index.d.ts +2 -0
- package/dist/server/plugins/index.js +1 -0
- package/dist/server/plugins/registry.d.ts +9 -0
- package/dist/server/plugins/registry.js +75 -0
- package/dist/server/rpc/delegate-transport.d.ts +11 -0
- package/dist/server/rpc/delegate-transport.js +60 -0
- package/dist/server/rpc/handle-request.d.ts +0 -9
- package/dist/server/rpc/handle-request.js +13 -321
- package/dist/server/rpc/handler-registry.d.ts +3 -0
- package/dist/server/rpc/handler-registry.js +84 -0
- package/dist/server/rpc/handler-utils.d.ts +22 -0
- package/dist/server/rpc/handler-utils.js +87 -0
- package/dist/server/rpc/handlers/cancelHandler.js +1 -1
- package/dist/server/rpc/handlers/completion-stream-delegated.js +1 -1
- package/dist/server/rpc/handlers/completion-stream.js +2 -43
- package/dist/server/rpc/handlers/delete-cache.js +1 -1
- package/dist/server/rpc/handlers/embed.js +2 -21
- package/dist/server/rpc/handlers/get-model-info.js +19 -15
- package/dist/server/rpc/handlers/index.d.ts +9 -0
- package/dist/server/rpc/handlers/index.js +9 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +1 -0
- package/dist/server/rpc/handlers/load-model/download-manager.js +3 -0
- package/dist/server/rpc/handlers/load-model/handler.js +47 -24
- package/dist/server/rpc/handlers/load-model/http.js +3 -2
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +14 -10
- package/dist/server/rpc/handlers/load-model/registry.d.ts +10 -0
- package/dist/server/rpc/handlers/load-model/registry.js +571 -0
- package/dist/server/rpc/handlers/load-model/resolve.js +18 -5
- package/dist/server/rpc/handlers/load-model-delegated.js +4 -2
- package/dist/server/rpc/handlers/ocr-stream.js +2 -37
- package/dist/server/rpc/handlers/ping.d.ts +3 -0
- package/dist/server/rpc/handlers/ping.js +3 -0
- package/dist/server/rpc/handlers/plugin-dispatch.d.ts +15 -0
- package/dist/server/rpc/handlers/plugin-dispatch.js +54 -0
- package/dist/server/rpc/handlers/plugin-invoke.d.ts +4 -0
- package/dist/server/rpc/handlers/plugin-invoke.js +87 -0
- package/dist/server/rpc/handlers/registry.d.ts +5 -0
- package/dist/server/rpc/handlers/registry.js +157 -0
- package/dist/server/rpc/handlers/text-to-speech.js +2 -5
- package/dist/server/rpc/handlers/transcribe-stream.js +2 -30
- package/dist/server/rpc/handlers/translate.js +2 -42
- package/dist/server/rpc/handlers/unload-model.js +1 -1
- package/dist/server/rpc/index.d.ts +1 -1
- package/dist/server/utils/archive.d.ts +1 -0
- package/dist/server/utils/archive.js +10 -2
- package/dist/server/utils/cache.d.ts +5 -0
- package/dist/server/utils/cache.js +26 -2
- package/dist/server/utils/gguf-tensor-extractor.js +3 -3
- package/dist/server/utils/index.d.ts +1 -1
- package/dist/server/utils/index.js +1 -1
- package/dist/server/utils/path-security.d.ts +12 -0
- package/dist/server/utils/path-security.js +25 -0
- package/dist/server/utils/shard-utils.js +3 -3
- package/dist/server/worker-core.d.ts +6 -0
- package/dist/server/worker-core.js +88 -0
- package/dist/server/worker.d.ts +4 -5
- package/dist/server/worker.js +18 -116
- package/dist/utils/errors-client.d.ts +9 -6
- package/dist/utils/errors-client.js +19 -11
- package/dist/utils/errors-server.d.ts +44 -5
- package/dist/utils/errors-server.js +82 -9
- package/dist/utils/path-sanitize.d.ts +17 -0
- package/dist/utils/path-sanitize.js +54 -0
- package/expo/plugins/patches/android-link.mjs +63 -0
- package/expo/plugins/patches/ios-link.mjs +63 -0
- package/package.json +72 -10
- package/dist/examples/text-to-speech.d.ts +0 -3
- package/dist/examples/text-to-speech.js +0 -137
- package/dist/models/hyperdrive/models.d.ts +0 -4003
- package/dist/models/hyperdrive/models.js +0 -4282
- package/dist/server/bare/addons/index.d.ts +0 -4
- package/dist/server/bare/addons/index.js +0 -3
- package/dist/server/bare/addons/llamacpp-completion/create-model.d.ts +0 -8
- package/dist/server/bare/addons/llamacpp-completion/create-model.js +0 -43
- package/dist/server/bare/addons/llamacpp-completion/index.d.ts +0 -4
- package/dist/server/bare/addons/llamacpp-completion/index.js +0 -3
- package/dist/server/bare/addons/llamacpp-embedding/create-model.d.ts +0 -8
- package/dist/server/bare/addons/llamacpp-embedding/create-model.js +0 -38
- package/dist/server/bare/addons/llamacpp-embedding/index.d.ts +0 -3
- package/dist/server/bare/addons/llamacpp-embedding/index.js +0 -2
- package/dist/server/bare/addons/nmtcpp-translation/create-model.d.ts +0 -8
- package/dist/server/bare/addons/nmtcpp-translation/create-model.js +0 -52
- package/dist/server/bare/addons/nmtcpp-translation/index.d.ts +0 -3
- package/dist/server/bare/addons/nmtcpp-translation/index.js +0 -2
- package/dist/server/bare/addons/onnx-ocr/create-model.d.ts +0 -10
- package/dist/server/bare/addons/onnx-ocr/index.d.ts +0 -3
- package/dist/server/bare/addons/onnx-ocr/index.js +0 -2
- package/dist/server/bare/addons/onnx-tts/create-model.d.ts +0 -10
- package/dist/server/bare/addons/onnx-tts/create-model.js +0 -25
- package/dist/server/bare/addons/onnx-tts/index.d.ts +0 -3
- package/dist/server/bare/addons/onnx-tts/index.js +0 -2
- package/dist/server/bare/addons/whispercpp-transcription/create-model.d.ts +0 -10
- package/dist/server/bare/addons/whispercpp-transcription/create-model.js +0 -37
- package/dist/server/bare/addons/whispercpp-transcription/handlers/transcribe-stream.d.ts +0 -3
- package/dist/server/bare/addons/whispercpp-transcription/index.d.ts +0 -3
- package/dist/server/bare/addons/whispercpp-transcription/index.js +0 -2
- /package/dist/models/{hyperdrive → registry}/index.d.ts +0 -0
- /package/dist/server/bare/{addons → ops}/cancel.d.ts +0 -0
- /package/dist/server/bare/{addons → ops}/cancel.js +0 -0
- /package/dist/server/bare/{addons/llamacpp-completion → ops}/kv-cache-utils.d.ts +0 -0
- /package/dist/server/bare/{addons → ops}/load-model.d.ts +0 -0
- /package/dist/server/bare/{addons → ops}/unload-model.d.ts +0 -0
- /package/dist/server/bare/{addons → ops}/unload-model.js +0 -0
- /package/dist/server/bare/{addons/llamacpp-completion → plugins/llamacpp-completion/ops}/cache-logger.d.ts +0 -0
- /package/dist/server/bare/{addons/onnx-ocr/handlers → plugins/onnx-ocr/ops}/ocr-stream.d.ts +0 -0
- /package/dist/server/bare/{addons/onnx-tts/handlers → plugins/onnx-tts/ops}/text-to-speech.d.ts +0 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { ExpoConfig } from "expo/config";
|
|
2
2
|
/**
|
|
3
|
-
* Expo plugin that automatically generates the mobile worker bundle during build
|
|
4
|
-
*
|
|
3
|
+
* Expo plugin that automatically generates the mobile worker bundle during build.
|
|
4
|
+
*
|
|
5
|
+
* Runs qvac CLI (prefers local @qvac/cli, falls back to npx).
|
|
6
|
+
* Uses qvac.config.* if exists, else includes all built-in plugins.
|
|
7
|
+
* Output: node_modules/<sdk-package>/dist/worker.mobile.bundle.js
|
|
5
8
|
*/
|
|
6
9
|
declare function withMobileBundle(config: ExpoConfig): ExpoConfig;
|
|
7
10
|
export default withMobileBundle;
|
|
@@ -2,84 +2,140 @@ import configPlugins from "@expo/config-plugins";
|
|
|
2
2
|
import { execSync } from "child_process";
|
|
3
3
|
import * as fs from "fs";
|
|
4
4
|
import * as path from "path";
|
|
5
|
-
import {
|
|
5
|
+
import { resolveSDKPackageDir } from "./resolve-sdk-package-dir.js";
|
|
6
6
|
const { withDangerousMod } = configPlugins;
|
|
7
|
+
const CONFIG_CANDIDATES = [
|
|
8
|
+
"qvac.config.json",
|
|
9
|
+
"qvac.config.js",
|
|
10
|
+
"qvac.config.mjs",
|
|
11
|
+
];
|
|
12
|
+
/** Modules to defer from mobile bundles (not available at bundle time) */
|
|
13
|
+
const DEFERRED_MODULES = ["expo-file-system", "react-native-bare-kit"];
|
|
14
|
+
const MOBILE_HOSTS = [
|
|
15
|
+
"android-arm64",
|
|
16
|
+
"ios-arm64",
|
|
17
|
+
"ios-arm64-simulator",
|
|
18
|
+
"ios-x64-simulator",
|
|
19
|
+
];
|
|
7
20
|
/**
|
|
8
|
-
* Expo plugin that automatically generates the mobile worker bundle during build
|
|
9
|
-
*
|
|
21
|
+
* Expo plugin that automatically generates the mobile worker bundle during build.
|
|
22
|
+
*
|
|
23
|
+
* Runs qvac CLI (prefers local @qvac/cli, falls back to npx).
|
|
24
|
+
* Uses qvac.config.* if exists, else includes all built-in plugins.
|
|
25
|
+
* Output: node_modules/<sdk-package>/dist/worker.mobile.bundle.js
|
|
10
26
|
*/
|
|
11
27
|
function withMobileBundle(config) {
|
|
12
28
|
function buildMobileBundle(config) {
|
|
13
|
-
console.log("🕚 QVAC: Generating mobile worker bundle with current dependencies...");
|
|
14
29
|
const projectRoot = config.modRequest.projectRoot;
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
30
|
+
const sdkPackage = resolveSDKPackageDir(projectRoot);
|
|
31
|
+
const outputPath = path.join(sdkPackage.dir, "dist", "worker.mobile.bundle.js");
|
|
32
|
+
// Generate bundle via qvac CLI
|
|
33
|
+
// (uses qvac.config.* if exists, else includes all built-in plugins)
|
|
34
|
+
const configPath = findConfigFile(projectRoot);
|
|
35
|
+
if (configPath) {
|
|
36
|
+
console.log(`🕚 QVAC: Found ${path.basename(configPath)}, generating tree-shaken bundle...`);
|
|
19
37
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// Check if worker.js exists
|
|
23
|
-
if (!fs.existsSync(workerPath)) {
|
|
24
|
-
throw new WorkerFileNotFoundError(workerPath);
|
|
38
|
+
else {
|
|
39
|
+
console.log("🕚 QVAC: No config found, generating default bundle (all plugins)...");
|
|
25
40
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
// Copy bare imports configuration for bare-pack
|
|
39
|
-
const bareImportsSource = path.join(qvacSdkPath, "bare-imports.json");
|
|
40
|
-
const importsMapPath = path.join(qvacSdkPath, "dist", "imports.json");
|
|
41
|
-
if (fs.existsSync(bareImportsSource)) {
|
|
42
|
-
fs.copyFileSync(bareImportsSource, importsMapPath);
|
|
43
|
-
console.log("🔧 QVAC: Copied bare-imports.json for mobile bundle");
|
|
44
|
-
}
|
|
45
|
-
// Remove optional modules from the bundle
|
|
46
|
-
const optionalModules = [
|
|
47
|
-
"expo-file-system",
|
|
48
|
-
"react-native-bare-kit",
|
|
49
|
-
"@qvac/sdk/worker.mobile.bundle",
|
|
50
|
-
];
|
|
51
|
-
const deferFlags = optionalModules
|
|
52
|
-
.map((mod) => `--defer "${mod}"`)
|
|
53
|
-
.join(" ");
|
|
54
|
-
// Detect bare-pack version (v1.x uses --target, v2.x uses --host)
|
|
55
|
-
let platformFlag = "--host";
|
|
56
|
-
try {
|
|
57
|
-
const versionOutput = execSync(`npx bare-pack --version "${workerPath}"`, { cwd: projectRoot, encoding: "utf-8" }).trim();
|
|
58
|
-
const versionMatch = versionOutput.match(/v?(\d+)\./);
|
|
59
|
-
const majorVersion = versionMatch && versionMatch[1] ? parseInt(versionMatch[1], 10) : 2;
|
|
60
|
-
if (majorVersion < 2) {
|
|
61
|
-
platformFlag = "--target";
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
throw new Error(`Failed to detect bare-pack version. Ensure bare-pack is installed: npm install bare-pack`, { cause: error });
|
|
66
|
-
}
|
|
67
|
-
const platforms = ["android-arm64", "ios-arm64", "ios-arm64-simulator"];
|
|
68
|
-
const platformFlags = platforms
|
|
69
|
-
.map((p) => `${platformFlag} ${p}`)
|
|
70
|
-
.join(" ");
|
|
71
|
-
// Generate the bundle using bare-pack with the current project's dependencies
|
|
72
|
-
execSync(`cd "${projectRoot}" && npx bare-pack ${platformFlags} --linked --imports "${importsMapPath}" ${deferFlags} --out "${outputPath}" "${workerPath}"`, { stdio: "inherit", cwd: projectRoot });
|
|
73
|
-
console.log("🫡 QVAC: Mobile worker bundle generated successfully");
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
console.error("❌ QVAC: Failed to generate mobile worker bundle:", error);
|
|
77
|
-
throw error;
|
|
41
|
+
const deferredModules = [
|
|
42
|
+
...DEFERRED_MODULES,
|
|
43
|
+
`${sdkPackage.name}/worker.mobile.bundle`,
|
|
44
|
+
];
|
|
45
|
+
runBundler(projectRoot, sdkPackage.dir, configPath, deferredModules);
|
|
46
|
+
// Copy the generated bundle to SDK location
|
|
47
|
+
const generatedBundle = path.join(projectRoot, "qvac", "worker.bundle.js");
|
|
48
|
+
if (!fs.existsSync(generatedBundle)) {
|
|
49
|
+
throw new Error(`QVAC: Bundle generation failed — ${generatedBundle} not found. ` +
|
|
50
|
+
`Check qvac CLI output above for errors.`);
|
|
78
51
|
}
|
|
52
|
+
fs.copyFileSync(generatedBundle, outputPath);
|
|
53
|
+
console.log("🫡 QVAC: Mobile bundle generated");
|
|
79
54
|
return config;
|
|
80
55
|
}
|
|
81
56
|
config = withDangerousMod(config, ["android", buildMobileBundle]);
|
|
82
57
|
config = withDangerousMod(config, ["ios", buildMobileBundle]);
|
|
83
58
|
return config;
|
|
84
59
|
}
|
|
60
|
+
/** Finds qvac.config.* file in project root */
|
|
61
|
+
function findConfigFile(projectRoot) {
|
|
62
|
+
for (const candidate of CONFIG_CANDIDATES) {
|
|
63
|
+
const configPath = path.join(projectRoot, candidate);
|
|
64
|
+
if (fs.existsSync(configPath)) {
|
|
65
|
+
return configPath;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Resolves the qvac CLI command.
|
|
72
|
+
*
|
|
73
|
+
* Prefers local @qvac/cli installation for version consistency,
|
|
74
|
+
* falls back to npx for convenience when CLI is not installed.
|
|
75
|
+
*/
|
|
76
|
+
function resolveCliCommand(projectRoot) {
|
|
77
|
+
const cliPath = path.join(projectRoot, "node_modules", "@qvac", "cli", "src", "index.js");
|
|
78
|
+
if (fs.existsSync(cliPath)) {
|
|
79
|
+
return `node "${cliPath}"`;
|
|
80
|
+
}
|
|
81
|
+
console.log("⚠️ QVAC: @qvac/cli not found in node_modules, falling back to npx");
|
|
82
|
+
console.log(" Tip: Add @qvac/cli as a dependency for consistent versioning");
|
|
83
|
+
return "npx --package=@qvac/cli qvac";
|
|
84
|
+
}
|
|
85
|
+
/** Runs qvac CLI with mobile-specific options */
|
|
86
|
+
function runBundler(projectRoot, qvacSdkPath, configPath, deferredModules) {
|
|
87
|
+
// Patch bare-kit linkers to use addons manifest
|
|
88
|
+
patchBareKitLinkers(projectRoot, qvacSdkPath);
|
|
89
|
+
const hostFlags = MOBILE_HOSTS.map((h) => `--host ${h}`).join(" ");
|
|
90
|
+
const deferFlags = deferredModules.map((m) => `--defer "${m}"`).join(" ");
|
|
91
|
+
const configFlag = configPath ? `--config "${configPath}"` : "";
|
|
92
|
+
const sdkPathFlag = `--sdk-path "${qvacSdkPath}"`;
|
|
93
|
+
const cliCommand = resolveCliCommand(projectRoot);
|
|
94
|
+
try {
|
|
95
|
+
execSync(`${cliCommand} bundle sdk ${sdkPathFlag} ${configFlag} ${hostFlags} ${deferFlags} --quiet`, { stdio: "inherit", cwd: projectRoot });
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.error("❌ QVAC: Failed to generate bundle:", error);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Patches react-native-bare-kit linkers to use the addons manifest.
|
|
104
|
+
*
|
|
105
|
+
* Copies the manifest-aware link.mjs files over the originals so that
|
|
106
|
+
* bare-link only links the native addons actually required by the bundle.
|
|
107
|
+
* This reduces app size by excluding unused native addon binaries.
|
|
108
|
+
*/
|
|
109
|
+
function patchBareKitLinkers(projectRoot, qvacSdkPath) {
|
|
110
|
+
const bareKitPath = path.join(projectRoot, "node_modules", "react-native-bare-kit");
|
|
111
|
+
if (!fs.existsSync(bareKitPath)) {
|
|
112
|
+
console.log("⚠️ QVAC: react-native-bare-kit not found, skipping linker patch");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const patchesDir = path.join(qvacSdkPath, "expo", "plugins", "patches");
|
|
116
|
+
if (!fs.existsSync(patchesDir)) {
|
|
117
|
+
console.log(`⚠️ QVAC: patches directory not found (${patchesDir}), skipping linker patch`);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Patch Android linker
|
|
121
|
+
const androidPatch = path.join(patchesDir, "android-link.mjs");
|
|
122
|
+
const androidTarget = path.join(bareKitPath, "android", "link.mjs");
|
|
123
|
+
if (fs.existsSync(androidPatch)) {
|
|
124
|
+
fs.copyFileSync(androidPatch, androidTarget);
|
|
125
|
+
console.log("✅ QVAC: Patched android/link.mjs for manifest-aware linking");
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
console.log(`⚠️ QVAC: Android linker patch not found (${androidPatch})`);
|
|
129
|
+
}
|
|
130
|
+
// Patch iOS linker
|
|
131
|
+
const iosPatch = path.join(patchesDir, "ios-link.mjs");
|
|
132
|
+
const iosTarget = path.join(bareKitPath, "ios", "link.mjs");
|
|
133
|
+
if (fs.existsSync(iosPatch)) {
|
|
134
|
+
fs.copyFileSync(iosPatch, iosTarget);
|
|
135
|
+
console.log("✅ QVAC: Patched ios/link.mjs for manifest-aware linking");
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
console.log(`⚠️ QVAC: iOS linker patch not found (${iosPatch})`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
85
141
|
export default withMobileBundle;
|
|
@@ -2,6 +2,10 @@ import type { ExpoConfig } from "expo/config";
|
|
|
2
2
|
/**
|
|
3
3
|
* Main Qvac SDK Expo plugin that combines all necessary mobile configurations:
|
|
4
4
|
* - Mobile worker bundle generation
|
|
5
|
+
* - Device info stubbing when expo-device is not installed
|
|
6
|
+
* - Android build properties (minSdkVersion, NDK, proguard)
|
|
7
|
+
* - Android NDK version pinning in build.gradle
|
|
8
|
+
* - Android architecture filtering (arm64-v8a only)
|
|
5
9
|
* - OpenCL native library support for Android
|
|
6
10
|
*/
|
|
7
11
|
declare function withQvacSDK(config: ExpoConfig): ExpoConfig;
|
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
import configPlugins from "@expo/config-plugins";
|
|
2
|
+
import withAndroidArchitecture from "./withAndroidArchitecture.js";
|
|
3
|
+
import withAndroidNdkVersion from "./withAndroidNdkVersion.js";
|
|
4
|
+
import withDeviceInfo from "./withDeviceInfo.js";
|
|
2
5
|
import withMobileBundle from "./withMobileBundle.js";
|
|
3
6
|
import withOpenCL from "./withOpenCL.js";
|
|
4
7
|
const { withPlugins } = configPlugins;
|
|
5
8
|
/**
|
|
6
9
|
* Main Qvac SDK Expo plugin that combines all necessary mobile configurations:
|
|
7
10
|
* - Mobile worker bundle generation
|
|
11
|
+
* - Device info stubbing when expo-device is not installed
|
|
12
|
+
* - Android build properties (minSdkVersion, NDK, proguard)
|
|
13
|
+
* - Android NDK version pinning in build.gradle
|
|
14
|
+
* - Android architecture filtering (arm64-v8a only)
|
|
8
15
|
* - OpenCL native library support for Android
|
|
9
16
|
*/
|
|
10
17
|
function withQvacSDK(config) {
|
|
11
|
-
return withPlugins(config, [
|
|
18
|
+
return withPlugins(config, [
|
|
19
|
+
withMobileBundle,
|
|
20
|
+
withDeviceInfo,
|
|
21
|
+
[
|
|
22
|
+
"expo-build-properties",
|
|
23
|
+
{
|
|
24
|
+
android: {
|
|
25
|
+
minSdkVersion: 29,
|
|
26
|
+
ndkVersion: "29.0.14206865",
|
|
27
|
+
enableProguardInReleaseBuilds: true,
|
|
28
|
+
enableShrinkResourcesInReleaseBuilds: true,
|
|
29
|
+
enableMinifyInReleaseBuilds: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
withAndroidNdkVersion,
|
|
34
|
+
withAndroidArchitecture,
|
|
35
|
+
withOpenCL,
|
|
36
|
+
]);
|
|
12
37
|
}
|
|
13
38
|
export default withQvacSDK;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, } from "./client/api/index";
|
|
1
|
+
export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, } from "./client/api/index";
|
|
2
2
|
export { close } from "./client/index";
|
|
3
|
-
export { type ModelProgressUpdate, type LoadModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallWithCall, type ToolCallError, type ToolCallEvent, type CompletionStats, VERBOSITY, type Attachment, type CompletionParams, type RagSearchResult, type RagSaveEmbeddingsResult, type RagReindexResult, type RagEmbeddedDoc, type RagDoc, type RagWorkspaceInfo, type RagCloseWorkspaceParams, type RagDeleteWorkspaceParams, type RagIngestStage, type RagReindexStage, type RagSaveStage, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, type QvacConfig, type ModelInfo, type GetModelInfoParams, type LoadedInstance, type CacheFileInfo, toolSchema, type McpClient, type McpClientInput, type OCRClientParams, type OCRTextBlock, type OCROptions, } from "./schemas/index";
|
|
3
|
+
export { type ModelProgressUpdate, type LoadModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallWithCall, type ToolCallError, type ToolCallEvent, type CompletionStats, VERBOSITY, type Attachment, type CompletionParams, type RagSearchResult, type RagSaveEmbeddingsResult, type RagReindexResult, type RagEmbeddedDoc, type RagDoc, type RagWorkspaceInfo, type RagCloseWorkspaceParams, type RagDeleteWorkspaceParams, type RagIngestStage, type RagReindexStage, type RagSaveStage, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, type QvacConfig, type ModelInfo, type GetModelInfoParams, type LoadedInstance, type CacheFileInfo, toolSchema, type McpClient, type McpClientInput, type OCRClientParams, type OCRTextBlock, type OCROptions, definePlugin, defineHandler, type QvacPlugin, type CreateModelParams, type PluginModelResult, type ModelRegistryEntry, type ModelRegistryEntryAddon, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, SDK_DEFAULT_PLUGINS, type BuiltinPlugin, } from "./schemas/index";
|
|
4
4
|
export { type ToolInput, type ToolHandler } from "./utils/tool-helpers";
|
|
5
|
-
export {
|
|
6
|
-
export * from "./models/
|
|
5
|
+
export { MODEL_TYPES, ModelType } from "./schemas/index";
|
|
6
|
+
export * from "./models/registry/index";
|
|
7
7
|
export { SUPPORTED_AUDIO_FORMATS } from "./constants/audio";
|
|
8
8
|
export { getLogger, SDK_LOG_ID } from "./logging/index";
|
|
9
9
|
export type { Logger, LogTransport, LoggerOptions } from "./logging/index";
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Public API exports only
|
|
2
|
-
export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, } from "./client/api/index.js";
|
|
2
|
+
export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, invokePlugin, invokePluginStream, modelRegistryList, modelRegistrySearch, modelRegistryGetModel, } from "./client/api/index.js";
|
|
3
3
|
export { close } from "./client/index.js";
|
|
4
|
-
export { VERBOSITY, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, toolSchema, } from "./schemas/index.js";
|
|
4
|
+
export { VERBOSITY, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, toolSchema, definePlugin, defineHandler, PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_WHISPER, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, SDK_DEFAULT_PLUGINS, } from "./schemas/index.js";
|
|
5
5
|
export {} from "./utils/tool-helpers.js";
|
|
6
6
|
// Model types - canonical naming with backward-compatible aliases
|
|
7
|
-
export {
|
|
8
|
-
//
|
|
9
|
-
export * from "./models/
|
|
7
|
+
export { MODEL_TYPES, ModelType } from "./schemas/index.js";
|
|
8
|
+
// Model registry constants
|
|
9
|
+
export * from "./models/registry/index.js";
|
|
10
10
|
export { SUPPORTED_AUDIO_FORMATS } from "./constants/audio.js";
|
|
11
11
|
// Logging exports
|
|
12
12
|
export { getLogger, SDK_LOG_ID } from "./logging/index.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Re-export all models
|
|
2
2
|
export * from "./models.js";
|