@qvac/inference 0.21.1 → 0.23.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/NOTICE +89 -41
- package/README.md +44 -1
- package/dist/api/assess-model-fit.d.ts +4 -4
- package/dist/api/assess-model-fit.js +4 -4
- package/dist/api/audio-gen.d.ts +4 -1
- package/dist/api/audio-gen.js +5 -2
- package/dist/api/batch-completion.js +1 -1
- package/dist/api/completion-stream.d.ts +2 -1
- package/dist/api/completion-stream.js +4 -2
- package/dist/api/decide.d.ts +26 -0
- package/dist/api/decide.js +26 -0
- package/dist/api/diffusion.d.ts +18 -1
- package/dist/api/diffusion.js +18 -1
- package/dist/api/download-asset.js +1 -1
- package/dist/api/finetune.js +1 -1
- package/dist/api/get-model-info.d.ts +1 -1
- package/dist/api/index.d.ts +39 -37
- package/dist/api/index.js +38 -36
- package/dist/api/load-model.js +2 -2
- package/dist/api/logging-stream-registry.js +11 -7
- package/dist/api/logging-stream.d.ts +11 -1
- package/dist/api/logging-stream.js +11 -2
- package/dist/api/registry.d.ts +2 -1
- package/dist/api/registry.js +5 -4
- package/dist/api/rerank.d.ts +17 -0
- package/dist/api/rerank.js +36 -0
- package/dist/api/subscribe-logs.js +5 -3
- package/dist/api/text-to-speech.d.ts +1 -0
- package/dist/api/text-to-speech.js +15 -19
- package/dist/api/transcribe.js +5 -2
- package/dist/api/unload-model.js +1 -1
- package/dist/api/video-request.d.ts +5 -5
- package/dist/api/video.d.ts +5 -4
- package/dist/api/video.js +6 -5
- package/dist/api/vla.js +1 -1
- package/dist/api/world-result.js +1 -1
- package/dist/api/world.d.ts +1 -1
- package/dist/api/world.js +1 -1
- package/dist/config/resolve-config.d.ts +1 -1
- package/dist/config/resolve-config.js +1 -1
- package/dist/constants/index.d.ts +2 -2
- package/dist/constants/index.js +2 -2
- package/dist/dispatch.d.ts +3 -2
- package/dist/dispatch.js +16 -4
- package/dist/errors/index.d.ts +9 -0
- package/dist/errors/index.js +18 -1
- package/dist/handlers/assess-model-fit.d.ts +5 -3
- package/dist/handlers/assess-model-fit.js +84 -32
- package/dist/handlers/cancelHandler.js +1 -1
- package/dist/handlers/completion-orchestrate.js +2 -2
- package/dist/handlers/download-asset.js +2 -2
- package/dist/handlers/finetune.js +1 -1
- package/dist/handlers/get-loaded-model-info.js +3 -5
- package/dist/handlers/get-model-info.js +1 -1
- package/dist/handlers/load-model/coreml-sidecars.d.ts +15 -0
- package/dist/handlers/load-model/coreml-sidecars.js +71 -8
- package/dist/handlers/load-model/download-manager.d.ts +1 -1
- package/dist/handlers/load-model/download-stats.d.ts +2 -2
- package/dist/handlers/load-model/download-stats.js +3 -3
- package/dist/handlers/load-model/handler.js +10 -7
- package/dist/handlers/load-model/http-verify.d.ts +1 -1
- package/dist/handlers/load-model/http.d.ts +1 -1
- package/dist/handlers/load-model/http.js +3 -3
- package/dist/handlers/load-model/hyperdrive.d.ts +1 -1
- package/dist/handlers/load-model/hyperdrive.js +2 -2
- package/dist/handlers/load-model/index.d.ts +2 -2
- package/dist/handlers/load-model/index.js +2 -2
- package/dist/handlers/load-model/registry-companion-set.d.ts +1 -1
- package/dist/handlers/load-model/registry-companion-set.js +1 -1
- package/dist/handlers/load-model/registry-download-utils.d.ts +3 -3
- package/dist/handlers/load-model/registry-download-utils.js +2 -2
- package/dist/handlers/load-model/registry.d.ts +2 -2
- package/dist/handlers/load-model/registry.js +5 -5
- package/dist/handlers/load-model/resolve-session.d.ts +1 -1
- package/dist/handlers/load-model/resolve-session.js +11 -3
- package/dist/handlers/load-model/resolve.d.ts +1 -1
- package/dist/handlers/load-model/resolve.js +5 -5
- package/dist/handlers/load-model/safe-fetch.js +5 -6
- package/dist/handlers/logging-stream.d.ts +2 -1
- package/dist/handlers/logging-stream.js +23 -7
- package/dist/handlers/registry.d.ts +3 -1
- package/dist/handlers/registry.js +7 -5
- package/dist/handlers/types.d.ts +7 -1
- package/dist/handlers/vector-index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/logging/addon.d.ts +1 -1
- package/dist/logging/addon.js +1 -1
- package/dist/logging/index.d.ts +5 -5
- package/dist/logging/index.js +4 -4
- package/dist/logging/logger.d.ts +1 -1
- package/dist/logging/logger.js +2 -2
- package/dist/{resources/model-fit → model-fit}/assess.d.ts +18 -26
- package/dist/{resources/model-fit → model-fit}/assess.js +210 -274
- package/dist/{resources/model-fit/native-probe/classify-fit.d.ts → model-fit/classify.d.ts} +2 -2
- package/dist/{resources/model-fit/native-probe/classify-fit.js → model-fit/classify.js} +36 -5
- package/dist/{resources/model-fit/fit-stub/fetch-fit-stub.d.ts → model-fit/description/fetch.d.ts} +4 -2
- package/dist/{resources/model-fit/fit-stub/fetch-fit-stub.js → model-fit/description/fetch.js} +11 -6
- package/dist/{resources/model-fit/fit-stub/project-fit-from-load.d.ts → model-fit/description/project.d.ts} +3 -3
- package/dist/{resources/model-fit/fit-stub/project-fit-from-load.js → model-fit/description/project.js} +4 -2
- package/dist/{resources/model-fit/fit-stub/resolve-load-from-stubs.d.ts → model-fit/description/resolve-load.d.ts} +6 -4
- package/dist/{resources/model-fit/fit-stub/resolve-load-from-stubs.js → model-fit/description/resolve-load.js} +14 -6
- package/dist/model-fit/floor.d.ts +31 -0
- package/dist/{resources/model-fit → model-fit}/floor.js +13 -13
- package/dist/model-fit/kv-cache.d.ts +23 -0
- package/dist/model-fit/kv-cache.js +85 -0
- package/dist/{resources/model-fit/native-probe/advisory-fit.d.ts → model-fit/load-check.d.ts} +17 -14
- package/dist/{resources/model-fit/native-probe/advisory-fit.js → model-fit/load-check.js} +23 -64
- package/dist/model-fit/platform.d.ts +14 -0
- package/dist/model-fit/platform.js +26 -0
- package/dist/{resources/model-fit/native-probe/create-fit-request.d.ts → model-fit/request/create.d.ts} +5 -2
- package/dist/model-fit/request/create.js +61 -0
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/asr.d.ts +5 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/asr.js +32 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/audiogen.d.ts +1 -1
- package/dist/model-fit/request/engines/audiogen.js +63 -0
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/diffusion.d.ts +1 -1
- package/dist/model-fit/request/engines/diffusion.js +93 -0
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/llama.d.ts +2 -3
- package/dist/model-fit/request/engines/llama.js +44 -0
- package/dist/model-fit/request/engines/nmt.d.ts +8 -0
- package/dist/model-fit/request/engines/nmt.js +11 -0
- package/dist/model-fit/request/engines/ocr.d.ts +9 -0
- package/dist/model-fit/request/engines/ocr.js +13 -0
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/tts.d.ts +3 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/tts.js +50 -4
- package/dist/{resources/model-fit/native-probe/engine-fit.d.ts → model-fit/run/engine.d.ts} +17 -4
- package/dist/{resources/model-fit/native-probe/engine-fit.js → model-fit/run/engine.js} +2 -2
- package/dist/model-fit/run/run.d.ts +43 -0
- package/dist/model-fit/run/run.js +204 -0
- package/dist/models/registry/index.d.ts +1 -1
- package/dist/models/registry/index.js +2 -2
- package/dist/models/registry/models.d.ts +1072 -815
- package/dist/models/registry/models.js +3704 -3405
- package/dist/models/registry/resource-profiles.d.ts +1 -2
- package/dist/models/registry/resource-profiles.js +406 -3
- package/dist/plugins/builtin/asr-ggml/config.d.ts +7 -1
- package/dist/plugins/builtin/asr-ggml/config.js +6 -0
- package/dist/plugins/builtin/asr-ggml/logging.d.ts +1 -1
- package/dist/plugins/builtin/audiogen-ggml/config.d.ts +1 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-edit-stream.js +29 -11
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.d.ts +27 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.js +23 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.js +7 -28
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-understand.js +2 -2
- package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +106 -13
- package/dist/plugins/builtin/audiogen-ggml/plugin.js +5 -4
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +20 -3
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +3 -3
- package/dist/plugins/builtin/ggml-classification/plugin.js +1 -1
- package/dist/plugins/builtin/ggml-ocr/params.d.ts +18 -0
- package/dist/plugins/builtin/ggml-ocr/params.js +37 -0
- package/dist/plugins/builtin/ggml-ocr/plugin.d.ts +9 -0
- package/dist/plugins/builtin/ggml-ocr/plugin.js +17 -39
- package/dist/plugins/builtin/ggml-vla/plugin.d.ts +9 -2
- package/dist/plugins/builtin/ggml-vla/plugin.js +4 -4
- package/dist/plugins/builtin/index.d.ts +15 -12
- package/dist/plugins/builtin/index.js +15 -12
- package/dist/plugins/builtin/llamacpp-completion/ops/batch-completion-stream.js +5 -7
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.d.ts +2 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.js +6 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.d.ts +10 -7
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +141 -204
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.d.ts +36 -92
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.js +67 -216
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.d.ts +2 -49
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.js +2 -46
- package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +208 -19
- package/dist/plugins/builtin/llamacpp-completion/plugin.js +28 -20
- package/dist/plugins/builtin/llamacpp-completion/transform.js +5 -1
- package/dist/plugins/builtin/llamacpp-decision/helpers.d.ts +5 -0
- package/dist/plugins/builtin/llamacpp-decision/helpers.js +89 -0
- package/dist/plugins/builtin/llamacpp-decision/ops/decide.d.ts +91 -0
- package/dist/plugins/builtin/llamacpp-decision/ops/decide.js +129 -0
- package/dist/plugins/builtin/llamacpp-decision/plugin.d.ts +222 -0
- package/dist/plugins/builtin/llamacpp-decision/plugin.js +44 -0
- package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +9 -1
- package/dist/plugins/builtin/llamacpp-embedding/plugin.js +15 -5
- package/dist/plugins/builtin/llamacpp-embedding/transform.js +9 -0
- package/dist/plugins/builtin/llamacpp-rerank/helpers.d.ts +3 -0
- package/dist/plugins/builtin/llamacpp-rerank/helpers.js +16 -0
- package/dist/plugins/builtin/llamacpp-rerank/ops/rerank.d.ts +5 -0
- package/dist/plugins/builtin/llamacpp-rerank/ops/rerank.js +117 -0
- package/dist/plugins/builtin/llamacpp-rerank/plugin.d.ts +91 -0
- package/dist/plugins/builtin/llamacpp-rerank/plugin.js +45 -0
- package/dist/plugins/builtin/moss-transcribe/plugin.d.ts +143 -0
- package/dist/plugins/builtin/moss-transcribe/plugin.js +96 -0
- package/dist/plugins/builtin/nmtcpp-translation/load-files.d.ts +6 -0
- package/dist/plugins/builtin/nmtcpp-translation/load-files.js +70 -0
- package/dist/plugins/builtin/nmtcpp-translation/plugin.d.ts +17 -0
- package/dist/plugins/builtin/nmtcpp-translation/plugin.js +10 -74
- package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +25 -4
- package/dist/plugins/builtin/parakeet-transcription/plugin.js +20 -5
- package/dist/plugins/builtin/sdcpp-generation/ops/diffusion.d.ts +5 -2
- package/dist/plugins/builtin/sdcpp-generation/ops/diffusion.js +168 -52
- package/dist/plugins/builtin/sdcpp-generation/ops/video.d.ts +5 -2
- package/dist/plugins/builtin/sdcpp-generation/ops/video.js +28 -13
- package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +83 -1
- package/dist/plugins/builtin/sdcpp-generation/plugin.js +55 -52
- package/dist/plugins/builtin/sdcpp-generation/upscaler-config.d.ts +15 -0
- package/dist/plugins/builtin/sdcpp-generation/upscaler-config.js +19 -0
- package/dist/plugins/builtin/sdcpp-generation/world-config.d.ts +8 -0
- package/dist/plugins/builtin/sdcpp-generation/world-config.js +9 -0
- package/dist/plugins/builtin/tts-ggml/ops/moss-options.d.ts +22 -0
- package/dist/plugins/builtin/tts-ggml/ops/moss-options.js +79 -0
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.d.ts +1 -1
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.js +5 -2
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +19 -7
- package/dist/plugins/builtin/tts-ggml/plugin.d.ts +151 -1
- package/dist/plugins/builtin/tts-ggml/plugin.js +39 -2
- package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +28 -4
- package/dist/plugins/builtin/whispercpp-transcription/plugin.js +8 -4
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +2 -2
- package/dist/plugins/ops/kv-cache-utils.d.ts +5 -4
- package/dist/plugins/ops/kv-cache-utils.js +25 -33
- package/dist/plugins/ops/load-model.d.ts +8 -2
- package/dist/plugins/ops/load-model.js +33 -19
- package/dist/plugins/ops/transcribe.js +18 -2
- package/dist/plugins/ops/translate.js +3 -3
- package/dist/plugins/ops/unload-model.js +1 -1
- package/dist/plugins/turbovec-backend.js +5 -5
- package/dist/profiling/aggregator.d.ts +1 -1
- package/dist/profiling/aggregator.js +1 -1
- package/dist/profiling/controller.d.ts +1 -1
- package/dist/profiling/controller.js +2 -2
- package/dist/profiling/events.d.ts +1 -1
- package/dist/profiling/events.js +2 -2
- package/dist/profiling/exporters.d.ts +1 -1
- package/dist/profiling/exporters.js +3 -3
- package/dist/profiling/index.d.ts +13 -13
- package/dist/profiling/index.js +12 -12
- package/dist/profiling/operation-metrics.d.ts +1 -1
- package/dist/profiling/operation-metrics.js +2 -2
- package/dist/profiling/operation-wrappers.js +3 -3
- package/dist/profiling/profiler.js +1 -1
- package/dist/rag/handler.js +1 -1
- package/dist/rag/handlers/close-workspace.js +1 -1
- package/dist/rag/handlers/delete-embeddings.js +1 -1
- package/dist/rag/handlers/delete-workspace.js +1 -1
- package/dist/rag/handlers/ingest.js +1 -1
- package/dist/rag/handlers/list-workspaces.d.ts +1 -1
- package/dist/rag/handlers/list-workspaces.js +1 -1
- package/dist/rag/handlers/reindex.js +1 -1
- package/dist/rag/handlers/save-embeddings.js +1 -1
- package/dist/rag/handlers/search.js +1 -1
- package/dist/rag/index.d.ts +11 -11
- package/dist/rag/index.js +11 -11
- package/dist/rag/rag-workspace-manager.js +1 -1
- package/dist/registry.js +3 -1
- package/dist/resources/collector.d.ts +1 -1
- package/dist/resources/collector.js +1 -1
- package/dist/resources/instance.d.ts +1 -1
- package/dist/resources/instance.js +1 -1
- package/dist/resources/native.d.ts +1 -1
- package/dist/resources/normalize.d.ts +1 -1
- package/dist/rpc/inventory.js +5 -7
- package/dist/runtime/env.d.ts +0 -2
- package/dist/runtime/env.js +2 -9
- package/dist/runtime/index.d.ts +5 -5
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/lifecycle.js +7 -7
- package/dist/runtime/model-config-utils.js +9 -1
- package/dist/runtime/model-registry.d.ts +3 -1
- package/dist/runtime/model-registry.js +2 -1
- package/dist/runtime/registry-client.js +1 -1
- package/dist/runtime/request-context.d.ts +3 -3
- package/dist/runtime/request-context.js +22 -1
- package/dist/runtime/request-registry.d.ts +1 -1
- package/dist/runtime/request-registry.js +1 -1
- package/dist/runtime/state.d.ts +1 -1
- package/dist/runtime/state.js +7 -2
- package/dist/runtime/vector-index-backend.d.ts +2 -2
- package/dist/runtime/vector-index-registry.d.ts +5 -5
- package/dist/runtime/vector-index-registry.js +36 -13
- package/dist/schemas/assess-model-fit.d.ts +106 -43
- package/dist/schemas/assess-model-fit.js +69 -32
- package/dist/schemas/audio-gen.d.ts +199 -19
- package/dist/schemas/audio-gen.js +183 -51
- package/dist/schemas/batch-completion-stream.d.ts +210 -36
- package/dist/schemas/batch-completion-stream.js +3 -3
- package/dist/schemas/bci-config.d.ts +3 -0
- package/dist/schemas/bci-config.js +2 -2
- package/dist/schemas/bci.d.ts +24 -3
- package/dist/schemas/bci.js +2 -2
- package/dist/schemas/cancel.d.ts +10 -0
- package/dist/schemas/cancel.js +2 -0
- package/dist/schemas/common.d.ts +1465 -162
- package/dist/schemas/common.js +37 -31
- package/dist/schemas/completion-event.d.ts +8 -2
- package/dist/schemas/completion-event.js +4 -1
- package/dist/schemas/completion-stream.d.ts +243 -39
- package/dist/schemas/completion-stream.js +100 -29
- package/dist/schemas/config.d.ts +1326 -18
- package/dist/schemas/config.js +30 -8
- package/dist/schemas/decision.d.ts +610 -0
- package/dist/schemas/decision.js +219 -0
- package/dist/schemas/download-asset.d.ts +10 -4
- package/dist/schemas/download-asset.js +1 -1
- package/dist/schemas/engine-addon-map.d.ts +9 -1
- package/dist/schemas/engine-addon-map.js +26 -5
- package/dist/schemas/errors.d.ts +2 -0
- package/dist/schemas/errors.js +11 -1
- package/dist/schemas/index.d.ts +51 -48
- package/dist/schemas/index.js +50 -47
- package/dist/schemas/llamacpp-config.d.ts +222 -6
- package/dist/schemas/llamacpp-config.js +129 -7
- package/dist/schemas/load-model.d.ts +7960 -1492
- package/dist/schemas/load-model.js +122 -10
- package/dist/schemas/mcp-adapter.d.ts +1 -1
- package/dist/schemas/model-config-schemas.d.ts +428 -9
- package/dist/schemas/model-config-schemas.js +16 -11
- package/dist/schemas/model-fit-policy.d.ts +17 -0
- package/dist/schemas/model-fit-policy.js +17 -0
- package/dist/schemas/model-info.d.ts +20 -2
- package/dist/schemas/model-info.js +4 -3
- package/dist/schemas/model-resource-profile.d.ts +4 -4
- package/dist/schemas/model-resource-profile.js +2 -5
- package/dist/schemas/model-src-utils.d.ts +14 -2
- package/dist/schemas/model-src-utils.js +2 -2
- package/dist/schemas/model-types.d.ts +14 -1
- package/dist/schemas/model-types.js +4 -0
- package/dist/schemas/ocr.d.ts +76 -0
- package/dist/schemas/ocr.js +43 -1
- package/dist/schemas/plugin.d.ts +16 -4
- package/dist/schemas/plugin.js +12 -0
- package/dist/schemas/profiling.d.ts +4 -4
- package/dist/schemas/profiling.js +1 -1
- package/dist/schemas/rag.js +1 -1
- package/dist/schemas/registry.d.ts +34 -0
- package/dist/schemas/registry.js +5 -1
- package/dist/schemas/reload-config.d.ts +14 -2
- package/dist/schemas/reload-config.js +2 -2
- package/dist/schemas/rerank.d.ts +131 -0
- package/dist/schemas/rerank.js +102 -0
- package/dist/schemas/rpc-server.js +3 -3
- package/dist/schemas/sdcpp-config.d.ts +82 -0
- package/dist/schemas/sdcpp-config.js +41 -22
- package/dist/schemas/system-resources.d.ts +4 -4
- package/dist/schemas/text-to-speech.d.ts +463 -3
- package/dist/schemas/text-to-speech.js +129 -11
- package/dist/schemas/tools.d.ts +13 -4
- package/dist/schemas/tools.js +18 -6
- package/dist/schemas/transcription-config.d.ts +20 -0
- package/dist/schemas/transcription-config.js +54 -4
- package/dist/schemas/transcription.d.ts +47 -5
- package/dist/schemas/transcription.js +52 -5
- package/dist/schemas/translate.d.ts +2 -2
- package/dist/schemas/translate.js +1 -1
- package/dist/schemas/translation-config.d.ts +40 -10
- package/dist/schemas/translation-config.js +1 -1
- package/dist/schemas/vla.d.ts +9 -2
- package/dist/schemas/vla.js +9 -5
- package/dist/surface.d.ts +3 -2
- package/dist/surface.js +3 -2
- package/dist/utils/addon-responses.d.ts +3 -0
- package/dist/utils/aggregate-events.d.ts +1 -1
- package/dist/utils/aggregate-events.js +2 -2
- package/dist/utils/archive.js +2 -2
- package/dist/utils/asr-events.d.ts +1 -0
- package/dist/utils/asr-events.js +2 -1
- package/dist/utils/audio/decoder.js +3 -1
- package/dist/utils/audio-input.js +1 -1
- package/dist/utils/cache/auto-history.d.ts +2 -1
- package/dist/utils/cache/auto-history.js +2 -2
- package/dist/utils/cache/paths.js +6 -6
- package/dist/utils/cache/types.d.ts +7 -0
- package/dist/utils/checksum.d.ts +2 -0
- package/dist/utils/checksum.js +41 -2
- package/dist/utils/completion-normalizer.js +1 -1
- package/dist/utils/gguf-architecture.d.ts +7 -0
- package/dist/utils/gguf-architecture.js +142 -0
- package/dist/utils/gguf-tensor-extractor.js +1 -1
- package/dist/utils/index.d.ts +13 -13
- package/dist/utils/index.js +13 -13
- package/dist/utils/mcp-adapter.d.ts +1 -1
- package/dist/utils/mcp-adapter.js +13 -9
- package/dist/utils/path-security.js +1 -1
- package/dist/utils/shard-utils.d.ts +5 -0
- package/dist/utils/shard-utils.js +19 -3
- package/dist/utils/tool-helpers.d.ts +1 -1
- package/dist/utils/tool-helpers.js +20 -52
- package/dist/utils/tool-integration.d.ts +1 -0
- package/dist/utils/tool-integration.js +3 -6
- package/dist/utils/tools/defer.d.ts +16 -26
- package/dist/utils/tools/defer.js +50 -41
- package/dist/utils/tools/dialect.d.ts +15 -4
- package/dist/utils/tools/dialect.js +34 -5
- package/dist/utils/tools/index.d.ts +3 -3
- package/dist/utils/tools/index.js +3 -3
- package/dist/utils/tools/parser.js +8 -8
- package/dist/utils/tools/parsers/dsml.d.ts +1 -1
- package/dist/utils/tools/parsers/dsml.js +8 -5
- package/dist/utils/tools/parsers/gemma4native.d.ts +1 -1
- package/dist/utils/tools/parsers/gemma4native.js +1 -1
- package/dist/utils/tools/parsers/harmony.d.ts +1 -1
- package/dist/utils/tools/parsers/harmony.js +1 -1
- package/dist/utils/tools/parsers/hermes.d.ts +1 -1
- package/dist/utils/tools/parsers/hermes.js +1 -1
- package/dist/utils/tools/parsers/json.d.ts +1 -1
- package/dist/utils/tools/parsers/json.js +1 -1
- package/dist/utils/tools/parsers/pythonic.d.ts +1 -1
- package/dist/utils/tools/parsers/pythonic.js +1 -1
- package/dist/utils/tools/parsers/qwen35.d.ts +1 -1
- package/dist/utils/tools/parsers/qwen35.js +7 -4
- package/dist/utils/tools/shared.d.ts +3 -0
- package/dist/utils/tools/shared.js +62 -0
- package/dist/utils/transcribe-metadata.d.ts +8 -1
- package/dist/utils/transcribe-metadata.js +13 -3
- package/dist/utils/tts-stats.d.ts +2 -1
- package/dist/utils/until-aborted.d.ts +7 -0
- package/dist/utils/until-aborted.js +34 -0
- package/package.json +68 -51
- package/dist/resources/model-fit/calibration/darwin-arm64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/darwin-arm64.js +0 -36
- package/dist/resources/model-fit/calibration/darwin-x64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/darwin-x64.js +0 -38
- package/dist/resources/model-fit/calibration/fit.d.ts +0 -73
- package/dist/resources/model-fit/calibration/fit.js +0 -152
- package/dist/resources/model-fit/calibration/index.d.ts +0 -37
- package/dist/resources/model-fit/calibration/index.js +0 -75
- package/dist/resources/model-fit/calibration/linux-arm64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/linux-arm64.js +0 -38
- package/dist/resources/model-fit/calibration/linux-x64-vulkan.d.ts +0 -8
- package/dist/resources/model-fit/calibration/linux-x64-vulkan.js +0 -39
- package/dist/resources/model-fit/calibration/linux-x64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/linux-x64.js +0 -38
- package/dist/resources/model-fit/calibration/win32-x64-vulkan-shared.d.ts +0 -8
- package/dist/resources/model-fit/calibration/win32-x64-vulkan-shared.js +0 -39
- package/dist/resources/model-fit/calibration/win32-x64-vulkan.d.ts +0 -8
- package/dist/resources/model-fit/calibration/win32-x64-vulkan.js +0 -36
- package/dist/resources/model-fit/calibration/win32-x64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/win32-x64.js +0 -38
- package/dist/resources/model-fit/estimators/llm.d.ts +0 -46
- package/dist/resources/model-fit/estimators/llm.js +0 -222
- package/dist/resources/model-fit/estimators/whisper.d.ts +0 -10
- package/dist/resources/model-fit/estimators/whisper.js +0 -76
- package/dist/resources/model-fit/floor.d.ts +0 -31
- package/dist/resources/model-fit/native-probe/child-engine-fit.d.ts +0 -2
- package/dist/resources/model-fit/native-probe/child-engine-fit.js +0 -41
- package/dist/resources/model-fit/native-probe/create-fit-request.js +0 -51
- package/dist/resources/model-fit/native-probe/engines/audiogen.js +0 -35
- package/dist/resources/model-fit/native-probe/engines/diffusion.js +0 -55
- package/dist/resources/model-fit/native-probe/engines/llama.js +0 -145
- package/dist/resources/model-fit/native-probe/fit-outcome.d.ts +0 -16
- package/dist/resources/model-fit/native-probe/fit-outcome.js +0 -1
- package/dist/resources/model-fit/native-probe/fit-process.d.ts +0 -27
- package/dist/resources/model-fit/native-probe/fit-process.js +0 -55
- package/dist/resources/model-fit/native-probe/fit-runner.d.ts +0 -1
- package/dist/resources/model-fit/native-probe/fit-runner.js +0 -58
- package/dist/resources/model-fit/native-probe/run-fit.d.ts +0 -24
- package/dist/resources/model-fit/native-probe/run-fit.js +0 -20
- package/dist/resources/model-fit/native-probe/run-in-process-fit.d.ts +0 -22
- package/dist/resources/model-fit/native-probe/run-in-process-fit.js +0 -108
- package/dist/resources/model-fit/native-probe/run-isolated-fit.d.ts +0 -63
- package/dist/resources/model-fit/native-probe/run-isolated-fit.js +0 -377
- package/dist/resources/model-fit/platform.d.ts +0 -9
- package/dist/resources/model-fit/platform.js +0 -28
- package/dist/resources/model-fit/types.d.ts +0 -120
- package/dist/resources/model-fit/types.js +0 -1
- /package/dist/{resources/model-fit/native-probe/engines → model-fit/request}/gpu.d.ts +0 -0
- /package/dist/{resources/model-fit/native-probe/engines → model-fit/request}/gpu.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'bare-fs';
|
|
2
2
|
import path from 'bare-path';
|
|
3
|
-
import { gpuLayersFromCount } from '
|
|
3
|
+
import { gpuLayersFromCount } from '../../../model-fit/request/gpu.js';
|
|
4
4
|
function unsupported(detail) {
|
|
5
5
|
return { supported: false, detail };
|
|
6
6
|
}
|
|
@@ -46,9 +46,14 @@ function cosyvoiceRequest(modelPath, common) {
|
|
|
46
46
|
export function createTtsFitRequest(params) {
|
|
47
47
|
const config = (params.modelConfig ?? {});
|
|
48
48
|
const artifacts = params.artifacts ?? {};
|
|
49
|
+
const lavasrEnhancerPath = artifacts['lavasrEnhancerPath'];
|
|
50
|
+
const lavasrDenoiserPath = artifacts['lavasrDenoiserPath'];
|
|
49
51
|
const common = {
|
|
50
52
|
nGpuLayers: gpuLayersFromCount(config.useGPU, config.nGpuLayers),
|
|
51
|
-
...(
|
|
53
|
+
...(config.backendsDir !== undefined && { backendsDir: config.backendsDir }),
|
|
54
|
+
...(params.marginBytes !== undefined && { marginBytes: params.marginBytes }),
|
|
55
|
+
...(lavasrEnhancerPath !== undefined && { lavasrEnhancerPath }),
|
|
56
|
+
...(lavasrDenoiserPath !== undefined && { lavasrDenoiserPath })
|
|
52
57
|
};
|
|
53
58
|
const supported = (request) => ({
|
|
54
59
|
supported: true,
|
|
@@ -86,8 +91,49 @@ export function createTtsFitRequest(params) {
|
|
|
86
91
|
}
|
|
87
92
|
case 'cosyvoice3':
|
|
88
93
|
return cosyvoiceRequest(params.modelPath, common);
|
|
89
|
-
case 'moss':
|
|
90
|
-
|
|
94
|
+
case 'moss': {
|
|
95
|
+
const decoder = artifacts['mossCodecDecoderPath'];
|
|
96
|
+
const encoder = artifacts['mossCodecEncoderPath'];
|
|
97
|
+
if (!decoder)
|
|
98
|
+
return unsupported('the moss codec decoder is not resolved');
|
|
99
|
+
if (!params.ttsWorkload || !('promptRows' in params.ttsWorkload)) {
|
|
100
|
+
return unsupported('MOSS fit requires ttsWorkload with promptRows, referenceSamples and streaming');
|
|
101
|
+
}
|
|
102
|
+
if (params.ttsWorkload.referenceSamples > 0 && !encoder) {
|
|
103
|
+
return unsupported('MOSS reference encoding requires the codec encoder');
|
|
104
|
+
}
|
|
105
|
+
return supported({
|
|
106
|
+
engineType: 'moss',
|
|
107
|
+
mossBackbonePath: params.modelPath,
|
|
108
|
+
mossCodecDecoderPath: decoder,
|
|
109
|
+
...(encoder ? { mossCodecEncoderPath: encoder } : {}),
|
|
110
|
+
...common,
|
|
111
|
+
...params.ttsWorkload,
|
|
112
|
+
...(config.threads !== undefined ? { threads: config.threads } : {}),
|
|
113
|
+
...(config.streamChunkTokens !== undefined
|
|
114
|
+
? { streamChunkTokens: config.streamChunkTokens }
|
|
115
|
+
: {}),
|
|
116
|
+
...(config.durationTokens !== undefined ? { durationTokens: config.durationTokens } : {})
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
case 'moss-sfx': {
|
|
120
|
+
if (!params.ttsWorkload || !('prompt' in params.ttsWorkload)) {
|
|
121
|
+
return unsupported('MOSS-SoundEffect fit requires ttsWorkload with prompt and seconds');
|
|
122
|
+
}
|
|
123
|
+
return supported({
|
|
124
|
+
engineType: 'moss-sfx',
|
|
125
|
+
mossSoundEffectPath: params.modelPath,
|
|
126
|
+
...common,
|
|
127
|
+
...params.ttsWorkload,
|
|
128
|
+
...(config.negativePrompt !== undefined ? { negativePrompt: config.negativePrompt } : {}),
|
|
129
|
+
...(config.steps !== undefined ? { steps: config.steps } : {}),
|
|
130
|
+
...(config.guidance !== undefined ? { guidance: config.guidance } : {}),
|
|
131
|
+
...(config.shift !== undefined ? { shift: config.shift } : {}),
|
|
132
|
+
...(config.threads !== undefined ? { threads: config.threads } : {})
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
case 'moss-speech':
|
|
136
|
+
return unsupported('the addon does not provide MOSS-Speech memory fit');
|
|
91
137
|
default: {
|
|
92
138
|
const s3genPath = artifacts['s3genPath'];
|
|
93
139
|
if (s3genPath === undefined) {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { AsrFitRequest, AsrFitResult } from '@qvac/asr-ggml';
|
|
2
2
|
import type { AudiogenFitRequest, AudiogenFitResult } from '@qvac/audiogen-ggml';
|
|
3
3
|
import type { BciFitRequest, BciFitResult } from '@qvac/bci-whispercpp';
|
|
4
|
-
import type { DiffusionFitRequest, DiffusionFitResult } from '@qvac/diffusion-cpp';
|
|
4
|
+
import type { DiffusionFitRequest, DiffusionFitResult, EsrganFitRequest, WorldFitRequest } from '@qvac/diffusion-cpp';
|
|
5
5
|
import type { EmbedFitRequest, EmbedFitResult } from '@qvac/embed-llamacpp';
|
|
6
6
|
import type LlmLlamacpp from '@qvac/llm-llamacpp';
|
|
7
|
+
import type { OcrFitRequest, OcrFitResult } from '@qvac/ocr-ggml';
|
|
8
|
+
import type TranslationNmtcpp from '@qvac/translation-nmtcpp';
|
|
7
9
|
import type { TtsFitRequest, TtsFitResult } from '@qvac/tts-ggml';
|
|
8
10
|
/**
|
|
9
11
|
* The engine packages each expose their own `assessFit`, taking the same fields
|
|
10
|
-
* their loader takes and returning the figures their fitter measures.
|
|
11
|
-
* member is plain JSON, so a request can cross a process boundary unchanged.
|
|
12
|
+
* their loader takes and returning the figures their fitter measures.
|
|
12
13
|
*/
|
|
13
14
|
export type FitProbeRequest = {
|
|
14
15
|
engine: 'llm-llamacpp';
|
|
@@ -30,7 +31,13 @@ export type FitProbeRequest = {
|
|
|
30
31
|
request: AudiogenFitRequest;
|
|
31
32
|
} | {
|
|
32
33
|
engine: 'diffusion-cpp';
|
|
33
|
-
request: DiffusionFitRequest;
|
|
34
|
+
request: DiffusionFitRequest | EsrganFitRequest | WorldFitRequest;
|
|
35
|
+
} | {
|
|
36
|
+
engine: 'ocr-ggml';
|
|
37
|
+
request: OcrFitRequest;
|
|
38
|
+
} | {
|
|
39
|
+
engine: 'translation-nmtcpp';
|
|
40
|
+
request: TranslationNmtcpp.FitRequest;
|
|
34
41
|
};
|
|
35
42
|
export type FitProbeEngine = FitProbeRequest['engine'];
|
|
36
43
|
export type FitProbeResult = {
|
|
@@ -54,6 +61,12 @@ export type FitProbeResult = {
|
|
|
54
61
|
} | {
|
|
55
62
|
engine: 'diffusion-cpp';
|
|
56
63
|
result: DiffusionFitResult;
|
|
64
|
+
} | {
|
|
65
|
+
engine: 'ocr-ggml';
|
|
66
|
+
result: OcrFitResult;
|
|
67
|
+
} | {
|
|
68
|
+
engine: 'translation-nmtcpp';
|
|
69
|
+
result: TranslationNmtcpp.FitResult;
|
|
57
70
|
};
|
|
58
71
|
/** Calls one engine's fitter, taken from the plugin that owns its addon. */
|
|
59
72
|
export declare function callEngineFit(probe: FitProbeRequest): Promise<FitProbeResult>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Calls one engine's fitter, taken from the plugin that owns its addon. */
|
|
2
2
|
export async function callEngineFit(probe) {
|
|
3
|
-
const { getAllPlugins } = await import('
|
|
3
|
+
const { getAllPlugins } = await import('../../plugins/registry.js');
|
|
4
4
|
const addonPackage = `@qvac/${probe.engine}`;
|
|
5
5
|
const plugin = getAllPlugins().find((candidate) => candidate.addonPackage === addonPackage);
|
|
6
6
|
if (plugin?.assessFit === undefined) {
|
|
@@ -8,6 +8,6 @@ export async function callEngineFit(probe) {
|
|
|
8
8
|
}
|
|
9
9
|
return {
|
|
10
10
|
engine: probe.engine,
|
|
11
|
-
result: plugin.assessFit(probe.request)
|
|
11
|
+
result: await plugin.assessFit(probe.request)
|
|
12
12
|
};
|
|
13
13
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
|
+
import { callEngineFit } from '../../model-fit/run/engine.js';
|
|
3
|
+
import type { FitProbeRequest, FitProbeResult } from '../../model-fit/run/engine.js';
|
|
4
|
+
/**
|
|
5
|
+
* Why a run produced no projection. Every one of these is absence of evidence,
|
|
6
|
+
* so the caller proceeds with the load it was going to run anyway.
|
|
7
|
+
*/
|
|
8
|
+
export type FitRunUnknownReason = 'cancelled' | 'crashed' | 'invocation-error' | 'timeout';
|
|
9
|
+
export type FitRunResult = {
|
|
10
|
+
status: 'completed';
|
|
11
|
+
probe: FitProbeResult;
|
|
12
|
+
} | {
|
|
13
|
+
status: 'unknown';
|
|
14
|
+
reason: FitRunUnknownReason;
|
|
15
|
+
message: string;
|
|
16
|
+
};
|
|
17
|
+
export interface RunFitOptions {
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
stateDir?: string;
|
|
21
|
+
callFit?: typeof callEngineFit;
|
|
22
|
+
}
|
|
23
|
+
export declare function runningMarkerPath(stateDir: string, probe: FitProbeRequest, pid?: number): string;
|
|
24
|
+
export declare function suspectMarkerPath(stateDir: string, probe: FitProbeRequest): string;
|
|
25
|
+
export declare function crashedMarkerPath(stateDir: string, probe: FitProbeRequest): string;
|
|
26
|
+
/**
|
|
27
|
+
* Runs one engine's fitter in this process.
|
|
28
|
+
*
|
|
29
|
+
* A fitter that aborts takes the process with it, as does a process that quits
|
|
30
|
+
* or is killed mid-fit. Each process marks its fit with a `.running` file named
|
|
31
|
+
* by its pid, so a marker whose process is gone is a fit that never finished,
|
|
32
|
+
* while one whose process is alive is a fit still running there. The first
|
|
33
|
+
* unfinished fit of a request leaves `.suspect` and the fit runs again. A
|
|
34
|
+
* second one in a row leaves `.crashed`, and the request skips native until
|
|
35
|
+
* that marker expires.
|
|
36
|
+
*
|
|
37
|
+
* Fits of one request in this process share one marker, removed by the last.
|
|
38
|
+
* An aborted `signal` answers `cancelled` and a fit past `timeoutMs` answers
|
|
39
|
+
* `timeout`, both at once, while the fitter runs on and releases the marker
|
|
40
|
+
* when it returns. Until a timed-out fitter returns, further fits of its
|
|
41
|
+
* request answer `timeout` without calling it again.
|
|
42
|
+
*/
|
|
43
|
+
export declare function runFit(probe: FitProbeRequest, options?: RunFitOptions): Promise<FitRunResult>;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import fs from 'bare-fs';
|
|
2
|
+
import os from 'bare-os';
|
|
3
|
+
import path from 'bare-path';
|
|
4
|
+
import { generateShortHash } from '../../utils/formatting.js';
|
|
5
|
+
import { callEngineFit } from '../../model-fit/run/engine.js';
|
|
6
|
+
function unknown(reason, message) {
|
|
7
|
+
return { status: 'unknown', reason, message };
|
|
8
|
+
}
|
|
9
|
+
function describe(error) {
|
|
10
|
+
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
11
|
+
}
|
|
12
|
+
/** How long a marker keeps a model off the native path. */
|
|
13
|
+
const MARKER_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
14
|
+
/** A fit sits in front of a load, so a fitter that never returns must not hold it. */
|
|
15
|
+
const FIT_TIMEOUT_MS = 30_000;
|
|
16
|
+
/** Fits this process has in flight, per request. */
|
|
17
|
+
const inFlight = new Map();
|
|
18
|
+
/** Requests whose fit timed out and has not returned. */
|
|
19
|
+
const hung = new Set();
|
|
20
|
+
/**
|
|
21
|
+
* `marginBytes` is excluded: it carries the bytes of every model resident at
|
|
22
|
+
* the time, so it differs between two attempts at the same load.
|
|
23
|
+
*/
|
|
24
|
+
function markerKey(probe) {
|
|
25
|
+
const { marginBytes: _margin, ...request } = probe.request;
|
|
26
|
+
return generateShortHash(JSON.stringify({ engine: probe.engine, request }));
|
|
27
|
+
}
|
|
28
|
+
export function runningMarkerPath(stateDir, probe, pid = os.pid()) {
|
|
29
|
+
return path.join(stateDir, `${markerKey(probe)}.${pid}.running`);
|
|
30
|
+
}
|
|
31
|
+
export function suspectMarkerPath(stateDir, probe) {
|
|
32
|
+
return path.join(stateDir, `${markerKey(probe)}.suspect`);
|
|
33
|
+
}
|
|
34
|
+
export function crashedMarkerPath(stateDir, probe) {
|
|
35
|
+
return path.join(stateDir, `${markerKey(probe)}.crashed`);
|
|
36
|
+
}
|
|
37
|
+
function exists(file) {
|
|
38
|
+
try {
|
|
39
|
+
fs.accessSync(file);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function expired(file) {
|
|
47
|
+
try {
|
|
48
|
+
return Date.now() - fs.statSync(file).mtimeMs > MARKER_TTL_MS;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function remove(file) {
|
|
55
|
+
try {
|
|
56
|
+
fs.unlinkSync(file);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Marker cleanup must not turn an advisory fit into a load failure.
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function mark(file) {
|
|
63
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
64
|
+
fs.writeFileSync(file, '');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A marker with this process's pid is from an earlier process that had the
|
|
68
|
+
* same pid, since this one holds no fit of the request. `EPERM` means the
|
|
69
|
+
* process exists under another user.
|
|
70
|
+
*/
|
|
71
|
+
function isAlive(pid) {
|
|
72
|
+
if (pid === os.pid())
|
|
73
|
+
return false;
|
|
74
|
+
try {
|
|
75
|
+
os.kill(pid, 0);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
return error.code === 'EPERM';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** `.running` markers of this request whose process is gone or that have expired. */
|
|
83
|
+
function unfinishedFits(stateDir, probe) {
|
|
84
|
+
let names;
|
|
85
|
+
try {
|
|
86
|
+
names = fs.readdirSync(stateDir);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
const pattern = new RegExp(`^${markerKey(probe)}\\.(\\d+)\\.running$`);
|
|
92
|
+
return names.flatMap((name) => {
|
|
93
|
+
const pid = pattern.exec(name)?.[1];
|
|
94
|
+
if (pid === undefined)
|
|
95
|
+
return [];
|
|
96
|
+
const file = path.join(stateDir, name);
|
|
97
|
+
return isAlive(Number(pid)) && !expired(file) ? [] : [file];
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async function resolveStateDir(explicit) {
|
|
101
|
+
if (explicit !== undefined)
|
|
102
|
+
return explicit;
|
|
103
|
+
const { getCacheDir } = await import('../../utils/cache/paths.js');
|
|
104
|
+
return getCacheDir('model-fit');
|
|
105
|
+
}
|
|
106
|
+
async function settle(probe, callFit, stateDir) {
|
|
107
|
+
const key = markerKey(probe);
|
|
108
|
+
try {
|
|
109
|
+
return { status: 'completed', probe: await callFit(probe) };
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
return unknown('invocation-error', describe(error));
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
const remaining = (inFlight.get(key) ?? 1) - 1;
|
|
116
|
+
if (remaining === 0) {
|
|
117
|
+
inFlight.delete(key);
|
|
118
|
+
hung.delete(key);
|
|
119
|
+
remove(runningMarkerPath(stateDir, probe));
|
|
120
|
+
remove(suspectMarkerPath(stateDir, probe));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
inFlight.set(key, remaining);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function bounded(fit, key, timeoutMs, signal) {
|
|
128
|
+
return new Promise((resolve) => {
|
|
129
|
+
const finish = (result) => {
|
|
130
|
+
clearTimeout(timer);
|
|
131
|
+
signal?.removeEventListener('abort', onAbort);
|
|
132
|
+
resolve(result);
|
|
133
|
+
};
|
|
134
|
+
const onAbort = () => finish(unknown('cancelled', 'Fit was cancelled'));
|
|
135
|
+
const timer = setTimeout(() => {
|
|
136
|
+
hung.add(key);
|
|
137
|
+
finish(unknown('timeout', `Fit did not return within ${timeoutMs} ms`));
|
|
138
|
+
}, timeoutMs);
|
|
139
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
140
|
+
void fit.then(finish);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Runs one engine's fitter in this process.
|
|
145
|
+
*
|
|
146
|
+
* A fitter that aborts takes the process with it, as does a process that quits
|
|
147
|
+
* or is killed mid-fit. Each process marks its fit with a `.running` file named
|
|
148
|
+
* by its pid, so a marker whose process is gone is a fit that never finished,
|
|
149
|
+
* while one whose process is alive is a fit still running there. The first
|
|
150
|
+
* unfinished fit of a request leaves `.suspect` and the fit runs again. A
|
|
151
|
+
* second one in a row leaves `.crashed`, and the request skips native until
|
|
152
|
+
* that marker expires.
|
|
153
|
+
*
|
|
154
|
+
* Fits of one request in this process share one marker, removed by the last.
|
|
155
|
+
* An aborted `signal` answers `cancelled` and a fit past `timeoutMs` answers
|
|
156
|
+
* `timeout`, both at once, while the fitter runs on and releases the marker
|
|
157
|
+
* when it returns. Until a timed-out fitter returns, further fits of its
|
|
158
|
+
* request answer `timeout` without calling it again.
|
|
159
|
+
*/
|
|
160
|
+
export async function runFit(probe, options = {}) {
|
|
161
|
+
if (options.signal?.aborted === true) {
|
|
162
|
+
return unknown('cancelled', 'Fit was cancelled');
|
|
163
|
+
}
|
|
164
|
+
const key = markerKey(probe);
|
|
165
|
+
if (hung.has(key)) {
|
|
166
|
+
return unknown('timeout', 'An earlier fit of this request has not returned');
|
|
167
|
+
}
|
|
168
|
+
const stateDir = await resolveStateDir(options.stateDir);
|
|
169
|
+
const crashed = crashedMarkerPath(stateDir, probe);
|
|
170
|
+
const suspect = suspectMarkerPath(stateDir, probe);
|
|
171
|
+
const held = inFlight.get(key) ?? 0;
|
|
172
|
+
if (held === 0) {
|
|
173
|
+
for (const marker of [crashed, suspect]) {
|
|
174
|
+
if (exists(marker) && expired(marker))
|
|
175
|
+
remove(marker);
|
|
176
|
+
}
|
|
177
|
+
const unfinished = unfinishedFits(stateDir, probe);
|
|
178
|
+
if (exists(crashed) || (unfinished.length > 0 && exists(suspect))) {
|
|
179
|
+
try {
|
|
180
|
+
mark(crashed);
|
|
181
|
+
remove(suspect);
|
|
182
|
+
unfinished.forEach(remove);
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
// Keep the unfinished markers if `.crashed` could not be written so
|
|
186
|
+
// the next attempt still counts them.
|
|
187
|
+
}
|
|
188
|
+
return unknown('crashed', 'Earlier fits did not finish; treating this model as unknown');
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
if (unfinished.length > 0) {
|
|
192
|
+
mark(suspect);
|
|
193
|
+
unfinished.forEach(remove);
|
|
194
|
+
}
|
|
195
|
+
mark(runningMarkerPath(stateDir, probe));
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
return unknown('invocation-error', `Fit marker could not be written: ${describe(error)}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
inFlight.set(key, held + 1);
|
|
202
|
+
const fit = settle(probe, options.callFit ?? callEngineFit, stateDir);
|
|
203
|
+
return bounded(fit, key, options.timeoutMs ?? FIT_TIMEOUT_MS, options.signal);
|
|
204
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { models } from '
|
|
1
|
+
import { models } from '../../models/registry/models.js';
|
|
2
2
|
// Re-export all generated models
|
|
3
|
-
export * from '
|
|
3
|
+
export * from '../../models/registry/models.js';
|
|
4
4
|
const bciEmbedder = models.find((model) => model.name === 'BCI_EMBEDDER');
|
|
5
5
|
export const BCI_EMBEDDER = {
|
|
6
6
|
name: 'BCI_EMBEDDER',
|