@qvac/harness 1.0.0-rc.2 → 1.0.0-rc.4
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/.nvmrc +1 -0
- package/CHANGELOG.md +2280 -1485
- package/README.md +56 -43
- package/dist-lib/index.d.ts +50 -6
- package/dist-lib/index.js +130 -28
- package/dist-lib/lib/agent/delegate.d.ts +3 -2
- package/dist-lib/lib/agent/delegate.js +6 -4
- package/dist-lib/lib/agent/follow.d.ts +5 -0
- package/dist-lib/lib/agent/follow.js +2 -0
- package/dist-lib/lib/agent/resolve.js +22 -17
- package/dist-lib/lib/agent/tool-selection.d.ts +4 -2
- package/dist-lib/lib/agent/tool-selection.js +5 -6
- package/dist-lib/lib/agent/tools.d.ts +1 -0
- package/dist-lib/lib/agent/tools.js +2 -1
- package/dist-lib/lib/capabilities/agent-ports.js +3 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/batching.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +60 -9
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +4 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +35 -6
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +67 -27
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +6 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +61 -16
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +23 -13
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +8 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +61 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +5 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +47 -21
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +30 -5
- package/dist-lib/lib/capabilities/completion-engine/driver.js +27 -11
- package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/durable.js +5 -1
- package/dist-lib/lib/capabilities/completion-engine/index.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/index.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +15 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.js +7 -0
- package/dist-lib/lib/capabilities/completion-engine/metrics.d.ts +9 -2
- package/dist-lib/lib/capabilities/completion-engine/metrics.js +28 -7
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +46 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.js +45 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.js +1 -1
- package/dist-lib/lib/capabilities/completion-engine/ports.js +3 -7
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +23 -3
- package/dist-lib/lib/capabilities/completion-engine/round.js +323 -97
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +10 -3
- package/dist-lib/lib/capabilities/completion-engine/session.js +30 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +4 -3
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +15 -10
- package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +11 -4
- package/dist-lib/lib/capabilities/completion-engine/turns.js +48 -65
- package/dist-lib/lib/capabilities/download.d.ts +9 -7
- package/dist-lib/lib/capabilities/download.js +1 -1
- package/dist-lib/lib/capabilities/enhance.d.ts +1 -1
- package/dist-lib/lib/capabilities/enhance.js +20 -8
- package/dist-lib/lib/capabilities/preview-model-source.d.ts +7 -0
- package/dist-lib/lib/capabilities/preview-model-source.js +83 -23
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +1 -0
- package/dist-lib/lib/capabilities/sdk-tool.js +18 -1
- package/dist-lib/lib/capabilities/tool-plan.d.ts +1 -1
- package/dist-lib/lib/capabilities/tool-plan.js +5 -5
- package/dist-lib/lib/capabilities/tool-prompt-log.js +3 -3
- package/dist-lib/lib/capabilities/tool-turns.d.ts +7 -9
- package/dist-lib/lib/capabilities/tool-turns.js +25 -20
- package/dist-lib/lib/client/index.d.ts +19 -0
- package/dist-lib/lib/client/index.js +262 -0
- package/dist-lib/lib/connect.d.ts +13 -10
- package/dist-lib/lib/connect.js +62 -24
- package/dist-lib/lib/context-window.d.ts +1 -0
- package/dist-lib/lib/context-window.js +3 -3
- package/dist-lib/lib/contract/agent.d.ts +7 -3
- package/dist-lib/lib/contract/completion.d.ts +44 -29
- package/dist-lib/lib/contract/egress-proxy.d.ts +13 -0
- package/dist-lib/lib/contract/egress-proxy.js +1 -0
- package/dist-lib/lib/contract/exec.d.ts +3 -3
- package/dist-lib/lib/contract/hooks.d.ts +4 -1
- package/dist-lib/lib/contract/index.d.ts +1 -0
- package/dist-lib/lib/contract/models.d.ts +6 -4
- package/dist-lib/lib/contract/policy.d.ts +75 -0
- package/dist-lib/lib/contract/policy.js +1 -0
- package/dist-lib/lib/contract/run.d.ts +9 -3
- package/dist-lib/lib/contract/sandbox.d.ts +3 -1
- package/dist-lib/lib/contract/translation.d.ts +20 -0
- package/dist-lib/lib/contract/translation.js +1 -0
- package/dist-lib/lib/contract-types.d.ts +32 -14
- package/dist-lib/lib/embeddings/index.d.ts +7 -1
- package/dist-lib/lib/embeddings/index.js +26 -5
- package/dist-lib/lib/errors.d.ts +266 -0
- package/dist-lib/lib/errors.js +198 -0
- package/dist-lib/lib/fold/index.d.ts +25 -1
- package/dist-lib/lib/fold/index.js +75 -9
- package/dist-lib/lib/guarded-fetch.js +11 -7
- package/dist-lib/lib/hardware/gpu-probe.js +10 -1
- package/dist-lib/lib/helpers/completion-params.d.ts +6 -2
- package/dist-lib/lib/helpers/completion-params.js +10 -1
- package/dist-lib/lib/helpers/engine-error.d.ts +2 -1
- package/dist-lib/lib/helpers/engine-error.js +12 -12
- package/dist-lib/lib/helpers/goal-check.d.ts +4 -0
- package/dist-lib/lib/helpers/goal-check.js +81 -0
- package/dist-lib/lib/helpers/head-tail.js +1 -1
- package/dist-lib/lib/helpers/load-stall.d.ts +1 -1
- package/dist-lib/lib/helpers/load-stall.js +2 -2
- package/dist-lib/lib/helpers/markup-stream-filter.d.ts +4 -1
- package/dist-lib/lib/helpers/markup-stream-filter.js +20 -6
- package/dist-lib/lib/helpers/repeated-reply.js +24 -16
- package/dist-lib/lib/helpers/thinking.d.ts +3 -2
- package/dist-lib/lib/helpers/thinking.js +19 -0
- package/dist-lib/lib/hooks/built-in/arg-repair.js +6 -2
- package/dist-lib/lib/hooks/built-in/policy-rules.d.ts +8 -0
- package/dist-lib/lib/hooks/built-in/policy-rules.js +192 -0
- package/dist-lib/lib/hooks/built-in/sandbox.js +23 -5
- package/dist-lib/lib/hooks/index.d.ts +4 -1
- package/dist-lib/lib/hooks/index.js +9 -4
- package/dist-lib/lib/hooks/run.js +3 -3
- package/dist-lib/lib/lifecycle/index.js +15 -14
- package/dist-lib/lib/lifecycle/machine.js +2 -2
- package/dist-lib/lib/log.d.ts +26 -5
- package/dist-lib/lib/log.js +86 -23
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +4 -2
- package/dist-lib/lib/machine/completion/actions/completion.js +75 -10
- package/dist-lib/lib/machine/completion/actions/prepare.js +1 -1
- package/dist-lib/lib/machine/completion/actions/tools.js +48 -5
- package/dist-lib/lib/machine/completion/context.js +4 -1
- package/dist-lib/lib/machine/completion/guards/retry.d.ts +1 -0
- package/dist-lib/lib/machine/completion/guards/retry.js +8 -2
- package/dist-lib/lib/machine/completion/implementations.d.ts +10 -4
- package/dist-lib/lib/machine/completion/implementations.js +27 -6
- package/dist-lib/lib/machine/completion/machine.d.ts +21 -3
- package/dist-lib/lib/machine/completion/machine.js +33 -4
- package/dist-lib/lib/machine/completion/rules.d.ts +17 -2
- package/dist-lib/lib/machine/completion/rules.js +49 -3
- package/dist-lib/lib/machine/completion/types.d.ts +36 -0
- package/dist-lib/lib/machine/index.d.ts +27 -4
- package/dist-lib/lib/machine/index.js +6 -1
- package/dist-lib/lib/models/context-choice.d.ts +15 -0
- package/dist-lib/lib/models/context-choice.js +55 -0
- package/dist-lib/lib/models/download-gate.d.ts +20 -0
- package/dist-lib/lib/models/download-gate.js +73 -0
- package/dist-lib/lib/models/gguf-header.d.ts +5 -0
- package/dist-lib/lib/models/gguf-header.js +165 -14
- package/dist-lib/lib/models/llm-presets.d.ts +5 -1
- package/dist-lib/lib/models/llm-presets.js +6 -5
- package/dist-lib/lib/models/memory-cap.d.ts +13 -0
- package/dist-lib/lib/models/memory-cap.js +21 -0
- package/dist-lib/lib/models/model-catalog.d.ts +2 -0
- package/dist-lib/lib/models/model-catalog.js +15 -0
- package/dist-lib/lib/models/model-fit.d.ts +1 -1
- package/dist-lib/lib/models/model-fit.js +5 -6
- package/dist-lib/lib/models/model-handle.d.ts +8 -2
- package/dist-lib/lib/models/model-handle.js +14 -3
- package/dist-lib/lib/models/model-list.d.ts +8 -1
- package/dist-lib/lib/models/model-list.js +23 -0
- package/dist-lib/lib/models/model-pool.d.ts +35 -5
- package/dist-lib/lib/models/model-pool.js +121 -43
- package/dist-lib/lib/models/model-source.d.ts +1 -0
- package/dist-lib/lib/models/model-source.js +23 -5
- package/dist-lib/lib/models/sdk-faults.d.ts +1 -0
- package/dist-lib/lib/models/sdk-faults.js +9 -0
- package/dist-lib/lib/no-redirect-fetch-bare.js +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.js +2 -1
- package/dist-lib/lib/office/engine/pptx/picture-area.d.ts +23 -0
- package/dist-lib/lib/office/engine/pptx/picture-area.js +84 -0
- package/dist-lib/lib/office/engine/pptx/presentation.d.ts +2 -0
- package/dist-lib/lib/office/engine/pptx/presentation.js +55 -17
- package/dist-lib/lib/office/engine/pptx/types.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/workbook.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/workbook.js +34 -3
- package/dist-lib/lib/office/extract.js +4 -3
- package/dist-lib/lib/office/index.js +2 -1
- package/dist-lib/lib/plugins/registry.d.ts +3 -0
- package/dist-lib/lib/plugins/registry.js +16 -7
- package/dist-lib/lib/policy/index.d.ts +10 -0
- package/dist-lib/lib/policy/index.js +229 -0
- package/dist-lib/lib/prompt.d.ts +1 -0
- package/dist-lib/lib/prompt.js +7 -1
- package/dist-lib/lib/residency/completion-runtime.d.ts +1 -0
- package/dist-lib/lib/residency/completion-runtime.js +11 -4
- package/dist-lib/lib/residency/index.d.ts +44 -4
- package/dist-lib/lib/residency/index.js +399 -35
- package/dist-lib/lib/resolution-detector.js +3 -3
- package/dist-lib/lib/rpc-session.js +2 -1
- package/dist-lib/lib/sdk-loader.js +17 -11
- package/dist-lib/lib/serve.js +76 -36
- package/dist-lib/lib/sidecar/index.d.ts +29 -0
- package/dist-lib/lib/sidecar/index.js +174 -0
- package/dist-lib/lib/sidecar/user-plugins.d.ts +8 -0
- package/dist-lib/lib/sidecar/user-plugins.js +117 -0
- package/dist-lib/lib/skills-host/index.d.ts +1 -0
- package/dist-lib/lib/skills-host/index.js +8 -4
- package/dist-lib/lib/spawn.d.ts +3 -4
- package/dist-lib/lib/spawn.js +17 -17
- package/dist-lib/lib/spill.d.ts +1 -0
- package/dist-lib/lib/spill.js +12 -8
- package/dist-lib/lib/tools/attachments/staging.js +8 -8
- package/dist-lib/lib/tools/exec/runner.js +2 -1
- package/dist-lib/lib/tools/exec/scope.d.ts +0 -1
- package/dist-lib/lib/tools/exec/scope.js +23 -114
- package/dist-lib/lib/tools/exec/shell-guidance.js +4 -4
- package/dist-lib/lib/tools/exec/shell-line.d.ts +26 -0
- package/dist-lib/lib/tools/exec/shell-line.js +334 -0
- package/dist-lib/lib/tools/exec.d.ts +4 -1
- package/dist-lib/lib/tools/exec.js +87 -26
- package/dist-lib/lib/tools/files/edit-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/edit-file.js +74 -0
- package/dist-lib/lib/tools/files/glob.d.ts +3 -0
- package/dist-lib/lib/tools/files/glob.js +65 -0
- package/dist-lib/lib/tools/files/grep.d.ts +6 -0
- package/dist-lib/lib/tools/files/grep.js +114 -0
- package/dist-lib/lib/tools/files/index.d.ts +3 -0
- package/dist-lib/lib/tools/files/index.js +23 -0
- package/dist-lib/lib/tools/files/list-dir.d.ts +6 -0
- package/dist-lib/lib/tools/files/list-dir.js +136 -0
- package/dist-lib/lib/tools/files/make-dir.d.ts +3 -0
- package/dist-lib/lib/tools/files/make-dir.js +48 -0
- package/dist-lib/lib/tools/files/read-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/read-file.js +105 -0
- package/dist-lib/lib/tools/files/transfer.d.ts +4 -0
- package/dist-lib/lib/tools/files/transfer.js +83 -0
- package/dist-lib/lib/tools/files/trash-file.d.ts +4 -0
- package/dist-lib/lib/tools/files/trash-file.js +62 -0
- package/dist-lib/lib/tools/files/write-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/write-file.js +56 -0
- package/dist-lib/lib/tools/fs/document-text.d.ts +2 -0
- package/dist-lib/lib/tools/fs/document-text.js +38 -0
- package/dist-lib/lib/tools/fs/drive.d.ts +14 -3
- package/dist-lib/lib/tools/fs/drive.js +9 -1
- package/dist-lib/lib/tools/fs/edit-match.d.ts +11 -0
- package/dist-lib/lib/tools/fs/edit-match.js +85 -0
- package/dist-lib/lib/tools/fs/ignore.d.ts +13 -0
- package/dist-lib/lib/tools/fs/ignore.js +104 -0
- package/dist-lib/lib/tools/fs/local.js +28 -5
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +23 -3
- package/dist-lib/lib/tools/fs/remote.d.ts +3 -4
- package/dist-lib/lib/tools/fs/remote.js +23 -13
- package/dist-lib/lib/tools/fs/scope.d.ts +5 -1
- package/dist-lib/lib/tools/fs/scope.js +5 -2
- package/dist-lib/lib/tools/fs/search.d.ts +41 -0
- package/dist-lib/lib/tools/fs/search.js +382 -0
- package/dist-lib/lib/tools/{file-glob.d.ts → fs/targets.d.ts} +1 -5
- package/dist-lib/lib/tools/fs/targets.js +32 -0
- package/dist-lib/lib/tools/fs/tool-path.d.ts +27 -0
- package/dist-lib/lib/tools/fs/tool-path.js +70 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +15 -3
- package/dist-lib/lib/tools/fs/walk.js +118 -24
- package/dist-lib/lib/tools/http-request.js +12 -2
- package/dist-lib/lib/tools/index.js +2 -10
- package/dist-lib/lib/tools/office/ops.js +1 -1
- package/dist-lib/lib/tools/office.js +77 -21
- package/dist-lib/lib/tools/pdf/build.d.ts +5 -1
- package/dist-lib/lib/tools/pdf/build.js +31 -6
- package/dist-lib/lib/tools/pdf.js +17 -2
- package/dist-lib/lib/tools/skill.js +10 -7
- package/dist-lib/lib/tools/skills/bundled-dir.js +4 -4
- package/dist-lib/lib/tools/skills/catalog.d.ts +2 -0
- package/dist-lib/lib/tools/skills/catalog.js +6 -2
- package/dist-lib/lib/tools/skills/cli-argv.js +25 -5
- package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/cli-schema-check.js +3 -0
- package/dist-lib/lib/tools/skills/cli-schema-load.js +10 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +2 -0
- package/dist-lib/lib/tools/skills/cli-schema.js +6 -3
- package/dist-lib/lib/tools/skills/credential-health.js +3 -3
- package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +2 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +4 -0
- package/dist-lib/lib/tools/skills/manifest-parse.d.ts +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +12 -0
- package/dist-lib/lib/tools/skills/mention-name.d.ts +6 -0
- package/dist-lib/lib/tools/skills/mention-name.js +6 -0
- package/dist-lib/lib/tools/skills/mention.d.ts +2 -2
- package/dist-lib/lib/tools/skills/mention.js +11 -4
- package/dist-lib/lib/tools/skills/overlay-crud.js +3 -2
- package/dist-lib/lib/tools/url-guard.d.ts +6 -1
- package/dist-lib/lib/tools/url-guard.js +8 -2
- package/dist-lib/lib/tools/web-fetch.js +10 -4
- package/dist-lib/lib/wire.js +3 -5
- package/dist-lib/plugins/coding/index.d.ts +1 -1
- package/dist-lib/plugins/coding/index.js +2 -4
- package/dist-lib/plugins/coding/session.d.ts +3 -3
- package/dist-lib/plugins/coding/session.js +26 -14
- package/dist-lib/plugins/command-hooks/index.js +5 -3
- package/dist-lib/plugins/egress-proxy/index.d.ts +53 -0
- package/dist-lib/plugins/egress-proxy/index.js +182 -0
- package/dist-lib/plugins/image/edit-image.js +4 -3
- package/dist-lib/plugins/image/generate-image.d.ts +4 -3
- package/dist-lib/plugins/image/generate-image.js +10 -9
- package/dist-lib/plugins/image/index.d.ts +1 -1
- package/dist-lib/plugins/image/index.js +13 -10
- package/dist-lib/plugins/language-hint/index.d.ts +15 -0
- package/dist-lib/plugins/language-hint/index.js +51 -0
- package/dist-lib/plugins/lsp/tool.js +2 -2
- package/dist-lib/plugins/mcp/index.js +6 -3
- package/dist-lib/plugins/music/generate-music.d.ts +4 -2
- package/dist-lib/plugins/music/generate-music.js +7 -4
- package/dist-lib/plugins/music/index.js +12 -9
- package/dist-lib/plugins/obsidian/command.js +2 -2
- package/dist-lib/plugins/obsidian/note-name.js +2 -1
- package/dist-lib/plugins/obsidian/safe-path.js +5 -4
- package/dist-lib/plugins/obsidian/vault-create.js +3 -2
- package/dist-lib/plugins/obsidian/vault-fs.js +2 -2
- package/dist-lib/plugins/obsidian/vault-paths.js +3 -2
- package/dist-lib/plugins/obsidian/vault-read.js +6 -5
- package/dist-lib/plugins/obsidian/vault-write.js +13 -12
- package/dist-lib/plugins/python/guarded-fetch.d.ts +2 -1
- package/dist-lib/plugins/python/guarded-fetch.js +5 -1
- package/dist-lib/plugins/python/interrupt-timer.js +2 -2
- package/dist-lib/plugins/python/loader.js +68 -3
- package/dist-lib/plugins/python/memfs.js +2 -2
- package/dist-lib/plugins/python/pyodide.d.ts +1 -0
- package/dist-lib/plugins/python/pyodide.js +9 -8
- package/dist-lib/plugins/python/python-adapter.js +3 -1
- package/dist-lib/plugins/python/run-session.d.ts +1 -0
- package/dist-lib/plugins/python/run-session.js +19 -8
- package/dist-lib/plugins/python/wheels.js +8 -6
- package/dist-lib/plugins/python/worker/active.js +2 -2
- package/dist-lib/plugins/python/worker/client.js +9 -8
- package/dist-lib/plugins/python/worker/protocol.d.ts +2 -0
- package/dist-lib/plugins/python/worker/serve.js +23 -4
- package/dist-lib/plugins/python/worker/spawn.d.ts +2 -1
- package/dist-lib/plugins/python/worker/spawn.js +2 -1
- package/dist-lib/plugins/run-report/chain.d.ts +2 -0
- package/dist-lib/plugins/run-report/chain.js +73 -0
- package/dist-lib/plugins/run-report/flow-view.js +2 -1
- package/dist-lib/plugins/run-report/flow.d.ts +1 -1
- package/dist-lib/plugins/run-report/flow.js +66 -14
- package/dist-lib/plugins/run-report/index.d.ts +23 -2
- package/dist-lib/plugins/run-report/index.js +27 -12
- package/dist-lib/plugins/run-report/model.d.ts +10 -1
- package/dist-lib/plugins/run-report/model.js +12 -6
- package/dist-lib/plugins/run-report/page.d.ts +9 -0
- package/dist-lib/plugins/run-report/page.js +55 -15
- package/dist-lib/plugins/run-report/script.js +317 -43
- package/dist-lib/plugins/run-report/story.d.ts +2 -1
- package/dist-lib/plugins/run-report/story.js +3 -3
- package/dist-lib/plugins/run-report/style.d.ts +1 -1
- package/dist-lib/plugins/run-report/style.js +126 -0
- package/dist-lib/plugins/run-report/why.js +1 -1
- package/dist-lib/plugins/sandbox-linux/index.d.ts +60 -0
- package/dist-lib/plugins/sandbox-linux/index.js +347 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.d.ts +2 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.js +74 -0
- package/dist-lib/plugins/sandbox-macos/index.d.ts +23 -11
- package/dist-lib/plugins/sandbox-macos/index.js +239 -49
- package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +4 -2
- package/dist-lib/plugins/sandbox-vm/vm-shell.js +9 -4
- package/dist-lib/plugins/sandbox-windows/helper/qvac-sandbox.c +554 -0
- package/dist-lib/plugins/sandbox-windows/index.d.ts +53 -0
- package/dist-lib/plugins/sandbox-windows/index.js +205 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/speech/audio-resample.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-resample.js +7 -8
- package/dist-lib/plugins/speech/audio-transcode-bare.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-bare.js +23 -26
- package/dist-lib/plugins/speech/audio-transcode-node.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-node.js +1 -3
- package/dist-lib/plugins/speech/speech-runtime.js +37 -37
- package/dist-lib/plugins/speech/voice.d.ts +5 -1
- package/dist-lib/plugins/speech/voice.js +100 -31
- package/dist-lib/plugins/translation/index.d.ts +1 -0
- package/dist-lib/plugins/translation/index.js +16 -9
- package/dist-lib/plugins/translation/translate.d.ts +7 -3
- package/dist-lib/plugins/translation/translate.js +64 -58
- package/dist-lib/plugins/weather/geocode.js +2 -1
- package/dist-lib/plugins/weather/lookup.js +5 -4
- package/dist-lib/plugins/web-search/engines/bing.js +2 -1
- package/dist-lib/plugins/web-search/engines/google.js +2 -1
- package/dist-lib/plugins/web-search/fetch-html.d.ts +5 -5
- package/dist-lib/plugins/web-search/fetch-html.js +12 -15
- package/dist-lib/plugins/web-search/tool.js +1 -0
- package/dist-lib/schema/harness.js +48 -7
- package/dist-lib/spec/bind.js +9 -0
- package/dist-lib/spec/calls.js +3 -0
- package/dist-lib/spec/hrpc/hrpc.json +42 -3
- package/dist-lib/spec/hrpc/index.js +44 -8
- package/dist-lib/spec/hrpc/messages.js +297 -202
- package/dist-lib/spec/hyperschema/index.js +297 -202
- package/dist-lib/spec/hyperschema/schema.json +155 -84
- package/dist-lib/spec/hyperschema/types.d.ts +23 -3
- package/package.json +101 -38
- package/patches/@qvac%2Finference@0.22.0.patch +59 -0
- package/patches/pyodide@314.0.2.patch +37 -8
- package/scripts/addon-externals.cjs +10 -5
- package/worker/harness-sidecar.mjs +18 -154
- package/dist-lib/lib/tools/create-documents.d.ts +0 -3
- package/dist-lib/lib/tools/create-documents.js +0 -95
- package/dist-lib/lib/tools/edit-documents.d.ts +0 -3
- package/dist-lib/lib/tools/edit-documents.js +0 -132
- package/dist-lib/lib/tools/exec/shell-argv.d.ts +0 -2
- package/dist-lib/lib/tools/exec/shell-argv.js +0 -61
- package/dist-lib/lib/tools/file-glob.js +0 -118
- package/dist-lib/lib/tools/grep.d.ts +0 -5
- package/dist-lib/lib/tools/grep.js +0 -184
- package/dist-lib/lib/tools/read-files.d.ts +0 -5
- package/dist-lib/lib/tools/read-files.js +0 -160
- package/dist-lib/plugins/coding/write-file.d.ts +0 -3
- package/dist-lib/plugins/coding/write-file.js +0 -52
- package/patches/@qvac%2Finference@0.21.0.patch +0 -67
- package/patches/bare-stow@0.1.5.patch +0 -68
- package/patches/hypercore-blob-server@1.15.0.patch +0 -15
|
@@ -5,9 +5,15 @@ import os from 'os';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
7
|
import defaultFetch from '#fetch';
|
|
8
|
+
import { errorMessage } from '../guards.js';
|
|
9
|
+
import { HarnessLog } from '../log.js';
|
|
8
10
|
const rangeFetch = defaultFetch;
|
|
9
11
|
export const GGUF_HEADER_BYTES = 1_048_576;
|
|
10
12
|
export const GGUF_HEADER_TIMEOUT_MS = 30_000;
|
|
13
|
+
export const GGUF_HEADER_ATTEMPTS = 3;
|
|
14
|
+
export const GGUF_STUB_MAX_BYTES = 33_554_432;
|
|
15
|
+
export const GGUF_STUB_TIMEOUT_MS = 60_000;
|
|
16
|
+
const MAX_ALIGNMENT = 1_048_576;
|
|
11
17
|
const UINT8 = 0;
|
|
12
18
|
const INT8 = 1;
|
|
13
19
|
const UINT16 = 2;
|
|
@@ -48,34 +54,179 @@ function filePath(src) {
|
|
|
48
54
|
}
|
|
49
55
|
export function readGgufHeaderBytes(src, opts = {}) {
|
|
50
56
|
const maxBytes = opts.maxBytes ?? GGUF_HEADER_BYTES;
|
|
57
|
+
const fetch = opts.fetch ?? rangeFetch;
|
|
51
58
|
return isRemoteSource(src)
|
|
52
|
-
?
|
|
59
|
+
? withDeadline(GGUF_HEADER_TIMEOUT_MS, (signal) => fetchRange(src, { start: 0, length: maxBytes, fetch, signal }))
|
|
53
60
|
: readLocalHead(src, maxBytes);
|
|
54
61
|
}
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
export function fetchGgufStub(src, opts = {}) {
|
|
63
|
+
const fetch = opts.fetch ?? rangeFetch;
|
|
64
|
+
const maxBytes = opts.maxBytes ?? GGUF_STUB_MAX_BYTES;
|
|
65
|
+
return withDeadline(GGUF_STUB_TIMEOUT_MS, (signal) => readStub(src, { fetch, maxBytes, signal }));
|
|
66
|
+
}
|
|
67
|
+
async function readStub(src, { fetch, maxBytes, signal }) {
|
|
68
|
+
let bytes = b4a.alloc(0);
|
|
69
|
+
let want = Math.min(GGUF_HEADER_BYTES, maxBytes);
|
|
70
|
+
for (;;) {
|
|
71
|
+
const start = bytes.byteLength;
|
|
72
|
+
const more = await fetchRange(src, { start, length: want - start, fetch, signal });
|
|
73
|
+
if (more === null) {
|
|
64
74
|
return null;
|
|
65
75
|
}
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
bytes = b4a.concat([bytes, more]);
|
|
77
|
+
const dataOffset = ggufDataOffset(bytes);
|
|
78
|
+
if (dataOffset !== null) {
|
|
79
|
+
return padded(bytes, dataOffset);
|
|
80
|
+
}
|
|
81
|
+
if (more.byteLength < want - start || want >= maxBytes) {
|
|
68
82
|
return null;
|
|
69
83
|
}
|
|
70
|
-
|
|
84
|
+
want = Math.min(want * 2, maxBytes);
|
|
71
85
|
}
|
|
72
|
-
|
|
86
|
+
}
|
|
87
|
+
export function ggufDataOffset(bytes) {
|
|
88
|
+
if (bytes.byteLength < 24 || b4a.toString(bytes.subarray(0, 4), 'latin1') !== 'GGUF') {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const c = {
|
|
92
|
+
view: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength),
|
|
93
|
+
bytes,
|
|
94
|
+
offset: 8
|
|
95
|
+
};
|
|
96
|
+
const tensors = readU64(c);
|
|
97
|
+
const alignment = skipMetadata(c, readU64(c));
|
|
98
|
+
if (alignment === null || !skipTensorInfos(c, tensors)) {
|
|
73
99
|
return null;
|
|
74
100
|
}
|
|
101
|
+
return Math.ceil(c.offset / alignment) * alignment;
|
|
102
|
+
}
|
|
103
|
+
function skipTensorInfos(c, count) {
|
|
104
|
+
for (let i = 0; i < count; i += 1) {
|
|
105
|
+
if (readString(c) === null || !has(c, 4)) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
const dims = readU32(c);
|
|
109
|
+
if (!has(c, dims * 8 + 12)) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
c.offset += dims * 8 + 12;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
function skipMetadata(c, count) {
|
|
117
|
+
let alignment = 32;
|
|
118
|
+
for (let i = 0; i < count; i += 1) {
|
|
119
|
+
const key = readString(c);
|
|
120
|
+
if (key === null || !has(c, 4)) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
const value = readValue(c, readU32(c));
|
|
124
|
+
if (!value.ok) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
if (key === 'general.alignment') {
|
|
128
|
+
if (!isAlignment(value.num)) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
alignment = value.num;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return alignment;
|
|
135
|
+
}
|
|
136
|
+
function isAlignment(value) {
|
|
137
|
+
return (value !== undefined &&
|
|
138
|
+
Number.isInteger(value) &&
|
|
139
|
+
value > 0 &&
|
|
140
|
+
value <= MAX_ALIGNMENT &&
|
|
141
|
+
(value & (value - 1)) === 0);
|
|
142
|
+
}
|
|
143
|
+
function padded(bytes, length) {
|
|
144
|
+
if (length <= bytes.byteLength) {
|
|
145
|
+
return bytes.subarray(0, length);
|
|
146
|
+
}
|
|
147
|
+
const stub = b4a.alloc(length);
|
|
148
|
+
stub.set(bytes);
|
|
149
|
+
return stub;
|
|
150
|
+
}
|
|
151
|
+
async function withDeadline(ms, run) {
|
|
152
|
+
const controller = new AbortController();
|
|
153
|
+
const timeout = setTimeout(() => controller.abort(undefined), ms);
|
|
154
|
+
try {
|
|
155
|
+
return await run(controller.signal);
|
|
156
|
+
}
|
|
75
157
|
finally {
|
|
76
158
|
clearTimeout(timeout);
|
|
77
159
|
}
|
|
78
160
|
}
|
|
161
|
+
async function fetchRange(src, range) {
|
|
162
|
+
for (let attempt = 1; attempt <= GGUF_HEADER_ATTEMPTS; attempt++) {
|
|
163
|
+
const read = await requestRange(src, range);
|
|
164
|
+
if (read.kind === 'read') {
|
|
165
|
+
return read.bytes;
|
|
166
|
+
}
|
|
167
|
+
HarnessLog.warn('gguf header read failed', { host: hostOf(src), attempt, cause: read.cause });
|
|
168
|
+
if (!read.transient || range.signal.aborted) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
async function requestRange(src, { start, length, fetch, signal }) {
|
|
175
|
+
let response;
|
|
176
|
+
try {
|
|
177
|
+
response = await fetch(src, {
|
|
178
|
+
headers: { Range: `bytes=${start}-${start + length - 1}` },
|
|
179
|
+
signal
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
return { kind: 'failed', transient: true, cause: failureOf(err) };
|
|
184
|
+
}
|
|
185
|
+
const refused = refusedRange(response, { start, length });
|
|
186
|
+
if (refused) {
|
|
187
|
+
return refused;
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
return {
|
|
191
|
+
kind: 'read',
|
|
192
|
+
bytes: new Uint8Array(await response.arrayBuffer()).subarray(0, length)
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
return { kind: 'failed', transient: true, cause: failureOf(err) };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function refusedRange(response, { start, length }) {
|
|
200
|
+
if (!response.ok) {
|
|
201
|
+
return {
|
|
202
|
+
kind: 'failed',
|
|
203
|
+
transient: retryableStatus(response.status),
|
|
204
|
+
cause: `HTTP ${response.status}`
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
if (start > 0 && response.status !== 206) {
|
|
208
|
+
return { kind: 'failed', transient: false, cause: `HTTP ${response.status} for a range` };
|
|
209
|
+
}
|
|
210
|
+
const announced = response.headers.get('content-length');
|
|
211
|
+
return announced === null || !(Number(announced) <= length)
|
|
212
|
+
? { kind: 'failed', transient: false, cause: `content-length ${announced ?? 'missing'}` }
|
|
213
|
+
: null;
|
|
214
|
+
}
|
|
215
|
+
function failureOf(err) {
|
|
216
|
+
const cause = err instanceof Error ? err.cause : undefined;
|
|
217
|
+
return cause === undefined ? errorMessage(err) : `${errorMessage(err)}: ${errorMessage(cause)}`;
|
|
218
|
+
}
|
|
219
|
+
function retryableStatus(status) {
|
|
220
|
+
return status === 408 || status === 429 || status >= 500;
|
|
221
|
+
}
|
|
222
|
+
function hostOf(src) {
|
|
223
|
+
try {
|
|
224
|
+
return new URL(src).host;
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
return '';
|
|
228
|
+
}
|
|
229
|
+
}
|
|
79
230
|
async function readLocalHead(src, maxBytes) {
|
|
80
231
|
const file = localSourcePath(src);
|
|
81
232
|
if (file === null) {
|
|
@@ -5,7 +5,11 @@ export interface LlmGenerationParams {
|
|
|
5
5
|
presence_penalty?: number;
|
|
6
6
|
repeat_penalty?: number;
|
|
7
7
|
frequency_penalty?: number;
|
|
8
|
-
|
|
8
|
+
seed?: number;
|
|
9
|
+
reasoning_budget?: number;
|
|
9
10
|
tool_choice?: 'auto' | 'none' | 'required';
|
|
11
|
+
predict?: number;
|
|
12
|
+
parallel_tool_calls?: boolean;
|
|
10
13
|
}
|
|
14
|
+
export declare const DEFAULT_REASONING_BUDGET = 8192;
|
|
11
15
|
export declare function resolveLlmGenerationParams(modelName: string | undefined, reasoningEnabled: boolean | undefined, deviceDefault?: boolean): LlmGenerationParams | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export const DEFAULT_REASONING_BUDGET = 8192;
|
|
1
2
|
const QWEN_NONTHINKING_VL_SAMPLER = {
|
|
2
3
|
temp: 0.7,
|
|
3
4
|
top_p: 0.8,
|
|
@@ -28,17 +29,17 @@ const PRESET_RESOLVERS = [
|
|
|
28
29
|
{ prefix: 'Qwen3.5-4B-', resolve: qwen4BPreset }
|
|
29
30
|
];
|
|
30
31
|
export function resolveLlmGenerationParams(modelName, reasoningEnabled, deviceDefault) {
|
|
32
|
+
const effective = reasoningEnabled ?? deviceDefault;
|
|
31
33
|
const resolver = modelName
|
|
32
34
|
? PRESET_RESOLVERS.find((entry) => modelName.startsWith(entry.prefix))
|
|
33
35
|
: undefined;
|
|
34
36
|
if (resolver) {
|
|
35
|
-
return resolver.resolve(
|
|
37
|
+
return resolver.resolve(effective);
|
|
36
38
|
}
|
|
37
|
-
const effective = reasoningEnabled ?? deviceDefault;
|
|
38
39
|
if (effective === undefined) {
|
|
39
40
|
return undefined;
|
|
40
41
|
}
|
|
41
|
-
return { reasoning_budget: effective ?
|
|
42
|
+
return { reasoning_budget: effective ? DEFAULT_REASONING_BUDGET : 0 };
|
|
42
43
|
}
|
|
43
44
|
function qwen08BPreset(reasoningEnabled) {
|
|
44
45
|
return reasoningEnabled === true ? thinkingVlPreset() : nonThinkingVlPreset();
|
|
@@ -53,8 +54,8 @@ function nonThinkingVlPreset() {
|
|
|
53
54
|
return { ...QWEN_NONTHINKING_VL_SAMPLER, reasoning_budget: 0 };
|
|
54
55
|
}
|
|
55
56
|
function thinkingVlPreset() {
|
|
56
|
-
return { ...QWEN_THINKING_VL_OR_CODING_SAMPLER, reasoning_budget:
|
|
57
|
+
return { ...QWEN_THINKING_VL_OR_CODING_SAMPLER, reasoning_budget: DEFAULT_REASONING_BUDGET };
|
|
57
58
|
}
|
|
58
59
|
function thinkingGeneralPreset() {
|
|
59
|
-
return { ...QWEN_THINKING_GENERAL_SAMPLER, reasoning_budget:
|
|
60
|
+
return { ...QWEN_THINKING_GENERAL_SAMPLER, reasoning_budget: DEFAULT_REASONING_BUDGET };
|
|
60
61
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const VictimRank: {
|
|
2
|
+
readonly generator: 0;
|
|
3
|
+
readonly companion: 1;
|
|
4
|
+
readonly requested: 2;
|
|
5
|
+
readonly pinned: 3;
|
|
6
|
+
readonly replying: 4;
|
|
7
|
+
};
|
|
8
|
+
export interface CapVictim {
|
|
9
|
+
readonly rank: number;
|
|
10
|
+
readonly lastUsed: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function nextVictim<T extends CapVictim>(victims: ReadonlyArray<T>): T | undefined;
|
|
13
|
+
export declare function memoryCapBytes(percent: number, availableBytes: number): number;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const VictimRank = {
|
|
2
|
+
generator: 0,
|
|
3
|
+
companion: 1,
|
|
4
|
+
requested: 2,
|
|
5
|
+
pinned: 3,
|
|
6
|
+
replying: 4
|
|
7
|
+
};
|
|
8
|
+
export function nextVictim(victims) {
|
|
9
|
+
let best;
|
|
10
|
+
for (const victim of victims) {
|
|
11
|
+
if (best === undefined ||
|
|
12
|
+
victim.rank < best.rank ||
|
|
13
|
+
(victim.rank === best.rank && victim.lastUsed < best.lastUsed)) {
|
|
14
|
+
best = victim;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return best;
|
|
18
|
+
}
|
|
19
|
+
export function memoryCapBytes(percent, availableBytes) {
|
|
20
|
+
return Math.round((Math.min(percent, 100) / 100) * availableBytes);
|
|
21
|
+
}
|
|
@@ -59,6 +59,7 @@ export interface DiffusionDownloadMetadata {
|
|
|
59
59
|
}
|
|
60
60
|
export declare function diffusionDownloadName(model: string): string | null;
|
|
61
61
|
export declare function diffusionDownloadMetadata(model: string, addon: ModelAddon | undefined): DiffusionDownloadMetadata | undefined;
|
|
62
|
+
export declare function assetBytes(src: string): number | undefined;
|
|
62
63
|
import { DEFAULT_MUSIC_MODEL_CHOICE, isMusicModelChoice, musicModelChoiceFrom, type MusicModelChoice } from './music-catalog.ts';
|
|
63
64
|
export { DEFAULT_MUSIC_MODEL_CHOICE, isMusicModelChoice, musicModelChoiceFrom, type MusicModelChoice };
|
|
64
65
|
export interface AudioGenCatalogEntry {
|
|
@@ -131,6 +132,7 @@ export declare function curatedListables(): CuratedListable[];
|
|
|
131
132
|
export declare function curatedModelAsset(name: string, addon: ModelRegistryEntry['addon']): SdkModelAsset | undefined;
|
|
132
133
|
export declare function modelAddonOf(model: string): ModelRegistryEntry['addon'];
|
|
133
134
|
export declare function residentSrc(model: string, addon: ModelRegistryEntry['addon']): string;
|
|
135
|
+
export declare function catalogModelName(model: string, addon: ModelRegistryEntry['addon']): string;
|
|
134
136
|
export declare const CUSTOM_TASK_TYPES: readonly ['llm'];
|
|
135
137
|
export type CustomTaskType = (typeof CUSTOM_TASK_TYPES)[number];
|
|
136
138
|
export interface CustomModelEntry {
|
|
@@ -224,6 +224,16 @@ export function diffusionDownloadMetadata(model, addon) {
|
|
|
224
224
|
assetSizes
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
|
+
export function assetBytes(src) {
|
|
228
|
+
const assets = [
|
|
229
|
+
...curatedListables().map((entry) => entry.asset),
|
|
230
|
+
...LLM_CATALOG.flatMap((entry) => (entry.projection ? [entry.projection] : [])),
|
|
231
|
+
...DIFFUSION_CATALOG.flatMap(diffusionAssets),
|
|
232
|
+
...AUDIOGEN_CATALOG.flatMap((entry) => [entry.dit, entry.textEnc, entry.lm, entry.vae])
|
|
233
|
+
];
|
|
234
|
+
const custom = customModels().find((entry) => entry.src === src);
|
|
235
|
+
return assets.find((asset) => asset.src === src)?.expectedSize ?? custom?.expectedSize;
|
|
236
|
+
}
|
|
227
237
|
import { DEFAULT_MUSIC_MODEL_CHOICE, isMusicModelChoice, musicModelChoiceFrom } from './music-catalog.js';
|
|
228
238
|
export { DEFAULT_MUSIC_MODEL_CHOICE, isMusicModelChoice, musicModelChoiceFrom };
|
|
229
239
|
const MUSIC_GENERATION_SKILL = 'music-generation';
|
|
@@ -420,6 +430,11 @@ export function modelAddonOf(model) {
|
|
|
420
430
|
export function residentSrc(model, addon) {
|
|
421
431
|
return curatedModelAsset(model, addon)?.src ?? model;
|
|
422
432
|
}
|
|
433
|
+
export function catalogModelName(model, addon) {
|
|
434
|
+
const known = curatedListables().find((entry) => entry.asset.addon === addon &&
|
|
435
|
+
(entry.name === model || entry.asset.name === model || entry.asset.src === model));
|
|
436
|
+
return known?.name ?? model;
|
|
437
|
+
}
|
|
423
438
|
export const CUSTOM_TASK_TYPES = ['llm'];
|
|
424
439
|
let CUSTOM_MODELS = new Map();
|
|
425
440
|
export function setCustomModels(entries) {
|
|
@@ -5,7 +5,7 @@ export type ModelFitEvidence = NonNullable<AssessModelFitResult['evidence']>;
|
|
|
5
5
|
export type FitModelType = 'llm' | 'embeddings';
|
|
6
6
|
export interface FitQuery {
|
|
7
7
|
src: string;
|
|
8
|
-
sha256Checksum
|
|
8
|
+
sha256Checksum?: string;
|
|
9
9
|
name: string;
|
|
10
10
|
registryPath?: string;
|
|
11
11
|
registrySource?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { errorMessage } from '../guards.js';
|
|
2
|
-
import {
|
|
2
|
+
import { HarnessLog } from '../log.js';
|
|
3
3
|
const CONTEXT_RUNGS = [32_768, 16_384, 8_192];
|
|
4
4
|
export class ModelFit {
|
|
5
5
|
_assess;
|
|
@@ -15,8 +15,7 @@ export class ModelFit {
|
|
|
15
15
|
: { src, sha256Checksum, name, modelType, contextTokens };
|
|
16
16
|
}
|
|
17
17
|
static confirms(assessed) {
|
|
18
|
-
return
|
|
19
|
-
(assessed.evidence === 'native-fit' || assessed.evidence === 'calibration'));
|
|
18
|
+
return assessed?.verdict === 'likely-fits' && assessed.evidence === 'native-fit';
|
|
20
19
|
}
|
|
21
20
|
async assess(query) {
|
|
22
21
|
const [assessed] = await this._ask([query]);
|
|
@@ -75,8 +74,8 @@ export class ModelFit {
|
|
|
75
74
|
}
|
|
76
75
|
async _ask(queries) {
|
|
77
76
|
const result = await this._assess({
|
|
78
|
-
models: queries.map(({ contextTokens, modelType = 'llm', ...
|
|
79
|
-
modelSrc,
|
|
77
|
+
models: queries.map(({ contextTokens, modelType = 'llm', sha256Checksum, ...source }) => ({
|
|
78
|
+
modelSrc: sha256Checksum ? { ...source, sha256Checksum } : source.src,
|
|
80
79
|
modelType,
|
|
81
80
|
modelConfig: { ctx_size: contextTokens }
|
|
82
81
|
})),
|
|
@@ -95,7 +94,7 @@ export class ModelFit {
|
|
|
95
94
|
}
|
|
96
95
|
settle(query) {
|
|
97
96
|
return this.assess(query).catch((err) => {
|
|
98
|
-
|
|
97
|
+
HarnessLog.warn('fit estimate failed', { model: query.name, err: errorMessage(err) });
|
|
99
98
|
return null;
|
|
100
99
|
});
|
|
101
100
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { type AbortSignal } from 'bare-abort-controller';
|
|
1
2
|
import type { LoadFit } from '../contract-types.ts';
|
|
2
3
|
export interface ModelResource {
|
|
3
4
|
model: string;
|
|
4
5
|
modelId: string;
|
|
5
6
|
ctxSize?: number;
|
|
7
|
+
slots?: number;
|
|
6
8
|
fit?: LoadFit | undefined;
|
|
9
|
+
bytes?: number;
|
|
7
10
|
}
|
|
8
11
|
export interface ModelHandleOptions {
|
|
9
|
-
load(): Promise<ModelResource>;
|
|
12
|
+
load(signal: AbortSignal): Promise<ModelResource>;
|
|
10
13
|
onLoaded?(): void;
|
|
11
14
|
onFailed?(err: unknown): void;
|
|
12
15
|
}
|
|
@@ -18,9 +21,12 @@ export declare class ModelHandle {
|
|
|
18
21
|
private _tracked;
|
|
19
22
|
private _loading;
|
|
20
23
|
private _resource;
|
|
24
|
+
lastUsed: number;
|
|
25
|
+
private _attempt;
|
|
21
26
|
constructor({ load, onLoaded, onFailed }: ModelHandleOptions);
|
|
22
27
|
load(): Promise<ModelResource>;
|
|
23
28
|
get loading(): boolean;
|
|
24
|
-
|
|
29
|
+
abandon(): void;
|
|
25
30
|
peek(): Promise<ModelResource> | null;
|
|
31
|
+
get resource(): ModelResource | null;
|
|
26
32
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AbortController } from 'bare-abort-controller';
|
|
2
|
+
import { AbortedError } from '../helpers/race-abort.js';
|
|
1
3
|
import { retryMemo } from '../helpers/retry-memo.js';
|
|
2
4
|
export class ModelHandle {
|
|
3
5
|
_load;
|
|
@@ -7,8 +9,14 @@ export class ModelHandle {
|
|
|
7
9
|
_tracked = null;
|
|
8
10
|
_loading = false;
|
|
9
11
|
_resource = null;
|
|
12
|
+
lastUsed = 0;
|
|
13
|
+
_attempt = null;
|
|
10
14
|
constructor({ load, onLoaded, onFailed }) {
|
|
11
|
-
const memo = retryMemo(
|
|
15
|
+
const memo = retryMemo(() => {
|
|
16
|
+
const attempt = new AbortController();
|
|
17
|
+
this._attempt = attempt;
|
|
18
|
+
return load(attempt.signal);
|
|
19
|
+
});
|
|
12
20
|
this._load = memo;
|
|
13
21
|
this._peek = memo.peek;
|
|
14
22
|
this._onLoaded = onLoaded;
|
|
@@ -36,11 +44,14 @@ export class ModelHandle {
|
|
|
36
44
|
get loading() {
|
|
37
45
|
return this._loading;
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
abandon() {
|
|
48
|
+
this._attempt?.abort(new AbortedError());
|
|
41
49
|
}
|
|
42
50
|
peek() {
|
|
43
51
|
return this._peek();
|
|
44
52
|
}
|
|
53
|
+
get resource() {
|
|
54
|
+
return this._loading ? null : this._resource;
|
|
55
|
+
}
|
|
45
56
|
}
|
|
46
57
|
function noop() { }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as QvacSdk from '@qvac/sdk';
|
|
2
|
-
import type
|
|
2
|
+
import { type ModelAddon, type ModelRegistrySdk } from './model-source.ts';
|
|
3
3
|
import { type ModelTaskType } from './model-task.ts';
|
|
4
4
|
import type { ModelFitBasis, ModelFitEvidence, ModelFitVerdict } from './model-fit.ts';
|
|
5
5
|
export type ModelType = ModelAddon;
|
|
@@ -21,6 +21,7 @@ export interface ModelInfo {
|
|
|
21
21
|
supportsImages: boolean;
|
|
22
22
|
expectedSize: number;
|
|
23
23
|
actualSize?: number;
|
|
24
|
+
memoryBytes?: number;
|
|
24
25
|
label?: string;
|
|
25
26
|
taskType: ModelTaskType;
|
|
26
27
|
fit?: ModelFitVerdict;
|
|
@@ -58,4 +59,10 @@ export interface CustomModelRowsContext {
|
|
|
58
59
|
}
|
|
59
60
|
export declare function customModelRows({ type, cachedOnly }: ListModelsOptions, { modelsDir, loaded }: CustomModelRowsContext): Promise<CatalogRow[]>;
|
|
60
61
|
export declare function mergeCustomRows(catalog: ReadonlyArray<CatalogRow>, custom: ReadonlyArray<CatalogRow>): CatalogRow[];
|
|
62
|
+
export interface ModelSourceQuery {
|
|
63
|
+
readonly model: string;
|
|
64
|
+
readonly addon: ModelAddon;
|
|
65
|
+
readonly modelsDir: string | undefined;
|
|
66
|
+
}
|
|
67
|
+
export declare function isModelSourceCached(sdk: ModelListSdk, { model, addon, modelsDir }: ModelSourceQuery): Promise<boolean>;
|
|
61
68
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveModelSrc } from './model-source.js';
|
|
1
2
|
import { addonTaskType } from './model-task.js';
|
|
2
3
|
import { isCustomModelCached } from './custom-model-cache.js';
|
|
3
4
|
import { companionRegistryPaths, curatedListables, customModels, musicListables } from './model-catalog.js';
|
|
@@ -153,3 +154,25 @@ export function mergeCustomRows(catalog, custom) {
|
|
|
153
154
|
const shadowed = new Set(custom.map((row) => row.name));
|
|
154
155
|
return [...catalog.filter((row) => !shadowed.has(row.name)), ...custom];
|
|
155
156
|
}
|
|
157
|
+
export async function isModelSourceCached(sdk, { model, addon, modelsDir }) {
|
|
158
|
+
const src = await resolveModelSrc(sdk, model, addon).catch(() => null);
|
|
159
|
+
if (src === null) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
const name = registryCatalogName(sdk, src);
|
|
163
|
+
if (name === undefined) {
|
|
164
|
+
return typeof src === 'string' && isCustomModelCached({ name: model, src }, modelsDir);
|
|
165
|
+
}
|
|
166
|
+
const info = await sdk.getModelInfo({ name }).catch(() => null);
|
|
167
|
+
return info?.isCached ?? false;
|
|
168
|
+
}
|
|
169
|
+
function registryCatalogName(sdk, src) {
|
|
170
|
+
if (typeof src !== 'string') {
|
|
171
|
+
return sdk.models.find((entry) => entry.registryPath === src.registryPath)?.name ?? src.name;
|
|
172
|
+
}
|
|
173
|
+
const registryPath = /^registry:\/\/[^/]+\/(.+)$/.exec(src)?.[1];
|
|
174
|
+
if (registryPath === undefined) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
return sdk.models.find((entry) => entry.registryPath === registryPath)?.name;
|
|
178
|
+
}
|
|
@@ -5,14 +5,16 @@ import { type ModelAddon } from './model-source.ts';
|
|
|
5
5
|
import type { GpuFaultState } from './sdk-faults.ts';
|
|
6
6
|
import type { LoadedModelInfo } from '@qvac/sdk';
|
|
7
7
|
import type { LoadedModel } from '../contract-types.ts';
|
|
8
|
+
import type { HoldFn } from './download-gate.ts';
|
|
8
9
|
type SdkModule = typeof import('@qvac/sdk');
|
|
10
|
+
type FitModelType = NonNullable<import('@qvac/sdk').AssessModelFitInput['models'][number]['modelType']>;
|
|
9
11
|
export interface FitProbeSdk {
|
|
10
12
|
getLoadedModelInfo?(params: {
|
|
11
13
|
modelId: string;
|
|
12
14
|
}): Promise<Pick<LoadedModelInfo, 'fitProbe'>>;
|
|
13
15
|
}
|
|
14
16
|
export interface ModelState {
|
|
15
|
-
status: 'loading' | 'downloading' | 'downloaded' | 'ready' | 'error' | 'unloading' | 'unloaded';
|
|
17
|
+
status: 'held' | 'loading' | 'downloading' | 'downloaded' | 'ready' | 'error' | 'unloading' | 'unloaded';
|
|
16
18
|
model: string;
|
|
17
19
|
catalogChanged?: boolean;
|
|
18
20
|
[key: string]: unknown;
|
|
@@ -28,6 +30,19 @@ export interface LlamaLoadKnobs {
|
|
|
28
30
|
'kv-offload'?: false;
|
|
29
31
|
'n-cpu-moe'?: number;
|
|
30
32
|
}
|
|
33
|
+
export interface PendingLoad {
|
|
34
|
+
readonly key: string;
|
|
35
|
+
readonly model: string;
|
|
36
|
+
readonly modelSrc: ModelSrc;
|
|
37
|
+
readonly modelType: FitModelType;
|
|
38
|
+
readonly modelConfig?: Record<string, unknown> | undefined;
|
|
39
|
+
}
|
|
40
|
+
export interface Admission {
|
|
41
|
+
readonly bytes: number | undefined;
|
|
42
|
+
release(): void;
|
|
43
|
+
}
|
|
44
|
+
export type BeforeLoad = (load: PendingLoad) => Promise<Admission | undefined>;
|
|
45
|
+
export type ChooseContext = (load: PendingLoad, tier: number) => Promise<number>;
|
|
31
46
|
export interface LlmDeviceConfig {
|
|
32
47
|
device?: 'cpu' | 'gpu';
|
|
33
48
|
gpuLayers?: number;
|
|
@@ -101,6 +116,13 @@ export declare function modelOf(key: string): string;
|
|
|
101
116
|
export declare function releaseModel(pool: PoolLike, key: string): void;
|
|
102
117
|
export declare function loadedModels(pool: PoolLike): LoadedModel[];
|
|
103
118
|
export declare function settledModels(pool: PoolLike): string[];
|
|
119
|
+
export interface SettledEntry {
|
|
120
|
+
readonly key: string;
|
|
121
|
+
readonly refs: number;
|
|
122
|
+
readonly bytes: number | undefined;
|
|
123
|
+
readonly lastUsed: number;
|
|
124
|
+
}
|
|
125
|
+
export declare function settledEntries(pool: PoolLike): SettledEntry[];
|
|
104
126
|
export declare function loadingModels(pool: PoolLike): string[];
|
|
105
127
|
export interface ResidentLease {
|
|
106
128
|
model: string;
|
|
@@ -125,6 +147,7 @@ export interface ModelCapacityOptions extends DeadlineOptions {
|
|
|
125
147
|
}
|
|
126
148
|
export declare function awaitModelCapacity(pool: PoolLike, { cap, deadlineMs, tickMs, signal, evictable }: ModelCapacityOptions): Promise<boolean>;
|
|
127
149
|
export declare function evictModelWithin(pool: PoolLike, key: string, options: DeadlineOptions): Promise<boolean>;
|
|
150
|
+
export declare function evictIdleWithin(pool: PoolLike, key: string, { deadlineMs }: DeadlineOptions): Promise<boolean>;
|
|
128
151
|
export declare function evictModel(pool: PoolLike, model: string, options: DeadlineOptions): Promise<boolean>;
|
|
129
152
|
export type LoadSdk = () => Promise<ModelLifecycleSdk>;
|
|
130
153
|
export type EmbedLifecycleSdk = Pick<SdkModule, 'unloadModel' | 'modelRegistrySearch'> & Partial<CancelSdk> & FitProbeSdk & {
|
|
@@ -164,16 +187,21 @@ export interface ModelPoolOptions {
|
|
|
164
187
|
deviceConfig?: LlmDeviceConfig;
|
|
165
188
|
loads?: LoadTracker;
|
|
166
189
|
onUnloadFailure?: UnloadFailureFn | undefined;
|
|
190
|
+
beforeLoad?: BeforeLoad;
|
|
191
|
+
chooseContext?: ChooseContext;
|
|
192
|
+
hold?: HoldFn;
|
|
167
193
|
}
|
|
168
|
-
export declare function createModelPool(loadSdk: LoadSdk, notify: NotifyFn, { deviceConfig, loads, onUnloadFailure }?: ModelPoolOptions): ModelPuddle;
|
|
194
|
+
export declare function createModelPool(loadSdk: LoadSdk, notify: NotifyFn, { deviceConfig, loads, onUnloadFailure, beforeLoad, chooseContext, hold }?: ModelPoolOptions): ModelPuddle;
|
|
169
195
|
export interface EmbedPoolOptions {
|
|
170
196
|
faults: GpuFaultState;
|
|
171
197
|
batchSize?: number;
|
|
172
198
|
openclCacheDir?: (() => string | undefined) | undefined;
|
|
173
199
|
loads?: LoadTracker;
|
|
174
200
|
onUnloadFailure?: UnloadFailureFn | undefined;
|
|
201
|
+
beforeLoad?: BeforeLoad;
|
|
202
|
+
hold?: HoldFn;
|
|
175
203
|
}
|
|
176
|
-
export declare function createEmbedPool(loadSdk: LoadEmbedSdk, notify: NotifyFn, { faults, batchSize, openclCacheDir, loads, onUnloadFailure }: EmbedPoolOptions): ModelPuddle;
|
|
204
|
+
export declare function createEmbedPool(loadSdk: LoadEmbedSdk, notify: NotifyFn, { faults, batchSize, openclCacheDir, loads, onUnloadFailure, beforeLoad, hold }: EmbedPoolOptions): ModelPuddle;
|
|
177
205
|
export type VoiceLifecycleSdk = Pick<SdkModule, 'unloadModel' | 'modelRegistrySearch'> & Partial<CancelSdk> & FitProbeSdk & {
|
|
178
206
|
loadModel(params: {
|
|
179
207
|
modelSrc: ModelSrc;
|
|
@@ -184,13 +212,15 @@ export type VoiceLifecycleSdk = Pick<SdkModule, 'unloadModel' | 'modelRegistrySe
|
|
|
184
212
|
};
|
|
185
213
|
export type LoadVoiceSdk = () => Promise<VoiceLifecycleSdk>;
|
|
186
214
|
export interface VoicePoolOptions {
|
|
187
|
-
modelType:
|
|
215
|
+
modelType: FitModelType;
|
|
188
216
|
addon: ModelAddon;
|
|
189
217
|
modelConfig?: Record<string, unknown> | undefined;
|
|
190
218
|
modelConfigFor?: (modelSrc: ModelSrc) => Readonly<Record<string, unknown>> | undefined;
|
|
191
219
|
openclCacheDir?: (() => string | undefined) | undefined;
|
|
192
220
|
loads?: LoadTracker;
|
|
193
221
|
onUnloadFailure?: UnloadFailureFn | undefined;
|
|
222
|
+
beforeLoad?: BeforeLoad;
|
|
223
|
+
hold?: HoldFn;
|
|
194
224
|
}
|
|
195
|
-
export declare function createVoicePool(loadSdk: LoadVoiceSdk, notify: NotifyFn, { modelType, addon, modelConfig, modelConfigFor, openclCacheDir, loads, onUnloadFailure }: VoicePoolOptions): ModelPuddle;
|
|
225
|
+
export declare function createVoicePool(loadSdk: LoadVoiceSdk, notify: NotifyFn, { modelType, addon, modelConfig, modelConfigFor, openclCacheDir, loads, onUnloadFailure, beforeLoad, hold }: VoicePoolOptions): ModelPuddle;
|
|
196
226
|
export {};
|