@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
package/dist/pear/pre.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QVAC Pear Pre-Hook
|
|
3
|
-
*
|
|
4
|
-
* Invoked by Pear before `pear run` or `pear stage` to:
|
|
5
|
-
* 1. Generate `qvac/worker.pear.entry.mjs` with selected plugins
|
|
6
|
-
* 2. Persist `pear.stage.entrypoints` to package.json for routing
|
|
7
|
-
*
|
|
8
|
-
* @example package.json configuration
|
|
9
|
-
* ```json
|
|
10
|
-
* {
|
|
11
|
-
* "pear": {
|
|
12
|
-
* "pre": ["@qvac/sdk/pear-pre"]
|
|
13
|
-
* }
|
|
14
|
-
* }
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=pre.d.ts.map
|
package/dist/pear/pre.js
DELETED
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QVAC Pear Pre-Hook
|
|
3
|
-
*
|
|
4
|
-
* Invoked by Pear before `pear run` or `pear stage` to:
|
|
5
|
-
* 1. Generate `qvac/worker.pear.entry.mjs` with selected plugins
|
|
6
|
-
* 2. Persist `pear.stage.entrypoints` to package.json for routing
|
|
7
|
-
*
|
|
8
|
-
* @example package.json configuration
|
|
9
|
-
* ```json
|
|
10
|
-
* {
|
|
11
|
-
* "pear": {
|
|
12
|
-
* "pre": ["@qvac/sdk/pear-pre"]
|
|
13
|
-
* }
|
|
14
|
-
* }
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
import * as cenc from "compact-encoding";
|
|
18
|
-
import pearPipe from "pear-pipe";
|
|
19
|
-
import fs from "bare-fs";
|
|
20
|
-
import path from "bare-path";
|
|
21
|
-
const CONFIG_CANDIDATES = [
|
|
22
|
-
"qvac.config.json",
|
|
23
|
-
"qvac.config.js",
|
|
24
|
-
"qvac.config.mjs",
|
|
25
|
-
"qvac.config.ts",
|
|
26
|
-
];
|
|
27
|
-
const BUILTIN_PLUGINS = [
|
|
28
|
-
"@qvac/sdk/llamacpp-completion/plugin",
|
|
29
|
-
"@qvac/sdk/llamacpp-embedding/plugin",
|
|
30
|
-
"@qvac/sdk/whispercpp-transcription/plugin",
|
|
31
|
-
"@qvac/sdk/nmtcpp-translation/plugin",
|
|
32
|
-
"@qvac/sdk/onnx-tts/plugin",
|
|
33
|
-
"@qvac/sdk/onnx-ocr/plugin",
|
|
34
|
-
];
|
|
35
|
-
const BUILTIN_PLUGIN_EXPORTS = {
|
|
36
|
-
"llamacpp-completion": "llmPlugin",
|
|
37
|
-
"llamacpp-embedding": "embeddingsPlugin",
|
|
38
|
-
"whispercpp-transcription": "whisperPlugin",
|
|
39
|
-
"nmtcpp-translation": "nmtPlugin",
|
|
40
|
-
"onnx-tts": "ttsPlugin",
|
|
41
|
-
"onnx-ocr": "ocrPlugin",
|
|
42
|
-
};
|
|
43
|
-
const SDK_NAME = "@qvac/sdk";
|
|
44
|
-
const DEFAULT_PEAR_WORKER = "worker.js";
|
|
45
|
-
const PEAR_WORKER_ENTRY_PATH = "qvac/worker.pear.entry.mjs";
|
|
46
|
-
const LOG_PREFIX = "[qvac/pear-pre]";
|
|
47
|
-
/** Normalize path to Pear config format (POSIX-style, leading slash) */
|
|
48
|
-
function toPearConfigPath(pathFromAppRoot) {
|
|
49
|
-
let p = String(pathFromAppRoot).replaceAll("\\", "/");
|
|
50
|
-
if (p.startsWith("./"))
|
|
51
|
-
p = p.slice(2);
|
|
52
|
-
if (!p.startsWith("/"))
|
|
53
|
-
p = `/${p}`;
|
|
54
|
-
return p.replaceAll("/./", "/").replace(/\/{2,}/g, "/");
|
|
55
|
-
}
|
|
56
|
-
function toPosixPath(p) {
|
|
57
|
-
return String(p).replaceAll("\\", "/");
|
|
58
|
-
}
|
|
59
|
-
function pathToFileUrl(absPath) {
|
|
60
|
-
let p = toPosixPath(absPath);
|
|
61
|
-
// Windows drive letter paths need a leading slash in file:// URLs.
|
|
62
|
-
if (/^[A-Za-z]:\//.test(p))
|
|
63
|
-
p = `/${p}`;
|
|
64
|
-
if (!p.startsWith("/"))
|
|
65
|
-
p = `/${p}`;
|
|
66
|
-
const segments = p.split("/");
|
|
67
|
-
const encoded = segments
|
|
68
|
-
.map((seg, idx) => {
|
|
69
|
-
if (idx === 0)
|
|
70
|
-
return "";
|
|
71
|
-
// Preserve "C:" drive segment in Windows file URLs (file:///C:/...)
|
|
72
|
-
if (idx === 1 && /^[A-Za-z]:$/.test(seg))
|
|
73
|
-
return seg;
|
|
74
|
-
return encodeURIComponent(seg);
|
|
75
|
-
})
|
|
76
|
-
.join("/");
|
|
77
|
-
return `file://${encoded}`;
|
|
78
|
-
}
|
|
79
|
-
function detectJsonIndent(raw) {
|
|
80
|
-
const match = raw.match(/\n([ \t]+)"/);
|
|
81
|
-
if (match?.[1])
|
|
82
|
-
return match[1];
|
|
83
|
-
return 2;
|
|
84
|
-
}
|
|
85
|
-
function detectJsonNewline(raw) {
|
|
86
|
-
return raw.includes("\r\n") ? "\r\n" : "\n";
|
|
87
|
-
}
|
|
88
|
-
function ensureObjectProp(obj, prop) {
|
|
89
|
-
const existing = obj[prop];
|
|
90
|
-
if (existing === undefined) {
|
|
91
|
-
const created = {};
|
|
92
|
-
obj[prop] = created;
|
|
93
|
-
return created;
|
|
94
|
-
}
|
|
95
|
-
if (typeof existing === "object" && existing && !Array.isArray(existing)) {
|
|
96
|
-
return existing;
|
|
97
|
-
}
|
|
98
|
-
throw new Error(`package.json "${prop}" must be an object`);
|
|
99
|
-
}
|
|
100
|
-
function normalizeStringArray(value) {
|
|
101
|
-
if (value === undefined || value === null)
|
|
102
|
-
return [];
|
|
103
|
-
if (typeof value === "string")
|
|
104
|
-
return value.length ? [value] : [];
|
|
105
|
-
if (Array.isArray(value))
|
|
106
|
-
return uniqStrings(value);
|
|
107
|
-
throw new Error("Expected an array of strings");
|
|
108
|
-
}
|
|
109
|
-
function atomicWriteFileSync(targetPath, content) {
|
|
110
|
-
const tmpPath = `${targetPath}.qvac-pre.tmp`;
|
|
111
|
-
fs.writeFileSync(tmpPath, content, "utf8");
|
|
112
|
-
fs.renameSync(tmpPath, targetPath);
|
|
113
|
-
}
|
|
114
|
-
function normalizePearWorkerPath(value) {
|
|
115
|
-
if (typeof value !== "string")
|
|
116
|
-
return DEFAULT_PEAR_WORKER;
|
|
117
|
-
let p = value.trim();
|
|
118
|
-
if (!p)
|
|
119
|
-
return DEFAULT_PEAR_WORKER;
|
|
120
|
-
p = toPosixPath(p);
|
|
121
|
-
if (/^[A-Za-z]:\//.test(p)) {
|
|
122
|
-
throw new Error(`"pearWorker" must be a path inside the app root (got absolute path: ${JSON.stringify(value)})`);
|
|
123
|
-
}
|
|
124
|
-
if (p.startsWith("./"))
|
|
125
|
-
p = p.slice(2);
|
|
126
|
-
while (p.startsWith("/"))
|
|
127
|
-
p = p.slice(1);
|
|
128
|
-
if (!p)
|
|
129
|
-
return DEFAULT_PEAR_WORKER;
|
|
130
|
-
if (p === "." || p === ".." || p.startsWith("../") || p.includes("/../")) {
|
|
131
|
-
throw new Error(`"pearWorker" must be a path inside the app root (got: ${JSON.stringify(value)})`);
|
|
132
|
-
}
|
|
133
|
-
return p;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Converts an absolute path to a relative ESM import specifier, using POSIX separators.
|
|
137
|
-
*/
|
|
138
|
-
function toRelativeImportSpecifier(fromDir, targetPath) {
|
|
139
|
-
let rel = path.relative(fromDir, targetPath);
|
|
140
|
-
rel = toPosixPath(rel);
|
|
141
|
-
if (!rel.startsWith("."))
|
|
142
|
-
rel = `./${rel}`;
|
|
143
|
-
return rel;
|
|
144
|
-
}
|
|
145
|
-
/** Extract unique strings from an array, preserving order */
|
|
146
|
-
function uniqStrings(values) {
|
|
147
|
-
if (!Array.isArray(values))
|
|
148
|
-
return [];
|
|
149
|
-
const out = [];
|
|
150
|
-
const seen = new Set();
|
|
151
|
-
for (const v of values) {
|
|
152
|
-
if (typeof v === "string" && !seen.has(v)) {
|
|
153
|
-
seen.add(v);
|
|
154
|
-
out.push(v);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return out;
|
|
158
|
-
}
|
|
159
|
-
/** Ensure array contains required values, returning new array and change flag */
|
|
160
|
-
function ensureArrayIncludes(existing, required) {
|
|
161
|
-
const next = [...existing];
|
|
162
|
-
const set = new Set(existing);
|
|
163
|
-
let changed = false;
|
|
164
|
-
for (const v of required) {
|
|
165
|
-
if (!set.has(v)) {
|
|
166
|
-
set.add(v);
|
|
167
|
-
next.push(v);
|
|
168
|
-
changed = true;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return { next, changed };
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Persist pear.stage.entrypoints to package.json.
|
|
175
|
-
*
|
|
176
|
-
* Required because workers are spawned with --no-pre, bypassing dynamic config.
|
|
177
|
-
* pear-state merges stage.entrypoints into unrouted automatically.
|
|
178
|
-
*/
|
|
179
|
-
function persistStageEntrypointsToPackageJson(appRoot, requiredEntrypoints) {
|
|
180
|
-
const packageJsonPath = path.join(appRoot, "package.json");
|
|
181
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
182
|
-
throw new Error(`package.json not found at ${packageJsonPath}`);
|
|
183
|
-
}
|
|
184
|
-
const raw = fs.readFileSync(packageJsonPath, "utf8");
|
|
185
|
-
const newline = detectJsonNewline(raw);
|
|
186
|
-
const indent = detectJsonIndent(raw);
|
|
187
|
-
const hasFinalNewline = raw.endsWith("\n") || raw.endsWith("\r\n");
|
|
188
|
-
let pkg;
|
|
189
|
-
try {
|
|
190
|
-
pkg = JSON.parse(raw);
|
|
191
|
-
}
|
|
192
|
-
catch (err) {
|
|
193
|
-
throw new Error(`Failed to parse ${packageJsonPath}: ${String(err)}`);
|
|
194
|
-
}
|
|
195
|
-
const pear = ensureObjectProp(pkg, "pear");
|
|
196
|
-
const stage = ensureObjectProp(pear, "stage");
|
|
197
|
-
const existing = normalizeStringArray(stage["entrypoints"]);
|
|
198
|
-
const required = uniqStrings(requiredEntrypoints);
|
|
199
|
-
const { next, changed } = ensureArrayIncludes(existing, required);
|
|
200
|
-
if (!changed)
|
|
201
|
-
return;
|
|
202
|
-
stage["entrypoints"] = next;
|
|
203
|
-
let nextRaw = JSON.stringify(pkg, null, indent);
|
|
204
|
-
if (newline === "\r\n")
|
|
205
|
-
nextRaw = nextRaw.replaceAll("\n", "\r\n");
|
|
206
|
-
if (hasFinalNewline)
|
|
207
|
-
nextRaw += newline;
|
|
208
|
-
atomicWriteFileSync(packageJsonPath, nextRaw);
|
|
209
|
-
}
|
|
210
|
-
/** Extract app root directory from Pear's applink */
|
|
211
|
-
function getAppRoot() {
|
|
212
|
-
const applink = Pear.config?.applink;
|
|
213
|
-
if (typeof applink !== "string" || applink.length === 0) {
|
|
214
|
-
throw new Error("Pear.config.applink is not available");
|
|
215
|
-
}
|
|
216
|
-
// Pear provides a file:// URL to the application root.
|
|
217
|
-
let pathname;
|
|
218
|
-
let url;
|
|
219
|
-
try {
|
|
220
|
-
url = new URL(applink);
|
|
221
|
-
}
|
|
222
|
-
catch {
|
|
223
|
-
// Some environments may provide a plain filesystem path instead of a URL.
|
|
224
|
-
return path.normalize(applink);
|
|
225
|
-
}
|
|
226
|
-
if (url.protocol !== "file:") {
|
|
227
|
-
throw new Error(`Expected Pear.config.applink to be a file:// URL (got: ${applink})`);
|
|
228
|
-
}
|
|
229
|
-
pathname = url.pathname;
|
|
230
|
-
try {
|
|
231
|
-
pathname = decodeURIComponent(pathname);
|
|
232
|
-
}
|
|
233
|
-
catch {
|
|
234
|
-
// If decoding fails, keep the raw pathname.
|
|
235
|
-
}
|
|
236
|
-
// Handle Windows paths (e.g., /C:/path)
|
|
237
|
-
if (pathname[0] === "/" && pathname[2] === ":") {
|
|
238
|
-
pathname = pathname.slice(1);
|
|
239
|
-
}
|
|
240
|
-
return path.normalize(pathname);
|
|
241
|
-
}
|
|
242
|
-
/** Find the first existing qvac config file */
|
|
243
|
-
function findConfigFile(appRoot) {
|
|
244
|
-
for (const candidate of CONFIG_CANDIDATES) {
|
|
245
|
-
const configPath = path.join(appRoot, candidate);
|
|
246
|
-
if (fs.existsSync(configPath)) {
|
|
247
|
-
return configPath;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return null;
|
|
251
|
-
}
|
|
252
|
-
/** Load and parse a qvac config file */
|
|
253
|
-
async function loadConfig(configPath) {
|
|
254
|
-
const ext = path.extname(configPath).toLowerCase();
|
|
255
|
-
if (ext === ".json") {
|
|
256
|
-
const content = fs.readFileSync(configPath, "utf8");
|
|
257
|
-
try {
|
|
258
|
-
return JSON.parse(content);
|
|
259
|
-
}
|
|
260
|
-
catch (err) {
|
|
261
|
-
throw new Error(`Failed to parse ${configPath}: ${String(err)}`);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
if (ext === ".js" || ext === ".mjs") {
|
|
265
|
-
const module = (await import(pathToFileUrl(configPath)));
|
|
266
|
-
return module.default ?? module;
|
|
267
|
-
}
|
|
268
|
-
if (ext === ".ts") {
|
|
269
|
-
throw new Error("TypeScript config not supported in Pear pre-hook. Use qvac.config.json or qvac.config.mjs.");
|
|
270
|
-
}
|
|
271
|
-
throw new Error(`Unsupported config format: ${ext}. Use .json, .js, or .mjs`);
|
|
272
|
-
}
|
|
273
|
-
/** Discover and load qvac config, returning null if not found */
|
|
274
|
-
async function discoverConfig(appRoot) {
|
|
275
|
-
const configPath = findConfigFile(appRoot);
|
|
276
|
-
if (!configPath) {
|
|
277
|
-
return { config: null, configFile: null };
|
|
278
|
-
}
|
|
279
|
-
const config = await loadConfig(configPath);
|
|
280
|
-
return { config, configFile: path.basename(configPath) };
|
|
281
|
-
}
|
|
282
|
-
/** Resolve plugin set from config or default to all built-in plugins */
|
|
283
|
-
function resolvePlugins(config) {
|
|
284
|
-
const fromConfig = uniqStrings(config?.plugins);
|
|
285
|
-
if (fromConfig.length)
|
|
286
|
-
return fromConfig;
|
|
287
|
-
return [...BUILTIN_PLUGINS];
|
|
288
|
-
}
|
|
289
|
-
/** Parse SDK builtin plugin specifier to extract export info */
|
|
290
|
-
function parseBuiltinSpecifier(specifier) {
|
|
291
|
-
const prefix = `${SDK_NAME}/`;
|
|
292
|
-
const pluginSuffix = "/plugin";
|
|
293
|
-
if (specifier.startsWith(prefix) && specifier.endsWith(pluginSuffix)) {
|
|
294
|
-
const middle = specifier.slice(prefix.length, -pluginSuffix.length);
|
|
295
|
-
const exportName = BUILTIN_PLUGIN_EXPORTS[middle];
|
|
296
|
-
if (!middle.includes("/") && exportName) {
|
|
297
|
-
return { suffix: middle, exportName };
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return null;
|
|
301
|
-
}
|
|
302
|
-
/** Generate the Pear worker entry file content */
|
|
303
|
-
function generatePearWorkerEntry(plugins, appWorkerPath) {
|
|
304
|
-
const imports = [];
|
|
305
|
-
const registrations = [];
|
|
306
|
-
let varIndex = 0;
|
|
307
|
-
for (const specifier of plugins) {
|
|
308
|
-
const builtin = parseBuiltinSpecifier(specifier);
|
|
309
|
-
if (builtin) {
|
|
310
|
-
imports.push(`import { ${builtin.exportName} } from "${SDK_NAME}/${builtin.suffix}/plugin";`);
|
|
311
|
-
registrations.push(`registerPlugin(${builtin.exportName});`);
|
|
312
|
-
}
|
|
313
|
-
else {
|
|
314
|
-
const varName = `customPlugin${varIndex++}`;
|
|
315
|
-
imports.push(`import ${varName} from "${specifier}";`);
|
|
316
|
-
registrations.push(`registerPlugin(${varName});`);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
const pluginsList = plugins.map((p) => `* - ${p}`).join("\n");
|
|
320
|
-
return `/**
|
|
321
|
-
* QVAC Pear Worker Entry (auto-generated)
|
|
322
|
-
* Plugins: ${plugins.length}
|
|
323
|
-
*
|
|
324
|
-
${pluginsList}
|
|
325
|
-
*/
|
|
326
|
-
|
|
327
|
-
import { registerPlugin } from "${SDK_NAME}/plugins";
|
|
328
|
-
|
|
329
|
-
${imports.join("\n")}
|
|
330
|
-
|
|
331
|
-
${registrations.join("\n")}
|
|
332
|
-
|
|
333
|
-
await import(${JSON.stringify(appWorkerPath)});
|
|
334
|
-
`;
|
|
335
|
-
}
|
|
336
|
-
/** Write worker entry file if content changed (idempotent) */
|
|
337
|
-
function writeWorkerEntryIfChanged(appRoot, content) {
|
|
338
|
-
const outputDir = path.join(appRoot, "qvac");
|
|
339
|
-
const entryPath = path.join(appRoot, PEAR_WORKER_ENTRY_PATH);
|
|
340
|
-
if (fs.existsSync(entryPath)) {
|
|
341
|
-
try {
|
|
342
|
-
if (fs.readFileSync(entryPath, "utf8") === content) {
|
|
343
|
-
return false;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
catch {
|
|
347
|
-
// Will rewrite on error
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
if (!fs.existsSync(outputDir)) {
|
|
351
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
352
|
-
}
|
|
353
|
-
atomicWriteFileSync(entryPath, content);
|
|
354
|
-
return true;
|
|
355
|
-
}
|
|
356
|
-
/** Main configuration handler */
|
|
357
|
-
async function configure(options) {
|
|
358
|
-
const appRoot = getAppRoot();
|
|
359
|
-
const { config: qvacConfig } = await discoverConfig(appRoot);
|
|
360
|
-
const plugins = resolvePlugins(qvacConfig);
|
|
361
|
-
const pearWorker = normalizePearWorkerPath(qvacConfig?.pearWorker);
|
|
362
|
-
// Validate worker file exists
|
|
363
|
-
const workerAbs = path.join(appRoot, pearWorker);
|
|
364
|
-
if (!fs.existsSync(workerAbs)) {
|
|
365
|
-
const hint = qvacConfig?.pearWorker
|
|
366
|
-
? `"${String(qvacConfig.pearWorker)}" (resolved to ${workerAbs})`
|
|
367
|
-
: `"${DEFAULT_PEAR_WORKER}". Set "pearWorker" in qvac.config.json to specify your worker path.`;
|
|
368
|
-
throw new Error(`Worker file not found: ${hint}`);
|
|
369
|
-
}
|
|
370
|
-
// Generate worker entry with relative import path from qvac/ directory
|
|
371
|
-
const outputDir = path.join(appRoot, "qvac");
|
|
372
|
-
const appWorkerImport = toRelativeImportSpecifier(outputDir, workerAbs);
|
|
373
|
-
const workerEntryContent = generatePearWorkerEntry(plugins, appWorkerImport);
|
|
374
|
-
writeWorkerEntryIfChanged(appRoot, workerEntryContent);
|
|
375
|
-
// Persist entrypoint to package.json for worker routing
|
|
376
|
-
const workerEntryPath = toPearConfigPath(PEAR_WORKER_ENTRY_PATH);
|
|
377
|
-
persistStageEntrypointsToPackageJson(appRoot, [workerEntryPath]);
|
|
378
|
-
return options;
|
|
379
|
-
}
|
|
380
|
-
// IPC Protocol
|
|
381
|
-
const pipe = pearPipe();
|
|
382
|
-
if (!pipe) {
|
|
383
|
-
console.error(`${LOG_PREFIX} No IPC pipe available`);
|
|
384
|
-
process.exit(1);
|
|
385
|
-
}
|
|
386
|
-
pipe.autoexit = true;
|
|
387
|
-
let exitCode = 0;
|
|
388
|
-
pipe.on("end", () => {
|
|
389
|
-
try {
|
|
390
|
-
Pear.pipe.end();
|
|
391
|
-
}
|
|
392
|
-
finally {
|
|
393
|
-
if (exitCode !== 0)
|
|
394
|
-
process.exit(exitCode);
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
pipe.once("error", (err) => {
|
|
398
|
-
exitCode = exitCode || 1;
|
|
399
|
-
console.error(LOG_PREFIX, err);
|
|
400
|
-
});
|
|
401
|
-
pipe.once("data", (data) => {
|
|
402
|
-
void (async () => {
|
|
403
|
-
let options = null;
|
|
404
|
-
try {
|
|
405
|
-
options = cenc.decode(cenc.any, data);
|
|
406
|
-
}
|
|
407
|
-
catch (err) {
|
|
408
|
-
exitCode = 1;
|
|
409
|
-
console.error(LOG_PREFIX, err);
|
|
410
|
-
try {
|
|
411
|
-
pipe.end(cenc.encode(cenc.any, { tag: "configure", data: {} }));
|
|
412
|
-
}
|
|
413
|
-
catch {
|
|
414
|
-
pipe.destroy(err);
|
|
415
|
-
}
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
try {
|
|
419
|
-
const config = await configure(options);
|
|
420
|
-
pipe.end(cenc.encode(cenc.any, { tag: "configure", data: config }));
|
|
421
|
-
}
|
|
422
|
-
catch (err) {
|
|
423
|
-
exitCode = 1;
|
|
424
|
-
console.error(LOG_PREFIX, err);
|
|
425
|
-
try {
|
|
426
|
-
pipe.end(cenc.encode(cenc.any, { tag: "configure", data: options }));
|
|
427
|
-
}
|
|
428
|
-
catch {
|
|
429
|
-
pipe.destroy(err);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
})();
|
|
433
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accumulates profiling statistics and maintains a bounded buffer of recent events.
|
|
3
|
-
* Uses a ring buffer for O(1) event insertion.
|
|
4
|
-
*/
|
|
5
|
-
import type { ProfilingEvent, AggregatedStats } from "./types";
|
|
6
|
-
export declare function createAggregator(maxRecentEvents?: number): void;
|
|
7
|
-
export declare function recordEvent(event: ProfilingEvent, storeInBuffer?: boolean): void;
|
|
8
|
-
export declare function getAggregates(): Record<string, AggregatedStats>;
|
|
9
|
-
/** Returns events in chronological order (oldest first). */
|
|
10
|
-
export declare function getRecentEvents(): ProfilingEvent[];
|
|
11
|
-
export declare function getEventCount(): number;
|
|
12
|
-
export declare function getDroppedCount(): number;
|
|
13
|
-
export declare function clearAggregator(): void;
|
|
14
|
-
export declare function setMaxRecentEvents(max: number): void;
|
|
15
|
-
//# sourceMappingURL=aggregator.d.ts.map
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accumulates profiling statistics and maintains a bounded buffer of recent events.
|
|
3
|
-
* Uses a ring buffer for O(1) event insertion.
|
|
4
|
-
*/
|
|
5
|
-
import { getGlobalSingleton } from "../utils/global-singleton.js";
|
|
6
|
-
import { createRingBuffer, ringBufferPush, ringBufferToArray, ringBufferClear, ringBufferResize, ringBufferDroppedCount, } from "./ring-buffer.js";
|
|
7
|
-
const DEFAULT_MAX_RECENT_EVENTS = 1000;
|
|
8
|
-
const AGGREGATOR_STATE_KEY = Symbol.for("@qvac/sdk:profiler-aggregator-state");
|
|
9
|
-
function getAggregatorState() {
|
|
10
|
-
return getGlobalSingleton(AGGREGATOR_STATE_KEY, () => {
|
|
11
|
-
return {
|
|
12
|
-
stats: new Map(),
|
|
13
|
-
eventBuffer: createRingBuffer(DEFAULT_MAX_RECENT_EVENTS),
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
export function createAggregator(maxRecentEvents = DEFAULT_MAX_RECENT_EVENTS) {
|
|
18
|
-
const state = getAggregatorState();
|
|
19
|
-
state.stats = new Map();
|
|
20
|
-
state.eventBuffer = createRingBuffer(maxRecentEvents);
|
|
21
|
-
}
|
|
22
|
-
function recordStats(key, value) {
|
|
23
|
-
const aggregator = getAggregatorState();
|
|
24
|
-
let statsState = aggregator.stats.get(key);
|
|
25
|
-
if (!statsState) {
|
|
26
|
-
statsState = {
|
|
27
|
-
count: 0,
|
|
28
|
-
min: Infinity,
|
|
29
|
-
max: -Infinity,
|
|
30
|
-
sum: 0,
|
|
31
|
-
last: 0,
|
|
32
|
-
};
|
|
33
|
-
aggregator.stats.set(key, statsState);
|
|
34
|
-
}
|
|
35
|
-
statsState.count++;
|
|
36
|
-
statsState.sum += value;
|
|
37
|
-
statsState.last = value;
|
|
38
|
-
if (value < statsState.min)
|
|
39
|
-
statsState.min = value;
|
|
40
|
-
if (value > statsState.max)
|
|
41
|
-
statsState.max = value;
|
|
42
|
-
}
|
|
43
|
-
function getStats(state) {
|
|
44
|
-
return {
|
|
45
|
-
count: state.count,
|
|
46
|
-
min: state.count > 0 ? state.min : 0,
|
|
47
|
-
max: state.count > 0 ? state.max : 0,
|
|
48
|
-
avg: state.count > 0 ? state.sum / state.count : 0,
|
|
49
|
-
sum: state.sum,
|
|
50
|
-
last: state.last,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export function recordEvent(event, storeInBuffer = true) {
|
|
54
|
-
const state = getAggregatorState();
|
|
55
|
-
if (storeInBuffer) {
|
|
56
|
-
ringBufferPush(state.eventBuffer, event);
|
|
57
|
-
}
|
|
58
|
-
if (event.ms !== undefined) {
|
|
59
|
-
const key = event.phase ? `${event.op}.${event.phase}` : event.op;
|
|
60
|
-
recordStats(key, event.ms);
|
|
61
|
-
}
|
|
62
|
-
if (event.gauges) {
|
|
63
|
-
const baseKey = event.phase ? `${event.op}.${event.phase}` : event.op;
|
|
64
|
-
for (const [gaugeName, value] of Object.entries(event.gauges)) {
|
|
65
|
-
recordStats(`${baseKey}.${gaugeName}`, value);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
export function getAggregates() {
|
|
70
|
-
const state = getAggregatorState();
|
|
71
|
-
const result = {};
|
|
72
|
-
for (const [key, statsState] of state.stats) {
|
|
73
|
-
result[key] = getStats(statsState);
|
|
74
|
-
}
|
|
75
|
-
return result;
|
|
76
|
-
}
|
|
77
|
-
/** Returns events in chronological order (oldest first). */
|
|
78
|
-
export function getRecentEvents() {
|
|
79
|
-
return ringBufferToArray(getAggregatorState().eventBuffer);
|
|
80
|
-
}
|
|
81
|
-
export function getEventCount() {
|
|
82
|
-
const state = getAggregatorState();
|
|
83
|
-
let total = 0;
|
|
84
|
-
for (const statsState of state.stats.values()) {
|
|
85
|
-
total += statsState.count;
|
|
86
|
-
}
|
|
87
|
-
return total;
|
|
88
|
-
}
|
|
89
|
-
export function getDroppedCount() {
|
|
90
|
-
return ringBufferDroppedCount(getAggregatorState().eventBuffer);
|
|
91
|
-
}
|
|
92
|
-
export function clearAggregator() {
|
|
93
|
-
const state = getAggregatorState();
|
|
94
|
-
state.stats.clear();
|
|
95
|
-
ringBufferClear(state.eventBuffer);
|
|
96
|
-
}
|
|
97
|
-
export function setMaxRecentEvents(max) {
|
|
98
|
-
const state = getAggregatorState();
|
|
99
|
-
state.eventBuffer = ringBufferResize(state.eventBuffer, max);
|
|
100
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime-safe monotonic clock for profiling.
|
|
3
|
-
* Priority: performance.now > process.hrtime > Date.now
|
|
4
|
-
*/
|
|
5
|
-
export type ClockSource = "performance" | "hrtime" | "date";
|
|
6
|
-
export declare function getClockSource(): ClockSource;
|
|
7
|
-
export declare function isMonotonic(): boolean;
|
|
8
|
-
export declare function nowMs(): number;
|
|
9
|
-
export declare function measureAsync<T>(fn: () => Promise<T>): Promise<[T, number]>;
|
|
10
|
-
export declare function measureSync<T>(fn: () => T): [T, number];
|
|
11
|
-
export declare function generateProfileId(): string;
|
|
12
|
-
//# sourceMappingURL=clock.d.ts.map
|
package/dist/profiling/clock.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime-safe monotonic clock for profiling.
|
|
3
|
-
* Priority: performance.now > process.hrtime > Date.now
|
|
4
|
-
*/
|
|
5
|
-
let clockSource;
|
|
6
|
-
let nowMsImpl;
|
|
7
|
-
// Detect and cache the best available clock source at module load
|
|
8
|
-
if (typeof globalThis !== "undefined" &&
|
|
9
|
-
typeof globalThis.performance !== "undefined" &&
|
|
10
|
-
typeof globalThis.performance.now === "function") {
|
|
11
|
-
clockSource = "performance";
|
|
12
|
-
const perfNow = globalThis.performance.now.bind(globalThis.performance);
|
|
13
|
-
nowMsImpl = () => perfNow();
|
|
14
|
-
}
|
|
15
|
-
else if (typeof process !== "undefined" &&
|
|
16
|
-
typeof process.hrtime === "function" &&
|
|
17
|
-
typeof process.hrtime.bigint === "function") {
|
|
18
|
-
clockSource = "hrtime";
|
|
19
|
-
const hrtime = process.hrtime.bigint.bind(process.hrtime);
|
|
20
|
-
const startNs = hrtime();
|
|
21
|
-
nowMsImpl = () => Number(hrtime() - startNs) / 1_000_000;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
clockSource = "date";
|
|
25
|
-
const startMs = Date.now();
|
|
26
|
-
nowMsImpl = () => Date.now() - startMs;
|
|
27
|
-
}
|
|
28
|
-
export function getClockSource() {
|
|
29
|
-
return clockSource;
|
|
30
|
-
}
|
|
31
|
-
export function isMonotonic() {
|
|
32
|
-
return clockSource === "performance" || clockSource === "hrtime";
|
|
33
|
-
}
|
|
34
|
-
export function nowMs() {
|
|
35
|
-
return nowMsImpl();
|
|
36
|
-
}
|
|
37
|
-
export async function measureAsync(fn) {
|
|
38
|
-
const start = nowMs();
|
|
39
|
-
const result = await fn();
|
|
40
|
-
return [result, nowMs() - start];
|
|
41
|
-
}
|
|
42
|
-
export function measureSync(fn) {
|
|
43
|
-
const start = nowMs();
|
|
44
|
-
const result = fn();
|
|
45
|
-
return [result, nowMs() - start];
|
|
46
|
-
}
|
|
47
|
-
export function generateProfileId() {
|
|
48
|
-
const timestamp = Date.now().toString(36);
|
|
49
|
-
const random = Math.random().toString(36).substring(2, 8);
|
|
50
|
-
return `${timestamp}-${random}`;
|
|
51
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Central state management for profiling enablement, configuration, and recording.
|
|
3
|
-
*
|
|
4
|
-
* Precedence (highest to lowest):
|
|
5
|
-
* 1. Per-call override
|
|
6
|
-
* 2. Runtime API (enable/disable)
|
|
7
|
-
* 3. Disabled default
|
|
8
|
-
*/
|
|
9
|
-
import type { ProfilerMode, PerCallProfiling } from "../schemas/index";
|
|
10
|
-
import type { ProfilerRuntimeOptions, ProfilingEvent, AggregatedStats } from "./types";
|
|
11
|
-
export interface ResolvedProfilerConfig {
|
|
12
|
-
enabled: boolean;
|
|
13
|
-
mode: ProfilerMode;
|
|
14
|
-
includeServerBreakdown: boolean;
|
|
15
|
-
operationFilters: string[];
|
|
16
|
-
maxRecentEvents: number;
|
|
17
|
-
}
|
|
18
|
-
type RecordCallback = (event: ProfilingEvent) => void;
|
|
19
|
-
export declare function enable(options?: ProfilerRuntimeOptions): void;
|
|
20
|
-
export declare function disable(): void;
|
|
21
|
-
export declare function isEnabled(): boolean;
|
|
22
|
-
export declare function getEffectiveConfig(): ResolvedProfilerConfig;
|
|
23
|
-
export declare function shouldProfile(operation: string, perCallOptions?: PerCallProfiling): boolean;
|
|
24
|
-
export declare function shouldIncludeServerBreakdown(perCallOptions?: PerCallProfiling): boolean;
|
|
25
|
-
export declare function generateId(): string;
|
|
26
|
-
export declare function record(event: ProfilingEvent): void;
|
|
27
|
-
/** Returns unsubscribe function. */
|
|
28
|
-
export declare function onRecord(callback: RecordCallback): () => void;
|
|
29
|
-
export declare function getAggregates(): Record<string, AggregatedStats>;
|
|
30
|
-
export declare function getRecentEvents(): ProfilingEvent[];
|
|
31
|
-
export declare function clear(): void;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=controller.d.ts.map
|