@qvac/inference 0.22.0 → 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 +59 -40
- package/README.md +1 -1
- package/dist/api/audio-gen.js +1 -1
- package/dist/api/completion-stream.d.ts +2 -1
- package/dist/api/completion-stream.js +3 -1
- package/dist/api/decide.js +1 -1
- 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/index.d.ts +39 -38
- package/dist/api/index.js +38 -37
- 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/unload-model.js +1 -1
- package/dist/api/video.js +1 -1
- 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 +6 -0
- package/dist/errors/index.js +13 -1
- package/dist/handlers/assess-model-fit.d.ts +1 -1
- package/dist/handlers/assess-model-fit.js +4 -4
- 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 +2 -3
- 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/logging-stream.d.ts +2 -1
- package/dist/handlers/logging-stream.js +23 -7
- package/dist/handlers/registry.js +4 -2
- 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 +3 -3
- package/dist/logging/utils.js +1 -1
- package/dist/{resources/model-fit → model-fit}/assess.d.ts +4 -4
- package/dist/{resources/model-fit → model-fit}/assess.js +3 -3
- 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} +4 -4
- package/dist/{resources/model-fit/fit-stub/fetch-fit-stub.d.ts → model-fit/description/fetch.d.ts} +1 -1
- package/dist/{resources/model-fit/fit-stub/fetch-fit-stub.js → model-fit/description/fetch.js} +5 -5
- 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} +2 -2
- package/dist/{resources/model-fit/fit-stub/resolve-load-from-stubs.d.ts → model-fit/description/resolve-load.d.ts} +3 -3
- package/dist/{resources/model-fit/fit-stub/resolve-load-from-stubs.js → model-fit/description/resolve-load.js} +6 -6
- package/dist/{resources/model-fit → model-fit}/floor.d.ts +2 -2
- package/dist/{resources/model-fit → model-fit}/floor.js +1 -1
- package/dist/{resources/model-fit → model-fit}/kv-cache.d.ts +1 -1
- package/dist/{resources/model-fit/native-probe/advisory-fit.d.ts → model-fit/load-check.d.ts} +8 -10
- package/dist/{resources/model-fit/native-probe/advisory-fit.js → model-fit/load-check.js} +14 -40
- package/dist/{resources/model-fit/types.d.ts → model-fit/platform.d.ts} +8 -0
- package/dist/{resources/model-fit/native-probe/create-fit-request.d.ts → model-fit/request/create.d.ts} +3 -3
- package/dist/{resources/model-fit/native-probe/create-fit-request.js → model-fit/request/create.js} +8 -8
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/asr.d.ts +2 -2
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/asr.js +9 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/audiogen.d.ts +1 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/audiogen.js +1 -1
- 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 -2
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/llama.js +13 -10
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/nmt.d.ts +1 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/nmt.js +1 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/ocr.d.ts +1 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/ocr.js +1 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/tts.d.ts +2 -2
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/tts.js +1 -1
- package/dist/{resources/model-fit/native-probe/engine-fit.d.ts → model-fit/run/engine.d.ts} +3 -4
- package/dist/{resources/model-fit/native-probe/engine-fit.js → model-fit/run/engine.js} +1 -1
- 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 +510 -0
- package/dist/models/registry/models.js +2946 -2410
- package/dist/models/registry/resource-profiles.js +203 -1
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-edit-stream.js +2 -2
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.js +2 -2
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-understand.js +2 -2
- package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +60 -54
- package/dist/plugins/builtin/audiogen-ggml/plugin.js +4 -4
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +26 -25
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +4 -4
- package/dist/plugins/builtin/ggml-classification/plugin.d.ts +4 -4
- package/dist/plugins/builtin/ggml-classification/plugin.js +1 -1
- package/dist/plugins/builtin/ggml-ocr/plugin.d.ts +11 -10
- package/dist/plugins/builtin/ggml-ocr/plugin.js +4 -4
- package/dist/plugins/builtin/ggml-vla/plugin.d.ts +12 -12
- package/dist/plugins/builtin/ggml-vla/plugin.js +3 -3
- package/dist/plugins/builtin/index.d.ts +15 -14
- package/dist/plugins/builtin/index.js +15 -14
- 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 +1 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +36 -19
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.d.ts +5 -3
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.js +9 -7
- package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +169 -78
- package/dist/plugins/builtin/llamacpp-completion/plugin.js +26 -17
- package/dist/plugins/builtin/llamacpp-completion/transform.js +4 -0
- package/dist/plugins/builtin/llamacpp-decision/helpers.d.ts +0 -1
- package/dist/plugins/builtin/llamacpp-decision/helpers.js +7 -15
- package/dist/plugins/builtin/llamacpp-decision/ops/decide.js +1 -1
- package/dist/plugins/builtin/llamacpp-decision/plugin.d.ts +39 -33
- package/dist/plugins/builtin/llamacpp-decision/plugin.js +4 -3
- package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +7 -6
- package/dist/plugins/builtin/llamacpp-embedding/plugin.js +16 -6
- package/dist/plugins/builtin/llamacpp-embedding/transform.js +6 -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 +16 -16
- package/dist/plugins/builtin/moss-transcribe/plugin.js +4 -4
- package/dist/plugins/builtin/nmtcpp-translation/plugin.d.ts +18 -13
- package/dist/plugins/builtin/nmtcpp-translation/plugin.js +4 -4
- package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +29 -29
- package/dist/plugins/builtin/parakeet-transcription/plugin.js +4 -4
- 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 +19 -8
- package/dist/plugins/builtin/sdcpp-generation/ops/world.d.ts +2 -2
- package/dist/plugins/builtin/sdcpp-generation/ops/world.js +1 -1
- package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +90 -34
- package/dist/plugins/builtin/sdcpp-generation/plugin.js +45 -45
- 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/text-to-speech-stream.d.ts +1 -1
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.js +2 -2
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +2 -2
- package/dist/plugins/builtin/tts-ggml/plugin.d.ts +47 -32
- package/dist/plugins/builtin/tts-ggml/plugin.js +3 -3
- package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +34 -33
- package/dist/plugins/builtin/whispercpp-transcription/plugin.js +4 -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 +4 -3
- package/dist/plugins/ops/kv-cache-utils.js +15 -8
- package/dist/plugins/ops/load-model.d.ts +8 -2
- package/dist/plugins/ops/load-model.js +14 -5
- package/dist/plugins/ops/transcribe.js +1 -1
- 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 +2 -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 +3 -3
- 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 +3 -0
- 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 +14 -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 +2 -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 +6 -0
- package/dist/schemas/assess-model-fit.js +4 -4
- package/dist/schemas/audio-gen.d.ts +13 -1
- package/dist/schemas/audio-gen.js +3 -3
- package/dist/schemas/batch-completion-stream.d.ts +8 -2
- package/dist/schemas/batch-completion-stream.js +3 -3
- package/dist/schemas/bci-config.d.ts +1 -0
- package/dist/schemas/bci-config.js +2 -2
- package/dist/schemas/bci.d.ts +1 -1
- package/dist/schemas/bci.js +2 -2
- package/dist/schemas/cancel.d.ts +5 -0
- package/dist/schemas/cancel.js +1 -0
- package/dist/schemas/common.d.ts +478 -100
- package/dist/schemas/common.js +35 -32
- package/dist/schemas/completion-event.d.ts +8 -2
- package/dist/schemas/completion-event.js +4 -1
- package/dist/schemas/completion-stream.d.ts +11 -2
- package/dist/schemas/completion-stream.js +37 -10
- package/dist/schemas/config.d.ts +849 -6
- package/dist/schemas/config.js +12 -10
- package/dist/schemas/decision.d.ts +8 -0
- package/dist/schemas/decision.js +14 -0
- package/dist/schemas/download-asset.d.ts +6 -4
- package/dist/schemas/download-asset.js +1 -1
- package/dist/schemas/engine-addon-map.d.ts +2 -1
- package/dist/schemas/engine-addon-map.js +4 -3
- package/dist/schemas/errors.d.ts +1 -0
- package/dist/schemas/errors.js +6 -1
- package/dist/schemas/index.d.ts +51 -50
- package/dist/schemas/index.js +50 -49
- package/dist/schemas/llamacpp-config.d.ts +182 -6
- package/dist/schemas/llamacpp-config.js +102 -7
- package/dist/schemas/load-model.d.ts +3176 -646
- package/dist/schemas/load-model.js +34 -1
- package/dist/schemas/mcp-adapter.d.ts +1 -1
- package/dist/schemas/model-config-schemas.d.ts +195 -1
- package/dist/schemas/model-config-schemas.js +14 -12
- package/dist/schemas/model-fit-policy.d.ts +1 -1
- package/dist/schemas/model-info.js +2 -2
- package/dist/schemas/model-resource-profile.d.ts +1 -0
- package/dist/schemas/model-resource-profile.js +1 -1
- package/dist/schemas/model-src-utils.d.ts +6 -2
- package/dist/schemas/model-src-utils.js +2 -2
- package/dist/schemas/model-types.d.ts +5 -1
- package/dist/schemas/model-types.js +1 -0
- package/dist/schemas/ocr.d.ts +2 -0
- package/dist/schemas/ocr.js +1 -1
- package/dist/schemas/plugin.d.ts +9 -3
- package/dist/schemas/plugin.js +6 -0
- package/dist/schemas/profiling.js +1 -1
- package/dist/schemas/rag.js +1 -1
- package/dist/schemas/registry.d.ts +8 -0
- package/dist/schemas/registry.js +2 -1
- package/dist/schemas/reload-config.d.ts +6 -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/sdcpp-config.d.ts +56 -0
- package/dist/schemas/sdcpp-config.js +33 -15
- package/dist/schemas/text-to-speech.d.ts +61 -0
- package/dist/schemas/transcription-config.d.ts +5 -0
- package/dist/schemas/transcription-config.js +16 -1
- package/dist/schemas/transcription.d.ts +1 -1
- package/dist/schemas/transcription.js +1 -1
- package/dist/schemas/translate.d.ts +2 -2
- package/dist/schemas/translate.js +1 -1
- package/dist/schemas/translation-config.d.ts +20 -10
- package/dist/schemas/translation-config.js +1 -1
- package/dist/surface.d.ts +2 -1
- package/dist/surface.js +2 -1
- package/dist/utils/addon-responses.d.ts +2 -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/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/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 +1 -1
- 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-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 +1 -1
- 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 +1 -1
- package/dist/utils/tts-stats.d.ts +1 -1
- package/dist/utils/until-aborted.d.ts +7 -0
- package/dist/utils/until-aborted.js +34 -0
- package/package.json +53 -45
- 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 -49
- package/dist/resources/model-fit/native-probe/engines/diffusion.js +0 -65
- 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 -24
- package/dist/resources/model-fit/native-probe/run-in-process-fit.js +0 -123
- 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/types.js +0 -1
- /package/dist/{resources/model-fit → model-fit}/kv-cache.js +0 -0
- /package/dist/{resources/model-fit → model-fit}/platform.js +0 -0
- /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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/inference",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Bare-only in-process core of the QVAC SDK. Runs inference directly on the Bare runtime with explicit plugin assembly and no RPC, worker, or subprocess layer.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -149,6 +149,10 @@
|
|
|
149
149
|
"./llamacpp-decision/plugin": {
|
|
150
150
|
"types": "./dist/plugins/builtin/llamacpp-decision/plugin.d.ts",
|
|
151
151
|
"import": "./dist/plugins/builtin/llamacpp-decision/plugin.js"
|
|
152
|
+
},
|
|
153
|
+
"./llamacpp-rerank/plugin": {
|
|
154
|
+
"types": "./dist/plugins/builtin/llamacpp-rerank/plugin.d.ts",
|
|
155
|
+
"import": "./dist/plugins/builtin/llamacpp-rerank/plugin.js"
|
|
152
156
|
}
|
|
153
157
|
},
|
|
154
158
|
"files": [
|
|
@@ -157,29 +161,13 @@
|
|
|
157
161
|
"LICENSE",
|
|
158
162
|
"NOTICE"
|
|
159
163
|
],
|
|
160
|
-
"scripts": {
|
|
161
|
-
"lint": "lunte",
|
|
162
|
-
"lint:fix": "lunte --fix",
|
|
163
|
-
"format": "prettier --check .",
|
|
164
|
-
"format:fix": "prettier --write .",
|
|
165
|
-
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p test/tsconfig.json",
|
|
166
|
-
"compile": "tsc -p tsconfig.build.json",
|
|
167
|
-
"postcompile:aliases": "tsc-alias -p tsconfig.alias.json",
|
|
168
|
-
"build": "npm run compile && npm run postcompile:aliases",
|
|
169
|
-
"prepare": "npm run build",
|
|
170
|
-
"build:test": "tsc -p test/tsconfig.build.json && tsc-alias -p test/tsconfig.alias.json",
|
|
171
|
-
"test": "npm run build:test && brittle-bare 'test/dist/test/**/*.test.js'",
|
|
172
|
-
"test:bare": "npm run test",
|
|
173
|
-
"check-models": "bare ./dist/models/update-models/index.js --check",
|
|
174
|
-
"update-models": "bare ./dist/models/update-models/index.js && prettier --write src/models/registry/models.ts src/models/registry/resource-profiles.ts"
|
|
175
|
-
},
|
|
176
164
|
"engines": {
|
|
177
165
|
"bare": ">=1.32.0"
|
|
178
166
|
},
|
|
179
167
|
"dependencies": {
|
|
180
168
|
"@qvac/error": "^0.1.1",
|
|
181
169
|
"@qvac/logging": "^0.1.1",
|
|
182
|
-
"@qvac/rag": "^0.
|
|
170
|
+
"@qvac/rag": "^0.9.0",
|
|
183
171
|
"@qvac/registry-client": "^0.7.0",
|
|
184
172
|
"bare-abort-controller": "^1.1.2",
|
|
185
173
|
"bare-buffer": "^3.6.2",
|
|
@@ -193,9 +181,7 @@
|
|
|
193
181
|
"bare-net": "^2.3.2",
|
|
194
182
|
"bare-os": "^3.9.3",
|
|
195
183
|
"bare-path": "^3.1.1",
|
|
196
|
-
"bare-process": "^4.5.1",
|
|
197
184
|
"bare-rpc": "^1.3.8",
|
|
198
|
-
"bare-runtime": "^1.34.1",
|
|
199
185
|
"bare-stream": "^2.13.3",
|
|
200
186
|
"bare-url": "^2.4.5",
|
|
201
187
|
"bare-zlib": "^1.4.0",
|
|
@@ -210,20 +196,21 @@
|
|
|
210
196
|
"zod": "4.6.5"
|
|
211
197
|
},
|
|
212
198
|
"peerDependencies": {
|
|
213
|
-
"@qvac/asr-ggml": "^0.
|
|
214
|
-
"@qvac/audiogen-ggml": "^0.
|
|
215
|
-
"@qvac/bci-whispercpp": "^0.
|
|
216
|
-
"@qvac/classification-ggml": "^0.
|
|
199
|
+
"@qvac/asr-ggml": "^0.11.1",
|
|
200
|
+
"@qvac/audiogen-ggml": "^0.9.0",
|
|
201
|
+
"@qvac/bci-whispercpp": "^0.14.0",
|
|
202
|
+
"@qvac/classification-ggml": "^0.34.0",
|
|
217
203
|
"@qvac/decoder-audio": "^0.8.1",
|
|
218
|
-
"@qvac/diffusion-cpp": "^0.
|
|
219
|
-
"@qvac/embed-llamacpp": "^0.
|
|
204
|
+
"@qvac/diffusion-cpp": "^0.31.0",
|
|
205
|
+
"@qvac/embed-llamacpp": "^0.53.0",
|
|
220
206
|
"@qvac/langdetect-text": "^0.1.2",
|
|
221
|
-
"@qvac/llm-llamacpp": "^0.
|
|
222
|
-
"@qvac/ocr-ggml": "^0.
|
|
223
|
-
"@qvac/translation-nmtcpp": "^0.
|
|
224
|
-
"@qvac/tts-ggml": "^0.
|
|
225
|
-
"@qvac/
|
|
226
|
-
"@qvac/ggml
|
|
207
|
+
"@qvac/llm-llamacpp": "^0.65.0",
|
|
208
|
+
"@qvac/ocr-ggml": "^0.31.0",
|
|
209
|
+
"@qvac/translation-nmtcpp": "^0.23.0",
|
|
210
|
+
"@qvac/tts-ggml": "^0.14.0",
|
|
211
|
+
"@qvac/turbovec-ggml": "^0.3.0",
|
|
212
|
+
"@qvac/vla-ggml": "^0.34.0",
|
|
213
|
+
"@qvac/ggml-rpc-server": "^0.7.0"
|
|
227
214
|
},
|
|
228
215
|
"peerDependenciesMeta": {
|
|
229
216
|
"@qvac/asr-ggml": {
|
|
@@ -262,6 +249,9 @@
|
|
|
262
249
|
"@qvac/tts-ggml": {
|
|
263
250
|
"optional": true
|
|
264
251
|
},
|
|
252
|
+
"@qvac/turbovec-ggml": {
|
|
253
|
+
"optional": true
|
|
254
|
+
},
|
|
265
255
|
"@qvac/vla-ggml": {
|
|
266
256
|
"optional": true
|
|
267
257
|
},
|
|
@@ -270,23 +260,25 @@
|
|
|
270
260
|
}
|
|
271
261
|
},
|
|
272
262
|
"devDependencies": {
|
|
273
|
-
"@qvac/asr-ggml": "^0.
|
|
274
|
-
"@qvac/audiogen-ggml": "^0.
|
|
275
|
-
"@qvac/bci-whispercpp": "^0.
|
|
276
|
-
"@qvac/classification-ggml": "^0.
|
|
263
|
+
"@qvac/asr-ggml": "^0.11.1",
|
|
264
|
+
"@qvac/audiogen-ggml": "^0.9.0",
|
|
265
|
+
"@qvac/bci-whispercpp": "^0.14.0",
|
|
266
|
+
"@qvac/classification-ggml": "^0.34.0",
|
|
277
267
|
"@qvac/decoder-audio": "^0.8.1",
|
|
278
|
-
"@qvac/diffusion-cpp": "^0.
|
|
279
|
-
"@qvac/embed-llamacpp": "^0.
|
|
268
|
+
"@qvac/diffusion-cpp": "^0.31.0",
|
|
269
|
+
"@qvac/embed-llamacpp": "^0.53.0",
|
|
280
270
|
"@qvac/langdetect-text": "^0.1.2",
|
|
281
|
-
"@qvac/llm-llamacpp": "^0.
|
|
282
|
-
"@qvac/ocr-ggml": "^0.
|
|
283
|
-
"@qvac/translation-nmtcpp": "^0.
|
|
284
|
-
"@qvac/tts-ggml": "^0.
|
|
285
|
-
"@qvac/
|
|
271
|
+
"@qvac/llm-llamacpp": "^0.65.0",
|
|
272
|
+
"@qvac/ocr-ggml": "^0.31.0",
|
|
273
|
+
"@qvac/translation-nmtcpp": "^0.23.0",
|
|
274
|
+
"@qvac/tts-ggml": "^0.14.0",
|
|
275
|
+
"@qvac/turbovec-ggml": "^0.3.0",
|
|
276
|
+
"@qvac/vla-ggml": "^0.34.0",
|
|
286
277
|
"@types/brittle": "^3.5.0",
|
|
287
278
|
"bare": "1.34.1 || >=1.35.1",
|
|
288
279
|
"bare-console": "*",
|
|
289
280
|
"bare-events": "^2.9.1",
|
|
281
|
+
"bare-process": "^4.5.1",
|
|
290
282
|
"bare-stdio": "^1.0.3",
|
|
291
283
|
"bare-subprocess": "^6.1.0",
|
|
292
284
|
"bare-timers": "*",
|
|
@@ -296,6 +288,22 @@
|
|
|
296
288
|
"prettier-config-holepunch": "^2.0.0",
|
|
297
289
|
"tsc-alias": "^1.8.17",
|
|
298
290
|
"typescript": "^5.9.3",
|
|
299
|
-
"@qvac/ggml-rpc-server": "^0.
|
|
291
|
+
"@qvac/ggml-rpc-server": "^0.7.0"
|
|
292
|
+
},
|
|
293
|
+
"gitHead": "4badf6ff1900bbf099b63792fe663a33cc0e6c82",
|
|
294
|
+
"scripts": {
|
|
295
|
+
"lint": "lunte",
|
|
296
|
+
"lint:fix": "lunte --fix",
|
|
297
|
+
"format": "prettier --check .",
|
|
298
|
+
"format:fix": "prettier --write .",
|
|
299
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p test/tsconfig.json",
|
|
300
|
+
"compile": "tsc -p tsconfig.build.json",
|
|
301
|
+
"postcompile:aliases": "tsc-alias -p tsconfig.alias.json",
|
|
302
|
+
"build": "npm run compile && npm run postcompile:aliases",
|
|
303
|
+
"build:test": "tsc -p test/tsconfig.build.json && tsc-alias -p test/tsconfig.alias.json",
|
|
304
|
+
"test": "npm run build:test && brittle-bare 'test/dist/test/**/*.test.js'",
|
|
305
|
+
"test:bare": "npm run test",
|
|
306
|
+
"check-models": "bare ./dist/models/update-models/index.js --check",
|
|
307
|
+
"update-models": "bare ./dist/models/update-models/index.js && prettier --write src/models/registry/models.ts src/models/registry/resource-profiles.ts"
|
|
300
308
|
}
|
|
301
|
-
}
|
|
309
|
+
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loads the one addon a probe names and asks it for a projection. The child
|
|
3
|
-
* registers no plugins, so the fitter cannot come off the registry here. Only
|
|
4
|
-
* the child reaches this module, and the supervisor spawns it by path rather
|
|
5
|
-
* than importing it, so these specifiers stay out of the graph a host bundles.
|
|
6
|
-
*/
|
|
7
|
-
async function assessFitOf(probe) {
|
|
8
|
-
switch (probe.engine) {
|
|
9
|
-
case 'llm-llamacpp': {
|
|
10
|
-
const { default: LlmLlamacpp } = await import('@qvac/llm-llamacpp');
|
|
11
|
-
return LlmLlamacpp.assessFit(probe.request);
|
|
12
|
-
}
|
|
13
|
-
case 'embed-llamacpp': {
|
|
14
|
-
const { assessFit } = await import('@qvac/embed-llamacpp');
|
|
15
|
-
return assessFit(probe.request);
|
|
16
|
-
}
|
|
17
|
-
case 'asr-ggml': {
|
|
18
|
-
const { default: ASRGgml } = await import('@qvac/asr-ggml');
|
|
19
|
-
return ASRGgml.assessFit(probe.request);
|
|
20
|
-
}
|
|
21
|
-
case 'bci-whispercpp': {
|
|
22
|
-
const { assessFit } = await import('@qvac/bci-whispercpp');
|
|
23
|
-
return assessFit(probe.request);
|
|
24
|
-
}
|
|
25
|
-
case 'tts-ggml': {
|
|
26
|
-
const { default: TTSGgml } = await import('@qvac/tts-ggml');
|
|
27
|
-
return TTSGgml.assessFit(probe.request);
|
|
28
|
-
}
|
|
29
|
-
case 'audiogen-ggml': {
|
|
30
|
-
const { assessFit } = await import('@qvac/audiogen-ggml');
|
|
31
|
-
return assessFit(probe.request);
|
|
32
|
-
}
|
|
33
|
-
case 'diffusion-cpp': {
|
|
34
|
-
const { assessFit } = await import('@qvac/diffusion-cpp');
|
|
35
|
-
return assessFit(probe.request);
|
|
36
|
-
}
|
|
37
|
-
case 'ocr-ggml': {
|
|
38
|
-
const { assessFit } = await import('@qvac/ocr-ggml');
|
|
39
|
-
return assessFit(probe.request);
|
|
40
|
-
}
|
|
41
|
-
case 'translation-nmtcpp': {
|
|
42
|
-
const { default: TranslationNmtcpp } = await import('@qvac/translation-nmtcpp');
|
|
43
|
-
return TranslationNmtcpp.assessFit(probe.request);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export async function callChildEngineFit(probe) {
|
|
48
|
-
return { engine: probe.engine, result: await assessFitOf(probe) };
|
|
49
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modes whose load the projection would not describe.
|
|
3
|
-
*
|
|
4
|
-
* `upscale` is an ESRGAN checkpoint, which has no fitter. `world` assembles a
|
|
5
|
-
* TAEHV preview decoder and a seed scene that the fit request has no place for.
|
|
6
|
-
*/
|
|
7
|
-
const UNFITTABLE_MODES = {
|
|
8
|
-
upscale: 'a standalone upscaler load has no fitter',
|
|
9
|
-
world: 'world loads are not representable'
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Frames to project a video load at. The fitter reads one frame when nothing
|
|
13
|
-
* is passed, which projects image generation; `run` generates 33. The frame
|
|
14
|
-
* count is a generation parameter, and this assessment sees load config alone.
|
|
15
|
-
*/
|
|
16
|
-
const DEFAULT_VIDEO_FRAMES = 33;
|
|
17
|
-
export function createDiffusionFitRequest(params) {
|
|
18
|
-
const config = (params.modelConfig ?? {});
|
|
19
|
-
const artifacts = params.artifacts ?? {};
|
|
20
|
-
const unfittable = config.mode === undefined ? undefined : UNFITTABLE_MODES[config.mode];
|
|
21
|
-
if (unfittable !== undefined)
|
|
22
|
-
return { supported: false, detail: unfittable };
|
|
23
|
-
// A configured upscaler adds a second resident model the projection does not
|
|
24
|
-
// account for.
|
|
25
|
-
if (config.upscaler !== undefined) {
|
|
26
|
-
return { supported: false, detail: 'a configured upscaler is not part of the projection' };
|
|
27
|
-
}
|
|
28
|
-
const files = {
|
|
29
|
-
model: params.modelPath,
|
|
30
|
-
...(artifacts['clipLModelPath'] !== undefined && { clipL: artifacts['clipLModelPath'] }),
|
|
31
|
-
...(artifacts['clipGModelPath'] !== undefined && { clipG: artifacts['clipGModelPath'] }),
|
|
32
|
-
...(artifacts['t5XxlModelPath'] !== undefined && { t5Xxl: artifacts['t5XxlModelPath'] }),
|
|
33
|
-
...(artifacts['llmModelPath'] !== undefined && { llm: artifacts['llmModelPath'] }),
|
|
34
|
-
...(artifacts['vaeModelPath'] !== undefined && { vae: artifacts['vaeModelPath'] }),
|
|
35
|
-
...(artifacts['uncondModelPath'] !== undefined && {
|
|
36
|
-
uncondModel: artifacts['uncondModelPath']
|
|
37
|
-
}),
|
|
38
|
-
...(artifacts['clipVisionModelPath'] !== undefined && {
|
|
39
|
-
clipVision: artifacts['clipVisionModelPath']
|
|
40
|
-
}),
|
|
41
|
-
...(artifacts['audioVaeModelPath'] !== undefined && {
|
|
42
|
-
audioVae: artifacts['audioVaeModelPath']
|
|
43
|
-
}),
|
|
44
|
-
...(artifacts['embeddingsConnectorsModelPath'] !== undefined && {
|
|
45
|
-
embeddingsConnectors: artifacts['embeddingsConnectorsModelPath']
|
|
46
|
-
})
|
|
47
|
-
};
|
|
48
|
-
// `mode` and `upscaler` are this SDK's own keys; the engine config has no
|
|
49
|
-
// field for either.
|
|
50
|
-
const { mode: _mode, upscaler: _upscaler, ...engineConfig } = config;
|
|
51
|
-
return {
|
|
52
|
-
supported: true,
|
|
53
|
-
probe: {
|
|
54
|
-
engine: 'diffusion-cpp',
|
|
55
|
-
request: {
|
|
56
|
-
files,
|
|
57
|
-
config: engineConfig,
|
|
58
|
-
workload: {
|
|
59
|
-
...(config.vae_tiling !== undefined && { vaeTiling: config.vae_tiling }),
|
|
60
|
-
...(config.mode === 'video' && { videoFrames: DEFAULT_VIDEO_FRAMES })
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { FitProbeResult } from './engine-fit.js';
|
|
2
|
-
/**
|
|
3
|
-
* Why a run produced no projection. Every one of these is absence of evidence,
|
|
4
|
-
* so the caller proceeds with the load it was going to run anyway.
|
|
5
|
-
*/
|
|
6
|
-
export type FitRunUnknownReason = 'unsupported-platform' | 'spawn-failed' | 'timeout' | 'cancelled' | 'crashed' | 'invalid-response' | 'invocation-error';
|
|
7
|
-
/** The contract both isolation strategies answer with. */
|
|
8
|
-
export type FitRunResult = {
|
|
9
|
-
status: 'completed';
|
|
10
|
-
probe: FitProbeResult;
|
|
11
|
-
} | {
|
|
12
|
-
status: 'unknown';
|
|
13
|
-
reason: FitRunUnknownReason;
|
|
14
|
-
message: string;
|
|
15
|
-
stderrTail?: string;
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { FitProbeRequest, FitProbeResult } from './engine-fit.js';
|
|
2
|
-
/**
|
|
3
|
-
* One JSON line in, one JSON line out. The child holds a native addon for the
|
|
4
|
-
* duration of the call, so the boundary stays deliberately narrow: nothing
|
|
5
|
-
* streams, nothing is stateful, and a child that dies mid-call costs only the
|
|
6
|
-
* projection.
|
|
7
|
-
*/
|
|
8
|
-
export declare const FIT_PROCESS_PROTOCOL_VERSION = 1;
|
|
9
|
-
export declare const FIT_PROCESS_MAX_REQUEST_BYTES: number;
|
|
10
|
-
export declare const FIT_PROCESS_MAX_RESPONSE_BYTES: number;
|
|
11
|
-
export interface FitProcessRequest {
|
|
12
|
-
version: number;
|
|
13
|
-
probe: FitProbeRequest;
|
|
14
|
-
}
|
|
15
|
-
export type FitProcessResponse = {
|
|
16
|
-
status: 'completed';
|
|
17
|
-
probe: FitProbeResult;
|
|
18
|
-
} | {
|
|
19
|
-
status: 'invocation-error';
|
|
20
|
-
error: {
|
|
21
|
-
name: string;
|
|
22
|
-
message: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export declare function encodeFitProcessRequest(probe: FitProbeRequest): string;
|
|
26
|
-
export declare function parseFitProcessRequest(value: unknown): FitProcessRequest;
|
|
27
|
-
export declare function parseFitProcessResponse(value: unknown): FitProcessResponse;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One JSON line in, one JSON line out. The child holds a native addon for the
|
|
3
|
-
* duration of the call, so the boundary stays deliberately narrow: nothing
|
|
4
|
-
* streams, nothing is stateful, and a child that dies mid-call costs only the
|
|
5
|
-
* projection.
|
|
6
|
-
*/
|
|
7
|
-
export const FIT_PROCESS_PROTOCOL_VERSION = 1;
|
|
8
|
-
export const FIT_PROCESS_MAX_REQUEST_BYTES = 256 * 1024;
|
|
9
|
-
export const FIT_PROCESS_MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
10
|
-
export function encodeFitProcessRequest(probe) {
|
|
11
|
-
const line = `${JSON.stringify({ version: FIT_PROCESS_PROTOCOL_VERSION, probe })}\n`;
|
|
12
|
-
if (Buffer.byteLength(line) > FIT_PROCESS_MAX_REQUEST_BYTES) {
|
|
13
|
-
throw new RangeError(`Fit request exceeds ${FIT_PROCESS_MAX_REQUEST_BYTES} bytes`);
|
|
14
|
-
}
|
|
15
|
-
return line;
|
|
16
|
-
}
|
|
17
|
-
function isRecord(value) {
|
|
18
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
19
|
-
}
|
|
20
|
-
export function parseFitProcessRequest(value) {
|
|
21
|
-
if (!isRecord(value))
|
|
22
|
-
throw new TypeError('Fit request must be an object');
|
|
23
|
-
if (value['version'] !== FIT_PROCESS_PROTOCOL_VERSION) {
|
|
24
|
-
throw new TypeError(`Unsupported fit protocol version: ${String(value['version'])}`);
|
|
25
|
-
}
|
|
26
|
-
const probe = value['probe'];
|
|
27
|
-
if (!isRecord(probe) || typeof probe['engine'] !== 'string' || !isRecord(probe['request'])) {
|
|
28
|
-
throw new TypeError('Fit request must carry an engine and a request');
|
|
29
|
-
}
|
|
30
|
-
return { version: FIT_PROCESS_PROTOCOL_VERSION, probe: probe };
|
|
31
|
-
}
|
|
32
|
-
export function parseFitProcessResponse(value) {
|
|
33
|
-
if (!isRecord(value))
|
|
34
|
-
throw new TypeError('Fit response must be an object');
|
|
35
|
-
if (value['status'] === 'invocation-error') {
|
|
36
|
-
const error = value['error'];
|
|
37
|
-
if (!isRecord(error) ||
|
|
38
|
-
typeof error['name'] !== 'string' ||
|
|
39
|
-
typeof error['message'] !== 'string') {
|
|
40
|
-
throw new TypeError('Fit invocation error must carry a name and a message');
|
|
41
|
-
}
|
|
42
|
-
return { status: 'invocation-error', error: { name: error['name'], message: error['message'] } };
|
|
43
|
-
}
|
|
44
|
-
if (value['status'] !== 'completed') {
|
|
45
|
-
throw new TypeError(`Unknown fit response status: ${String(value['status'])}`);
|
|
46
|
-
}
|
|
47
|
-
const probe = value['probe'];
|
|
48
|
-
if (!isRecord(probe) || typeof probe['engine'] !== 'string' || !isRecord(probe['result'])) {
|
|
49
|
-
throw new TypeError('Fit response must carry an engine and a result');
|
|
50
|
-
}
|
|
51
|
-
if (typeof probe['result']['status'] !== 'string') {
|
|
52
|
-
throw new TypeError('Fit result must carry a status');
|
|
53
|
-
}
|
|
54
|
-
return { status: 'completed', probe: probe };
|
|
55
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import processModule from 'bare-process';
|
|
2
|
-
import { callChildEngineFit } from './child-engine-fit.js';
|
|
3
|
-
import { FIT_PROCESS_MAX_REQUEST_BYTES, parseFitProcessRequest } from './fit-process.js';
|
|
4
|
-
/**
|
|
5
|
-
* Entry point of the disposable fit child. It loads one engine addon, asks it
|
|
6
|
-
* for a projection and exits, so a fitter that aborts the process takes nothing
|
|
7
|
-
* with it — which is the whole reason the projection does not run in the host.
|
|
8
|
-
*
|
|
9
|
-
* Writes exactly one JSON line to stdout and nothing else. Whatever an addon
|
|
10
|
-
* prints goes to stderr, where the supervisor keeps the tail.
|
|
11
|
-
*/
|
|
12
|
-
const process = processModule;
|
|
13
|
-
let finished = false;
|
|
14
|
-
function respond(line) {
|
|
15
|
-
if (finished)
|
|
16
|
-
return;
|
|
17
|
-
finished = true;
|
|
18
|
-
// One shot: stop reading before replying, so a still-open stdin cannot hold
|
|
19
|
-
// the child open once the response has been flushed.
|
|
20
|
-
process.stdin.pause();
|
|
21
|
-
process.stdout.write(line, (error) => {
|
|
22
|
-
if (error !== null && error !== undefined) {
|
|
23
|
-
process.stderr.write(`fit runner failed to write its response: ${error.message}\n`, () => {
|
|
24
|
-
process.exit(2);
|
|
25
|
-
});
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
process.exit(0);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function fail(error) {
|
|
32
|
-
const name = error instanceof Error ? error.name : 'Error';
|
|
33
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
34
|
-
respond(`${JSON.stringify({ status: 'invocation-error', error: { name, message } })}\n`);
|
|
35
|
-
}
|
|
36
|
-
async function answer(input) {
|
|
37
|
-
const { probe } = parseFitProcessRequest(JSON.parse(input));
|
|
38
|
-
const result = await callChildEngineFit(probe);
|
|
39
|
-
respond(`${JSON.stringify({ status: 'completed', probe: result })}\n`);
|
|
40
|
-
}
|
|
41
|
-
let input = '';
|
|
42
|
-
process.stdin.setEncoding('utf8');
|
|
43
|
-
process.stdin.on('data', (chunk) => {
|
|
44
|
-
if (finished)
|
|
45
|
-
return;
|
|
46
|
-
input += chunk;
|
|
47
|
-
if (Buffer.byteLength(input) > FIT_PROCESS_MAX_REQUEST_BYTES) {
|
|
48
|
-
fail(new RangeError(`Fit request exceeds ${FIT_PROCESS_MAX_REQUEST_BYTES} bytes`));
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
process.stdin.on('error', (error) => {
|
|
52
|
-
fail(error ?? new Error('fit runner stdin failed'));
|
|
53
|
-
});
|
|
54
|
-
process.stdin.on('end', () => {
|
|
55
|
-
if (finished)
|
|
56
|
-
return;
|
|
57
|
-
answer(input).catch(fail);
|
|
58
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
|
-
import type { FitProbeRequest } from './engine-fit.js';
|
|
3
|
-
import type { FitRunResult } from './fit-outcome.js';
|
|
4
|
-
export interface RunFitOptions {
|
|
5
|
-
signal?: AbortSignal;
|
|
6
|
-
timeoutMs?: number;
|
|
7
|
-
/**
|
|
8
|
-
* Whether this host can spawn a disposable child. Resolved by the caller,
|
|
9
|
-
* which already knows the runtime.
|
|
10
|
-
*/
|
|
11
|
-
mobile?: boolean;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Runs one engine's fitter and returns what it projected.
|
|
15
|
-
*
|
|
16
|
-
* A disposable child is the stronger boundary — a fitter that aborts takes only
|
|
17
|
-
* the child with it — so it is used wherever one can be spawned. Mobile has no
|
|
18
|
-
* such child and runs the fitter in process, carrying crash markers to bound
|
|
19
|
-
* the abort it cannot contain. `bare-subprocess` stays deferred from the mobile
|
|
20
|
-
* pack that way.
|
|
21
|
-
*
|
|
22
|
-
* Both strategies are imported lazily, so a host only loads the one it uses.
|
|
23
|
-
*/
|
|
24
|
-
export declare function runFit(probe: FitProbeRequest, options?: RunFitOptions): Promise<FitRunResult>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runs one engine's fitter and returns what it projected.
|
|
3
|
-
*
|
|
4
|
-
* A disposable child is the stronger boundary — a fitter that aborts takes only
|
|
5
|
-
* the child with it — so it is used wherever one can be spawned. Mobile has no
|
|
6
|
-
* such child and runs the fitter in process, carrying crash markers to bound
|
|
7
|
-
* the abort it cannot contain. `bare-subprocess` stays deferred from the mobile
|
|
8
|
-
* pack that way.
|
|
9
|
-
*
|
|
10
|
-
* Both strategies are imported lazily, so a host only loads the one it uses.
|
|
11
|
-
*/
|
|
12
|
-
export async function runFit(probe, options = {}) {
|
|
13
|
-
const { mobile, timeoutMs, ...runOptions } = options;
|
|
14
|
-
if (mobile === true) {
|
|
15
|
-
const { runInProcessFit } = await import('./run-in-process-fit.js');
|
|
16
|
-
return runInProcessFit(probe, runOptions);
|
|
17
|
-
}
|
|
18
|
-
const { runIsolatedFit } = await import('./run-isolated-fit.js');
|
|
19
|
-
return runIsolatedFit(probe, { ...runOptions, ...(timeoutMs !== undefined && { timeoutMs }) });
|
|
20
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
|
-
import { callEngineFit } from './engine-fit.js';
|
|
3
|
-
import type { FitProbeRequest } from './engine-fit.js';
|
|
4
|
-
import type { FitRunResult } from './fit-outcome.js';
|
|
5
|
-
export interface RunInProcessFitOptions {
|
|
6
|
-
signal?: AbortSignal;
|
|
7
|
-
stateDir?: string;
|
|
8
|
-
callFit?: typeof callEngineFit;
|
|
9
|
-
}
|
|
10
|
-
export declare function crashMarkerPath(stateDir: string, probe: FitProbeRequest): string;
|
|
11
|
-
export declare function crashedMarkerPath(stateDir: string, probe: FitProbeRequest): string;
|
|
12
|
-
/**
|
|
13
|
-
* Runs one engine's fitter in this process, for hosts that cannot spawn a
|
|
14
|
-
* disposable child.
|
|
15
|
-
*
|
|
16
|
-
* There is no boundary here to contain a fitter that aborts: it takes the host
|
|
17
|
-
* with it. A leftover `.running` marker is that abort, observed on the next
|
|
18
|
-
* launch, and it is promoted to `.crashed` so the same request skips native
|
|
19
|
-
* rather than repeating the abort. `timeoutMs` is not applied on this path.
|
|
20
|
-
*
|
|
21
|
-
* Fits of the same request can be in flight together. A `.running` marker this
|
|
22
|
-
* process holds is not an abort, so it is shared and removed by the last fit.
|
|
23
|
-
*/
|
|
24
|
-
export declare function runInProcessFit(probe: FitProbeRequest, options?: RunInProcessFitOptions): Promise<FitRunResult>;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import fs from 'bare-fs';
|
|
2
|
-
import path from 'bare-path';
|
|
3
|
-
import { generateShortHash } from '../../../utils/formatting.js';
|
|
4
|
-
import { callEngineFit } from './engine-fit.js';
|
|
5
|
-
function unknown(reason, message) {
|
|
6
|
-
return { status: 'unknown', reason, message };
|
|
7
|
-
}
|
|
8
|
-
function describe(error) {
|
|
9
|
-
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
10
|
-
}
|
|
11
|
-
/** How long a marker keeps a model off the native path. */
|
|
12
|
-
const MARKER_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
13
|
-
/** Fits this process has in flight, per `.running` marker path. */
|
|
14
|
-
const inFlight = new Map();
|
|
15
|
-
/**
|
|
16
|
-
* `marginBytes` is excluded: it carries the bytes of every model resident at
|
|
17
|
-
* the time, so it differs between two attempts at the same load.
|
|
18
|
-
*/
|
|
19
|
-
function markerKey(probe) {
|
|
20
|
-
const { marginBytes: _margin, ...request } = probe.request;
|
|
21
|
-
return generateShortHash(JSON.stringify({ engine: probe.engine, request }));
|
|
22
|
-
}
|
|
23
|
-
export function crashMarkerPath(stateDir, probe) {
|
|
24
|
-
return path.join(stateDir, `${markerKey(probe)}.running`);
|
|
25
|
-
}
|
|
26
|
-
export function crashedMarkerPath(stateDir, probe) {
|
|
27
|
-
return path.join(stateDir, `${markerKey(probe)}.crashed`);
|
|
28
|
-
}
|
|
29
|
-
function exists(file) {
|
|
30
|
-
try {
|
|
31
|
-
fs.accessSync(file);
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function expired(file) {
|
|
39
|
-
try {
|
|
40
|
-
return Date.now() - fs.statSync(file).mtimeMs > MARKER_TTL_MS;
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function clearRunning(file) {
|
|
47
|
-
try {
|
|
48
|
-
fs.unlinkSync(file);
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
// Marker cleanup must not turn an advisory fit into a load failure.
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async function resolveStateDir(explicit) {
|
|
55
|
-
if (explicit !== undefined)
|
|
56
|
-
return explicit;
|
|
57
|
-
const { getCacheDir } = await import('../../../utils/cache/paths.js');
|
|
58
|
-
return getCacheDir('model-fit');
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Runs one engine's fitter in this process, for hosts that cannot spawn a
|
|
62
|
-
* disposable child.
|
|
63
|
-
*
|
|
64
|
-
* There is no boundary here to contain a fitter that aborts: it takes the host
|
|
65
|
-
* with it. A leftover `.running` marker is that abort, observed on the next
|
|
66
|
-
* launch, and it is promoted to `.crashed` so the same request skips native
|
|
67
|
-
* rather than repeating the abort. `timeoutMs` is not applied on this path.
|
|
68
|
-
*
|
|
69
|
-
* Fits of the same request can be in flight together. A `.running` marker this
|
|
70
|
-
* process holds is not an abort, so it is shared and removed by the last fit.
|
|
71
|
-
*/
|
|
72
|
-
export async function runInProcessFit(probe, options = {}) {
|
|
73
|
-
if (options.signal?.aborted === true) {
|
|
74
|
-
return unknown('cancelled', 'In-process fit was cancelled');
|
|
75
|
-
}
|
|
76
|
-
const stateDir = await resolveStateDir(options.stateDir);
|
|
77
|
-
const running = crashMarkerPath(stateDir, probe);
|
|
78
|
-
const crashed = crashedMarkerPath(stateDir, probe);
|
|
79
|
-
const held = inFlight.get(running) ?? 0;
|
|
80
|
-
if (held === 0) {
|
|
81
|
-
for (const marker of [crashed, running]) {
|
|
82
|
-
if (exists(marker) && expired(marker))
|
|
83
|
-
clearRunning(marker);
|
|
84
|
-
}
|
|
85
|
-
if (exists(crashed) || exists(running)) {
|
|
86
|
-
try {
|
|
87
|
-
fs.mkdirSync(path.dirname(crashed), { recursive: true });
|
|
88
|
-
fs.writeFileSync(crashed, '');
|
|
89
|
-
clearRunning(running);
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
// Keep `.running` if `.crashed` could not be written so the next launch
|
|
93
|
-
// still skips native.
|
|
94
|
-
}
|
|
95
|
-
return unknown('crashed', 'Previous fit did not finish; treating this model as unknown');
|
|
96
|
-
}
|
|
97
|
-
try {
|
|
98
|
-
fs.mkdirSync(path.dirname(running), { recursive: true });
|
|
99
|
-
fs.writeFileSync(running, '');
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
return unknown('invocation-error', `Fit crash marker could not be written: ${describe(error)}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
inFlight.set(running, held + 1);
|
|
106
|
-
try {
|
|
107
|
-
const callFit = options.callFit ?? callEngineFit;
|
|
108
|
-
return { status: 'completed', probe: await callFit(probe) };
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
return unknown('invocation-error', describe(error));
|
|
112
|
-
}
|
|
113
|
-
finally {
|
|
114
|
-
const remaining = (inFlight.get(running) ?? 1) - 1;
|
|
115
|
-
if (remaining === 0) {
|
|
116
|
-
inFlight.delete(running);
|
|
117
|
-
clearRunning(running);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
inFlight.set(running, remaining);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|