@qvac/sdk 0.8.1 → 1.0.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 +24 -1
- package/README.md +191 -373
- package/dist/client/api/cancel.d.ts +4 -22
- package/dist/client/api/cancel.js +6 -25
- package/dist/client/api/completion-stream.d.ts +30 -24
- package/dist/client/api/completion-stream.js +70 -121
- package/dist/client/api/delete-cache.js +2 -3
- package/dist/client/api/download-asset.d.ts +5 -6
- package/dist/client/api/download-asset.js +20 -16
- package/dist/client/api/embed.d.ts +4 -21
- package/dist/client/api/embed.js +14 -4
- package/dist/client/api/index.d.ts +2 -6
- package/dist/client/api/index.js +2 -6
- package/dist/client/api/load-model.d.ts +21 -49
- package/dist/client/api/load-model.js +134 -40
- package/dist/client/api/logging-stream.d.ts +4 -7
- package/dist/client/api/logging-stream.js +5 -9
- package/dist/client/api/ping.d.ts +11 -0
- package/dist/client/api/ping.js +18 -0
- package/dist/client/api/provide.d.ts +1 -1
- package/dist/client/api/provide.js +3 -4
- package/dist/client/api/rag.d.ts +21 -216
- package/dist/client/api/rag.js +36 -396
- package/dist/client/api/stop-provider.d.ts +1 -1
- package/dist/client/api/stop-provider.js +3 -4
- package/dist/client/api/text-to-speech.d.ts +2 -2
- package/dist/client/api/text-to-speech.js +3 -3
- package/dist/client/api/transcribe.d.ts +5 -9
- package/dist/client/api/transcribe.js +9 -11
- package/dist/client/api/translate.d.ts +3 -3
- package/dist/client/api/translate.js +15 -15
- package/dist/client/api/unload-model.d.ts +1 -5
- package/dist/client/api/unload-model.js +4 -17
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/logging-stream-registry.d.ts +1 -1
- package/dist/client/logging-stream-registry.js +13 -14
- package/dist/client/rpc/bare-client.d.ts +139 -3
- package/dist/client/rpc/bare-client.js +16 -117
- package/dist/client/rpc/bare-rpc-client.d.ts +4 -0
- package/dist/client/rpc/bare-rpc-client.js +87 -0
- package/dist/client/rpc/expo-rpc-client.d.ts +1 -2
- package/dist/client/rpc/expo-rpc-client.js +14 -57
- package/dist/client/rpc/node-rpc-client.d.ts +8 -3
- package/dist/client/rpc/node-rpc-client.js +62 -218
- package/dist/client/rpc/rpc-client.d.ts +2 -3
- package/dist/client/rpc/rpc-client.js +49 -184
- package/dist/constants/audio.d.ts +2 -1
- package/dist/constants/audio.js +17 -1
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/index.js +0 -1
- package/dist/examples/delegated-inference/consumer.js +2 -3
- package/dist/examples/download-with-cancel.js +4 -3
- package/dist/examples/embed-hyperdrive.d.ts +2 -0
- package/dist/examples/embed-hyperdrive.js +19 -0
- package/dist/examples/kv-cache-cleanup.js +2 -1
- package/dist/examples/kv-cache-custom-key.js +2 -16
- package/dist/examples/kv-cache-example.js +2 -1
- package/dist/examples/llamacpp-file-logging.d.ts +2 -0
- package/dist/examples/{logging-file-transport.js → llamacpp-file-logging.js} +8 -3
- package/dist/examples/llamacpp-filesystem.js +2 -2
- package/dist/examples/llamacpp-http.js +1 -0
- package/dist/examples/llamacpp-hyperdrive.d.ts +2 -0
- package/dist/examples/{llamacpp-p2p.js → llamacpp-hyperdrive.js} +2 -1
- package/dist/examples/llamacpp-multimodal.js +4 -3
- package/dist/examples/llamacpp-native-tools.js +30 -72
- package/dist/examples/multi-model-demo.js +3 -2
- package/dist/examples/parallel-download.js +14 -46
- package/dist/examples/rag/rag-chromadb.js +1 -0
- package/dist/examples/rag/rag-hyperdb-workspaces.d.ts +2 -0
- package/dist/examples/rag/rag-hyperdb-workspaces.js +107 -0
- package/dist/examples/rag/rag-hyperdb.d.ts +2 -0
- package/dist/examples/rag/{rag-hyperdb/ingest.js → rag-hyperdb.js} +5 -10
- package/dist/examples/rag/rag-lancedb.js +1 -0
- package/dist/examples/rag/rag-sqlite.js +1 -0
- package/dist/examples/seed-hyperdrive.d.ts +2 -0
- package/dist/examples/text-to-speech.d.ts +3 -0
- package/dist/examples/{tts/utils.js → text-to-speech.js} +63 -18
- package/dist/examples/translation/translation-indic.js +1 -4
- package/dist/examples/translation/translation-llm-context.js +1 -0
- package/dist/examples/translation/translation-llm.js +2 -2
- package/dist/examples/translation/translation-opus.js +3 -6
- package/dist/examples/translation/translation-stream.js +3 -3
- package/dist/examples/whispercpp-filesystem.js +43 -0
- package/dist/examples/{transcription/whispercpp-microphone-record.js → whispercpp-microphone-record.js} +9 -8
- package/dist/expo/plugins/index.d.ts +0 -3
- package/dist/expo/plugins/index.js +0 -3
- package/dist/expo/plugins/withMobileBundle.d.ts +2 -5
- package/dist/expo/plugins/withMobileBundle.js +40 -121
- package/dist/expo/plugins/withQvacSDK.d.ts +0 -4
- package/dist/expo/plugins/withQvacSDK.js +1 -26
- package/dist/index.d.ts +4 -9
- package/dist/index.js +5 -11
- package/dist/logging/base-logger.js +16 -26
- package/dist/logging/index.d.ts +1 -7
- package/dist/logging/index.js +1 -7
- package/dist/logging/logger.d.ts +2 -0
- package/dist/logging/logger.js +6 -11
- package/dist/logging/stream-logger.d.ts +1 -1
- package/dist/logging/stream-logger.js +3 -6
- package/dist/logging/transport.js +2 -2
- package/dist/logging/types.d.ts +0 -2
- package/dist/logging/utils.d.ts +0 -2
- package/dist/logging/utils.js +0 -62
- package/dist/models/{registry → hyperdrive}/index.js +1 -1
- package/dist/models/hyperdrive/models.d.ts +619 -0
- package/dist/models/hyperdrive/models.js +693 -0
- package/dist/schemas/cancel.d.ts +0 -18
- package/dist/schemas/cancel.js +0 -7
- package/dist/schemas/common.d.ts +166 -3012
- package/dist/schemas/common.js +4 -27
- package/dist/schemas/completion-stream.d.ts +60 -31
- package/dist/schemas/completion-stream.js +44 -20
- package/dist/schemas/delegate.d.ts +0 -9
- package/dist/schemas/delegate.js +2 -6
- package/dist/schemas/download-asset.d.ts +3 -125
- package/dist/schemas/download-asset.js +5 -22
- package/dist/schemas/embed.d.ts +3 -3
- package/dist/schemas/embed.js +2 -9
- package/dist/schemas/index.d.ts +2 -20
- package/dist/schemas/index.js +2 -20
- package/dist/schemas/llamacpp-config.d.ts +12 -243
- package/dist/schemas/llamacpp-config.js +14 -50
- package/dist/schemas/load-model.d.ts +893 -14471
- package/dist/schemas/load-model.js +72 -325
- package/dist/schemas/logging-stream.d.ts +4 -11
- package/dist/schemas/logging-stream.js +3 -4
- package/dist/schemas/ping.d.ts +11 -0
- package/dist/schemas/ping.js +8 -0
- package/dist/schemas/rag.d.ts +52 -183
- package/dist/schemas/rag.js +23 -152
- package/dist/schemas/text-to-speech.d.ts +1 -692
- package/dist/schemas/text-to-speech.js +3 -35
- package/dist/schemas/transcription.d.ts +0 -3
- package/dist/schemas/transcription.js +0 -1
- package/dist/schemas/translate.d.ts +23 -68
- package/dist/schemas/translate.js +11 -37
- package/dist/schemas/translation-config.d.ts +7 -810
- package/dist/schemas/translation-config.js +7 -113
- package/dist/schemas/unload-model.d.ts +0 -2
- package/dist/schemas/unload-model.js +0 -2
- package/dist/schemas/whispercpp-config.d.ts +25 -0
- package/dist/schemas/whispercpp-config.js +18 -0
- package/dist/server/bare/{ops → addons}/cancel.js +1 -2
- package/dist/server/bare/addons/index.d.ts +4 -0
- package/dist/server/bare/addons/index.js +3 -0
- package/dist/server/bare/addons/llamacpp/create-model.d.ts +5 -0
- package/dist/server/bare/addons/llamacpp/create-model.js +67 -0
- package/dist/server/bare/{plugins/llamacpp-completion/ops → addons/llamacpp/handlers}/completion-stream.d.ts +1 -2
- package/dist/server/bare/{plugins/llamacpp-completion/ops → addons/llamacpp/handlers}/completion-stream.js +87 -54
- package/dist/server/bare/addons/llamacpp/handlers/embed.d.ts +4 -0
- package/dist/server/bare/{ops → addons/llamacpp/handlers}/embed.js +7 -22
- package/dist/server/bare/addons/llamacpp/index.d.ts +4 -0
- package/dist/server/bare/addons/llamacpp/index.js +3 -0
- package/dist/server/bare/{ops → addons/llamacpp}/kv-cache-utils.d.ts +1 -4
- package/dist/server/bare/{ops → addons/llamacpp}/kv-cache-utils.js +19 -54
- package/dist/server/bare/addons/load-model.d.ts +3 -0
- package/dist/server/bare/addons/load-model.js +62 -0
- package/dist/server/bare/addons/translation/create-model.d.ts +4 -0
- package/dist/server/bare/addons/translation/create-model.js +45 -0
- package/dist/server/bare/addons/translation/handlers/translate.d.ts +3 -0
- package/dist/server/bare/{ops → addons/translation/handlers}/translate.js +14 -47
- package/dist/server/bare/addons/translation/index.d.ts +3 -0
- package/dist/server/bare/addons/translation/index.js +2 -0
- package/dist/server/bare/addons/tts/create-model.d.ts +6 -0
- package/dist/server/bare/addons/tts/create-model.js +40 -0
- package/dist/server/bare/{plugins/onnx-tts/ops → addons/tts/handlers}/text-to-speech.js +3 -25
- package/dist/server/bare/addons/tts/index.d.ts +3 -0
- package/dist/server/bare/addons/tts/index.js +2 -0
- package/dist/server/bare/addons/unload-model.js +20 -0
- package/dist/server/bare/addons/whispercpp/create-model.d.ts +6 -0
- package/dist/server/bare/addons/whispercpp/create-model.js +55 -0
- package/dist/server/bare/addons/whispercpp/handlers/transcribe-stream.d.ts +3 -0
- package/dist/server/bare/addons/whispercpp/handlers/transcribe-stream.js +48 -0
- package/dist/server/bare/addons/whispercpp/index.d.ts +3 -0
- package/dist/server/bare/addons/whispercpp/index.js +2 -0
- package/dist/server/bare/delegate-rpc-client.d.ts +0 -6
- package/dist/server/bare/delegate-rpc-client.js +45 -187
- package/dist/server/bare/hyperswarm.d.ts +0 -3
- package/dist/server/bare/hyperswarm.js +6 -29
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.js +10 -9
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.d.ts +4 -7
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.js +14 -13
- package/dist/server/bare/rag-hyperdb/handlers/search.js +10 -10
- package/dist/server/bare/rag-hyperdb/index.d.ts +1 -8
- package/dist/server/bare/rag-hyperdb/index.js +1 -8
- package/dist/server/bare/rag-hyperdb/rag-manager.d.ts +5 -0
- package/dist/server/bare/rag-hyperdb/rag-manager.js +65 -0
- package/dist/server/bare/registry/logging-stream-registry.d.ts +7 -24
- package/dist/server/bare/registry/logging-stream-registry.js +20 -99
- package/dist/server/bare/registry/model-registry.d.ts +26 -16
- package/dist/server/bare/registry/model-registry.js +13 -34
- package/dist/server/error-handlers.d.ts +2 -3
- package/dist/server/error-handlers.js +10 -15
- package/dist/server/http-server.d.ts +2 -0
- package/dist/server/http-server.js +189 -0
- package/dist/server/rpc/create-server.js +3 -5
- package/dist/server/rpc/handle-request.d.ts +9 -0
- package/dist/server/rpc/handle-request.js +242 -92
- package/dist/server/rpc/handlers/cancelHandler.js +3 -14
- package/dist/server/rpc/handlers/completion-stream-delegated.d.ts +1 -3
- package/dist/server/rpc/handlers/completion-stream-delegated.js +8 -20
- package/dist/server/rpc/handlers/completion-stream.js +41 -2
- package/dist/server/rpc/handlers/delete-cache.js +2 -4
- package/dist/server/rpc/handlers/download-asset.js +6 -59
- package/dist/server/rpc/handlers/embed.js +19 -2
- package/dist/server/rpc/handlers/index.d.ts +0 -13
- package/dist/server/rpc/handlers/index.js +0 -13
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +11 -12
- package/dist/server/rpc/handlers/load-model/download-manager.js +28 -43
- package/dist/server/rpc/handlers/load-model/http.d.ts +1 -2
- package/dist/server/rpc/handlers/load-model/http.js +55 -424
- package/dist/server/rpc/handlers/load-model/hyperdrive.d.ts +1 -2
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +171 -364
- package/dist/server/rpc/handlers/load-model/index.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/index.js +2 -2
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +1 -3
- package/dist/server/rpc/handlers/load-model/resolve.js +29 -110
- package/dist/server/rpc/handlers/load-model-delegated.d.ts +2 -6
- package/dist/server/rpc/handlers/load-model-delegated.js +20 -60
- package/dist/server/rpc/handlers/{load-model/handler.d.ts → load-model.d.ts} +2 -2
- package/dist/server/rpc/handlers/load-model.js +57 -0
- package/dist/server/rpc/handlers/logging-stream.js +4 -4
- package/dist/server/rpc/handlers/provideHandler/connection.js +10 -12
- package/dist/server/rpc/handlers/provideHandler/handler.js +17 -20
- package/dist/server/rpc/handlers/provideHandler/proxy.js +6 -8
- package/dist/server/rpc/handlers/rag.d.ts +2 -2
- package/dist/server/rpc/handlers/rag.js +43 -130
- package/dist/server/rpc/handlers/stopProvideHandler.js +2 -6
- package/dist/server/rpc/handlers/text-to-speech.js +5 -2
- package/dist/server/rpc/handlers/transcribe-stream.js +24 -2
- package/dist/server/rpc/handlers/translate.js +49 -2
- package/dist/server/rpc/handlers/unload-model.js +3 -12
- package/dist/server/rpc/index.d.ts +1 -1
- package/dist/server/utils/audio/decoder.d.ts +1 -2
- package/dist/server/utils/audio/decoder.js +12 -49
- package/dist/server/utils/cache.d.ts +8 -19
- package/dist/server/utils/cache.js +15 -100
- package/dist/server/utils/hash.d.ts +5 -0
- package/dist/server/utils/hash.js +11 -0
- package/dist/server/utils/index.d.ts +2 -7
- package/dist/server/utils/index.js +2 -7
- package/dist/server/utils/tool-parser.js +14 -28
- package/dist/server/worker.d.ts +5 -4
- package/dist/server/worker.js +89 -22
- package/package.json +41 -148
- package/NOTICE +0 -695
- package/bare-imports.json +0 -44
- package/dist/client/api/get-model-info.d.ts +0 -36
- package/dist/client/api/get-model-info.js +0 -14
- package/dist/client/api/heartbeat.d.ts +0 -30
- package/dist/client/api/heartbeat.js +0 -38
- package/dist/client/api/invoke-plugin.d.ts +0 -15
- package/dist/client/api/invoke-plugin.js +0 -38
- package/dist/client/api/ocr.d.ts +0 -31
- package/dist/client/api/ocr.js +0 -88
- package/dist/client/api/registry.d.ts +0 -14
- package/dist/client/api/registry.js +0 -37
- package/dist/client/config-loader/config-utils.d.ts +0 -5
- package/dist/client/config-loader/config-utils.js +0 -20
- package/dist/client/config-loader/resolve-config.bare.d.ts +0 -9
- package/dist/client/config-loader/resolve-config.bare.js +0 -87
- package/dist/client/config-loader/resolve-config.expo.d.ts +0 -11
- package/dist/client/config-loader/resolve-config.expo.js +0 -62
- package/dist/client/config-loader/resolve-config.node.d.ts +0 -10
- package/dist/client/config-loader/resolve-config.node.js +0 -145
- package/dist/client/init-hooks.d.ts +0 -21
- package/dist/client/init-hooks.js +0 -66
- package/dist/client/rpc/expo-device-info.d.ts +0 -6
- package/dist/client/rpc/expo-device-info.js +0 -32
- package/dist/client/rpc/profiling/index.d.ts +0 -2
- package/dist/client/rpc/profiling/index.js +0 -1
- package/dist/client/rpc/profiling/profiler.d.ts +0 -27
- package/dist/client/rpc/profiling/profiler.js +0 -139
- package/dist/constants/registry.d.ts +0 -2
- package/dist/constants/registry.js +0 -1
- package/dist/examples/cache-management.d.ts +0 -2
- package/dist/examples/cache-management.js +0 -97
- package/dist/examples/config/blind-relay/blind-relay.config.d.ts +0 -5
- package/dist/examples/config/blind-relay/blind-relay.config.js +0 -7
- package/dist/examples/config/default/default.config.d.ts +0 -8
- package/dist/examples/config/default/default.config.js +0 -6
- package/dist/examples/config/plugins/plugins.config.d.ts +0 -5
- package/dist/examples/config/plugins/plugins.config.js +0 -4
- package/dist/examples/config-reload.d.ts +0 -2
- package/dist/examples/config-reload.js +0 -49
- package/dist/examples/default-config-usage.d.ts +0 -17
- package/dist/examples/default-config-usage.js +0 -47
- package/dist/examples/delegated-inference/consumer-profiled.d.ts +0 -2
- package/dist/examples/delegated-inference/consumer-profiled.js +0 -67
- package/dist/examples/download-with-blind-relays.d.ts +0 -2
- package/dist/examples/download-with-blind-relays.js +0 -49
- package/dist/examples/embed-p2p.d.ts +0 -2
- package/dist/examples/embed-p2p.js +0 -54
- package/dist/examples/llamacpp-p2p.d.ts +0 -2
- package/dist/examples/llamacpp-sharded.d.ts +0 -2
- package/dist/examples/llamacpp-sharded.js +0 -53
- package/dist/examples/logging-file-transport.d.ts +0 -2
- package/dist/examples/logging-streaming.d.ts +0 -2
- package/dist/examples/logging-streaming.js +0 -75
- package/dist/examples/mcp-websearch.d.ts +0 -13
- package/dist/examples/mcp-websearch.js +0 -176
- package/dist/examples/ocr-fasttext.d.ts +0 -2
- package/dist/examples/ocr-fasttext.js +0 -52
- package/dist/examples/plugins.d.ts +0 -14
- package/dist/examples/plugins.js +0 -129
- package/dist/examples/profiling/basic.d.ts +0 -2
- package/dist/examples/profiling/basic.js +0 -71
- package/dist/examples/profiling/per-call.d.ts +0 -2
- package/dist/examples/profiling/per-call.js +0 -30
- package/dist/examples/quickstart.d.ts +0 -2
- package/dist/examples/quickstart.js +0 -28
- package/dist/examples/rag/rag-hyperdb/cancellation.d.ts +0 -2
- package/dist/examples/rag/rag-hyperdb/cancellation.js +0 -75
- package/dist/examples/rag/rag-hyperdb/ingest.d.ts +0 -2
- package/dist/examples/rag/rag-hyperdb/pipeline.d.ts +0 -2
- package/dist/examples/rag/rag-hyperdb/pipeline.js +0 -74
- package/dist/examples/rag/rag-hyperdb/workspaces.d.ts +0 -2
- package/dist/examples/rag/rag-hyperdb/workspaces.js +0 -178
- package/dist/examples/registry-query.d.ts +0 -2
- package/dist/examples/registry-query.js +0 -87
- package/dist/examples/seed-p2p.d.ts +0 -2
- package/dist/examples/transcription/parakeet-ctc-filesystem.d.ts +0 -2
- package/dist/examples/transcription/parakeet-ctc-filesystem.js +0 -40
- package/dist/examples/transcription/parakeet-microphone-record.d.ts +0 -2
- package/dist/examples/transcription/parakeet-microphone-record.js +0 -95
- package/dist/examples/transcription/parakeet-sortformer.d.ts +0 -2
- package/dist/examples/transcription/parakeet-sortformer.js +0 -115
- package/dist/examples/transcription/parakeet-tdt-filesystem.d.ts +0 -2
- package/dist/examples/transcription/parakeet-tdt-filesystem.js +0 -44
- package/dist/examples/transcription/whispercpp-filesystem.js +0 -69
- package/dist/examples/transcription/whispercpp-prompt.d.ts +0 -2
- package/dist/examples/transcription/whispercpp-prompt.js +0 -67
- package/dist/examples/translation/translation-bergamot-batch.d.ts +0 -2
- package/dist/examples/translation/translation-bergamot-batch.js +0 -49
- package/dist/examples/translation/translation-bergamot-pivot.d.ts +0 -2
- package/dist/examples/translation/translation-bergamot-pivot.js +0 -73
- package/dist/examples/translation/translation-bergamot.d.ts +0 -2
- package/dist/examples/translation/translation-bergamot.js +0 -39
- package/dist/examples/translation/translation-llm-afriquegemma.d.ts +0 -2
- package/dist/examples/translation/translation-llm-afriquegemma.js +0 -39
- package/dist/examples/tts/chatterbox.d.ts +0 -2
- package/dist/examples/tts/chatterbox.js +0 -59
- package/dist/examples/tts/supertonic.d.ts +0 -2
- package/dist/examples/tts/supertonic.js +0 -51
- package/dist/examples/tts/utils.d.ts +0 -17
- package/dist/expo/plugins/resolve-sdk-package-dir.d.ts +0 -15
- package/dist/expo/plugins/resolve-sdk-package-dir.js +0 -31
- package/dist/expo/plugins/withAndroidArchitecture.d.ts +0 -8
- package/dist/expo/plugins/withAndroidArchitecture.js +0 -52
- package/dist/expo/plugins/withAndroidNdkVersion.d.ts +0 -8
- package/dist/expo/plugins/withAndroidNdkVersion.js +0 -31
- package/dist/expo/plugins/withDeviceInfo.d.ts +0 -10
- package/dist/expo/plugins/withDeviceInfo.js +0 -48
- package/dist/logging/addon.d.ts +0 -6
- package/dist/logging/addon.js +0 -75
- package/dist/logging/client-logger.d.ts +0 -3
- package/dist/logging/client-logger.js +0 -24
- package/dist/logging/namespaces.d.ts +0 -6
- package/dist/logging/namespaces.js +0 -6
- package/dist/logging/registry.d.ts +0 -31
- package/dist/logging/registry.js +0 -62
- package/dist/logging/server-logger.d.ts +0 -3
- package/dist/logging/server-logger.js +0 -16
- package/dist/models/registry/models.d.ts +0 -10417
- package/dist/models/registry/models.js +0 -10757
- package/dist/models/update-models/codegen.d.ts +0 -3
- package/dist/models/update-models/codegen.js +0 -135
- package/dist/models/update-models/history.d.ts +0 -24
- package/dist/models/update-models/history.js +0 -107
- package/dist/models/update-models/index.d.ts +0 -2
- package/dist/models/update-models/index.js +0 -125
- package/dist/models/update-models/naming.d.ts +0 -4
- package/dist/models/update-models/naming.js +0 -370
- package/dist/models/update-models/processing.d.ts +0 -8
- package/dist/models/update-models/processing.js +0 -67
- package/dist/models/update-models/registry.d.ts +0 -4
- package/dist/models/update-models/registry.js +0 -67
- package/dist/models/update-models/shards.d.ts +0 -4
- package/dist/models/update-models/shards.js +0 -57
- package/dist/models/update-models/types.d.ts +0 -60
- package/dist/models/update-models/types.js +0 -1
- package/dist/models/update-models/utils.d.ts +0 -3
- package/dist/models/update-models/utils.js +0 -21
- package/dist/pear/pre.d.ts +0 -18
- package/dist/pear/pre.js +0 -433
- package/dist/profiling/aggregator.d.ts +0 -15
- package/dist/profiling/aggregator.js +0 -100
- package/dist/profiling/clock.d.ts +0 -12
- package/dist/profiling/clock.js +0 -51
- package/dist/profiling/controller.d.ts +0 -33
- package/dist/profiling/controller.js +0 -123
- package/dist/profiling/envelope.d.ts +0 -10
- package/dist/profiling/envelope.js +0 -36
- package/dist/profiling/events.d.ts +0 -20
- package/dist/profiling/events.js +0 -37
- package/dist/profiling/exporters.d.ts +0 -10
- package/dist/profiling/exporters.js +0 -236
- package/dist/profiling/index.d.ts +0 -36
- package/dist/profiling/index.js +0 -31
- package/dist/profiling/ring-buffer.d.ts +0 -19
- package/dist/profiling/ring-buffer.js +0 -83
- package/dist/profiling/types.d.ts +0 -47
- package/dist/profiling/types.js +0 -1
- package/dist/schemas/archive.d.ts +0 -9
- package/dist/schemas/archive.js +0 -17
- package/dist/schemas/engine-addon-map.d.ts +0 -5
- package/dist/schemas/engine-addon-map.js +0 -52
- package/dist/schemas/get-model-info.d.ts +0 -120
- package/dist/schemas/get-model-info.js +0 -58
- package/dist/schemas/heartbeat.d.ts +0 -17
- package/dist/schemas/heartbeat.js +0 -10
- package/dist/schemas/json-schema.d.ts +0 -16
- package/dist/schemas/json-schema.js +0 -2
- package/dist/schemas/mcp-adapter.d.ts +0 -47
- package/dist/schemas/mcp-adapter.js +0 -1
- package/dist/schemas/model-src-utils.d.ts +0 -148
- package/dist/schemas/model-src-utils.js +0 -35
- package/dist/schemas/model-types.d.ts +0 -183
- package/dist/schemas/model-types.js +0 -168
- package/dist/schemas/ocr.d.ts +0 -125
- package/dist/schemas/ocr.js +0 -57
- package/dist/schemas/path-validation.d.ts +0 -10
- package/dist/schemas/path-validation.js +0 -22
- package/dist/schemas/plugin.d.ts +0 -226
- package/dist/schemas/plugin.js +0 -158
- package/dist/schemas/profiling.d.ts +0 -105
- package/dist/schemas/profiling.js +0 -66
- package/dist/schemas/registry.d.ts +0 -356
- package/dist/schemas/registry.js +0 -93
- package/dist/schemas/reload-config.d.ts +0 -476
- package/dist/schemas/reload-config.js +0 -44
- package/dist/schemas/runtime-context.d.ts +0 -19
- package/dist/schemas/runtime-context.js +0 -7
- package/dist/schemas/sdk-config.d.ts +0 -2973
- package/dist/schemas/sdk-config.js +0 -136
- package/dist/schemas/sdk-errors-client.d.ts +0 -31
- package/dist/schemas/sdk-errors-client.js +0 -143
- package/dist/schemas/sdk-errors-registry.d.ts +0 -6
- package/dist/schemas/sdk-errors-registry.js +0 -8
- package/dist/schemas/sdk-errors-server.d.ts +0 -89
- package/dist/schemas/sdk-errors-server.js +0 -451
- package/dist/schemas/shard.d.ts +0 -21
- package/dist/schemas/shard.js +0 -17
- package/dist/schemas/tools.d.ts +0 -65
- package/dist/schemas/tools.js +0 -43
- package/dist/schemas/transcription-config.d.ts +0 -383
- package/dist/schemas/transcription-config.js +0 -95
- package/dist/scripts/run-security-tests-bare.d.ts +0 -2
- package/dist/scripts/run-security-tests-bare.js +0 -78
- package/dist/scripts/run-security-tests.d.ts +0 -2
- package/dist/scripts/run-security-tests.js +0 -22
- package/dist/scripts/run-unit-tests.d.ts +0 -2
- package/dist/scripts/run-unit-tests.js +0 -17
- package/dist/server/bare/ops/embed.d.ts +0 -12
- package/dist/server/bare/ops/load-model.d.ts +0 -9
- package/dist/server/bare/ops/load-model.js +0 -85
- package/dist/server/bare/ops/transcribe.d.ts +0 -3
- package/dist/server/bare/ops/transcribe.js +0 -75
- package/dist/server/bare/ops/translate.d.ts +0 -5
- package/dist/server/bare/ops/unload-model.js +0 -41
- package/dist/server/bare/plugins/index.d.ts +0 -8
- package/dist/server/bare/plugins/index.js +0 -7
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.d.ts +0 -6
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.js +0 -34
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +0 -220
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +0 -155
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +0 -54
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +0 -87
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +0 -367
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +0 -201
- package/dist/server/bare/plugins/onnx-ocr/ops/ocr-stream.d.ts +0 -10
- package/dist/server/bare/plugins/onnx-ocr/ops/ocr-stream.js +0 -110
- package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +0 -86
- package/dist/server/bare/plugins/onnx-ocr/plugin.js +0 -117
- package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +0 -373
- package/dist/server/bare/plugins/onnx-tts/plugin.js +0 -182
- package/dist/server/bare/plugins/onnx-tts/wav-helper.d.ts +0 -14
- package/dist/server/bare/plugins/onnx-tts/wav-helper.js +0 -107
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +0 -317
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +0 -154
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +0 -237
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +0 -86
- package/dist/server/bare/rag-hyperdb/handlers/chunk.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/chunk.js +0 -7
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.js +0 -9
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.js +0 -14
- package/dist/server/bare/rag-hyperdb/handlers/ingest.d.ts +0 -9
- package/dist/server/bare/rag-hyperdb/handlers/ingest.js +0 -18
- package/dist/server/bare/rag-hyperdb/handlers/list-workspaces.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/list-workspaces.js +0 -4
- package/dist/server/bare/rag-hyperdb/handlers/reindex.d.ts +0 -9
- package/dist/server/bare/rag-hyperdb/handlers/reindex.js +0 -16
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.d.ts +0 -7
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +0 -39
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.d.ts +0 -15
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +0 -136
- package/dist/server/bare/registry/config-registry.d.ts +0 -14
- package/dist/server/bare/registry/config-registry.js +0 -82
- package/dist/server/bare/registry/model-config-registry.d.ts +0 -4
- package/dist/server/bare/registry/model-config-registry.js +0 -15
- package/dist/server/bare/registry/model-config-utils.d.ts +0 -15
- package/dist/server/bare/registry/model-config-utils.js +0 -112
- package/dist/server/bare/registry/registry-client.d.ts +0 -5
- package/dist/server/bare/registry/registry-client.js +0 -37
- package/dist/server/bare/registry/runtime-context-registry.d.ts +0 -7
- package/dist/server/bare/registry/runtime-context-registry.js +0 -26
- package/dist/server/bare/utils/audio-input.d.ts +0 -10
- package/dist/server/bare/utils/audio-input.js +0 -33
- package/dist/server/bare/utils/loader-adapter.d.ts +0 -7
- package/dist/server/bare/utils/loader-adapter.js +0 -9
- package/dist/server/env.d.ts +0 -22
- package/dist/server/env.js +0 -57
- package/dist/server/plugins/index.d.ts +0 -2
- package/dist/server/plugins/index.js +0 -1
- package/dist/server/plugins/registry.d.ts +0 -9
- package/dist/server/plugins/registry.js +0 -79
- package/dist/server/rpc/delegate-transport.d.ts +0 -19
- package/dist/server/rpc/delegate-transport.js +0 -236
- package/dist/server/rpc/delegate-utils.d.ts +0 -2
- package/dist/server/rpc/delegate-utils.js +0 -5
- package/dist/server/rpc/handler-registry.d.ts +0 -3
- package/dist/server/rpc/handler-registry.js +0 -113
- package/dist/server/rpc/handler-utils.d.ts +0 -23
- package/dist/server/rpc/handler-utils.js +0 -170
- package/dist/server/rpc/handlers/cancel-delegated.d.ts +0 -4
- package/dist/server/rpc/handlers/cancel-delegated.js +0 -71
- package/dist/server/rpc/handlers/get-model-info.d.ts +0 -3
- package/dist/server/rpc/handlers/get-model-info.js +0 -164
- package/dist/server/rpc/handlers/heartbeat-delegated.d.ts +0 -4
- package/dist/server/rpc/handlers/heartbeat-delegated.js +0 -32
- package/dist/server/rpc/handlers/heartbeat.d.ts +0 -3
- package/dist/server/rpc/handlers/heartbeat.js +0 -3
- package/dist/server/rpc/handlers/load-model/download-stats.d.ts +0 -6
- package/dist/server/rpc/handlers/load-model/download-stats.js +0 -87
- package/dist/server/rpc/handlers/load-model/handler.js +0 -187
- package/dist/server/rpc/handlers/load-model/registry.d.ts +0 -11
- package/dist/server/rpc/handlers/load-model/registry.js +0 -548
- package/dist/server/rpc/handlers/load-model/types.d.ts +0 -29
- package/dist/server/rpc/handlers/load-model/types.js +0 -1
- package/dist/server/rpc/handlers/ocr-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/ocr-stream.js +0 -4
- package/dist/server/rpc/handlers/plugin-dispatch.d.ts +0 -15
- package/dist/server/rpc/handlers/plugin-dispatch.js +0 -59
- package/dist/server/rpc/handlers/plugin-invoke.d.ts +0 -4
- package/dist/server/rpc/handlers/plugin-invoke.js +0 -92
- package/dist/server/rpc/handlers/registry.d.ts +0 -5
- package/dist/server/rpc/handlers/registry.js +0 -157
- package/dist/server/rpc/handlers/unload-model-delegated.d.ts +0 -3
- package/dist/server/rpc/handlers/unload-model-delegated.js +0 -32
- package/dist/server/rpc/profiling/context.d.ts +0 -18
- package/dist/server/rpc/profiling/context.js +0 -38
- package/dist/server/rpc/profiling/delegation-profiler.d.ts +0 -32
- package/dist/server/rpc/profiling/delegation-profiler.js +0 -154
- package/dist/server/rpc/profiling/index.d.ts +0 -5
- package/dist/server/rpc/profiling/index.js +0 -4
- package/dist/server/rpc/profiling/operation-metrics.d.ts +0 -25
- package/dist/server/rpc/profiling/operation-metrics.js +0 -199
- package/dist/server/rpc/profiling/operation-wrappers.d.ts +0 -18
- package/dist/server/rpc/profiling/operation-wrappers.js +0 -124
- package/dist/server/rpc/profiling/profiler.d.ts +0 -13
- package/dist/server/rpc/profiling/profiler.js +0 -97
- package/dist/server/utils/archive.d.ts +0 -4
- package/dist/server/utils/archive.js +0 -179
- package/dist/server/utils/checksum.d.ts +0 -4
- package/dist/server/utils/checksum.js +0 -31
- package/dist/server/utils/config-transform.d.ts +0 -3
- package/dist/server/utils/config-transform.js +0 -23
- package/dist/server/utils/formatting.d.ts +0 -19
- package/dist/server/utils/formatting.js +0 -61
- package/dist/server/utils/gguf-tensor-extractor.d.ts +0 -15
- package/dist/server/utils/gguf-tensor-extractor.js +0 -314
- package/dist/server/utils/path-security.d.ts +0 -12
- package/dist/server/utils/path-security.js +0 -25
- package/dist/server/utils/shard-utils.d.ts +0 -48
- package/dist/server/utils/shard-utils.js +0 -125
- package/dist/server/utils/tool-integration.d.ts +0 -13
- package/dist/server/utils/tool-integration.js +0 -43
- package/dist/server/worker-core.d.ts +0 -6
- package/dist/server/worker-core.js +0 -88
- package/dist/utils/errors-base.d.ts +0 -3
- package/dist/utils/errors-base.js +0 -13
- package/dist/utils/errors-client.d.ts +0 -137
- package/dist/utils/errors-client.js +0 -240
- package/dist/utils/errors-server.d.ts +0 -236
- package/dist/utils/errors-server.js +0 -412
- package/dist/utils/global-singleton.d.ts +0 -2
- package/dist/utils/global-singleton.js +0 -10
- package/dist/utils/mcp-adapter.d.ts +0 -12
- package/dist/utils/mcp-adapter.js +0 -103
- package/dist/utils/object.d.ts +0 -2
- package/dist/utils/object.js +0 -3
- package/dist/utils/path-sanitize.d.ts +0 -17
- package/dist/utils/path-sanitize.js +0 -54
- package/dist/utils/tool-helpers.d.ts +0 -25
- package/dist/utils/tool-helpers.js +0 -112
- package/expo/plugins/patches/android-link.mjs +0 -63
- package/expo/plugins/patches/ios-link.mjs +0 -63
- /package/dist/examples/{seed-p2p.js → seed-hyperdrive.js} +0 -0
- /package/dist/examples/{transcription/whispercpp-filesystem.d.ts → whispercpp-filesystem.d.ts} +0 -0
- /package/dist/examples/{transcription/whispercpp-microphone-record.d.ts → whispercpp-microphone-record.d.ts} +0 -0
- /package/dist/models/{registry → hyperdrive}/index.d.ts +0 -0
- /package/dist/server/bare/{ops → addons}/cancel.d.ts +0 -0
- /package/dist/server/bare/{plugins/onnx-tts/ops → addons/tts/handlers}/text-to-speech.d.ts +0 -0
- /package/dist/server/bare/{ops → addons}/unload-model.d.ts +0 -0
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Declarative extraction of operation-level metrics from request/response data.
|
|
3
|
-
* Used by operation wrappers to capture handler-specific profiling events.
|
|
4
|
-
*/
|
|
5
|
-
const metricsRegistry = new Map();
|
|
6
|
-
function extractDownloadStatsGauges(stats, gauges) {
|
|
7
|
-
if (stats?.downloadTimeMs !== undefined) {
|
|
8
|
-
gauges["downloadTime"] = stats.downloadTimeMs;
|
|
9
|
-
}
|
|
10
|
-
if (stats?.totalBytesDownloaded !== undefined) {
|
|
11
|
-
gauges["totalBytesDownloaded"] = stats.totalBytesDownloaded;
|
|
12
|
-
}
|
|
13
|
-
if (stats?.downloadSpeedBps !== undefined) {
|
|
14
|
-
gauges["downloadSpeedBps"] = stats.downloadSpeedBps;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export function registerOperationMetrics(config) {
|
|
18
|
-
metricsRegistry.set(config.op, config);
|
|
19
|
-
}
|
|
20
|
-
export function buildOperationEvent(op, profileId, ts, executionMs, request, finalResponse, ttfb) {
|
|
21
|
-
const config = metricsRegistry.get(op);
|
|
22
|
-
if (!config) {
|
|
23
|
-
return {
|
|
24
|
-
ts,
|
|
25
|
-
op,
|
|
26
|
-
kind: "handler",
|
|
27
|
-
profileId,
|
|
28
|
-
ms: executionMs,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const gauges = {};
|
|
32
|
-
if (ttfb !== undefined) {
|
|
33
|
-
gauges["ttfb"] = ttfb;
|
|
34
|
-
}
|
|
35
|
-
if (config.fromRequest && request) {
|
|
36
|
-
const extracted = config.fromRequest(request);
|
|
37
|
-
if (extracted)
|
|
38
|
-
Object.assign(gauges, extracted);
|
|
39
|
-
}
|
|
40
|
-
if (config.fromFinalChunk && finalResponse) {
|
|
41
|
-
const extracted = config.fromFinalChunk(finalResponse);
|
|
42
|
-
if (extracted)
|
|
43
|
-
Object.assign(gauges, extracted);
|
|
44
|
-
}
|
|
45
|
-
if (config.fromResult && finalResponse) {
|
|
46
|
-
const extracted = config.fromResult(finalResponse);
|
|
47
|
-
if (extracted)
|
|
48
|
-
Object.assign(gauges, extracted);
|
|
49
|
-
}
|
|
50
|
-
const requestTags = config.getTags?.(request);
|
|
51
|
-
const resultTags = config.getTagsFromResult?.(finalResponse);
|
|
52
|
-
const tags = { ...requestTags, ...resultTags };
|
|
53
|
-
const hasGauges = Object.keys(gauges).length > 0;
|
|
54
|
-
const hasTags = Object.keys(tags).length > 0;
|
|
55
|
-
const event = {
|
|
56
|
-
ts,
|
|
57
|
-
op: config.op,
|
|
58
|
-
kind: config.kind,
|
|
59
|
-
profileId,
|
|
60
|
-
ms: executionMs,
|
|
61
|
-
};
|
|
62
|
-
if (hasGauges) {
|
|
63
|
-
event.gauges = gauges;
|
|
64
|
-
}
|
|
65
|
-
if (hasTags) {
|
|
66
|
-
event.tags = tags;
|
|
67
|
-
}
|
|
68
|
-
return event;
|
|
69
|
-
}
|
|
70
|
-
registerOperationMetrics({
|
|
71
|
-
op: "completionStream",
|
|
72
|
-
kind: "handler",
|
|
73
|
-
getTags: (req) => (req.modelId ? { modelId: req.modelId } : {}),
|
|
74
|
-
fromFinalChunk: (res) => {
|
|
75
|
-
if (!res.stats)
|
|
76
|
-
return undefined;
|
|
77
|
-
const gauges = {};
|
|
78
|
-
if (res.stats.timeToFirstToken !== undefined)
|
|
79
|
-
gauges["timeToFirstToken"] = res.stats.timeToFirstToken;
|
|
80
|
-
if (res.stats.tokensPerSecond !== undefined)
|
|
81
|
-
gauges["tokensPerSecond"] = res.stats.tokensPerSecond;
|
|
82
|
-
if (res.stats.cacheTokens !== undefined)
|
|
83
|
-
gauges["cacheTokens"] = res.stats.cacheTokens;
|
|
84
|
-
return Object.keys(gauges).length > 0 ? gauges : undefined;
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
registerOperationMetrics({
|
|
88
|
-
op: "translate",
|
|
89
|
-
kind: "handler",
|
|
90
|
-
getTags: (req) => (req.modelId ? { modelId: req.modelId } : {}),
|
|
91
|
-
fromFinalChunk: (res) => {
|
|
92
|
-
if (!res.stats)
|
|
93
|
-
return undefined;
|
|
94
|
-
const gauges = {};
|
|
95
|
-
if (res.stats.processedTokens !== undefined)
|
|
96
|
-
gauges["processedTokens"] = res.stats.processedTokens;
|
|
97
|
-
if (res.stats.processingTime !== undefined)
|
|
98
|
-
gauges["processingTime"] = res.stats.processingTime;
|
|
99
|
-
return Object.keys(gauges).length > 0 ? gauges : undefined;
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
registerOperationMetrics({
|
|
103
|
-
op: "transcribeStream",
|
|
104
|
-
kind: "handler",
|
|
105
|
-
getTags: (req) => (req.modelId ? { modelId: req.modelId } : {}),
|
|
106
|
-
});
|
|
107
|
-
registerOperationMetrics({
|
|
108
|
-
op: "textToSpeech",
|
|
109
|
-
kind: "handler",
|
|
110
|
-
getTags: (req) => (req.modelId ? { modelId: req.modelId } : {}),
|
|
111
|
-
});
|
|
112
|
-
registerOperationMetrics({
|
|
113
|
-
op: "embed",
|
|
114
|
-
kind: "handler",
|
|
115
|
-
getTags: (req) => (req.modelId ? { modelId: req.modelId } : {}),
|
|
116
|
-
});
|
|
117
|
-
registerOperationMetrics({
|
|
118
|
-
op: "ocrStream",
|
|
119
|
-
kind: "handler",
|
|
120
|
-
getTags: (req) => (req.modelId ? { modelId: req.modelId } : {}),
|
|
121
|
-
fromFinalChunk: (res) => {
|
|
122
|
-
if (!res.stats)
|
|
123
|
-
return undefined;
|
|
124
|
-
const gauges = {};
|
|
125
|
-
if (res.stats.detectionTime !== undefined)
|
|
126
|
-
gauges["detectionTime"] = res.stats.detectionTime;
|
|
127
|
-
if (res.stats.recognitionTime !== undefined)
|
|
128
|
-
gauges["recognitionTime"] = res.stats.recognitionTime;
|
|
129
|
-
if (res.stats.totalTime !== undefined)
|
|
130
|
-
gauges["totalTime"] = res.stats.totalTime;
|
|
131
|
-
return Object.keys(gauges).length > 0 ? gauges : undefined;
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
registerOperationMetrics({
|
|
135
|
-
op: "pluginInvoke",
|
|
136
|
-
kind: "handler",
|
|
137
|
-
getTags: (req) => {
|
|
138
|
-
const tags = {};
|
|
139
|
-
if (req.modelId)
|
|
140
|
-
tags["modelId"] = req.modelId;
|
|
141
|
-
if (req.handler)
|
|
142
|
-
tags["handler"] = req.handler;
|
|
143
|
-
return tags;
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
registerOperationMetrics({
|
|
147
|
-
op: "pluginInvokeStream",
|
|
148
|
-
kind: "handler",
|
|
149
|
-
getTags: (req) => {
|
|
150
|
-
const tags = {};
|
|
151
|
-
if (req.modelId)
|
|
152
|
-
tags["modelId"] = req.modelId;
|
|
153
|
-
if (req.handler)
|
|
154
|
-
tags["handler"] = req.handler;
|
|
155
|
-
return tags;
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
registerOperationMetrics({
|
|
159
|
-
op: "loadModel",
|
|
160
|
-
kind: "handler",
|
|
161
|
-
getTags: (req) => (req.modelType ? { modelType: req.modelType } : {}),
|
|
162
|
-
getTagsFromResult: (res) => {
|
|
163
|
-
const sourceType = res.__profilingMeta?.sourceType;
|
|
164
|
-
return sourceType ? { sourceType } : undefined;
|
|
165
|
-
},
|
|
166
|
-
fromResult: (res) => {
|
|
167
|
-
const meta = res.__profilingMeta;
|
|
168
|
-
if (!meta)
|
|
169
|
-
return undefined;
|
|
170
|
-
const gauges = {};
|
|
171
|
-
extractDownloadStatsGauges(meta.downloadStats, gauges);
|
|
172
|
-
if (meta.modelInitializationTimeMs !== undefined) {
|
|
173
|
-
gauges["modelInitializationTime"] = meta.modelInitializationTimeMs;
|
|
174
|
-
}
|
|
175
|
-
if (meta.totalLoadTimeMs !== undefined) {
|
|
176
|
-
gauges["totalLoadTime"] = meta.totalLoadTimeMs;
|
|
177
|
-
}
|
|
178
|
-
return Object.keys(gauges).length > 0 ? gauges : undefined;
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
registerOperationMetrics({
|
|
182
|
-
op: "downloadAsset",
|
|
183
|
-
kind: "handler",
|
|
184
|
-
getTagsFromResult: (res) => {
|
|
185
|
-
const sourceType = res.__profilingMeta?.sourceType;
|
|
186
|
-
return sourceType ? { sourceType } : undefined;
|
|
187
|
-
},
|
|
188
|
-
fromResult: (res) => {
|
|
189
|
-
const meta = res.__profilingMeta;
|
|
190
|
-
if (!meta)
|
|
191
|
-
return undefined;
|
|
192
|
-
const gauges = {};
|
|
193
|
-
extractDownloadStatsGauges(meta.downloadStats, gauges);
|
|
194
|
-
if (meta.totalDownloadTimeMs !== undefined) {
|
|
195
|
-
gauges["totalDownloadTime"] = meta.totalDownloadTimeMs;
|
|
196
|
-
}
|
|
197
|
-
return Object.keys(gauges).length > 0 ? gauges : undefined;
|
|
198
|
-
},
|
|
199
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic wrappers for profiling handler execution.
|
|
3
|
-
* Used to wrap dispatch/invoke functions with timing capture.
|
|
4
|
-
*/
|
|
5
|
-
import { type PerCallProfiling } from "../../../schemas/index";
|
|
6
|
-
export interface ProfiledReplyOptions<TRequest> {
|
|
7
|
-
op: string;
|
|
8
|
-
request: TRequest;
|
|
9
|
-
perCall?: PerCallProfiling;
|
|
10
|
-
}
|
|
11
|
-
export interface ProfiledStreamOptions<TRequest> {
|
|
12
|
-
op: string;
|
|
13
|
-
request: TRequest;
|
|
14
|
-
perCall?: PerCallProfiling;
|
|
15
|
-
}
|
|
16
|
-
export declare function profileReplyHandler<TRequest, TResponse>(options: ProfiledReplyOptions<TRequest>, handler: () => Promise<TResponse>): Promise<TResponse>;
|
|
17
|
-
export declare function profileStreamHandler<TRequest, TResponse>(options: ProfiledStreamOptions<TRequest>, handler: () => AsyncGenerator<TResponse>): AsyncGenerator<TResponse>;
|
|
18
|
-
//# sourceMappingURL=operation-wrappers.d.ts.map
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic wrappers for profiling handler execution.
|
|
3
|
-
* Used to wrap dispatch/invoke functions with timing capture.
|
|
4
|
-
*/
|
|
5
|
-
import { PROFILING_KEY, } from "../../../schemas/index.js";
|
|
6
|
-
import { nowMs, generateProfileId } from "../../../profiling/clock.js";
|
|
7
|
-
import { record, shouldProfile } from "../../../profiling/controller.js";
|
|
8
|
-
import { buildOperationEvent } from "./operation-metrics.js";
|
|
9
|
-
function getRequestProfilingMeta(request) {
|
|
10
|
-
if (!request || typeof request !== "object") {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
const meta = request[PROFILING_KEY];
|
|
14
|
-
if (!meta || typeof meta !== "object") {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
return meta;
|
|
18
|
-
}
|
|
19
|
-
function resolvePerCallProfiling(options) {
|
|
20
|
-
if (options.perCall) {
|
|
21
|
-
return options.perCall;
|
|
22
|
-
}
|
|
23
|
-
const meta = getRequestProfilingMeta(options.request);
|
|
24
|
-
if (!meta) {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
if (meta.enabled === false) {
|
|
28
|
-
return { enabled: false };
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
enabled: true,
|
|
32
|
-
includeServerBreakdown: meta.includeServer,
|
|
33
|
-
mode: meta.mode,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function recordOperationEvent(params) {
|
|
37
|
-
const event = buildOperationEvent(params.options.op, params.profileId, params.startTs, params.executionMs, params.options.request, params.finalResponse, params.ttfb);
|
|
38
|
-
if (!event)
|
|
39
|
-
return;
|
|
40
|
-
if (params.errored) {
|
|
41
|
-
event.tags = { ...event.tags, error: "true" };
|
|
42
|
-
}
|
|
43
|
-
if (params.count !== undefined && params.count > 0) {
|
|
44
|
-
event.count = params.count;
|
|
45
|
-
}
|
|
46
|
-
record(event);
|
|
47
|
-
}
|
|
48
|
-
export async function profileReplyHandler(options, handler) {
|
|
49
|
-
const perCall = resolvePerCallProfiling(options);
|
|
50
|
-
if (!shouldProfile(options.op, perCall)) {
|
|
51
|
-
return handler();
|
|
52
|
-
}
|
|
53
|
-
const profileId = generateProfileId();
|
|
54
|
-
const startTs = nowMs();
|
|
55
|
-
try {
|
|
56
|
-
const result = await handler();
|
|
57
|
-
const executionMs = nowMs() - startTs;
|
|
58
|
-
recordOperationEvent({
|
|
59
|
-
options,
|
|
60
|
-
profileId,
|
|
61
|
-
startTs,
|
|
62
|
-
executionMs,
|
|
63
|
-
finalResponse: result,
|
|
64
|
-
});
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
const executionMs = nowMs() - startTs;
|
|
69
|
-
recordOperationEvent({
|
|
70
|
-
options,
|
|
71
|
-
profileId,
|
|
72
|
-
startTs,
|
|
73
|
-
executionMs,
|
|
74
|
-
errored: true,
|
|
75
|
-
});
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
export async function* profileStreamHandler(options, handler) {
|
|
80
|
-
const perCall = resolvePerCallProfiling(options);
|
|
81
|
-
if (!shouldProfile(options.op, perCall)) {
|
|
82
|
-
yield* handler();
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const profileId = generateProfileId();
|
|
86
|
-
const startTs = nowMs();
|
|
87
|
-
let ttfb;
|
|
88
|
-
let lastChunk;
|
|
89
|
-
let chunkCount = 0;
|
|
90
|
-
try {
|
|
91
|
-
for await (const chunk of handler()) {
|
|
92
|
-
if (ttfb === undefined) {
|
|
93
|
-
ttfb = nowMs() - startTs;
|
|
94
|
-
}
|
|
95
|
-
chunkCount++;
|
|
96
|
-
lastChunk = chunk;
|
|
97
|
-
yield chunk;
|
|
98
|
-
}
|
|
99
|
-
const executionMs = nowMs() - startTs;
|
|
100
|
-
recordOperationEvent({
|
|
101
|
-
options,
|
|
102
|
-
profileId,
|
|
103
|
-
startTs,
|
|
104
|
-
executionMs,
|
|
105
|
-
finalResponse: lastChunk,
|
|
106
|
-
ttfb,
|
|
107
|
-
count: chunkCount,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
const executionMs = nowMs() - startTs;
|
|
112
|
-
recordOperationEvent({
|
|
113
|
-
options,
|
|
114
|
-
profileId,
|
|
115
|
-
startTs,
|
|
116
|
-
executionMs,
|
|
117
|
-
finalResponse: lastChunk,
|
|
118
|
-
ttfb,
|
|
119
|
-
count: chunkCount,
|
|
120
|
-
errored: true,
|
|
121
|
-
});
|
|
122
|
-
throw error;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type Response, type ProfilingRequestMeta } from "../../../schemas/index";
|
|
2
|
-
import { type ServerProfilingContext } from "./context";
|
|
3
|
-
export type ServerProfiler = {
|
|
4
|
-
markRequestParsed: (ms: number) => void;
|
|
5
|
-
markRequestValidated: (ms: number) => void;
|
|
6
|
-
startHandler: () => void;
|
|
7
|
-
endHandler: () => void;
|
|
8
|
-
serialize: (response?: Response, final?: boolean) => string;
|
|
9
|
-
serializeError: (json: string) => string;
|
|
10
|
-
getContext: () => ServerProfilingContext | undefined;
|
|
11
|
-
};
|
|
12
|
-
export declare function createServerProfiler(meta?: ProfilingRequestMeta): ServerProfiler;
|
|
13
|
-
//# sourceMappingURL=profiler.d.ts.map
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { nowMs } from "../../../profiling/index.js";
|
|
2
|
-
import { responseSchema, DELEGATION_BREAKDOWN_KEY, OPERATION_EVENT_KEY, PROFILING_TRAILER_KEY, } from "../../../schemas/index.js";
|
|
3
|
-
import { createProfilingContext, injectProfilingIntoString, } from "./context.js";
|
|
4
|
-
const noopProfiler = {
|
|
5
|
-
markRequestParsed: () => { },
|
|
6
|
-
markRequestValidated: () => { },
|
|
7
|
-
startHandler: () => { },
|
|
8
|
-
endHandler: () => { },
|
|
9
|
-
serialize: (response) => {
|
|
10
|
-
if (!response)
|
|
11
|
-
return "";
|
|
12
|
-
const extended = response;
|
|
13
|
-
const delegation = extended[DELEGATION_BREAKDOWN_KEY];
|
|
14
|
-
const operation = extended[OPERATION_EVENT_KEY];
|
|
15
|
-
const json = JSON.stringify(responseSchema.parse(response));
|
|
16
|
-
if (delegation || operation) {
|
|
17
|
-
const opts = {};
|
|
18
|
-
if (delegation)
|
|
19
|
-
opts.delegation = delegation;
|
|
20
|
-
if (operation)
|
|
21
|
-
opts.operation = operation;
|
|
22
|
-
return injectProfilingIntoString(json, opts);
|
|
23
|
-
}
|
|
24
|
-
return json;
|
|
25
|
-
},
|
|
26
|
-
serializeError: (json) => json,
|
|
27
|
-
getContext: () => undefined,
|
|
28
|
-
};
|
|
29
|
-
function createActiveProfiler(meta) {
|
|
30
|
-
const ctx = createProfilingContext(meta);
|
|
31
|
-
let handlerStart = 0;
|
|
32
|
-
let handlerEnded = false;
|
|
33
|
-
let cachedDelegation;
|
|
34
|
-
let cachedOperation;
|
|
35
|
-
return {
|
|
36
|
-
markRequestParsed: (ms) => {
|
|
37
|
-
ctx.jsonParseMs = ms;
|
|
38
|
-
},
|
|
39
|
-
markRequestValidated: (ms) => {
|
|
40
|
-
ctx.zodValidationMs = ms;
|
|
41
|
-
},
|
|
42
|
-
startHandler: () => {
|
|
43
|
-
handlerStart = nowMs();
|
|
44
|
-
handlerEnded = false;
|
|
45
|
-
},
|
|
46
|
-
endHandler: () => {
|
|
47
|
-
if (handlerEnded)
|
|
48
|
-
return;
|
|
49
|
-
handlerEnded = true;
|
|
50
|
-
ctx.handlerExecutionMs = nowMs() - handlerStart;
|
|
51
|
-
},
|
|
52
|
-
serialize: (response, final = true) => {
|
|
53
|
-
if (!response) {
|
|
54
|
-
const opts = { ctx };
|
|
55
|
-
if (cachedDelegation)
|
|
56
|
-
opts.delegation = cachedDelegation;
|
|
57
|
-
if (cachedOperation)
|
|
58
|
-
opts.operation = cachedOperation;
|
|
59
|
-
return injectProfilingIntoString(`{"${PROFILING_TRAILER_KEY}":true}`, opts);
|
|
60
|
-
}
|
|
61
|
-
const extended = response;
|
|
62
|
-
const delegation = extended[DELEGATION_BREAKDOWN_KEY];
|
|
63
|
-
const operation = extended[OPERATION_EVENT_KEY];
|
|
64
|
-
if (delegation)
|
|
65
|
-
cachedDelegation = delegation;
|
|
66
|
-
if (operation)
|
|
67
|
-
cachedOperation = operation;
|
|
68
|
-
const zodStart = nowMs();
|
|
69
|
-
const validated = responseSchema.parse(response);
|
|
70
|
-
ctx.responseZodValidationMs =
|
|
71
|
-
(ctx.responseZodValidationMs ?? 0) + (nowMs() - zodStart);
|
|
72
|
-
const stringifyStart = nowMs();
|
|
73
|
-
const json = JSON.stringify(validated);
|
|
74
|
-
ctx.responseStringifyMs =
|
|
75
|
-
(ctx.responseStringifyMs ?? 0) + (nowMs() - stringifyStart);
|
|
76
|
-
if (final) {
|
|
77
|
-
const opts = { ctx };
|
|
78
|
-
if (delegation)
|
|
79
|
-
opts.delegation = delegation;
|
|
80
|
-
if (operation)
|
|
81
|
-
opts.operation = operation;
|
|
82
|
-
return injectProfilingIntoString(json, opts);
|
|
83
|
-
}
|
|
84
|
-
return json;
|
|
85
|
-
},
|
|
86
|
-
serializeError: (json) => injectProfilingIntoString(json, { ctx }),
|
|
87
|
-
getContext: () => ctx,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
export function createServerProfiler(meta) {
|
|
91
|
-
if (meta?.includeServer &&
|
|
92
|
-
typeof meta.id === "string" &&
|
|
93
|
-
meta.id.length > 0) {
|
|
94
|
-
return createActiveProfiler(meta);
|
|
95
|
-
}
|
|
96
|
-
return noopProfiler;
|
|
97
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function isArchiveUrl(url: string): boolean;
|
|
2
|
-
export declare function extractTarStream(archivePath: string, extractDir: string, useGunzip: boolean, signal?: AbortSignal): Promise<void>;
|
|
3
|
-
export declare function extractAndValidateShardedArchive(archivePath: string, extractDir: string, signal?: AbortSignal): Promise<string>;
|
|
4
|
-
//# sourceMappingURL=archive.d.ts.map
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { promises as fsPromises } from "bare-fs";
|
|
2
|
-
import path from "bare-path";
|
|
3
|
-
import fs from "bare-fs";
|
|
4
|
-
import { createGunzip } from "bare-zlib";
|
|
5
|
-
import tarStream from "tar-stream";
|
|
6
|
-
import { detectShardedModel, generateShardFilenames, extractTensorsFromShards, validateShardedModelCache, } from "./shard-utils.js";
|
|
7
|
-
import { ModelLoadFailedError, ArchiveExtractionFailedError, ArchiveUnsupportedTypeError, ArchiveMissingShardsError, DownloadCancelledError, } from "../../utils/errors-server.js";
|
|
8
|
-
import { isPathWithinBase } from "./path-security.js";
|
|
9
|
-
import { getServerLogger } from "../../logging/index.js";
|
|
10
|
-
import { SUPPORTED_ARCHIVE_EXTENSIONS, filenameToArchiveTypeSchema, } from "../../schemas/archive.js";
|
|
11
|
-
const logger = getServerLogger();
|
|
12
|
-
// Gzip magic bytes: 1f 8b 08
|
|
13
|
-
const GZIP_MAGIC_0 = 0x1f;
|
|
14
|
-
const GZIP_MAGIC_1 = 0x8b;
|
|
15
|
-
const GZIP_MAGIC_2 = 0x08;
|
|
16
|
-
export function isArchiveUrl(url) {
|
|
17
|
-
const filename = url.split("/").pop()?.split("?")[0]?.toLowerCase() || "";
|
|
18
|
-
return SUPPORTED_ARCHIVE_EXTENSIONS.some((ext) => filename.endsWith(ext));
|
|
19
|
-
}
|
|
20
|
-
// Whitelist of model file extensions to extract from archives
|
|
21
|
-
const ALLOWED_MODEL_EXTENSIONS = [".gguf", ".tensors.txt"];
|
|
22
|
-
function isModelFile(entryName) {
|
|
23
|
-
const basename = path.basename(entryName);
|
|
24
|
-
// Skip resource forks (._filename)
|
|
25
|
-
if (basename.startsWith("._")) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
return ALLOWED_MODEL_EXTENSIONS.some((ext) => basename.toLowerCase().endsWith(ext));
|
|
29
|
-
}
|
|
30
|
-
async function isGzip(archivePath) {
|
|
31
|
-
return new Promise((resolve, reject) => {
|
|
32
|
-
const stream = fs.createReadStream(archivePath, { start: 0, end: 2 });
|
|
33
|
-
const chunks = [];
|
|
34
|
-
stream.on("data", (chunk) => {
|
|
35
|
-
chunks.push(chunk);
|
|
36
|
-
});
|
|
37
|
-
stream.on("end", () => {
|
|
38
|
-
stream.destroy();
|
|
39
|
-
const buffer = Buffer.concat(chunks);
|
|
40
|
-
// Check for gzip magic bytes
|
|
41
|
-
const isGzipped = buffer[0] === GZIP_MAGIC_0 &&
|
|
42
|
-
buffer[1] === GZIP_MAGIC_1 &&
|
|
43
|
-
buffer[2] === GZIP_MAGIC_2;
|
|
44
|
-
resolve(isGzipped);
|
|
45
|
-
});
|
|
46
|
-
stream.on("error", reject);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
async function extractArchive(archivePath, extractDir, signal) {
|
|
50
|
-
const parseResult = filenameToArchiveTypeSchema.safeParse(archivePath);
|
|
51
|
-
const extensionType = parseResult.success ? parseResult.data : null;
|
|
52
|
-
if (!extensionType) {
|
|
53
|
-
throw new ArchiveUnsupportedTypeError(archivePath);
|
|
54
|
-
}
|
|
55
|
-
if (signal?.aborted) {
|
|
56
|
-
throw new DownloadCancelledError();
|
|
57
|
-
}
|
|
58
|
-
// Detect actual format from magic bytes (extension might be wrong)
|
|
59
|
-
const isGzipped = await isGzip(archivePath);
|
|
60
|
-
const actualType = isGzipped ? "tar.gz" : "tar";
|
|
61
|
-
if (actualType !== extensionType) {
|
|
62
|
-
logger.warn(`⚠️ Archive extension suggests ${extensionType} but content is ${actualType}`);
|
|
63
|
-
}
|
|
64
|
-
await fsPromises.mkdir(extractDir, { recursive: true });
|
|
65
|
-
await extractTarStream(archivePath, extractDir, isGzipped, signal);
|
|
66
|
-
}
|
|
67
|
-
export async function extractTarStream(archivePath, extractDir, useGunzip, signal) {
|
|
68
|
-
const extract = tarStream.extract();
|
|
69
|
-
const gunzip = useGunzip ? createGunzip() : null;
|
|
70
|
-
return new Promise((resolve, reject) => {
|
|
71
|
-
let aborted = false;
|
|
72
|
-
let readStream = null;
|
|
73
|
-
const cleanup = () => {
|
|
74
|
-
aborted = true;
|
|
75
|
-
readStream?.destroy();
|
|
76
|
-
gunzip?.destroy();
|
|
77
|
-
extract.destroy();
|
|
78
|
-
};
|
|
79
|
-
if (signal) {
|
|
80
|
-
signal.addEventListener("abort", () => {
|
|
81
|
-
cleanup();
|
|
82
|
-
reject(new DownloadCancelledError());
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
extract.on("entry", (header, stream, next) => {
|
|
86
|
-
if (aborted) {
|
|
87
|
-
stream.resume();
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if (!isModelFile(header.name)) {
|
|
91
|
-
stream.resume();
|
|
92
|
-
next();
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
// Prevent zip-slip: reject entries that escape extractDir (CWE-22)
|
|
96
|
-
const filePath = path.resolve(path.join(extractDir, header.name));
|
|
97
|
-
if (!isPathWithinBase(extractDir, filePath)) {
|
|
98
|
-
logger.warn(`⚠️ Skipping archive entry with path traversal: ${header.name}`);
|
|
99
|
-
stream.resume();
|
|
100
|
-
next();
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (header.type === "file") {
|
|
104
|
-
const dir = path.dirname(filePath);
|
|
105
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
106
|
-
const writeStream = fs.createWriteStream(filePath);
|
|
107
|
-
stream.pipe(writeStream);
|
|
108
|
-
writeStream.on("finish", next);
|
|
109
|
-
writeStream.on("error", reject);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
stream.on("end", next);
|
|
113
|
-
stream.resume();
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
extract.on("finish", resolve);
|
|
117
|
-
extract.on("error", reject);
|
|
118
|
-
if (gunzip) {
|
|
119
|
-
gunzip.on("error", reject);
|
|
120
|
-
}
|
|
121
|
-
readStream = fs.createReadStream(archivePath);
|
|
122
|
-
if (gunzip) {
|
|
123
|
-
readStream.pipe(gunzip).pipe(extract);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
readStream.pipe(extract);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
export async function extractAndValidateShardedArchive(archivePath, extractDir, signal) {
|
|
131
|
-
// Check if shards already extracted
|
|
132
|
-
try {
|
|
133
|
-
const existingFiles = await fsPromises.readdir(extractDir);
|
|
134
|
-
const existingShard = existingFiles.find((f) => detectShardedModel(String(f)).isSharded);
|
|
135
|
-
if (existingShard) {
|
|
136
|
-
const isComplete = await validateShardedModelCache(extractDir, String(existingShard));
|
|
137
|
-
if (isComplete) {
|
|
138
|
-
logger.info(`✅ Archive already extracted: ${extractDir}`);
|
|
139
|
-
const shardFilenames = generateShardFilenames(String(existingShard));
|
|
140
|
-
return path.join(extractDir, shardFilenames[0]);
|
|
141
|
-
}
|
|
142
|
-
logger.warn(`⚠️ Incomplete extraction found, re-extracting archive`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
// Directory doesn't exist, proceed with extraction
|
|
147
|
-
}
|
|
148
|
-
logger.info(`Extracting archive: ${path.basename(archivePath)}`);
|
|
149
|
-
try {
|
|
150
|
-
await extractArchive(archivePath, extractDir, signal);
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
throw new ArchiveExtractionFailedError(archivePath, error);
|
|
154
|
-
}
|
|
155
|
-
const files = await fsPromises.readdir(extractDir);
|
|
156
|
-
const shardedFile = files.find((f) => detectShardedModel(String(f)).isSharded);
|
|
157
|
-
if (!shardedFile) {
|
|
158
|
-
throw new ModelLoadFailedError(`No sharded model files found in archive. Expected pattern: *-00001-of-0000X.*`);
|
|
159
|
-
}
|
|
160
|
-
const shardedFileName = String(shardedFile);
|
|
161
|
-
const shardInfo = detectShardedModel(shardedFileName);
|
|
162
|
-
if (!shardInfo.baseFilename) {
|
|
163
|
-
throw new ModelLoadFailedError(`Could not extract base filename from sharded model: ${shardedFileName}`);
|
|
164
|
-
}
|
|
165
|
-
const shardFilenames = generateShardFilenames(shardedFileName);
|
|
166
|
-
for (const shardFilename of shardFilenames) {
|
|
167
|
-
const filePath = path.join(extractDir, shardFilename);
|
|
168
|
-
try {
|
|
169
|
-
await fsPromises.access(filePath);
|
|
170
|
-
}
|
|
171
|
-
catch {
|
|
172
|
-
throw new ArchiveMissingShardsError(shardFilename);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
// Generate tensors.txt if it doesn't exist
|
|
176
|
-
await extractTensorsFromShards(extractDir, shardedFileName);
|
|
177
|
-
logger.info(`Archive extracted to ${extractDir} successfully: ${files.length} files`);
|
|
178
|
-
return path.join(extractDir, shardFilenames[0]);
|
|
179
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { DownloadMetricsHooks } from "../rpc/handlers/load-model/types";
|
|
2
|
-
export declare function calculateFileChecksum(filePath: string): Promise<string>;
|
|
3
|
-
export declare function measureChecksum(filePath: string, hooks?: DownloadMetricsHooks): Promise<string>;
|
|
4
|
-
//# sourceMappingURL=checksum.d.ts.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import fs from "bare-fs";
|
|
2
|
-
import crypto from "bare-crypto";
|
|
3
|
-
import { nowMs } from "../../profiling/index.js";
|
|
4
|
-
export async function calculateFileChecksum(filePath) {
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
try {
|
|
7
|
-
const hash = crypto.createHash("sha256");
|
|
8
|
-
const stream = fs.createReadStream(filePath);
|
|
9
|
-
stream.on("data", (chunk) => {
|
|
10
|
-
hash.update(chunk);
|
|
11
|
-
});
|
|
12
|
-
stream.on("end", () => {
|
|
13
|
-
resolve(hash.digest("hex"));
|
|
14
|
-
});
|
|
15
|
-
stream.on("error", (error) => {
|
|
16
|
-
reject(new Error(`Checksum calculation error: ${error.message}`));
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
reject(error instanceof Error
|
|
21
|
-
? error
|
|
22
|
-
: new Error(`Checksum calculation error: ${String(error)}`));
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
export async function measureChecksum(filePath, hooks) {
|
|
27
|
-
const start = nowMs();
|
|
28
|
-
const checksum = await calculateFileChecksum(filePath);
|
|
29
|
-
hooks?.addChecksumValidationTimeMs(nowMs() - start);
|
|
30
|
-
return checksum;
|
|
31
|
-
}
|