@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import process from 'process';
|
|
2
|
+
import { HarnessError } from '../errors.js';
|
|
2
3
|
import { transferProgress } from '../model-download-progress.js';
|
|
3
4
|
import ResourcePuddle from 'resource-puddle';
|
|
4
5
|
import { ModelHandle } from './model-handle.js';
|
|
@@ -7,10 +8,11 @@ import { customContextLength } from './model-catalog.js';
|
|
|
7
8
|
import { adrenoSafeKvCache } from './kv-cache.js';
|
|
8
9
|
import { DEFAULT_EMBED_BATCH_SIZE } from './embed-config.js';
|
|
9
10
|
import { errorMessage } from '../guards.js';
|
|
10
|
-
import {
|
|
11
|
+
import { HarnessLog } from '../log.js';
|
|
11
12
|
import { RUNAWAY_STOP_SEQUENCES } from '../helpers/control-tokens.js';
|
|
12
13
|
import { raceTimeout } from '../helpers/race-timeout.js';
|
|
13
|
-
import { resolveModelSrc } from './model-source.js';
|
|
14
|
+
import { resolveModelSrc, resolveProjectionSrc } from './model-source.js';
|
|
15
|
+
import { AbortedError } from '../helpers/race-abort.js';
|
|
14
16
|
export class ModelUnloadError extends Error {
|
|
15
17
|
constructor(cause) {
|
|
16
18
|
super(errorMessage(cause));
|
|
@@ -101,10 +103,14 @@ function entryOf(pool, key) {
|
|
|
101
103
|
export function modelOf(key) {
|
|
102
104
|
return key.split('\0')[0];
|
|
103
105
|
}
|
|
106
|
+
let uses = 0;
|
|
104
107
|
export function releaseModel(pool, key) {
|
|
105
108
|
if (pool.destroyed)
|
|
106
109
|
return;
|
|
107
110
|
const handle = entryOf(pool, key)?.value;
|
|
111
|
+
if (handle) {
|
|
112
|
+
handle.lastUsed = ++uses;
|
|
113
|
+
}
|
|
108
114
|
if (handle === undefined || !handle.loading) {
|
|
109
115
|
pool.release(key);
|
|
110
116
|
return;
|
|
@@ -114,8 +120,18 @@ export function releaseModel(pool, key) {
|
|
|
114
120
|
pool.release(key);
|
|
115
121
|
return;
|
|
116
122
|
}
|
|
117
|
-
|
|
123
|
+
const deferred = (deferredReleases.get(handle) ?? 0) + 1;
|
|
124
|
+
deferredReleases.set(handle, deferred);
|
|
125
|
+
if (deferred >= (entryOf(pool, key)?.refs ?? 0)) {
|
|
126
|
+
handle.abandon();
|
|
127
|
+
}
|
|
128
|
+
const settle = () => {
|
|
129
|
+
deferredReleases.set(handle, (deferredReleases.get(handle) ?? 1) - 1);
|
|
130
|
+
releaseSettled(pool, key);
|
|
131
|
+
};
|
|
132
|
+
void pending.then(settle, settle);
|
|
118
133
|
}
|
|
134
|
+
const deferredReleases = new WeakMap();
|
|
119
135
|
function releaseSettled(pool, key) {
|
|
120
136
|
if (pool.destroyed) {
|
|
121
137
|
return;
|
|
@@ -142,6 +158,21 @@ export function settledModels(pool) {
|
|
|
142
158
|
}
|
|
143
159
|
return out;
|
|
144
160
|
}
|
|
161
|
+
export function settledEntries(pool) {
|
|
162
|
+
const out = [];
|
|
163
|
+
for (const entry of pool.resources.values()) {
|
|
164
|
+
const resource = entry.value.resource;
|
|
165
|
+
if (resource !== null) {
|
|
166
|
+
out.push({
|
|
167
|
+
key: entry.id,
|
|
168
|
+
refs: entry.refs,
|
|
169
|
+
bytes: resource.bytes,
|
|
170
|
+
lastUsed: entry.value.lastUsed
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
145
176
|
export function loadingModels(pool) {
|
|
146
177
|
const out = [];
|
|
147
178
|
for (const entry of pool.resources.values()) {
|
|
@@ -151,14 +182,19 @@ export function loadingModels(pool) {
|
|
|
151
182
|
}
|
|
152
183
|
return out;
|
|
153
184
|
}
|
|
154
|
-
function reportedHandle(notify, model, load) {
|
|
185
|
+
function reportedHandle({ notify, model, addon, hold, load }) {
|
|
155
186
|
return new ModelHandle({
|
|
156
|
-
load: () => {
|
|
187
|
+
load: async (signal) => {
|
|
188
|
+
await hold?.(model, addon, signal);
|
|
157
189
|
notify({ status: 'loading', model, catalogChanged: true });
|
|
158
190
|
return load();
|
|
159
191
|
},
|
|
160
192
|
onLoaded: () => notify({ status: 'ready', model, catalogChanged: true }),
|
|
161
|
-
onFailed: (err) =>
|
|
193
|
+
onFailed: (err) => {
|
|
194
|
+
if (err instanceof AbortedError)
|
|
195
|
+
return;
|
|
196
|
+
notify({ status: 'error', model, message: errorMessage(err), catalogChanged: true });
|
|
197
|
+
}
|
|
162
198
|
});
|
|
163
199
|
}
|
|
164
200
|
export async function leaseResidentModel(pool, wanted = () => true) {
|
|
@@ -257,6 +293,10 @@ export async function awaitModelCapacity(pool, { cap, deadlineMs, tickMs = 250,
|
|
|
257
293
|
export function evictModelWithin(pool, key, options) {
|
|
258
294
|
return evictWhereWithin(pool, (candidate) => candidate === key, options);
|
|
259
295
|
}
|
|
296
|
+
export function evictIdleWithin(pool, key, { deadlineMs }) {
|
|
297
|
+
const evicting = evictIdleWhere(pool, (candidate) => candidate === key).then(() => !isResident(pool, key));
|
|
298
|
+
return raceTimeout(evicting, { ms: deadlineMs, fallback: false });
|
|
299
|
+
}
|
|
260
300
|
export function evictModel(pool, model, options) {
|
|
261
301
|
return evictWhereWithin(pool, (key) => modelOf(key) === model, options);
|
|
262
302
|
}
|
|
@@ -322,7 +362,7 @@ export function loadClockGuard(model, sdk, { now = () => Date.now(), monoMs = mo
|
|
|
322
362
|
const mono = monoMs();
|
|
323
363
|
if (wall - lastWall < mono - lastMono - jumpMs) {
|
|
324
364
|
abandoned = true;
|
|
325
|
-
fail(new
|
|
365
|
+
fail(new HarnessError('MODEL_LOAD_CLOCK_SKEW', [model]));
|
|
326
366
|
return;
|
|
327
367
|
}
|
|
328
368
|
lastWall = wall;
|
|
@@ -364,15 +404,14 @@ export async function resolveCtxSize(loadSdk, model, load) {
|
|
|
364
404
|
const sdk = await loadSdk();
|
|
365
405
|
return contextSize(model, await resolveModelSrc(sdk, model), load);
|
|
366
406
|
}
|
|
367
|
-
export function createModelPool(loadSdk, notify, { deviceConfig = {}, loads = createLoadTracker(), onUnloadFailure } = {}) {
|
|
368
|
-
const load = async (model, opts) => {
|
|
407
|
+
export function createModelPool(loadSdk, notify, { deviceConfig = {}, loads = createLoadTracker(), onUnloadFailure, beforeLoad, chooseContext, hold } = {}) {
|
|
408
|
+
const load = async (key, model, opts) => {
|
|
369
409
|
const sdk = await loadSdk();
|
|
370
410
|
const modelSrc = await resolveModelSrc(sdk, model);
|
|
371
411
|
const resolved = resolveLoadOptions(opts, deviceConfig);
|
|
372
|
-
const ctxSize = contextSize(model, modelSrc, { opts: resolved, deviceConfig });
|
|
373
412
|
const slots = slotCount(model, { opts: resolved, deviceConfig });
|
|
374
413
|
const projectionModelSrc = resolved.projectionModel
|
|
375
|
-
? await
|
|
414
|
+
? await resolveProjectionSrc(sdk, resolved.projectionModel)
|
|
376
415
|
: undefined;
|
|
377
416
|
const mainGpu = deviceConfig.device !== 'cpu' && deviceConfig.mainGpu
|
|
378
417
|
? await deviceConfig.mainGpu()
|
|
@@ -384,13 +423,12 @@ export function createModelPool(loadSdk, notify, { deviceConfig = {}, loads = cr
|
|
|
384
423
|
const openclCache = deviceConfig.device !== 'cpu' && deviceConfig.openclCacheDir
|
|
385
424
|
? deviceConfig.openclCacheDir()
|
|
386
425
|
: undefined;
|
|
387
|
-
const
|
|
426
|
+
const config = definedFields({
|
|
388
427
|
...resolved.llama,
|
|
389
428
|
verbosity: llmVerbosity(),
|
|
390
429
|
system_prompt: '',
|
|
391
430
|
tools: true,
|
|
392
431
|
stop_sequences: RUNAWAY_STOP_SEQUENCES,
|
|
393
|
-
ctx_size: ctxSize * slots,
|
|
394
432
|
parallel: slots > 1 ? slots : undefined,
|
|
395
433
|
'cache-type-k': kvCache.k,
|
|
396
434
|
'cache-type-v': kvCache.v,
|
|
@@ -400,56 +438,89 @@ export function createModelPool(loadSdk, notify, { deviceConfig = {}, loads = cr
|
|
|
400
438
|
'main-gpu': mainGpu,
|
|
401
439
|
openclCacheDir: openclCache || undefined
|
|
402
440
|
});
|
|
441
|
+
const pending = { key, model, modelSrc, modelType: 'llamacpp-completion' };
|
|
442
|
+
const chosen = contextSize(model, modelSrc, { opts: resolved, deviceConfig });
|
|
443
|
+
const ctxSize = resolved.ctxSize || !chooseContext
|
|
444
|
+
? chosen
|
|
445
|
+
: await chooseContext({ ...pending, modelConfig: { ...config } }, chosen);
|
|
446
|
+
const modelConfig = { ...config, ctx_size: ctxSize * slots };
|
|
403
447
|
const { projectionModelSrc: projection, ...loggedConfig } = modelConfig;
|
|
404
|
-
|
|
448
|
+
HarnessLog.debug('llm load config', { model, projection: Boolean(projection), ...loggedConfig });
|
|
449
|
+
const admission = await beforeLoad?.({ ...pending, modelConfig });
|
|
405
450
|
const loadStarted = Date.now();
|
|
406
|
-
const modelId = await loadClockGuard(model, sdk)
|
|
451
|
+
const modelId = await loadClockGuard(model, sdk)
|
|
452
|
+
.race(loads.track(sdk.loadModel({
|
|
407
453
|
modelSrc,
|
|
408
454
|
modelType: 'llamacpp-completion',
|
|
409
455
|
modelConfig,
|
|
410
456
|
onProgress: (progress) => notify(progressState(model, progress))
|
|
411
|
-
}), sdk))
|
|
412
|
-
|
|
413
|
-
|
|
457
|
+
}), sdk))
|
|
458
|
+
.finally(() => admission?.release());
|
|
459
|
+
HarnessLog.info('llm loaded', { model, loadMs: Date.now() - loadStarted });
|
|
460
|
+
return {
|
|
461
|
+
model,
|
|
462
|
+
modelId,
|
|
463
|
+
ctxSize,
|
|
464
|
+
slots,
|
|
465
|
+
bytes: admission?.bytes,
|
|
466
|
+
fit: await loadFit(sdk, model, modelId)
|
|
467
|
+
};
|
|
414
468
|
};
|
|
415
469
|
return new ModelPuddle({
|
|
416
|
-
open: (key, model = key, opts = {}) => reportedHandle(notify, model, () => load(model, opts)),
|
|
470
|
+
open: (key, model = key, opts = {}) => reportedHandle({ notify, model, addon: 'llm', hold, load: () => load(key, model, opts) }),
|
|
417
471
|
gc: unloadOnGc(loadSdk, notify, onUnloadFailure),
|
|
418
472
|
...NO_IDLE_GC
|
|
419
473
|
});
|
|
420
474
|
}
|
|
421
|
-
export function createEmbedPool(loadSdk, notify, { faults, batchSize = DEFAULT_EMBED_BATCH_SIZE, openclCacheDir, loads = createLoadTracker(), onUnloadFailure }) {
|
|
422
|
-
const load = async (model) => {
|
|
475
|
+
export function createEmbedPool(loadSdk, notify, { faults, batchSize = DEFAULT_EMBED_BATCH_SIZE, openclCacheDir, loads = createLoadTracker(), onUnloadFailure, beforeLoad, hold }) {
|
|
476
|
+
const load = async (key, model) => {
|
|
423
477
|
const sdk = await loadSdk();
|
|
424
478
|
const modelSrc = await resolveModelSrc(sdk, model, 'embeddings');
|
|
425
479
|
const openclCache = faults.device !== 'cpu' && openclCacheDir ? openclCacheDir() : undefined;
|
|
426
|
-
const
|
|
480
|
+
const modelConfig = {
|
|
481
|
+
batchSize,
|
|
482
|
+
gpuLayers: faults.gpuLayers(),
|
|
483
|
+
device: faults.device,
|
|
484
|
+
openclCacheDir: openclCache || undefined
|
|
485
|
+
};
|
|
486
|
+
const admission = await beforeLoad?.({
|
|
487
|
+
key,
|
|
488
|
+
model,
|
|
427
489
|
modelSrc,
|
|
428
490
|
modelType: 'llamacpp-embedding',
|
|
429
|
-
modelConfig
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
491
|
+
modelConfig
|
|
492
|
+
});
|
|
493
|
+
const modelId = await loadClockGuard(model, sdk)
|
|
494
|
+
.race(loads.track(sdk.loadModel({
|
|
495
|
+
modelSrc,
|
|
496
|
+
modelType: 'llamacpp-embedding',
|
|
497
|
+
modelConfig,
|
|
435
498
|
onProgress: (progress) => notify(progressState(model, progress))
|
|
436
|
-
}), sdk))
|
|
437
|
-
|
|
499
|
+
}), sdk))
|
|
500
|
+
.finally(() => admission?.release());
|
|
501
|
+
return { model, modelId, bytes: admission?.bytes, fit: await loadFit(sdk, model, modelId) };
|
|
438
502
|
};
|
|
439
503
|
return new ModelPuddle({
|
|
440
|
-
open: (key, model = key) => reportedHandle(notify, model, () => load(model)),
|
|
504
|
+
open: (key, model = key) => reportedHandle({ notify, model, addon: 'embeddings', hold, load: () => load(key, model) }),
|
|
441
505
|
gc: unloadOnGc(loadSdk, notify, onUnloadFailure),
|
|
442
506
|
...NO_IDLE_GC
|
|
443
507
|
});
|
|
444
508
|
}
|
|
445
|
-
export function createVoicePool(loadSdk, notify, { modelType, addon, modelConfig, modelConfigFor, openclCacheDir, loads = createLoadTracker(), onUnloadFailure }) {
|
|
509
|
+
export function createVoicePool(loadSdk, notify, { modelType, addon, modelConfig, modelConfigFor, openclCacheDir, loads = createLoadTracker(), onUnloadFailure, beforeLoad, hold }) {
|
|
446
510
|
const wantsGpu = modelConfig?.['useGPU'] === true;
|
|
447
511
|
let gpuRefused = false;
|
|
448
|
-
const load = async (model) => {
|
|
512
|
+
const load = async (key, model) => {
|
|
449
513
|
const sdk = await loadSdk();
|
|
450
514
|
const modelSrc = await resolveModelSrc(sdk, model, addon);
|
|
451
515
|
const tuned = modelConfigFor?.(modelSrc);
|
|
452
516
|
const loadConfig = tuned ? { ...modelConfig, ...tuned } : modelConfig;
|
|
517
|
+
const admission = await beforeLoad?.({
|
|
518
|
+
key,
|
|
519
|
+
model,
|
|
520
|
+
modelSrc,
|
|
521
|
+
modelType,
|
|
522
|
+
modelConfig: loadConfig
|
|
523
|
+
});
|
|
453
524
|
const attempt = () => {
|
|
454
525
|
const config = gpuRefused ? { ...loadConfig, useGPU: false } : loadConfig;
|
|
455
526
|
const openclCache = gpuRefused ? undefined : openclCacheDir?.();
|
|
@@ -460,17 +531,23 @@ export function createVoicePool(loadSdk, notify, { modelType, addon, modelConfig
|
|
|
460
531
|
onProgress: (progress) => notify(progressState(model, progress))
|
|
461
532
|
}), sdk);
|
|
462
533
|
};
|
|
463
|
-
const modelId = await loadClockGuard(model, sdk)
|
|
534
|
+
const modelId = await loadClockGuard(model, sdk)
|
|
535
|
+
.race(attempt().catch((err) => {
|
|
464
536
|
if (!wantsGpu || gpuRefused || loads.draining)
|
|
465
537
|
throw err;
|
|
466
|
-
|
|
538
|
+
HarnessLog.warn('voice gpu load refused, retrying on cpu', {
|
|
539
|
+
model,
|
|
540
|
+
modelType,
|
|
541
|
+
error: String(err)
|
|
542
|
+
});
|
|
467
543
|
gpuRefused = true;
|
|
468
544
|
return attempt();
|
|
469
|
-
}))
|
|
470
|
-
|
|
545
|
+
}))
|
|
546
|
+
.finally(() => admission?.release());
|
|
547
|
+
return { model, modelId, bytes: admission?.bytes, fit: await loadFit(sdk, model, modelId) };
|
|
471
548
|
};
|
|
472
549
|
return new ModelPuddle({
|
|
473
|
-
open: (key, model = key) => reportedHandle(notify, model, () => load(model)),
|
|
550
|
+
open: (key, model = key) => reportedHandle({ notify, model, addon, hold, load: () => load(key, model) }),
|
|
474
551
|
gc: unloadOnGc(loadSdk, notify, onUnloadFailure),
|
|
475
552
|
...NO_IDLE_GC
|
|
476
553
|
});
|
|
@@ -481,7 +558,7 @@ async function loadFit(sdk, model, modelId) {
|
|
|
481
558
|
probe = (await sdk.getLoadedModelInfo?.({ modelId }))?.fitProbe;
|
|
482
559
|
}
|
|
483
560
|
catch (err) {
|
|
484
|
-
|
|
561
|
+
HarnessLog.info('fit probe read failed', { model, err: errorMessage(err) });
|
|
485
562
|
return undefined;
|
|
486
563
|
}
|
|
487
564
|
if (!probe) {
|
|
@@ -496,7 +573,7 @@ async function loadFit(sdk, model, modelId) {
|
|
|
496
573
|
hostBytes: projection?.hostBytes
|
|
497
574
|
};
|
|
498
575
|
if (verdict === 'does-not-fit') {
|
|
499
|
-
|
|
576
|
+
HarnessLog.info('loaded past a does-not-fit probe', { model, ...fit });
|
|
500
577
|
}
|
|
501
578
|
return fit;
|
|
502
579
|
}
|
|
@@ -521,7 +598,7 @@ function unloadOnGc(loadSdk, notify, onUnloadFailure) {
|
|
|
521
598
|
onUnloadFailure?.(modelId, error);
|
|
522
599
|
}
|
|
523
600
|
catch (callbackError) {
|
|
524
|
-
|
|
601
|
+
HarnessLog.info('model unload failure observer failed', { error: String(callbackError) });
|
|
525
602
|
}
|
|
526
603
|
};
|
|
527
604
|
let sdk;
|
|
@@ -541,12 +618,13 @@ function unloadOnGc(loadSdk, notify, onUnloadFailure) {
|
|
|
541
618
|
notify({ status: 'unloading', model });
|
|
542
619
|
}
|
|
543
620
|
catch (error) {
|
|
544
|
-
|
|
621
|
+
HarnessLog.info('model unloading observer failed', { error: String(error) });
|
|
545
622
|
}
|
|
546
623
|
try {
|
|
547
624
|
await sdk.unloadModel({ modelId });
|
|
548
625
|
}
|
|
549
626
|
catch (error) {
|
|
627
|
+
HarnessLog.warn('unload failed', { model, err: errorMessage(error) });
|
|
550
628
|
unloadError ??= error;
|
|
551
629
|
unloadFailed = true;
|
|
552
630
|
reportFailure(modelId, error);
|
|
@@ -556,7 +634,7 @@ function unloadOnGc(loadSdk, notify, onUnloadFailure) {
|
|
|
556
634
|
notify({ status: 'unloaded', model, catalogChanged: true });
|
|
557
635
|
}
|
|
558
636
|
catch (error) {
|
|
559
|
-
|
|
637
|
+
HarnessLog.info('model unloaded observer failed', { error: String(error) });
|
|
560
638
|
}
|
|
561
639
|
}
|
|
562
640
|
if (unloadFailed) {
|
|
@@ -4,3 +4,4 @@ import type { ModelSrc } from './context.ts';
|
|
|
4
4
|
export type ModelRegistrySdk = Pick<typeof QvacSdk, 'modelRegistrySearch'>;
|
|
5
5
|
export type ModelAddon = ModelRegistryEntryAddon;
|
|
6
6
|
export declare function resolveModelSrc(sdk: ModelRegistrySdk, model: string, addon?: ModelAddon): Promise<ModelSrc>;
|
|
7
|
+
export declare function resolveProjectionSrc(sdk: ModelRegistrySdk, model: string): Promise<ModelSrc>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HarnessError } from '../errors.js';
|
|
2
|
+
import { audioGenModelByName, curatedListables, curatedModelAsset, customModelSrc } from './model-catalog.js';
|
|
3
|
+
const SOURCE_PATTERN = /^(\/|~|\.|file:|https?:|registry:|pear:|hyper:)/;
|
|
2
4
|
export async function resolveModelSrc(sdk, model, addon = 'llm') {
|
|
3
|
-
if (
|
|
5
|
+
if (SOURCE_PATTERN.test(model)) {
|
|
4
6
|
return model;
|
|
5
7
|
}
|
|
6
8
|
const custom = customModelSrc(model, addon);
|
|
@@ -10,7 +12,7 @@ export async function resolveModelSrc(sdk, model, addon = 'llm') {
|
|
|
10
12
|
if (addon === 'audiogen') {
|
|
11
13
|
const audio = audioGenModelByName(model);
|
|
12
14
|
if (!audio) {
|
|
13
|
-
throw new
|
|
15
|
+
throw new HarnessError('AUDIOGEN_MODEL_NOT_FOUND', [model]);
|
|
14
16
|
}
|
|
15
17
|
return audio.src;
|
|
16
18
|
}
|
|
@@ -18,9 +20,25 @@ export async function resolveModelSrc(sdk, model, addon = 'llm') {
|
|
|
18
20
|
if (asset) {
|
|
19
21
|
return asset;
|
|
20
22
|
}
|
|
21
|
-
|
|
23
|
+
return await registryMatch(sdk, { model, addon, projection: false });
|
|
24
|
+
}
|
|
25
|
+
export async function resolveProjectionSrc(sdk, model) {
|
|
26
|
+
if (SOURCE_PATTERN.test(model)) {
|
|
27
|
+
return model;
|
|
28
|
+
}
|
|
29
|
+
return await registryMatch(sdk, { model, addon: 'llm', projection: true });
|
|
30
|
+
}
|
|
31
|
+
async function registryMatch(sdk, { model, addon, projection }) {
|
|
32
|
+
const entries = await sdk.modelRegistrySearch({ filter: model, addon });
|
|
33
|
+
const entry = bestMatch(entries.filter((candidate) => /mmproj/i.test(candidate.name) === projection), model);
|
|
22
34
|
if (!entry) {
|
|
23
|
-
throw new
|
|
35
|
+
throw new HarnessError('MODEL_NOT_IN_REGISTRY', [model, addon]);
|
|
24
36
|
}
|
|
25
37
|
return { ...entry, src: `registry://${entry.registrySource}/${entry.registryPath}` };
|
|
26
38
|
}
|
|
39
|
+
function bestMatch(entries, model) {
|
|
40
|
+
const curated = new Set(curatedListables().map((listable) => listable.asset.registryPath));
|
|
41
|
+
return (entries.find((entry) => entry.name === model) ??
|
|
42
|
+
entries.find((entry) => curated.has(entry.registryPath)) ??
|
|
43
|
+
entries[0]);
|
|
44
|
+
}
|
|
@@ -3,6 +3,7 @@ export declare function isSdkGpuDeviceLostError(err: unknown): boolean;
|
|
|
3
3
|
export declare function isSdkModelWedgedError(err: unknown): boolean;
|
|
4
4
|
export declare function isToolGrammarFault(err: unknown): boolean;
|
|
5
5
|
export declare function isForcedCallFault(err: unknown): boolean;
|
|
6
|
+
export declare function isKvCacheSaveFault(err: unknown): boolean;
|
|
6
7
|
export declare function isContextOverflowError(err: unknown): boolean;
|
|
7
8
|
export type GpuFaultDecision = 'reload' | 'fallback';
|
|
8
9
|
interface GpuFaultEscalation {
|
|
@@ -34,6 +34,15 @@ export function isForcedCallFault(err) {
|
|
|
34
34
|
}
|
|
35
35
|
return /demanded a tool call/i.test(message);
|
|
36
36
|
}
|
|
37
|
+
export function isKvCacheSaveFault(err) {
|
|
38
|
+
if (typeof err !== 'object' || err === null)
|
|
39
|
+
return false;
|
|
40
|
+
const message = 'message' in err ? err.message : undefined;
|
|
41
|
+
if (typeof message !== 'string') {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return /failed to (save session file|promote tmp file)/i.test(message);
|
|
45
|
+
}
|
|
37
46
|
export function isContextOverflowError(err) {
|
|
38
47
|
if (typeof err !== 'object' || err === null)
|
|
39
48
|
return false;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import http, { Agent as HttpAgent } from 'bare-http1';
|
|
2
2
|
import https, { Agent as HttpsAgent } from 'bare-https';
|
|
3
3
|
import * as bareDns from 'bare-dns';
|
|
4
|
+
import { HarnessError } from './errors.js';
|
|
4
5
|
import { isPrivateOrBlocked } from './tools/private-ip.js';
|
|
5
6
|
import { makeValidatingLookup } from './validating-lookup.js';
|
|
6
7
|
import { runNoRedirectFetch } from './no-redirect-fetch-impl.js';
|
|
@@ -55,5 +56,5 @@ function readMethod(method) {
|
|
|
55
56
|
method === 'OPTIONS') {
|
|
56
57
|
return method;
|
|
57
58
|
}
|
|
58
|
-
throw new
|
|
59
|
+
throw new HarnessError('UNSUPPORTED_HTTP_METHOD', [method]);
|
|
59
60
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
+
import { HarnessError } from './errors.js';
|
|
2
3
|
import { DEFAULT_USER_AGENT } from './user-agent.js';
|
|
3
4
|
const UA_SNIFFING_HOSTS = new Set(['wttr.in']);
|
|
4
5
|
export function runNoRedirectFetch(request, url, init = {}) {
|
|
@@ -55,7 +56,7 @@ export function runNoRedirectFetch(request, url, init = {}) {
|
|
|
55
56
|
req.destroy();
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
|
-
const err = new
|
|
59
|
+
const err = new HarnessError('RESPONSE_TOO_LARGE', [init.maxBytes]);
|
|
59
60
|
req.destroy(err);
|
|
60
61
|
fail(err);
|
|
61
62
|
return;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Box } from './inherit.ts';
|
|
2
|
+
import type { SlideSize } from './template.ts';
|
|
3
|
+
export type Role = 'slot' | 'blank' | 'body' | 'picture' | 'other';
|
|
4
|
+
export interface Size {
|
|
5
|
+
readonly width: number;
|
|
6
|
+
readonly height: number;
|
|
7
|
+
}
|
|
8
|
+
export interface Placed {
|
|
9
|
+
readonly box: Box;
|
|
10
|
+
readonly role: Role;
|
|
11
|
+
}
|
|
12
|
+
export interface Beside<T> {
|
|
13
|
+
readonly shape: T;
|
|
14
|
+
readonly box: Box;
|
|
15
|
+
}
|
|
16
|
+
export interface Area<T> {
|
|
17
|
+
readonly box: Box;
|
|
18
|
+
readonly cleared: readonly T[];
|
|
19
|
+
readonly beside: Beside<T> | null;
|
|
20
|
+
}
|
|
21
|
+
export declare function framed(slide: SlideSize): Box;
|
|
22
|
+
export declare function fitted(size: Size, area: Box): Box;
|
|
23
|
+
export declare function pictureArea<T extends Placed>(slide: SlideSize, shapes: readonly T[]): Area<T>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const FRAME = 0.8;
|
|
2
|
+
const MARGIN = 0.03;
|
|
3
|
+
const MIN_BAND = 0.15;
|
|
4
|
+
const MIN_SPLIT = 0.5;
|
|
5
|
+
export function framed(slide) {
|
|
6
|
+
return {
|
|
7
|
+
x: Math.round((slide.width * (1 - FRAME)) / 2),
|
|
8
|
+
y: Math.round((slide.height * (1 - FRAME)) / 2),
|
|
9
|
+
width: Math.round(slide.width * FRAME),
|
|
10
|
+
height: Math.round(slide.height * FRAME)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function fitted(size, area) {
|
|
14
|
+
const scale = Math.min(area.width / size.width, area.height / size.height);
|
|
15
|
+
const width = Math.round(size.width * scale);
|
|
16
|
+
const height = Math.round(size.height * scale);
|
|
17
|
+
return {
|
|
18
|
+
x: area.x + Math.round((area.width - width) / 2),
|
|
19
|
+
y: area.y + Math.round((area.height - height) / 2),
|
|
20
|
+
width,
|
|
21
|
+
height
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function bandBelow(slide, shapes, margin) {
|
|
25
|
+
const top = Math.max(...shapes.map(({ box }) => box.y + box.height)) + margin;
|
|
26
|
+
const band = {
|
|
27
|
+
x: margin,
|
|
28
|
+
y: top,
|
|
29
|
+
width: slide.width - 2 * margin,
|
|
30
|
+
height: slide.height - top - margin
|
|
31
|
+
};
|
|
32
|
+
return band.height >= slide.height * MIN_BAND ? band : null;
|
|
33
|
+
}
|
|
34
|
+
function halves(box, gap) {
|
|
35
|
+
if (box.width >= box.height) {
|
|
36
|
+
const half = Math.round((box.width - gap) / 2);
|
|
37
|
+
const rest = box.width - half - gap;
|
|
38
|
+
return [
|
|
39
|
+
{ ...box, width: half },
|
|
40
|
+
{ ...box, x: box.x + half + gap, width: rest }
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
const half = Math.round((box.height - gap) / 2);
|
|
44
|
+
const rest = box.height - half - gap;
|
|
45
|
+
return [
|
|
46
|
+
{ ...box, height: half },
|
|
47
|
+
{ ...box, y: box.y + half + gap, height: rest }
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
function split(shape, gap) {
|
|
51
|
+
const [kept, freed] = halves(shape.box, gap);
|
|
52
|
+
const box = shape.role === 'picture' ? fitted(shape.box, kept) : kept;
|
|
53
|
+
return { box: freed, cleared: [], beside: { shape, box } };
|
|
54
|
+
}
|
|
55
|
+
function largest(shapes) {
|
|
56
|
+
return shapes.reduce((best, shape) => !best || shape.box.width * shape.box.height > best.box.width * best.box.height ? shape : best, undefined);
|
|
57
|
+
}
|
|
58
|
+
function overlaps(a, b) {
|
|
59
|
+
return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;
|
|
60
|
+
}
|
|
61
|
+
function place(slide, shapes) {
|
|
62
|
+
const slot = shapes.find((shape) => shape.role === 'slot');
|
|
63
|
+
if (slot) {
|
|
64
|
+
return { box: slot.box, cleared: [slot], beside: null };
|
|
65
|
+
}
|
|
66
|
+
const whole = { box: framed(slide), cleared: [], beside: null };
|
|
67
|
+
if (!shapes.length) {
|
|
68
|
+
return whole;
|
|
69
|
+
}
|
|
70
|
+
const margin = Math.round(slide.height * MARGIN);
|
|
71
|
+
const band = bandBelow(slide, shapes, margin);
|
|
72
|
+
if (band) {
|
|
73
|
+
return { box: band, cleared: [], beside: null };
|
|
74
|
+
}
|
|
75
|
+
const bodies = shapes.filter((shape) => shape.role === 'body');
|
|
76
|
+
const wide = bodies.filter((shape) => shape.box.width >= slide.width * MIN_SPLIT);
|
|
77
|
+
const shared = largest(wide) ?? largest(shapes.filter((shape) => shape.role === 'picture')) ?? largest(bodies);
|
|
78
|
+
return shared ? split(shared, margin) : whole;
|
|
79
|
+
}
|
|
80
|
+
export function pictureArea(slide, shapes) {
|
|
81
|
+
const area = place(slide, shapes.filter((shape) => shape.role !== 'blank'));
|
|
82
|
+
const covered = shapes.filter((shape) => shape.role === 'blank' && overlaps(shape.box, area.box));
|
|
83
|
+
return { ...area, cleared: [...area.cleared, ...covered] };
|
|
84
|
+
}
|