@qvac/sdk 0.8.0 → 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 -13
- package/dist/client/api/cancel.js +6 -16
- 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 +1 -5
- package/dist/client/api/index.js +1 -5
- 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 +1 -1
- package/dist/client/api/ping.js +2 -3
- 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.js +4 -39
- 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.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/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 -6
- package/dist/schemas/cancel.js +0 -5
- package/dist/schemas/common.d.ts +164 -2973
- package/dist/schemas/common.js +1 -23
- package/dist/schemas/completion-stream.d.ts +60 -31
- package/dist/schemas/completion-stream.js +44 -20
- package/dist/schemas/delegate.d.ts +0 -1
- package/dist/schemas/delegate.js +0 -1
- 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 +1 -19
- package/dist/schemas/index.js +1 -19
- 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 -14358
- 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/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 +46 -157
- 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 -14
- package/dist/server/bare/registry/model-registry.js +12 -32
- 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 +6 -18
- 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 +21 -59
- 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 -141
- package/NOTICE +0 -358
- 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/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/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/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/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 -204
- 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 -215
- package/dist/server/rpc/handler-registry.d.ts +0 -3
- package/dist/server/rpc/handler-registry.js +0 -90
- package/dist/server/rpc/handler-utils.d.ts +0 -23
- package/dist/server/rpc/handler-utils.js +0 -128
- 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/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 -564
- 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/ping.d.ts +0 -3
- package/dist/server/rpc/handlers/ping.js +0 -3
- 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/{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,181 +1,70 @@
|
|
|
1
1
|
import { getSwarm } from "./hyperswarm.js";
|
|
2
2
|
import RPC from "bare-rpc";
|
|
3
3
|
import { withTimeout } from "../../utils/withTimeout.js";
|
|
4
|
-
import { DelegateConnectionFailedError } from "../../utils/errors-server.js";
|
|
5
|
-
import { getServerLogger } from "../../logging/index.js";
|
|
6
|
-
import { nowMs } from "../../profiling/index.js";
|
|
7
|
-
import { cacheDelegationConnectionTime, clearPeerConnectionTracking, } from "../rpc/profiling/delegation-profiler.js";
|
|
8
|
-
const logger = getServerLogger();
|
|
9
4
|
// Map of active RPC instances by public key
|
|
10
5
|
const activeRPCs = new Map();
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
let
|
|
15
|
-
/**
|
|
16
|
-
* Register the swarm "connection" handler once (not per getRPC call).
|
|
17
|
-
* This fixes the event listener leak where each getRPC() call added
|
|
18
|
-
* a new listener, causing duplicate RPC instances on the same stream.
|
|
19
|
-
*/
|
|
20
|
-
function ensureConnectionHandler() {
|
|
21
|
-
if (connectionHandlerRegistered)
|
|
22
|
-
return;
|
|
23
|
-
connectionHandlerRegistered = true;
|
|
6
|
+
// Establish RPC connection to a peer if not already connected
|
|
7
|
+
async function ensureRPCConnection(topic, publicKey, timeout) {
|
|
8
|
+
// Check if we already have an RPC instance for this peer
|
|
9
|
+
let rpc = activeRPCs.get(publicKey);
|
|
24
10
|
const swarm = getSwarm();
|
|
11
|
+
if (!rpc) {
|
|
12
|
+
// Need to establish connection first
|
|
13
|
+
try {
|
|
14
|
+
console.log(`🔗 Establishing RPC connection to topic: ${topic}, peer: ${publicKey}, timeout: ${timeout}ms`);
|
|
15
|
+
const connectionPromise = (async () => {
|
|
16
|
+
const topicBuffer = Buffer.from(topic, "hex");
|
|
17
|
+
// const discovery =
|
|
18
|
+
swarm.join(topicBuffer, {
|
|
19
|
+
server: false,
|
|
20
|
+
client: true,
|
|
21
|
+
});
|
|
22
|
+
await swarm.flush();
|
|
23
|
+
console.log(`✅ Connected to topic: ${topic}`);
|
|
24
|
+
console.log(`📊 Active RPC connections: ${activeRPCs.size}`);
|
|
25
|
+
// Check again if we now have an RPC instance for the target peer
|
|
26
|
+
rpc = activeRPCs.get(publicKey);
|
|
27
|
+
if (!rpc) {
|
|
28
|
+
console.error(`❌ No RPC instance found for peer ${publicKey}`);
|
|
29
|
+
console.log(`📊 Available RPC connections:`, Array.from(activeRPCs.keys()));
|
|
30
|
+
throw new Error(`Could not establish RPC connection to peer ${publicKey} on topic ${topic}`);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
console.log(`✅ RPC instance found for peer ${publicKey}`);
|
|
34
|
+
}
|
|
35
|
+
})();
|
|
36
|
+
await withTimeout(connectionPromise, timeout);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error("Failed to establish RPC connection:", error);
|
|
40
|
+
throw new Error(`RPC connection failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return rpc;
|
|
44
|
+
}
|
|
45
|
+
// Create an RPC instance for a specific HyperSwarm peer
|
|
46
|
+
export async function getRPC(topic, publicKey, options = {}) {
|
|
47
|
+
const swarm = getSwarm();
|
|
48
|
+
// Set up connection tracking
|
|
25
49
|
swarm.on("connection", (conn) => {
|
|
26
50
|
const peerPubkey = conn.remotePublicKey?.toString("hex");
|
|
27
51
|
if (!peerPubkey)
|
|
28
52
|
return;
|
|
29
|
-
|
|
53
|
+
console.log(`🍺 New peer connection established: ${peerPubkey}`);
|
|
30
54
|
// Create RPC instance for this connection (as client)
|
|
31
55
|
const rpc = new RPC(conn, () => {
|
|
32
56
|
// No-op handler since we're only sending requests, not receiving them
|
|
33
57
|
});
|
|
34
|
-
// Store RPC instance
|
|
58
|
+
// Store RPC instance by peer ID for lookup
|
|
35
59
|
activeRPCs.set(peerPubkey, rpc);
|
|
36
|
-
activeConnections.set(peerPubkey, conn);
|
|
37
60
|
conn.on("close", () => {
|
|
38
|
-
|
|
61
|
+
console.log(`Connection closed for peer: ${peerPubkey}`);
|
|
39
62
|
activeRPCs.delete(peerPubkey);
|
|
40
|
-
activeConnections.delete(peerPubkey);
|
|
41
|
-
clearPeerConnectionTracking(peerPubkey);
|
|
42
63
|
});
|
|
43
64
|
conn.on("error", (err) => {
|
|
44
|
-
|
|
65
|
+
console.error(`Connection error for peer ${peerPubkey}:`, err);
|
|
45
66
|
activeRPCs.delete(peerPubkey);
|
|
46
|
-
activeConnections.delete(peerPubkey);
|
|
47
|
-
clearPeerConnectionTracking(peerPubkey);
|
|
48
67
|
});
|
|
49
68
|
});
|
|
50
|
-
}
|
|
51
|
-
async function closeConnection(publicKey) {
|
|
52
|
-
const existingConnection = activeConnections.get(publicKey);
|
|
53
|
-
if (existingConnection) {
|
|
54
|
-
logger.info(`🔌 Closing existing connection for peer: ${publicKey}`);
|
|
55
|
-
// Wait for the close event before returning so Hyperswarm's internal
|
|
56
|
-
// _allConnections is cleaned up before we attempt to rejoin/flush.
|
|
57
|
-
await new Promise((resolve) => {
|
|
58
|
-
const timeout = setTimeout(resolve, 5000);
|
|
59
|
-
existingConnection.on("close", () => {
|
|
60
|
-
clearTimeout(timeout);
|
|
61
|
-
resolve();
|
|
62
|
-
});
|
|
63
|
-
existingConnection.destroy();
|
|
64
|
-
});
|
|
65
|
-
activeConnections.delete(publicKey);
|
|
66
|
-
activeRPCs.delete(publicKey);
|
|
67
|
-
clearPeerConnectionTracking(publicKey);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// Establish RPC connection to a peer if not already connected
|
|
71
|
-
async function ensureRPCConnection(topic, publicKey, timeout) {
|
|
72
|
-
// Check if we already have an RPC instance for this peer
|
|
73
|
-
const existingRpc = activeRPCs.get(publicKey);
|
|
74
|
-
if (existingRpc) {
|
|
75
|
-
return existingRpc;
|
|
76
|
-
}
|
|
77
|
-
const swarm = getSwarm();
|
|
78
|
-
const connectionStart = nowMs();
|
|
79
|
-
// Track the listener so we can clean it up on timeout
|
|
80
|
-
let onConnection = () => { };
|
|
81
|
-
try {
|
|
82
|
-
logger.info(`🔗 Establishing RPC connection to topic: ${topic}, peer: ${publicKey}, timeout: ${timeout}ms`);
|
|
83
|
-
const connectionPromise = new Promise((resolve, reject) => {
|
|
84
|
-
const topicBuffer = Buffer.from(topic, "hex");
|
|
85
|
-
swarm.join(topicBuffer, {
|
|
86
|
-
server: false,
|
|
87
|
-
client: true,
|
|
88
|
-
});
|
|
89
|
-
// Wait for the specific peer's connection event instead of just
|
|
90
|
-
// checking after flush. This handles the case where flush resolves
|
|
91
|
-
// (discovery done) but the P2P connection is still being established
|
|
92
|
-
// via holepunching or relays.
|
|
93
|
-
onConnection = (conn) => {
|
|
94
|
-
const peerPubkey = conn.remotePublicKey?.toString("hex");
|
|
95
|
-
if (peerPubkey === publicKey) {
|
|
96
|
-
swarm.removeListener("connection", onConnection);
|
|
97
|
-
// The global handler (ensureConnectionHandler) will create the RPC
|
|
98
|
-
// and store it in activeRPCs. Give it a tick to run first.
|
|
99
|
-
const rpc = activeRPCs.get(publicKey);
|
|
100
|
-
if (rpc) {
|
|
101
|
-
resolve(rpc);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
// Global handler runs synchronously before us in the same event,
|
|
105
|
-
// so this shouldn't happen, but handle it just in case
|
|
106
|
-
setTimeout(() => {
|
|
107
|
-
const delayedRpc = activeRPCs.get(publicKey);
|
|
108
|
-
if (delayedRpc) {
|
|
109
|
-
resolve(delayedRpc);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
reject(new DelegateConnectionFailedError(`Connection established but RPC not created for peer ${publicKey}`));
|
|
113
|
-
}
|
|
114
|
-
}, 100);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
swarm.on("connection", onConnection);
|
|
119
|
-
// Also flush to trigger discovery. After flush, check if the connection
|
|
120
|
-
// was already established (the global handler may have caught it).
|
|
121
|
-
void swarm.flush().then(() => {
|
|
122
|
-
logger.info(`✅ Flush completed for topic: ${topic}`);
|
|
123
|
-
logger.debug(`📊 Active RPC connections: ${activeRPCs.size}`);
|
|
124
|
-
const rpc = activeRPCs.get(publicKey);
|
|
125
|
-
if (rpc) {
|
|
126
|
-
swarm.removeListener("connection", onConnection);
|
|
127
|
-
resolve(rpc);
|
|
128
|
-
}
|
|
129
|
-
// If not connected after flush, the onConnection listener keeps
|
|
130
|
-
// waiting until the timeout from withTimeout kicks in.
|
|
131
|
-
// Hyperswarm may still establish the connection via retries/relays.
|
|
132
|
-
logger.debug(`⏳ Peer not connected after flush, waiting for connection event...`);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
const rpc = await withTimeout(connectionPromise, timeout);
|
|
136
|
-
const connectionDuration = nowMs() - connectionStart;
|
|
137
|
-
cacheDelegationConnectionTime(publicKey, connectionDuration);
|
|
138
|
-
return rpc;
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
// Clean up the per-request connection listener
|
|
142
|
-
swarm.removeListener("connection", onConnection);
|
|
143
|
-
// Remove stale connection so next attempt creates a fresh one
|
|
144
|
-
// instead of reusing a dead RPC
|
|
145
|
-
logger.info(`🗑️ Removing stale connection for peer: ${publicKey} after failed RPC attempt`);
|
|
146
|
-
activeRPCs.delete(publicKey);
|
|
147
|
-
const conn = activeConnections.get(publicKey);
|
|
148
|
-
if (conn) {
|
|
149
|
-
conn.destroy();
|
|
150
|
-
activeConnections.delete(publicKey);
|
|
151
|
-
}
|
|
152
|
-
logger.error("Failed to establish RPC connection:", error);
|
|
153
|
-
throw new DelegateConnectionFailedError(`RPC connection failed: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
// Create an RPC instance for a specific HyperSwarm peer
|
|
157
|
-
export async function getRPC(topic, publicKey, options = {}) {
|
|
158
|
-
// Ensure the global connection handler is registered (once)
|
|
159
|
-
ensureConnectionHandler();
|
|
160
|
-
// Close existing connection if forceNewConnection is true
|
|
161
|
-
// Await the close to avoid racing with the subsequent join/flush
|
|
162
|
-
if (options.forceNewConnection) {
|
|
163
|
-
await closeConnection(publicKey);
|
|
164
|
-
}
|
|
165
69
|
return await ensureRPCConnection(topic, publicKey, options.timeout);
|
|
166
70
|
}
|
|
167
|
-
/**
|
|
168
|
-
* Remove a stale RPC connection for a peer.
|
|
169
|
-
* Called when a delegation request fails (e.g., timeout) so the next
|
|
170
|
-
* attempt creates a fresh connection instead of reusing a dead RPC.
|
|
171
|
-
*/
|
|
172
|
-
export function cleanupStaleConnection(publicKey) {
|
|
173
|
-
logger.info(`🗑️ Removing stale connection for peer: ${publicKey} after failed delegation`);
|
|
174
|
-
activeRPCs.delete(publicKey);
|
|
175
|
-
const conn = activeConnections.get(publicKey);
|
|
176
|
-
if (conn) {
|
|
177
|
-
conn.destroy();
|
|
178
|
-
activeConnections.delete(publicKey);
|
|
179
|
-
}
|
|
180
|
-
clearPeerConnectionTracking(publicKey);
|
|
181
|
-
}
|
|
@@ -3,8 +3,5 @@ import { type FirewallConfig } from "../../schemas/provide";
|
|
|
3
3
|
export declare function getSwarm({ firewallConfig, }?: {
|
|
4
4
|
firewallConfig?: FirewallConfig | undefined;
|
|
5
5
|
}): Hyperswarm;
|
|
6
|
-
export declare function registerProviderTopic(topic: string): void;
|
|
7
|
-
export declare function unregisterProviderTopic(topic: string): void;
|
|
8
|
-
export declare function hasActiveProviders(): boolean;
|
|
9
6
|
export declare function destroySwarm(): Promise<void>;
|
|
10
7
|
//# sourceMappingURL=hyperswarm.d.ts.map
|
|
@@ -2,16 +2,13 @@ import process from "bare-process";
|
|
|
2
2
|
import Hyperswarm from "hyperswarm";
|
|
3
3
|
import crypto from "bare-crypto";
|
|
4
4
|
import { envSchema } from "../../schemas/provide.js";
|
|
5
|
-
import { getSDKConfig } from "./registry/config-registry.js";
|
|
6
|
-
import { getServerLogger } from "../../logging/index.js";
|
|
7
|
-
const logger = getServerLogger();
|
|
8
5
|
function getHyperswarmSeedBuffer() {
|
|
9
6
|
const parsedEnv = envSchema.safeParse(process.env);
|
|
10
7
|
if (parsedEnv.success) {
|
|
11
8
|
return Buffer.from(parsedEnv.data.QVAC_HYPERSWARM_SEED, "hex");
|
|
12
9
|
}
|
|
13
10
|
else {
|
|
14
|
-
|
|
11
|
+
console.log(`🎲 No seed provided, generating random seed (provider will have random identity)`);
|
|
15
12
|
return crypto.randomBytes(32);
|
|
16
13
|
}
|
|
17
14
|
}
|
|
@@ -26,20 +23,20 @@ function createFirewallFunction(config) {
|
|
|
26
23
|
if (mode === "allow") {
|
|
27
24
|
const allowed = publicKeySet.has(remoteKeyHex);
|
|
28
25
|
if (!allowed) {
|
|
29
|
-
|
|
26
|
+
console.log(`🚫 Firewall: Denied connection from ${remoteKeyHex.substring(0, 16)}... (not in allowlist)`);
|
|
30
27
|
}
|
|
31
28
|
else {
|
|
32
|
-
|
|
29
|
+
console.log(`✅ Firewall: Allowed connection from ${remoteKeyHex.substring(0, 16)}... (in allowlist)`);
|
|
33
30
|
}
|
|
34
31
|
return !allowed;
|
|
35
32
|
}
|
|
36
33
|
else {
|
|
37
34
|
const denied = publicKeySet.has(remoteKeyHex);
|
|
38
35
|
if (denied) {
|
|
39
|
-
|
|
36
|
+
console.log(`🚫 Firewall: Denied connection from ${remoteKeyHex.substring(0, 16)}... (in denylist)`);
|
|
40
37
|
}
|
|
41
38
|
else {
|
|
42
|
-
|
|
39
|
+
console.log(`✅ Firewall: Allowed connection from ${remoteKeyHex.substring(0, 16)}... (not in denylist)`);
|
|
43
40
|
}
|
|
44
41
|
return denied;
|
|
45
42
|
}
|
|
@@ -48,19 +45,9 @@ function createFirewallFunction(config) {
|
|
|
48
45
|
function createSwarm(firewallConfig) {
|
|
49
46
|
const seed = getHyperswarmSeedBuffer();
|
|
50
47
|
const firewall = createFirewallFunction(firewallConfig);
|
|
51
|
-
|
|
52
|
-
const config = getSDKConfig();
|
|
53
|
-
const relayPublicKeys = config.swarmRelays;
|
|
54
|
-
if (!relayPublicKeys || relayPublicKeys.length === 0) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return relayPublicKeys.map((key) => Buffer.from(key, "hex"));
|
|
58
|
-
};
|
|
59
|
-
const swarmOptions = { seed, firewall, relayThrough: getRelays };
|
|
60
|
-
return new Hyperswarm(swarmOptions);
|
|
48
|
+
return new Hyperswarm({ seed, firewall });
|
|
61
49
|
}
|
|
62
50
|
let swarm;
|
|
63
|
-
const activeProviderTopics = new Set();
|
|
64
51
|
export function getSwarm({ firewallConfig, } = {}) {
|
|
65
52
|
if (swarm) {
|
|
66
53
|
return swarm;
|
|
@@ -68,18 +55,8 @@ export function getSwarm({ firewallConfig, } = {}) {
|
|
|
68
55
|
swarm = createSwarm(firewallConfig);
|
|
69
56
|
return swarm;
|
|
70
57
|
}
|
|
71
|
-
export function registerProviderTopic(topic) {
|
|
72
|
-
activeProviderTopics.add(topic);
|
|
73
|
-
}
|
|
74
|
-
export function unregisterProviderTopic(topic) {
|
|
75
|
-
activeProviderTopics.delete(topic);
|
|
76
|
-
}
|
|
77
|
-
export function hasActiveProviders() {
|
|
78
|
-
return activeProviderTopics.size > 0;
|
|
79
|
-
}
|
|
80
58
|
export async function destroySwarm() {
|
|
81
59
|
if (swarm) {
|
|
82
|
-
activeProviderTopics.clear();
|
|
83
60
|
return swarm.destroy();
|
|
84
61
|
}
|
|
85
62
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type RagDeleteEmbeddingsParams } from "../../../../schemas/index";
|
|
2
|
-
export declare function deleteEmbeddings(params: RagDeleteEmbeddingsParams): Promise<
|
|
2
|
+
export declare function deleteEmbeddings(params: RagDeleteEmbeddingsParams): Promise<boolean>;
|
|
3
3
|
//# sourceMappingURL=delete-embeddings.d.ts.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { getRagInstance } from "../rag-manager.js";
|
|
2
|
+
import { embed } from "../../addons/llamacpp/index.js";
|
|
3
|
+
import { ragDeleteEmbeddingsOperationSchema, } from "../../../../schemas/index.js";
|
|
4
4
|
export async function deleteEmbeddings(params) {
|
|
5
|
-
const { ids, workspace } =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
const
|
|
10
|
-
await
|
|
5
|
+
const { modelId, ids, workspace } = ragDeleteEmbeddingsOperationSchema.parse(params);
|
|
6
|
+
const embeddingFunction = async (text) => {
|
|
7
|
+
return await embed({ modelId, text });
|
|
8
|
+
};
|
|
9
|
+
const rag = await getRagInstance(modelId, embeddingFunction, workspace);
|
|
10
|
+
const success = await rag.deleteEmbeddings(ids);
|
|
11
|
+
return success;
|
|
11
12
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { type RagSaveEmbeddingsParams } from "../../../../schemas/index";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export declare function saveEmbeddings(params: RagSaveEmbeddingsParams, options?: SaveEmbeddingsHandlerOptions): Promise<import("@qvac/rag").SaveEmbeddingsResult[]>;
|
|
8
|
-
export {};
|
|
2
|
+
export declare function saveEmbeddings(params: RagSaveEmbeddingsParams): Promise<{
|
|
3
|
+
processed: import("@qvac/rag").SaveEmbeddingsResult[];
|
|
4
|
+
droppedIndices: number[];
|
|
5
|
+
}>;
|
|
9
6
|
//# sourceMappingURL=save-embeddings.d.ts.map
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const dbAdapter = await getRagDbAdapter(workspace);
|
|
9
|
-
const saveOpts = {
|
|
10
|
-
progressInterval,
|
|
11
|
-
onProgress: options?.onProgress,
|
|
12
|
-
signal: options?.signal,
|
|
1
|
+
import { getRagInstance } from "../rag-manager.js";
|
|
2
|
+
import { embed } from "../../addons/llamacpp/index.js";
|
|
3
|
+
import { ragSaveEmbeddingsOperationSchema, } from "../../../../schemas/index.js";
|
|
4
|
+
export async function saveEmbeddings(params) {
|
|
5
|
+
const { modelId, documents, chunk, chunkOpts, workspace } = ragSaveEmbeddingsOperationSchema.parse(params);
|
|
6
|
+
const embeddingFunction = async (text) => {
|
|
7
|
+
return await embed({ modelId, text });
|
|
13
8
|
};
|
|
14
|
-
|
|
9
|
+
const rag = await getRagInstance(modelId, embeddingFunction, workspace);
|
|
10
|
+
const saveOpts = { chunk };
|
|
11
|
+
if (chunkOpts) {
|
|
12
|
+
saveOpts.chunkOpts = chunkOpts;
|
|
13
|
+
}
|
|
14
|
+
const result = await rag.saveEmbeddings(documents, saveOpts);
|
|
15
|
+
return result;
|
|
15
16
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { getRagInstance
|
|
2
|
-
import { embed } from "../../
|
|
3
|
-
import {
|
|
1
|
+
import { getRagInstance } from "../rag-manager.js";
|
|
2
|
+
import { embed } from "../../addons/llamacpp/index.js";
|
|
3
|
+
import { ragSearchOperationSchema } from "../../../../schemas/index.js";
|
|
4
4
|
export async function search(params) {
|
|
5
|
-
const { modelId, query, topK, n, workspace } =
|
|
6
|
-
|
|
7
|
-
return [];
|
|
8
|
-
}
|
|
9
|
-
async function embeddingFunction(text) {
|
|
5
|
+
const { modelId, query, topK, n, workspace } = ragSearchOperationSchema.parse(params);
|
|
6
|
+
const embeddingFunction = async (text) => {
|
|
10
7
|
return await embed({ modelId, text });
|
|
11
|
-
}
|
|
8
|
+
};
|
|
12
9
|
const rag = await getRagInstance(modelId, embeddingFunction, workspace);
|
|
13
|
-
const results = await rag.search(query, {
|
|
10
|
+
const results = await rag.search(query, {
|
|
11
|
+
topK,
|
|
12
|
+
n,
|
|
13
|
+
});
|
|
14
14
|
return results;
|
|
15
15
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
export { chunk } from "./handlers/chunk";
|
|
2
|
-
export { ingest } from "./handlers/ingest";
|
|
3
1
|
export { saveEmbeddings } from "./handlers/save-embeddings";
|
|
4
2
|
export { search } from "./handlers/search";
|
|
5
3
|
export { deleteEmbeddings } from "./handlers/delete-embeddings";
|
|
6
|
-
export {
|
|
7
|
-
export { listWorkspaces } from "./handlers/list-workspaces";
|
|
8
|
-
export { closeWorkspace } from "./handlers/close-workspace";
|
|
9
|
-
export { deleteWorkspace } from "./handlers/delete-workspace";
|
|
10
|
-
export { closeAllRagInstances, DEFAULT_WORKSPACE, type RagWorkspaceInfo, } from "./rag-workspace-manager";
|
|
11
|
-
export { registerRagOperation, unregisterRagOperation, cancelRagOperation, } from "./rag-operation-manager";
|
|
4
|
+
export { closeRagInstance, closeAllRagInstances, } from "./rag-manager";
|
|
12
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
export { chunk } from "./handlers/chunk.js";
|
|
2
|
-
export { ingest } from "./handlers/ingest.js";
|
|
3
1
|
export { saveEmbeddings } from "./handlers/save-embeddings.js";
|
|
4
2
|
export { search } from "./handlers/search.js";
|
|
5
3
|
export { deleteEmbeddings } from "./handlers/delete-embeddings.js";
|
|
6
|
-
export {
|
|
7
|
-
export { listWorkspaces } from "./handlers/list-workspaces.js";
|
|
8
|
-
export { closeWorkspace } from "./handlers/close-workspace.js";
|
|
9
|
-
export { deleteWorkspace } from "./handlers/delete-workspace.js";
|
|
10
|
-
export { closeAllRagInstances, DEFAULT_WORKSPACE, } from "./rag-workspace-manager.js";
|
|
11
|
-
export { registerRagOperation, unregisterRagOperation, cancelRagOperation, } from "./rag-operation-manager.js";
|
|
4
|
+
export { closeRagInstance, closeAllRagInstances, } from "./rag-manager.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RAG, type EmbeddingFunction } from "@qvac/rag";
|
|
2
|
+
export declare const getRagInstance: (modelId: string, embeddingFunction: EmbeddingFunction, workspace?: string) => Promise<RAG>;
|
|
3
|
+
export declare const closeRagInstance: (workspace?: string) => Promise<void>;
|
|
4
|
+
export declare const closeAllRagInstances: () => Promise<void>;
|
|
5
|
+
//# sourceMappingURL=rag-manager.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { RAG, HyperDBAdapter } from "@qvac/rag";
|
|
2
|
+
import Corestore from "corestore";
|
|
3
|
+
import path from "bare-path";
|
|
4
|
+
import { getEnv } from "../../worker.js";
|
|
5
|
+
const ragInstances = new Map();
|
|
6
|
+
const defaultWorkspace = "default";
|
|
7
|
+
const getStorePath = (workspace) => {
|
|
8
|
+
const homeDir = getEnv().HOME_DIR;
|
|
9
|
+
return path.join(homeDir, ".qvac", "rag-hyperdb", workspace);
|
|
10
|
+
};
|
|
11
|
+
export const getRagInstance = async (modelId, embeddingFunction, workspace) => {
|
|
12
|
+
const key = workspace ?? defaultWorkspace;
|
|
13
|
+
const existingEntry = ragInstances.get(key);
|
|
14
|
+
if (existingEntry) {
|
|
15
|
+
// Validate model consistency
|
|
16
|
+
if (existingEntry.modelId !== modelId) {
|
|
17
|
+
throw new Error(`Workspace "${key}" is configured for model "${existingEntry.modelId}", ` +
|
|
18
|
+
`but you're trying to use model "${modelId}". ` +
|
|
19
|
+
`Use a different workspace or the same model.`);
|
|
20
|
+
}
|
|
21
|
+
return existingEntry.rag;
|
|
22
|
+
}
|
|
23
|
+
// Create new instance for this workspace
|
|
24
|
+
const storePath = getStorePath(key);
|
|
25
|
+
const corestore = new Corestore(storePath);
|
|
26
|
+
// Create HyperDB adapter
|
|
27
|
+
const hyperdbAdapter = new HyperDBAdapter({
|
|
28
|
+
store: corestore,
|
|
29
|
+
});
|
|
30
|
+
const rag = new RAG({
|
|
31
|
+
dbAdapter: hyperdbAdapter,
|
|
32
|
+
embeddingFunction,
|
|
33
|
+
});
|
|
34
|
+
await rag.ready();
|
|
35
|
+
ragInstances.set(key, {
|
|
36
|
+
rag,
|
|
37
|
+
corestore,
|
|
38
|
+
modelId,
|
|
39
|
+
});
|
|
40
|
+
return rag;
|
|
41
|
+
};
|
|
42
|
+
export const closeRagInstance = async (workspace) => {
|
|
43
|
+
const key = workspace ?? defaultWorkspace;
|
|
44
|
+
const entry = ragInstances.get(key);
|
|
45
|
+
if (entry) {
|
|
46
|
+
await entry.rag.close();
|
|
47
|
+
ragInstances.delete(key);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
let isCleaningUp = false;
|
|
51
|
+
export const closeAllRagInstances = async () => {
|
|
52
|
+
if (isCleaningUp)
|
|
53
|
+
return;
|
|
54
|
+
isCleaningUp = true;
|
|
55
|
+
try {
|
|
56
|
+
const closures = Array.from(ragInstances.entries()).map(async ([key, entry]) => {
|
|
57
|
+
await entry.rag.close();
|
|
58
|
+
ragInstances.delete(key);
|
|
59
|
+
});
|
|
60
|
+
await Promise.all(closures);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.error("❌ Error during RAG cleanup:", error);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
@@ -1,30 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Logging Stream Registry
|
|
3
|
-
*
|
|
4
|
-
* Manages RPC subscriptions for streaming logs from server to connected clients.
|
|
5
|
-
*
|
|
6
|
-
* Purpose:
|
|
7
|
-
* - Registers client subscriptions to model/SDK log streams
|
|
8
|
-
* - Routes log messages to subscribed clients via RPC
|
|
9
|
-
* - Buffers logs during model loading (before client subscribes)
|
|
10
|
-
* - Manages stream lifecycle (subscribe/unsubscribe)
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
1
|
import type { LogLevel } from "@qvac/logging";
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function sendLogToStreams(id: string, level: LogLevel, namespace: string, message: string): void;
|
|
20
|
-
export declare function hasLoggingStreams(id: string): boolean | undefined;
|
|
2
|
+
export declare function registerLoggingStream(modelId: string, streamHandler: (level: LogLevel, namespace: string, message: string) => void): void;
|
|
3
|
+
export declare function unregisterLoggingStream(modelId: string, streamHandler: (level: LogLevel, namespace: string, message: string) => void): void;
|
|
4
|
+
export declare function unregisterAllLoggingStreams(modelId: string): void;
|
|
5
|
+
export declare function sendLogToStreams(modelId: string, level: LogLevel, namespace: string, message: string): void;
|
|
6
|
+
export declare function hasLoggingStreams(modelId: string): boolean | undefined;
|
|
21
7
|
export declare function getLoggingStreamStats(): {
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
totalModels: number;
|
|
9
|
+
modelIds: string[];
|
|
24
10
|
totalStreams: number;
|
|
25
|
-
bufferedIds: number;
|
|
26
|
-
idsWithBuffering: number;
|
|
27
|
-
activeTimeouts: number;
|
|
28
11
|
};
|
|
29
12
|
export declare function clearAllLoggingStreams(): void;
|
|
30
13
|
//# sourceMappingURL=logging-stream-registry.d.ts.map
|