@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/dist/utils/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from '
|
|
3
|
-
export * from '
|
|
4
|
-
export * from '
|
|
5
|
-
export * from '
|
|
6
|
-
export * from '
|
|
7
|
-
export * from '
|
|
8
|
-
export * from '
|
|
9
|
-
export * from '
|
|
10
|
-
export * from '
|
|
11
|
-
export * from '
|
|
12
|
-
export * from '
|
|
13
|
-
export * from '
|
|
1
|
+
export * from '../utils/archive.js';
|
|
2
|
+
export * from '../utils/cache/types.js';
|
|
3
|
+
export * from '../utils/cache/auto-history.js';
|
|
4
|
+
export * from '../utils/cache/paths.js';
|
|
5
|
+
export * from '../utils/checksum.js';
|
|
6
|
+
export * from '../utils/config-transform.js';
|
|
7
|
+
export * from '../utils/formatting.js';
|
|
8
|
+
export * from '../utils/gguf-tensor-extractor.js';
|
|
9
|
+
export * from '../utils/image-dimensions.js';
|
|
10
|
+
export * from '../utils/path-sanitize.js';
|
|
11
|
+
export * from '../utils/path-security.js';
|
|
12
|
+
export * from '../utils/shard-utils.js';
|
|
13
|
+
export * from '../utils/url-security.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Tool } from '../schemas/tools.js';
|
|
2
2
|
import type { McpClientInput } from '../schemas/mcp-adapter.js';
|
|
3
|
-
import type { ToolHandler } from '
|
|
3
|
+
import type { ToolHandler } from '../utils/tool-helpers.js';
|
|
4
4
|
export type { McpClient, McpClientInput } from '../schemas/mcp-adapter.js';
|
|
5
5
|
export type ToolHandlerMap = Map<string, ToolHandler>;
|
|
6
6
|
export type McpToolsResult = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'bare-path';
|
|
2
2
|
import { PathTraversalError } from '../errors/index.js';
|
|
3
|
-
import { sanitizePathComponent } from '
|
|
3
|
+
import { sanitizePathComponent } from '../utils/path-sanitize.js';
|
|
4
4
|
/**
|
|
5
5
|
* Check whether a resolved target path is contained within a base directory.
|
|
6
6
|
* Portable — caller provides the resolve function and separator for their runtime.
|
|
@@ -12,6 +12,11 @@ export declare function getFirstShardPath(modelPath: string): string;
|
|
|
12
12
|
* @returns Array of all numbered shard filenames
|
|
13
13
|
*/
|
|
14
14
|
export declare function generateShardFilenames(shardName: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* List the files a model path loads: the path itself, or for a sharded model
|
|
17
|
+
* its tensors file followed by every shard in order
|
|
18
|
+
*/
|
|
19
|
+
export declare function getModelShardFiles(modelPath: string): string[];
|
|
15
20
|
/**
|
|
16
21
|
* Parse pattern-based shard URL and generate all shard URLs with cache key
|
|
17
22
|
* Works with patterns like: https://example.com/path/model-00002-of-00005.gguf
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ModelLoadFailedError, InvalidShardUrlPatternError } from '../errors/index.js';
|
|
2
|
-
import { generateShortHash } from '
|
|
3
|
-
import { validateAndJoinPath } from '
|
|
4
|
-
import { extractAndWriteTensorsFile } from '
|
|
2
|
+
import { generateShortHash } from '../utils/formatting.js';
|
|
3
|
+
import { validateAndJoinPath } from '../utils/path-security.js';
|
|
4
|
+
import { extractAndWriteTensorsFile } from '../utils/gguf-tensor-extractor.js';
|
|
5
5
|
import { promises as fsPromises } from 'bare-fs';
|
|
6
|
+
import path from 'bare-path';
|
|
6
7
|
/**
|
|
7
8
|
* Detect if model filename follows shard pattern (00001-of-0000x)
|
|
8
9
|
*/
|
|
@@ -55,6 +56,21 @@ export function generateShardFilenames(shardName) {
|
|
|
55
56
|
}
|
|
56
57
|
return filenames;
|
|
57
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* List the files a model path loads: the path itself, or for a sharded model
|
|
61
|
+
* its tensors file followed by every shard in order
|
|
62
|
+
*/
|
|
63
|
+
export function getModelShardFiles(modelPath) {
|
|
64
|
+
const filename = path.basename(modelPath);
|
|
65
|
+
const info = detectShardedModel(filename);
|
|
66
|
+
if (!info.isSharded)
|
|
67
|
+
return [modelPath];
|
|
68
|
+
const directory = path.dirname(modelPath);
|
|
69
|
+
return [
|
|
70
|
+
path.join(directory, `${info.baseFilename}.tensors.txt`),
|
|
71
|
+
...generateShardFilenames(filename).map((shard) => path.join(directory, shard))
|
|
72
|
+
];
|
|
73
|
+
}
|
|
58
74
|
/**
|
|
59
75
|
* Parse pattern-based shard URL and generate all shard URLs with cache key
|
|
60
76
|
* Works with patterns like: https://example.com/path/model-00002-of-00005.gguf
|
|
@@ -12,5 +12,6 @@ interface HistoryMessage {
|
|
|
12
12
|
* whole chat session.
|
|
13
13
|
*/
|
|
14
14
|
export declare function prependToolsToHistory(history: HistoryMessage[], tools: Tool[]): Array<HistoryMessage | Tool>;
|
|
15
|
+
/** The tool-call dialect resolved when the model loaded. */
|
|
15
16
|
export declare function detectToolDialect(modelId: string): ToolDialect;
|
|
16
17
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getModelInfo } from '../runtime/model-registry.js';
|
|
1
|
+
import { getModelEntry } from '../runtime/model-registry.js';
|
|
3
2
|
/**
|
|
4
3
|
* Prepend tools right after the system message (or at the very start when no
|
|
5
4
|
* system message is present). The tool block stays in the kv-cache for the
|
|
@@ -12,9 +11,7 @@ export function prependToolsToHistory(history, tools) {
|
|
|
12
11
|
}
|
|
13
12
|
return [...tools, ...history];
|
|
14
13
|
}
|
|
14
|
+
/** The tool-call dialect resolved when the model loaded. */
|
|
15
15
|
export function detectToolDialect(modelId) {
|
|
16
|
-
|
|
17
|
-
if (!info)
|
|
18
|
-
return 'hermes';
|
|
19
|
-
return detectToolDialectFromName(info.name, info.path);
|
|
16
|
+
return getModelEntry(modelId)?.local.toolDialect ?? 'hermes';
|
|
20
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Tool } from '../../schemas/tools.js';
|
|
2
|
-
import { type ToolInput } from '
|
|
2
|
+
import { type ToolInput } from '../../utils/tool-helpers.js';
|
|
3
3
|
/**
|
|
4
4
|
* Reserved name of the built-in search tool. A caller cannot register a tool
|
|
5
5
|
* under this name, and it is never itself deferred — the model needs one
|
|
@@ -50,44 +50,34 @@ export declare function buildToolSearchResult(query: string, matches: readonly T
|
|
|
50
50
|
*/
|
|
51
51
|
export declare function loadedToolNames(history: readonly HistoryMessage[]): Set<string>;
|
|
52
52
|
export type DeferredResolution = {
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Definitions that go into the prompt and the parser: always-loaded tools,
|
|
55
|
+
* `tool_search`, and whatever history has loaded.
|
|
56
|
+
*/
|
|
54
57
|
toolsToRender: Tool[];
|
|
55
|
-
/**
|
|
56
|
-
callableTools: Tool[];
|
|
57
|
-
/** The full deferred inventory, for `tool_search` to search over. */
|
|
58
|
+
/** The deferred tools `tool_search` searches over. */
|
|
58
59
|
deferred: Tool[];
|
|
59
60
|
};
|
|
60
61
|
/**
|
|
61
|
-
* Split a registered tool list into what the prompt carries and what
|
|
62
|
-
*
|
|
62
|
+
* Split a registered tool list into what the prompt carries and what
|
|
63
|
+
* `tool_search` searches over.
|
|
63
64
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
65
|
+
* A loaded definition is declared in the tools block like any other tool, in
|
|
66
|
+
* registration order. A schema that sits only in a `tool` result, outside the
|
|
67
|
+
* block and the tool-call grammar, is not reliably called by small models: they
|
|
68
|
+
* search for it again instead. Declaring it changes the block at the front of
|
|
69
|
+
* the prompt, so the turn after a search re-prefills from there.
|
|
68
70
|
*
|
|
69
71
|
* Returns `null` when nothing defers, so the existing path is untouched.
|
|
70
72
|
*/
|
|
71
73
|
export declare function resolveDeferredTools(tools: readonly Tool[] | undefined, history: readonly HistoryMessage[]): DeferredResolution | null;
|
|
72
|
-
/**
|
|
73
|
-
* Generation params for a turn whose history may have loaded deferred definitions.
|
|
74
|
-
*
|
|
75
|
-
* The addon builds its tool-call grammar from the rendered tools only, and a
|
|
76
|
-
* loaded definition lives in the history rather than that block, so under the
|
|
77
|
-
* default grammar the model can never produce the name it just loaded. Unless
|
|
78
|
-
* the caller asked for more than the default, those turns run with the grammar
|
|
79
|
-
* off and the parser, which does accept loaded names, validates the call.
|
|
80
|
-
*/
|
|
81
|
-
export declare function withDeferredToolChoice<T extends {
|
|
82
|
-
tool_choice?: string | undefined;
|
|
83
|
-
}>(generationParams: T | undefined, resolution: DeferredResolution | null): T | undefined;
|
|
84
74
|
/**
|
|
85
75
|
* Run a `tool_search` call and produce the `tool` message that carries its
|
|
86
76
|
* result. Pure over the history it is given; the caller appends the message.
|
|
87
77
|
*
|
|
88
78
|
* Takes either wire `Tool`s or the Zod-schema `ToolInput` form, because what a
|
|
89
|
-
* caller holds is whatever they passed to `completion()`.
|
|
90
|
-
*
|
|
91
|
-
*
|
|
79
|
+
* caller holds is whatever they passed to `completion()`. Both are converted
|
|
80
|
+
* to wire form first, so the size cap measures the JSON schemas the prompt
|
|
81
|
+
* will declare, not Zod objects.
|
|
92
82
|
*/
|
|
93
83
|
export declare function executeToolSearch(tools: readonly Tool[] | readonly ToolInput[], args: Record<string, unknown>, history: readonly HistoryMessage[]): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateTools } from '
|
|
1
|
+
import { validateTools } from '../../utils/tool-helpers.js';
|
|
2
2
|
/**
|
|
3
3
|
* Reserved name of the built-in search tool. A caller cannot register a tool
|
|
4
4
|
* under this name, and it is never itself deferred — the model needs one
|
|
@@ -7,7 +7,7 @@ import { validateTools } from '../tool-helpers.js';
|
|
|
7
7
|
export const TOOL_SEARCH_NAME = 'tool_search';
|
|
8
8
|
const DEFAULT_SEARCH_LIMIT = 3;
|
|
9
9
|
const MAX_SEARCH_LIMIT = 8;
|
|
10
|
-
// Ceiling on the definitions one search may
|
|
10
|
+
// Ceiling on the definitions one search may declare. A query matching a dozen
|
|
11
11
|
// large schemas would otherwise undo the saving the catalog just made.
|
|
12
12
|
const MAX_DEFINITION_BYTES = 8 * 1024;
|
|
13
13
|
// Fixed text, so a repeated no-match search stays byte-identical and cannot
|
|
@@ -170,8 +170,7 @@ export function buildToolSearchResult(query, matches, alreadyLoaded) {
|
|
|
170
170
|
// Without this the model reads an empty result as "try again" and burns
|
|
171
171
|
// rounds rephrasing the same query.
|
|
172
172
|
...(loaded.length === 0 && alreadyLoaded.length === 0 ? { hint: NO_MATCH_HINT } : {})
|
|
173
|
-
}
|
|
174
|
-
tools: matches.map(toWireTool)
|
|
173
|
+
}
|
|
175
174
|
};
|
|
176
175
|
return JSON.stringify(result);
|
|
177
176
|
}
|
|
@@ -219,70 +218,80 @@ export function loadedToolNames(history) {
|
|
|
219
218
|
}
|
|
220
219
|
return loaded;
|
|
221
220
|
}
|
|
221
|
+
// `tool_choice` mode words and the empty name: the addon rejects a prompt that
|
|
222
|
+
// declares a tool under one of these, since it could never be selected by name.
|
|
223
|
+
const UNSELECTABLE_NAMES = new Set(['', 'auto', 'none', 'required']);
|
|
224
|
+
// The rule name a tool's call grammar is built under: fabric's `rule_name()`
|
|
225
|
+
// turns every run of characters outside [A-Za-z0-9-] into one '-'.
|
|
226
|
+
function grammarRuleName(name) {
|
|
227
|
+
return name.replace(/[^A-Za-z0-9-]+/g, '-');
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The deferred tools the prompt could declare once loaded. The addon rejects a
|
|
231
|
+
* prompt whose tool names it cannot select or whose names fold to one grammar
|
|
232
|
+
* rule, so a deferred tool with such a name, or one whose rule an always-loaded
|
|
233
|
+
* tool, `tool_search` or an earlier deferred tool already holds, is left out of
|
|
234
|
+
* the catalog and the search: the model is never pointed at a tool it cannot
|
|
235
|
+
* call, and the block does not depend on the order tools were loaded in.
|
|
236
|
+
*/
|
|
237
|
+
function declarableDeferred(alwaysLoaded, deferred) {
|
|
238
|
+
const taken = new Set([...alwaysLoaded.map((tool) => tool.name), TOOL_SEARCH_NAME].map(grammarRuleName));
|
|
239
|
+
return deferred.filter((tool) => {
|
|
240
|
+
const rule = grammarRuleName(tool.name);
|
|
241
|
+
if (UNSELECTABLE_NAMES.has(tool.name) || taken.has(rule))
|
|
242
|
+
return false;
|
|
243
|
+
taken.add(rule);
|
|
244
|
+
return true;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
222
247
|
/**
|
|
223
|
-
* Split a registered tool list into what the prompt carries and what
|
|
224
|
-
*
|
|
248
|
+
* Split a registered tool list into what the prompt carries and what
|
|
249
|
+
* `tool_search` searches over.
|
|
225
250
|
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
251
|
+
* A loaded definition is declared in the tools block like any other tool, in
|
|
252
|
+
* registration order. A schema that sits only in a `tool` result, outside the
|
|
253
|
+
* block and the tool-call grammar, is not reliably called by small models: they
|
|
254
|
+
* search for it again instead. Declaring it changes the block at the front of
|
|
255
|
+
* the prompt, so the turn after a search re-prefills from there.
|
|
230
256
|
*
|
|
231
257
|
* Returns `null` when nothing defers, so the existing path is untouched.
|
|
232
258
|
*/
|
|
233
259
|
export function resolveDeferredTools(tools, history) {
|
|
234
260
|
if (!tools || tools.length === 0)
|
|
235
261
|
return null;
|
|
236
|
-
const
|
|
237
|
-
if (deferred.length === 0)
|
|
262
|
+
const partitioned = partitionTools(tools);
|
|
263
|
+
if (partitioned.deferred.length === 0)
|
|
238
264
|
return null;
|
|
265
|
+
const { alwaysLoaded } = partitioned;
|
|
266
|
+
const deferred = declarableDeferred(alwaysLoaded, partitioned.deferred);
|
|
239
267
|
const loaded = loadedToolNames(history);
|
|
240
|
-
const rendered = [...alwaysLoaded.map(toWireTool), buildToolSearchTool(deferred)];
|
|
241
268
|
return {
|
|
242
|
-
toolsToRender:
|
|
243
|
-
|
|
244
|
-
|
|
269
|
+
toolsToRender: [
|
|
270
|
+
...alwaysLoaded.map(toWireTool),
|
|
271
|
+
buildToolSearchTool(deferred),
|
|
245
272
|
...deferred.filter((tool) => loaded.has(tool.name)).map(toWireTool)
|
|
246
273
|
],
|
|
247
|
-
deferred
|
|
274
|
+
deferred
|
|
248
275
|
};
|
|
249
276
|
}
|
|
250
|
-
/**
|
|
251
|
-
* Generation params for a turn whose history may have loaded deferred definitions.
|
|
252
|
-
*
|
|
253
|
-
* The addon builds its tool-call grammar from the rendered tools only, and a
|
|
254
|
-
* loaded definition lives in the history rather than that block, so under the
|
|
255
|
-
* default grammar the model can never produce the name it just loaded. Unless
|
|
256
|
-
* the caller asked for more than the default, those turns run with the grammar
|
|
257
|
-
* off and the parser, which does accept loaded names, validates the call.
|
|
258
|
-
*/
|
|
259
|
-
export function withDeferredToolChoice(generationParams, resolution) {
|
|
260
|
-
const toolChoice = generationParams?.tool_choice;
|
|
261
|
-
// An explicit "auto" is the default, which is exactly the grammar that cannot reach a loaded tool.
|
|
262
|
-
if (toolChoice !== undefined && toolChoice !== 'auto')
|
|
263
|
-
return generationParams;
|
|
264
|
-
if (!resolution || resolution.callableTools.length === resolution.toolsToRender.length) {
|
|
265
|
-
return generationParams;
|
|
266
|
-
}
|
|
267
|
-
return { ...(generationParams ?? {}), tool_choice: 'none' };
|
|
268
|
-
}
|
|
269
277
|
/**
|
|
270
278
|
* Run a `tool_search` call and produce the `tool` message that carries its
|
|
271
279
|
* result. Pure over the history it is given; the caller appends the message.
|
|
272
280
|
*
|
|
273
281
|
* Takes either wire `Tool`s or the Zod-schema `ToolInput` form, because what a
|
|
274
|
-
* caller holds is whatever they passed to `completion()`.
|
|
275
|
-
*
|
|
276
|
-
*
|
|
282
|
+
* caller holds is whatever they passed to `completion()`. Both are converted
|
|
283
|
+
* to wire form first, so the size cap measures the JSON schemas the prompt
|
|
284
|
+
* will declare, not Zod objects.
|
|
277
285
|
*/
|
|
278
286
|
export function executeToolSearch(tools, args, history) {
|
|
279
287
|
const { tools: wire } = validateTools([...tools]);
|
|
280
|
-
const { deferred } = partitionTools(wire);
|
|
288
|
+
const { alwaysLoaded, deferred: registered } = partitionTools(wire);
|
|
289
|
+
const deferred = declarableDeferred(alwaysLoaded, registered);
|
|
281
290
|
const query = typeof args['query'] === 'string' ? args['query'] : '';
|
|
282
291
|
const limit = typeof args['limit'] === 'number' ? args['limit'] : undefined;
|
|
283
292
|
const loaded = loadedToolNames(history);
|
|
284
293
|
const matches = searchDeferredTools(deferred, query, limit);
|
|
285
|
-
// A
|
|
294
|
+
// A tool the history already loaded is not reported as loaded again; naming
|
|
286
295
|
// it back tells the model it can call the tool without searching again.
|
|
287
296
|
const alreadyLoaded = matches.filter((tool) => loaded.has(tool.name)).map((tool) => tool.name);
|
|
288
297
|
const fresh = matches.filter((tool) => !loaded.has(tool.name));
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import type { ToolDialect } from '../../schemas/index.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* models). Bypass with `completion({ toolDialect })`.
|
|
3
|
+
* The tool-call dialect a model's registry name or file name points to, or
|
|
4
|
+
* undefined when neither matches a known pattern.
|
|
6
5
|
*/
|
|
7
|
-
export declare function
|
|
6
|
+
export declare function matchToolDialectFromName(name: string | undefined, path: string): ToolDialect | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* The tool-call dialect for a GGUF `general.architecture` value, or undefined
|
|
9
|
+
* for an architecture whose models use the default dialect.
|
|
10
|
+
*/
|
|
11
|
+
export declare function matchToolDialectFromArchitecture(architecture: string | undefined): ToolDialect | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves a model's tool-call dialect: its name first, then the
|
|
14
|
+
* `general.architecture` in its GGUF header, then "hermes", whose parser chain
|
|
15
|
+
* also covers unknown JSON-payload models. The header is read only when the
|
|
16
|
+
* name does not match. Bypass with `completion({ toolDialect })`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveToolDialect(name: string | undefined, path: string): Promise<ToolDialect>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { readGgufArchitecture } from '../../utils/gguf-architecture.js';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* models). Bypass with `completion({ toolDialect })`.
|
|
3
|
+
* The tool-call dialect a model's registry name or file name points to, or
|
|
4
|
+
* undefined when neither matches a known pattern.
|
|
5
5
|
*/
|
|
6
|
-
export function
|
|
6
|
+
export function matchToolDialectFromName(name, path) {
|
|
7
7
|
const basename = path.toLowerCase().split(/[/\\]/).pop() ?? '';
|
|
8
8
|
const tag = `${(name ?? '').toLowerCase()}|${basename}`;
|
|
9
9
|
if (/qwen3[._-]?[568](?![a-z0-9])/.test(tag))
|
|
@@ -16,5 +16,34 @@ export function detectToolDialectFromName(name, path) {
|
|
|
16
16
|
return 'dsml';
|
|
17
17
|
if (/lfm[_-]?\d/.test(tag))
|
|
18
18
|
return 'pythonic';
|
|
19
|
-
return
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const ARCHITECTURE_DIALECTS = new Map([
|
|
22
|
+
['qwen35', 'qwen35'],
|
|
23
|
+
['qwen35moe', 'qwen35'],
|
|
24
|
+
['qwen4exp', 'qwen35'],
|
|
25
|
+
['gemma4', 'gemma4'],
|
|
26
|
+
['gpt-oss', 'harmony'],
|
|
27
|
+
['deepseek32', 'dsml'],
|
|
28
|
+
['deepseek4', 'dsml'],
|
|
29
|
+
['lfm2', 'pythonic'],
|
|
30
|
+
['lfm2moe', 'pythonic']
|
|
31
|
+
]);
|
|
32
|
+
/**
|
|
33
|
+
* The tool-call dialect for a GGUF `general.architecture` value, or undefined
|
|
34
|
+
* for an architecture whose models use the default dialect.
|
|
35
|
+
*/
|
|
36
|
+
export function matchToolDialectFromArchitecture(architecture) {
|
|
37
|
+
return architecture === undefined ? undefined : ARCHITECTURE_DIALECTS.get(architecture);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolves a model's tool-call dialect: its name first, then the
|
|
41
|
+
* `general.architecture` in its GGUF header, then "hermes", whose parser chain
|
|
42
|
+
* also covers unknown JSON-payload models. The header is read only when the
|
|
43
|
+
* name does not match. Bypass with `completion({ toolDialect })`.
|
|
44
|
+
*/
|
|
45
|
+
export async function resolveToolDialect(name, path) {
|
|
46
|
+
return (matchToolDialectFromName(name, path) ??
|
|
47
|
+
matchToolDialectFromArchitecture(await readGgufArchitecture(path)) ??
|
|
48
|
+
'hermes');
|
|
20
49
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { parseToolCalls } from '
|
|
3
|
-
export { TOOL_SEARCH_NAME, buildCatalog, buildToolSearchTool, executeToolSearch, loadedToolNames, partitionTools, resolveDeferredTools, searchDeferredTools } from '
|
|
1
|
+
export { matchToolDialectFromArchitecture, matchToolDialectFromName, resolveToolDialect } from '../../utils/tools/dialect.js';
|
|
2
|
+
export { parseToolCalls } from '../../utils/tools/parser.js';
|
|
3
|
+
export { TOOL_SEARCH_NAME, buildCatalog, buildToolSearchTool, executeToolSearch, loadedToolNames, partitionTools, resolveDeferredTools, searchDeferredTools } from '../../utils/tools/defer.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { parseToolCalls } from '
|
|
3
|
-
export { TOOL_SEARCH_NAME, buildCatalog, buildToolSearchTool, executeToolSearch, loadedToolNames, partitionTools, resolveDeferredTools, searchDeferredTools } from '
|
|
1
|
+
export { matchToolDialectFromArchitecture, matchToolDialectFromName, resolveToolDialect } from '../../utils/tools/dialect.js';
|
|
2
|
+
export { parseToolCalls } from '../../utils/tools/parser.js';
|
|
3
|
+
export { TOOL_SEARCH_NAME, buildCatalog, buildToolSearchTool, executeToolSearch, loadedToolNames, partitionTools, resolveDeferredTools, searchDeferredTools } from '../../utils/tools/defer.js';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { stripThinkingBlocks } from '
|
|
2
|
-
import { parseGemmaFormat, parseGenericFormat, parseLlamacppFormat } from '
|
|
3
|
-
import { parseHermesFormat } from '
|
|
4
|
-
import { parsePythonicFormat } from '
|
|
5
|
-
import { parseHarmonyFormat } from '
|
|
6
|
-
import { parseQwen35Format } from '
|
|
7
|
-
import { parseGemma4NativeFormat } from '
|
|
8
|
-
import { parseDsmlFormat } from '
|
|
1
|
+
import { stripThinkingBlocks } from '../../utils/tools/shared.js';
|
|
2
|
+
import { parseGemmaFormat, parseGenericFormat, parseLlamacppFormat } from '../../utils/tools/parsers/json.js';
|
|
3
|
+
import { parseHermesFormat } from '../../utils/tools/parsers/hermes.js';
|
|
4
|
+
import { parsePythonicFormat } from '../../utils/tools/parsers/pythonic.js';
|
|
5
|
+
import { parseHarmonyFormat } from '../../utils/tools/parsers/harmony.js';
|
|
6
|
+
import { parseQwen35Format } from '../../utils/tools/parsers/qwen35.js';
|
|
7
|
+
import { parseGemma4NativeFormat } from '../../utils/tools/parsers/gemma4native.js';
|
|
8
|
+
import { parseDsmlFormat } from '../../utils/tools/parsers/dsml.js';
|
|
9
9
|
function pickFormatParsers(dialect) {
|
|
10
10
|
switch (dialect) {
|
|
11
11
|
case 'pythonic':
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateStableToolCallId, coerceByParameterTypes, parameterAllowsNull, parameterTypes, validateToolArguments } from '
|
|
1
|
+
import { generateStableToolCallId, coerceByParameterTypes, parameterAllowsNull, parameterTypes, validateToolArguments } from '../../../utils/tools/shared.js';
|
|
2
2
|
// DeepSeek marks DSML tags with a fullwidth vertical line (U+FF5C `|`), not
|
|
3
3
|
// the ASCII pipe used by the visually similar `<|...|>` markers of the harmony
|
|
4
4
|
// and gemma4 dialects — the two must not be conflated. V4 wraps calls in
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateStableToolCallId, validateToolArguments } from '
|
|
1
|
+
import { generateStableToolCallId, validateToolArguments } from '../../../utils/tools/shared.js';
|
|
2
2
|
// Transliterates Gemma 4's JS-literal argument body to valid JSON so it can
|
|
3
3
|
// be parsed with JSON.parse. The body uses:
|
|
4
4
|
// - <|"|>...<|"|> instead of "..." for string values
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateStableToolCallId, validateToolArguments } from '
|
|
1
|
+
import { generateStableToolCallId, validateToolArguments } from '../../../utils/tools/shared.js';
|
|
2
2
|
const HARMONY_FRAME_RE = /to=functions\.([\w-]+)\s+<\|constrain\|>json<\|message\|>([\s\S]*?)(?=<\|call\|>|$)/g;
|
|
3
3
|
export function parseHarmonyFormat(text, tools) {
|
|
4
4
|
const toolCalls = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateStableToolCallId, isValidToolCall, validateToolArguments } from '
|
|
1
|
+
import { generateStableToolCallId, isValidToolCall, validateToolArguments } from '../../../utils/tools/shared.js';
|
|
2
2
|
// Qwen3.5/3.6 can fuse its two tool templates into one frame, embedding the
|
|
3
3
|
// XML `<function=NAME>` token as a bare string key inside the JSON envelope:
|
|
4
4
|
// {"function=NAME","arguments":{...}} (invalid JSON, not parseable as-is)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Tool } from '../../../schemas/index.js';
|
|
2
|
-
import { type ParserResult } from '
|
|
2
|
+
import { type ParserResult } from '../../../utils/tools/shared.js';
|
|
3
3
|
export declare function parseGemmaFormat(text: string, tools: Tool[]): ParserResult;
|
|
4
4
|
export declare function parseLlamacppFormat(text: string, tools: Tool[]): ParserResult;
|
|
5
5
|
export declare function parseGenericFormat(text: string, tools: Tool[]): ParserResult;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateStableToolCallId, isValidToolCall, validateToolArguments } from '
|
|
1
|
+
import { generateStableToolCallId, isValidToolCall, validateToolArguments } from '../../../utils/tools/shared.js';
|
|
2
2
|
export function parseGemmaFormat(text, tools) {
|
|
3
3
|
const toolCalls = [];
|
|
4
4
|
const errors = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateStableToolCallId, validateToolArguments } from '
|
|
1
|
+
import { generateStableToolCallId, validateToolArguments } from '../../../utils/tools/shared.js';
|
|
2
2
|
// Pythonic `[name(k=v), ...]` arrays. LFM 2.x is auto-routed; Llama-style
|
|
3
3
|
// tokens are kept for callers that opt in via `completion({ toolDialect:
|
|
4
4
|
// "pythonic" })` for a model known to emit Pythonic. Pure string parsing —
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateStableToolCallId, coerceByParameterTypes, parameterAllowsNull, parameterTypes, validateToolArguments } from '
|
|
1
|
+
import { generateStableToolCallId, coerceByParameterTypes, parameterAllowsNull, parameterTypes, validateToolArguments } from '../../../utils/tools/shared.js';
|
|
2
2
|
// Coerce raw parameter text to the type declared in the tool's JSON schema.
|
|
3
3
|
// String values are raw (not JSON-quoted); arrays/objects are valid JSON.
|
|
4
4
|
function coerceParamValue(raw, schema) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TtsStats } from '../schemas/index.js';
|
|
2
|
-
import type { TtsStats as AddonTtsStats, TtsOutputChunk } from '
|
|
2
|
+
import type { TtsStats as AddonTtsStats, TtsOutputChunk } from '../utils/addon-responses.js';
|
|
3
3
|
/**
|
|
4
4
|
* Shared types and utilities for TTS operations.
|
|
5
5
|
* Used by both text-to-speech.ts and text-to-speech-stream.ts.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AbortSignalLike } from '../schemas/common.js';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates `source` until `signal` aborts, then ends without an error. Races
|
|
4
|
+
* each `next()` against the signal, since `return()` waits behind a pending
|
|
5
|
+
* `next()`. A rejection after the abort is dropped.
|
|
6
|
+
*/
|
|
7
|
+
export declare function untilAborted<T>(source: AsyncGenerator<T>, signal: AbortSignalLike | undefined): AsyncGenerator<T>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const ABORTED = Symbol('aborted');
|
|
2
|
+
/**
|
|
3
|
+
* Iterates `source` until `signal` aborts, then ends without an error. Races
|
|
4
|
+
* each `next()` against the signal, since `return()` waits behind a pending
|
|
5
|
+
* `next()`. A rejection after the abort is dropped.
|
|
6
|
+
*/
|
|
7
|
+
export async function* untilAborted(source, signal) {
|
|
8
|
+
if (!signal) {
|
|
9
|
+
yield* source;
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
while (!signal.aborted) {
|
|
14
|
+
const next = source.next();
|
|
15
|
+
const result = await new Promise((resolve, reject) => {
|
|
16
|
+
const onAbort = () => resolve(ABORTED);
|
|
17
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
18
|
+
next.then((value) => {
|
|
19
|
+
signal.removeEventListener('abort', onAbort);
|
|
20
|
+
resolve(value);
|
|
21
|
+
}, (error) => {
|
|
22
|
+
signal.removeEventListener('abort', onAbort);
|
|
23
|
+
reject(error);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
if (result === ABORTED || result.done)
|
|
27
|
+
return;
|
|
28
|
+
yield result.value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
void source.return(undefined).catch(() => { });
|
|
33
|
+
}
|
|
34
|
+
}
|