@qvac/harness 1.0.0-rc.3 → 1.0.0-rc.5
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 +2302 -1485
- package/README.md +44 -31
- package/dist-lib/index.d.ts +51 -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 +104 -40
- 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 +22 -13
- 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 +50 -22
- 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 +33 -6
- package/dist-lib/lib/capabilities/completion-engine/driver.js +28 -13
- 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/engine.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/engine.js +14 -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 +16 -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 +14 -9
- package/dist-lib/lib/capabilities/completion-engine/turns.js +63 -86
- 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 +68 -26
- 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 +51 -30
- package/dist-lib/lib/contract/drive.d.ts +4 -0
- package/dist-lib/lib/contract/drive.js +1 -0
- 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 +3 -0
- package/dist-lib/lib/contract/managed-skills.d.ts +1 -0
- package/dist-lib/lib/contract/managed-skills.js +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 +15 -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 +35 -15
- 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 +78 -12
- 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 +5 -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 +43 -10
- package/dist-lib/lib/machine/completion/machine.d.ts +23 -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 +43 -1
- package/dist-lib/lib/machine/index.d.ts +29 -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 +83 -38
- 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 +8 -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 +52 -9
- 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 +310 -205
- package/dist-lib/spec/hyperschema/index.js +310 -205
- package/dist-lib/spec/hyperschema/schema.json +164 -84
- package/dist-lib/spec/hyperschema/types.d.ts +25 -4
- package/package.json +98 -26
- 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/bench/README.md +0 -94
- package/bench/bfcl/checker.ts +0 -313
- package/bench/bfcl/data.ts +0 -93
- package/bench/bfcl/observe.ts +0 -93
- package/bench/bfcl/run.ts +0 -213
- package/bench/bfcl/tools.ts +0 -72
- package/bench/bridge/bridge.ts +0 -392
- package/bench/bridge/openai.ts +0 -150
- package/bench/bridge/python/qvac_bench/__init__.py +0 -3
- package/bench/bridge/python/qvac_bench/airline.py +0 -42
- package/bench/bridge/python/qvac_bench/approval.py +0 -26
- package/bench/bridge/python/qvac_bench/bfcl_multi_turn.py +0 -152
- package/bench/bridge/python/qvac_bench/client.py +0 -88
- package/bench/bridge/python/qvac_bench/harbor_agent.py +0 -85
- package/bench/bridge/python/qvac_bench/session.py +0 -107
- package/bench/bridge/python/qvac_bench/speed.py +0 -30
- package/bench/bridge/python/qvac_bench/tau2_agent.py +0 -106
- package/bench/bridge/python/qvac_bench/tools.py +0 -11
- package/bench/bridge/python/run_bfcl_multi_turn.py +0 -95
- package/bench/bridge/python/run_tau2.py +0 -150
- package/bench/bridge/python/smoke.py +0 -47
- package/bench/bridge/python/test_airline.py +0 -28
- package/bench/bridge/python/test_approval.py +0 -57
- package/bench/bridge/python/test_bfcl_multi_turn.py +0 -185
- package/bench/bridge/python/test_harbor_agent.py +0 -107
- package/bench/bridge/serve.ts +0 -52
- package/bench/bridge/transcript.ts +0 -52
- package/bench/bun-tsconfig.json +0 -15
- package/bench/cpu-main.mjs +0 -216
- package/bench/cpu.ts +0 -457
- package/bench/evidence/2026-09-28-review15.md +0 -225
- package/bench/evidence/redact-bun1.3.14.json +0 -92
- package/bench/evidence/redact-node24.11.json +0 -92
- package/bench/graph-metrics.ts +0 -43
- package/bench/harness.ts +0 -73
- package/bench/issue129-matrix.mjs +0 -722
- package/bench/redact-adversarial.ts +0 -256
- package/bench/repeat-cpu.mjs +0 -281
- package/bench/report.ts +0 -1075
- package/bench/skill-eval/harness.ts +0 -30
- package/bench/skill-eval/laws.ts +0 -37
- package/bench/skill-eval/mermaid/client.ts +0 -132
- package/bench/skill-eval/mermaid/validate.mjs +0 -115
- package/bench/skill-eval/pack.ts +0 -61
- package/bench/skill-eval/packs/diagrams/cases.ts +0 -281
- package/bench/skill-eval/packs/diagrams/index.ts +0 -50
- package/bench/skill-eval/packs/diagrams/score.ts +0 -74
- package/bench/skill-eval/packs/index.ts +0 -5
- package/bench/skill-eval/packs/weather/cases.ts +0 -279
- package/bench/skill-eval/packs/weather/fixtures/wttr.json +0 -566
- package/bench/skill-eval/packs/weather/fixtures.ts +0 -84
- package/bench/skill-eval/packs/weather/index.ts +0 -55
- package/bench/skill-eval/packs/weather/score.ts +0 -92
- package/bench/skill-eval/report.ts +0 -194
- package/bench/skill-eval/run.ts +0 -316
- package/bench/speed.ts +0 -80
- 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,6 +1,6 @@
|
|
|
1
1
|
import { errorMessage } from './guards.js';
|
|
2
2
|
import { retryMemo } from './helpers/retry-memo.js';
|
|
3
|
-
import {
|
|
3
|
+
import { HarnessLog } from './log.js';
|
|
4
4
|
const defaultImports = {
|
|
5
5
|
sdk: () => import('#sdk'),
|
|
6
6
|
plugins: () => import('@qvac/sdk/plugins'),
|
|
@@ -12,14 +12,18 @@ function register(registry, name, plugin) {
|
|
|
12
12
|
registry.registerPlugin(plugin);
|
|
13
13
|
}
|
|
14
14
|
catch (err) {
|
|
15
|
-
|
|
15
|
+
HarnessLog.warn('plugin registration skipped', {
|
|
16
16
|
plugin: name,
|
|
17
17
|
err: errorMessage(err)
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
const IN_PROCESS = typeof globalThis.Bare !== 'undefined';
|
|
21
22
|
export function createSdkLoader(imports = defaultImports) {
|
|
22
23
|
const load = retryMemo(async () => {
|
|
24
|
+
if (!IN_PROCESS) {
|
|
25
|
+
return imports.sdk();
|
|
26
|
+
}
|
|
23
27
|
const [sdk, { llmPlugin }, registry] = await Promise.all([
|
|
24
28
|
imports.sdk(),
|
|
25
29
|
imports.llm(),
|
|
@@ -28,15 +32,17 @@ export function createSdkLoader(imports = defaultImports) {
|
|
|
28
32
|
register(registry, 'llm', llmPlugin);
|
|
29
33
|
return sdk;
|
|
30
34
|
});
|
|
31
|
-
const loadEmbed =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
const loadEmbed = IN_PROCESS
|
|
36
|
+
? retryMemo(async () => {
|
|
37
|
+
const [sdk, { embeddingsPlugin }, registry] = await Promise.all([
|
|
38
|
+
load(),
|
|
39
|
+
imports.embeddings(),
|
|
40
|
+
imports.plugins()
|
|
41
|
+
]);
|
|
42
|
+
register(registry, 'embeddings', embeddingsPlugin);
|
|
43
|
+
return sdk;
|
|
44
|
+
})
|
|
45
|
+
: load;
|
|
40
46
|
const addons = {
|
|
41
47
|
sdk: load,
|
|
42
48
|
embeddings: loadEmbed,
|
package/dist-lib/lib/serve.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { AbortController } from 'bare-abort-controller';
|
|
3
3
|
import fs from 'fs';
|
|
4
|
+
import { HarnessError } from './errors.js';
|
|
4
5
|
import { settleOnClose } from './rpc-session.js';
|
|
5
6
|
import { pipeline, Readable } from 'streamx';
|
|
6
7
|
import { bindApi } from '../spec/bind.js';
|
|
7
8
|
import HRPC from '../spec/hrpc/index.js';
|
|
8
9
|
import { encode } from '../spec/hrpc/messages.js';
|
|
9
|
-
import { checkGoal } from './capabilities/tool-turns.js';
|
|
10
|
+
import { checkGoal, checkMaxToolRounds } from './capabilities/tool-turns.js';
|
|
10
11
|
import { isCapability } from './capabilities/invoke.js';
|
|
11
12
|
import { CUSTOM_TASK_TYPES } from './models/model-catalog.js';
|
|
12
13
|
import { unsupportedKvCacheDeletion } from './capabilities/kv-cache.js';
|
|
13
14
|
import { RunLog } from './run-log/index.js';
|
|
14
15
|
import { errorMessage, isRecord } from './guards.js';
|
|
15
|
-
import {
|
|
16
|
+
import { HarnessLog } from './log.js';
|
|
16
17
|
import { pushQueue } from './queue.js';
|
|
17
18
|
import { TextCoalescer } from './helpers/text-coalescer.js';
|
|
18
19
|
import { prepareOpenclCache } from './models/opencl-cache.js';
|
|
@@ -27,7 +28,8 @@ const MODEL_STATUSES = new Set([
|
|
|
27
28
|
'ready',
|
|
28
29
|
'error',
|
|
29
30
|
'unloading',
|
|
30
|
-
'unloaded'
|
|
31
|
+
'unloaded',
|
|
32
|
+
'held'
|
|
31
33
|
]);
|
|
32
34
|
const DOWNLOAD_PROGRESS_INTERVAL_MS = 500;
|
|
33
35
|
const WIRE_HIGH_WATER_MARK = 64;
|
|
@@ -89,14 +91,16 @@ function optionalNumber(value) {
|
|
|
89
91
|
return value === undefined || typeof value === 'number';
|
|
90
92
|
}
|
|
91
93
|
function goalFrom(value) {
|
|
92
|
-
const { objective, rounds, ms, tokens } = value;
|
|
94
|
+
const { objective, rounds, ms, tokens, checks } = value;
|
|
93
95
|
if (typeof objective !== 'string' ||
|
|
94
96
|
!optionalNumber(rounds) ||
|
|
95
97
|
!optionalNumber(ms) ||
|
|
96
|
-
!optionalNumber(tokens)
|
|
98
|
+
!optionalNumber(tokens) ||
|
|
99
|
+
(checks !== undefined &&
|
|
100
|
+
(!Array.isArray(checks) || !checks.every((check) => typeof check === 'string')))) {
|
|
97
101
|
throw new TypeError('Invalid goal');
|
|
98
102
|
}
|
|
99
|
-
return { objective, rounds, ms, tokens };
|
|
103
|
+
return { objective, rounds, ms, tokens, checks };
|
|
100
104
|
}
|
|
101
105
|
function startPayloadFrom(value) {
|
|
102
106
|
if (!isRecord(value)) {
|
|
@@ -156,12 +160,24 @@ function startPayloadFrom(value) {
|
|
|
156
160
|
if (value.planMode === true) {
|
|
157
161
|
payload.planMode = true;
|
|
158
162
|
}
|
|
163
|
+
if (value.deferTools === true) {
|
|
164
|
+
payload.deferTools = true;
|
|
165
|
+
}
|
|
159
166
|
if (typeof value.parentRunId === 'string') {
|
|
160
167
|
payload.parentRunId = value.parentRunId;
|
|
161
168
|
}
|
|
162
169
|
if (isRecord(value.goal)) {
|
|
163
170
|
payload.goal = goalFrom(value.goal);
|
|
164
171
|
}
|
|
172
|
+
if (typeof value.typedText === 'string') {
|
|
173
|
+
payload.typedText = value.typedText;
|
|
174
|
+
}
|
|
175
|
+
if (typeof value.maxToolRounds === 'number') {
|
|
176
|
+
payload.maxToolRounds = checkMaxToolRounds(value.maxToolRounds);
|
|
177
|
+
}
|
|
178
|
+
if (value.replaysContext === true) {
|
|
179
|
+
payload.replaysContext = true;
|
|
180
|
+
}
|
|
165
181
|
if (value.runLog === null) {
|
|
166
182
|
payload.runLog = null;
|
|
167
183
|
}
|
|
@@ -229,6 +245,10 @@ function normalizeAgentKnobs(agent) {
|
|
|
229
245
|
if (normalized.model === null || normalized.model === undefined) {
|
|
230
246
|
delete normalized.model;
|
|
231
247
|
}
|
|
248
|
+
if (normalized.policy === null || normalized.policy === undefined) {
|
|
249
|
+
delete normalized.policy;
|
|
250
|
+
}
|
|
251
|
+
Reflect.deleteProperty(normalized, 'sandboxMode');
|
|
232
252
|
return normalized;
|
|
233
253
|
}
|
|
234
254
|
function tick() {
|
|
@@ -252,6 +272,20 @@ export function serveHarness(stream, harness) {
|
|
|
252
272
|
await harness.setModelIdleTimeout?.(ms);
|
|
253
273
|
return { ok: true };
|
|
254
274
|
},
|
|
275
|
+
setModelMemoryCap: async ({ percent }) => {
|
|
276
|
+
await harness.setModelMemoryCap?.(percent);
|
|
277
|
+
return { ok: true };
|
|
278
|
+
},
|
|
279
|
+
memoryUsage: async () => {
|
|
280
|
+
if (!harness.memoryUsage) {
|
|
281
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['memoryUsage']);
|
|
282
|
+
}
|
|
283
|
+
return harness.memoryUsage();
|
|
284
|
+
},
|
|
285
|
+
setDownloadsAllowed: async ({ allowed }) => {
|
|
286
|
+
await harness.setDownloadsAllowed?.({ allowed: allowed === true });
|
|
287
|
+
return { ok: true };
|
|
288
|
+
},
|
|
255
289
|
listManagedSkills: async () => ({
|
|
256
290
|
skills: (await harness.listManagedSkills?.()) ?? []
|
|
257
291
|
}),
|
|
@@ -296,7 +330,7 @@ export function serveHarness(stream, harness) {
|
|
|
296
330
|
},
|
|
297
331
|
previewModelSource: async ({ src, mmprojSrc }) => {
|
|
298
332
|
if (!harness.previewModelSource) {
|
|
299
|
-
throw new
|
|
333
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['previewModelSource']);
|
|
300
334
|
}
|
|
301
335
|
return harness.previewModelSource({ src: src ?? '', mmprojSrc: mmprojSrc ?? undefined });
|
|
302
336
|
},
|
|
@@ -314,13 +348,14 @@ export function serveHarness(stream, harness) {
|
|
|
314
348
|
skills: []
|
|
315
349
|
},
|
|
316
350
|
embed: async ({ model, texts }) => {
|
|
317
|
-
if (!harness.embed)
|
|
318
|
-
throw new
|
|
351
|
+
if (!harness.embed) {
|
|
352
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['embed']);
|
|
353
|
+
}
|
|
319
354
|
return packVectors(await harness.embed({ model, texts: texts ?? [] }));
|
|
320
355
|
},
|
|
321
356
|
transcribe: async ({ model, audio }) => {
|
|
322
357
|
if (!harness.transcribe) {
|
|
323
|
-
throw new
|
|
358
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['transcribe']);
|
|
324
359
|
}
|
|
325
360
|
return {
|
|
326
361
|
text: await harness.transcribe({ model: model ?? '', audio: audio ?? b4a.alloc(0) })
|
|
@@ -328,7 +363,7 @@ export function serveHarness(stream, harness) {
|
|
|
328
363
|
},
|
|
329
364
|
detectLanguage: async ({ text, topK }) => {
|
|
330
365
|
if (!harness.detectLanguage) {
|
|
331
|
-
throw new
|
|
366
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['detectLanguage']);
|
|
332
367
|
}
|
|
333
368
|
const languages = await harness.detectLanguage({
|
|
334
369
|
text: text ?? '',
|
|
@@ -337,8 +372,9 @@ export function serveHarness(stream, harness) {
|
|
|
337
372
|
return { languages };
|
|
338
373
|
},
|
|
339
374
|
speak: async ({ model, text }) => {
|
|
340
|
-
if (!harness.speak)
|
|
341
|
-
throw new
|
|
375
|
+
if (!harness.speak) {
|
|
376
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['speak']);
|
|
377
|
+
}
|
|
342
378
|
return harness.speak({ model: model ?? '', text: text ?? '' });
|
|
343
379
|
},
|
|
344
380
|
speakStream: speakStream(harness),
|
|
@@ -382,26 +418,26 @@ export function serveHarness(stream, harness) {
|
|
|
382
418
|
}),
|
|
383
419
|
capability: async () => {
|
|
384
420
|
if (!harness.capability) {
|
|
385
|
-
throw new
|
|
421
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['capability']);
|
|
386
422
|
}
|
|
387
423
|
return harness.capability();
|
|
388
424
|
},
|
|
389
425
|
warmModel: async ({ model, agent }) => {
|
|
390
426
|
if (!harness.warmModel) {
|
|
391
|
-
throw new
|
|
427
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['warmModel']);
|
|
392
428
|
}
|
|
393
429
|
await harness.warmModel({ model, agent: agent ?? {} });
|
|
394
430
|
return { ok: true };
|
|
395
431
|
},
|
|
396
432
|
loadModel: async ({ model, agent }) => {
|
|
397
433
|
if (!harness.loadModel) {
|
|
398
|
-
throw new
|
|
434
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['loadModel']);
|
|
399
435
|
}
|
|
400
436
|
return harness.loadModel({ model, agent: agent ?? {} });
|
|
401
437
|
},
|
|
402
438
|
unloadModel: async ({ model }) => {
|
|
403
439
|
if (!harness.unloadModel) {
|
|
404
|
-
throw new
|
|
440
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['unloadModel']);
|
|
405
441
|
}
|
|
406
442
|
return harness.unloadModel({ model });
|
|
407
443
|
},
|
|
@@ -447,6 +483,7 @@ function toWireSkill(skill) {
|
|
|
447
483
|
}));
|
|
448
484
|
return {
|
|
449
485
|
name: skill.name,
|
|
486
|
+
displayName: skill.displayName || undefined,
|
|
450
487
|
description: skill.description,
|
|
451
488
|
tools: skill.tools,
|
|
452
489
|
credentials: skill.credentials,
|
|
@@ -468,7 +505,7 @@ function unsupportedKnowledge() {
|
|
|
468
505
|
return new Error('harness does not support knowledge');
|
|
469
506
|
}
|
|
470
507
|
function unsupportedEmbeddingDeviceControl() {
|
|
471
|
-
return new
|
|
508
|
+
return new HarnessError('CAPABILITY_UNSUPPORTED', ['embedding device control']);
|
|
472
509
|
}
|
|
473
510
|
function modelEvents(harness) {
|
|
474
511
|
let last = '';
|
|
@@ -511,7 +548,8 @@ function modelEvents(harness) {
|
|
|
511
548
|
total,
|
|
512
549
|
message: state.message,
|
|
513
550
|
catalogChanged,
|
|
514
|
-
loaded
|
|
551
|
+
loaded,
|
|
552
|
+
addon: state.addon
|
|
515
553
|
});
|
|
516
554
|
const now = Date.now();
|
|
517
555
|
if (frame.status === 'downloading') {
|
|
@@ -549,7 +587,7 @@ function encodableModelEvent(frame) {
|
|
|
549
587
|
function speakStream(harness) {
|
|
550
588
|
return async function* (duplex) {
|
|
551
589
|
if (!harness.speakStream) {
|
|
552
|
-
throw new
|
|
590
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['speakStream']);
|
|
553
591
|
}
|
|
554
592
|
const text = pushQueue();
|
|
555
593
|
const end = () => text.end();
|
|
@@ -577,11 +615,12 @@ function runFrame(harness, frame, context) {
|
|
|
577
615
|
if (frame.type !== 'invoke') {
|
|
578
616
|
return harness.completion(context);
|
|
579
617
|
}
|
|
580
|
-
if (!harness.invoke)
|
|
581
|
-
throw new
|
|
618
|
+
if (!harness.invoke) {
|
|
619
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['invoke']);
|
|
620
|
+
}
|
|
582
621
|
const capability = frame.capability ?? '';
|
|
583
622
|
if (!isCapability(capability)) {
|
|
584
|
-
throw new
|
|
623
|
+
throw new HarnessError('UNKNOWN_CAPABILITY', [capability]);
|
|
585
624
|
}
|
|
586
625
|
return harness.invoke({
|
|
587
626
|
capability,
|
|
@@ -617,11 +656,11 @@ function completion(harness) {
|
|
|
617
656
|
pending.clear();
|
|
618
657
|
for (const { reject, staged } of pendingAttach.values()) {
|
|
619
658
|
void fs.promises.unlink(staged).catch(noop);
|
|
620
|
-
reject(new
|
|
659
|
+
reject(new HarnessError('CLIENT_GONE'));
|
|
621
660
|
}
|
|
622
661
|
pendingAttach.clear();
|
|
623
662
|
for (const { reject } of pendingFetch.values()) {
|
|
624
|
-
reject(new
|
|
663
|
+
reject(new HarnessError('CLIENT_GONE'));
|
|
625
664
|
}
|
|
626
665
|
pendingFetch.clear();
|
|
627
666
|
for (const { resolve } of pendingQuestion.values()) {
|
|
@@ -632,11 +671,11 @@ function completion(harness) {
|
|
|
632
671
|
if (path) {
|
|
633
672
|
void fs.promises.unlink(path).catch(noop);
|
|
634
673
|
}
|
|
635
|
-
reject(new
|
|
674
|
+
reject(new HarnessError('CLIENT_GONE'));
|
|
636
675
|
}
|
|
637
676
|
pendingDrive.clear();
|
|
638
677
|
for (const { reject } of pendingRunLog.values()) {
|
|
639
|
-
reject(new
|
|
678
|
+
reject(new HarnessError('CLIENT_GONE'));
|
|
640
679
|
}
|
|
641
680
|
pendingRunLog.clear();
|
|
642
681
|
input.end();
|
|
@@ -716,7 +755,7 @@ function completion(harness) {
|
|
|
716
755
|
return;
|
|
717
756
|
}
|
|
718
757
|
if (frame.message) {
|
|
719
|
-
|
|
758
|
+
HarnessLog.warn('question failed', { callId: frame.callId, message: frame.message });
|
|
720
759
|
}
|
|
721
760
|
waiter.resolve(frame.answer || null);
|
|
722
761
|
return;
|
|
@@ -802,7 +841,7 @@ function completion(harness) {
|
|
|
802
841
|
const onStep = runLog
|
|
803
842
|
? (step) => {
|
|
804
843
|
if (clientGone) {
|
|
805
|
-
return Promise.reject(new
|
|
844
|
+
return Promise.reject(new HarnessError('CLIENT_GONE'));
|
|
806
845
|
}
|
|
807
846
|
return new Promise((resolve, reject) => {
|
|
808
847
|
const callId = String(calls++);
|
|
@@ -822,16 +861,20 @@ function completion(harness) {
|
|
|
822
861
|
model: frame.model ?? '',
|
|
823
862
|
agent,
|
|
824
863
|
cacheKey: frame.cacheKey ?? (explicitEmptyIdentity.has('cacheKey') ? '' : undefined),
|
|
864
|
+
session: frame.session ?? undefined,
|
|
825
865
|
thinkingDefault: frame.thinkingDefault ?? (explicitEmptyIdentity.has('thinkingDefault') ? '' : undefined),
|
|
826
866
|
generationParams: frame.generationParams ?? undefined,
|
|
827
867
|
responseFormat: frame.responseFormat ?? undefined,
|
|
828
868
|
captureInferenceCalls: frame.captureInferenceCalls ?? undefined,
|
|
829
|
-
maxToolRounds:
|
|
869
|
+
maxToolRounds: startPayload.maxToolRounds,
|
|
870
|
+
typedText: startPayload.typedText,
|
|
871
|
+
replaysContext: startPayload.replaysContext,
|
|
830
872
|
knowledge: startPayload.knowledge,
|
|
831
873
|
planMode: startPayload.planMode,
|
|
874
|
+
deferTools: startPayload.deferTools,
|
|
832
875
|
parentRunId: startPayload.parentRunId,
|
|
833
876
|
goal: startPayload.goal,
|
|
834
|
-
messages: (frame.messages ?? []).map(({ role, content, attachments, toolCalls, toolCallId, name, id }) => ({
|
|
877
|
+
messages: (frame.messages ?? []).map(({ role, content, attachments, toolCalls, toolCallId, name, id, context: added }) => ({
|
|
835
878
|
role,
|
|
836
879
|
content,
|
|
837
880
|
attachments: attachments?.length
|
|
@@ -840,19 +883,21 @@ function completion(harness) {
|
|
|
840
883
|
toolCalls: toolCalls ?? undefined,
|
|
841
884
|
toolCallId: toolCallId ?? undefined,
|
|
842
885
|
name: name ?? undefined,
|
|
843
|
-
id: id || undefined
|
|
886
|
+
id: id || undefined,
|
|
887
|
+
context: added ?? undefined
|
|
844
888
|
})),
|
|
845
889
|
toolConfigs: frame.toolConfigs ?? undefined,
|
|
846
890
|
grantedDirs: frame.grantedDirs ?? undefined,
|
|
847
891
|
grantedDrives: frame.grantedDrives?.length
|
|
848
892
|
? frame.grantedDrives.map((drive) => ({
|
|
849
893
|
key: drive.key,
|
|
850
|
-
writable: drive.writable === true
|
|
894
|
+
writable: drive.writable === true,
|
|
895
|
+
search: drive.search === true
|
|
851
896
|
}))
|
|
852
897
|
: undefined,
|
|
853
898
|
driveOp: frame.grantedDrives?.length
|
|
854
899
|
? (request) => controller.signal.aborted
|
|
855
|
-
? Promise.reject(new
|
|
900
|
+
? Promise.reject(new HarnessError('CLIENT_GONE'))
|
|
856
901
|
: new Promise((resolve, reject) => {
|
|
857
902
|
const callId = String(calls++);
|
|
858
903
|
pendingDrive.set(callId, {
|
|
@@ -889,7 +934,7 @@ function completion(harness) {
|
|
|
889
934
|
const staged = await stageFile('attach', input.bytes);
|
|
890
935
|
if (controller.signal.aborted) {
|
|
891
936
|
void fs.promises.unlink(staged).catch(noop);
|
|
892
|
-
throw new
|
|
937
|
+
throw new HarnessError('CLIENT_GONE');
|
|
893
938
|
}
|
|
894
939
|
return new Promise((resolve, reject) => {
|
|
895
940
|
const callId = String(calls++);
|
|
@@ -905,7 +950,7 @@ function completion(harness) {
|
|
|
905
950
|
});
|
|
906
951
|
},
|
|
907
952
|
fetchAttachment: ({ attachmentId, meta } = {}) => controller.signal.aborted
|
|
908
|
-
? Promise.reject(new
|
|
953
|
+
? Promise.reject(new HarnessError('CLIENT_GONE'))
|
|
909
954
|
: new Promise((resolve, reject) => {
|
|
910
955
|
const callId = String(calls++);
|
|
911
956
|
pendingFetch.set(callId, { resolve, reject });
|
|
@@ -1004,7 +1049,7 @@ function completion(harness) {
|
|
|
1004
1049
|
}
|
|
1005
1050
|
input.end();
|
|
1006
1051
|
events.push({ type: 'done' });
|
|
1007
|
-
|
|
1052
|
+
HarnessLog.debug('wire end', { produced, frames });
|
|
1008
1053
|
events.end();
|
|
1009
1054
|
})();
|
|
1010
1055
|
});
|
|
@@ -1023,7 +1068,7 @@ function completion(harness) {
|
|
|
1023
1068
|
yield event;
|
|
1024
1069
|
await tick();
|
|
1025
1070
|
}
|
|
1026
|
-
|
|
1071
|
+
HarnessLog.info('wire handed off');
|
|
1027
1072
|
};
|
|
1028
1073
|
}
|
|
1029
1074
|
function encodableDownloadEvent(wire) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import '../hardware/gpu-probe-entry.ts';
|
|
2
|
+
import type { HarnessPlugin } from '../plugins/index.ts';
|
|
3
|
+
import type { Stream } from '../rpc-session.ts';
|
|
4
|
+
import type { HarnessKnowledgeConfig, HarnessPluginOptions, MusicModelArg } from '../spawn.ts';
|
|
5
|
+
import type { SdkStorage } from '../storage.ts';
|
|
6
|
+
import type { CredentialStoreFn } from '../tools/skills/auth-resolver.ts';
|
|
7
|
+
import { type SkillCatalogEntry } from '../tools/skills/catalog.ts';
|
|
8
|
+
import { type LeftOut } from './user-plugins.ts';
|
|
9
|
+
import { type ImageClamps, type ImageModelSet, type MusicClamps } from '../models/model-catalog.ts';
|
|
10
|
+
export interface SidecarContext {
|
|
11
|
+
pluginOptions: HarnessPluginOptions;
|
|
12
|
+
sdkStorage: SdkStorage;
|
|
13
|
+
skillsDir: string;
|
|
14
|
+
skillCatalog: SkillCatalogEntry[] | undefined;
|
|
15
|
+
credentialStore: CredentialStoreFn | undefined;
|
|
16
|
+
imageModel: string | ImageModelSet | undefined;
|
|
17
|
+
imageClamps: ImageClamps | undefined;
|
|
18
|
+
musicModel: Exclude<MusicModelArg, string> | undefined;
|
|
19
|
+
musicClamps: MusicClamps | undefined;
|
|
20
|
+
knowledge: HarnessKnowledgeConfig | undefined;
|
|
21
|
+
}
|
|
22
|
+
export type SidecarPlugins = (ctx: SidecarContext) => HarnessPlugin[];
|
|
23
|
+
export declare class HarnessSidecar {
|
|
24
|
+
private readonly _plugins;
|
|
25
|
+
constructor(plugins: SidecarPlugins);
|
|
26
|
+
static start(ipc: Stream, ready: () => void, plugins: SidecarPlugins): Promise<() => void>;
|
|
27
|
+
static loadUserPlugins(dir: string, leftOut: LeftOut): Promise<HarnessPlugin[]>;
|
|
28
|
+
start(ipc: Stream, ready: () => void): Promise<() => void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import '../hardware/gpu-probe-entry.js';
|
|
2
|
+
import FileLog from 'bare-file-logger';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { dirname, join } from 'path';
|
|
5
|
+
import process from 'process';
|
|
6
|
+
import { sealAddons } from '#addon-seal';
|
|
7
|
+
import { Harness, serveHarness } from '../../index.js';
|
|
8
|
+
import { errorMessage } from '../guards.js';
|
|
9
|
+
import { HarnessLog } from '../log.js';
|
|
10
|
+
import { configureSdkStorage } from '../sdk-storage.js';
|
|
11
|
+
import { Tools } from '../tools/index.js';
|
|
12
|
+
import { loadSkillCatalog } from '../tools/skills/catalog.js';
|
|
13
|
+
import { loadUserPlugins, userConfigDir } from './user-plugins.js';
|
|
14
|
+
import { musicModelSet } from '../models/model-catalog.js';
|
|
15
|
+
const LOG_MAX_SIZE = 100_000_000;
|
|
16
|
+
const SCOPE = '[harness]';
|
|
17
|
+
const DISCARD = { info() { }, debug() { }, warn() { }, error() { } };
|
|
18
|
+
export class HarnessSidecar {
|
|
19
|
+
_plugins;
|
|
20
|
+
constructor(plugins) {
|
|
21
|
+
this._plugins = plugins;
|
|
22
|
+
}
|
|
23
|
+
static start(ipc, ready, plugins) {
|
|
24
|
+
return new HarnessSidecar(plugins).start(ipc, ready);
|
|
25
|
+
}
|
|
26
|
+
static loadUserPlugins(dir, leftOut) {
|
|
27
|
+
return loadUserPlugins(dir, leftOut);
|
|
28
|
+
}
|
|
29
|
+
async start(ipc, ready) {
|
|
30
|
+
let harness;
|
|
31
|
+
let dying = false;
|
|
32
|
+
const die = () => {
|
|
33
|
+
if (dying)
|
|
34
|
+
return;
|
|
35
|
+
dying = true;
|
|
36
|
+
Promise.resolve(harness?.close())
|
|
37
|
+
.catch(noop)
|
|
38
|
+
.then(() => Bare.exit(0));
|
|
39
|
+
};
|
|
40
|
+
Bare.IPC.on('end', die).on('close', die);
|
|
41
|
+
const argv = Bare.argv;
|
|
42
|
+
const sdkStorage = JSON.parse(argv[3] || '{}');
|
|
43
|
+
if (argv[7]) {
|
|
44
|
+
HarnessLog.followHost(argv[7]);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
HarnessLog.enable(false);
|
|
48
|
+
}
|
|
49
|
+
const hostWantsLogs = HarnessLog.level() !== 'off';
|
|
50
|
+
const log = openHarnessLog(join(dirname(sdkStorage.home), 'harness.log')) ?? DISCARD;
|
|
51
|
+
HarnessLog.setSink((line, level) => log[level](SCOPE, line));
|
|
52
|
+
captureConsole(log);
|
|
53
|
+
await alignSdkConsoleWithHost(hostWantsLogs);
|
|
54
|
+
const skillsDir = argv[2] || (await Tools.bundledSkillsDir());
|
|
55
|
+
if (argv[11]) {
|
|
56
|
+
process.env.QVAC_PYTHON_WHEELS_DIR = argv[11];
|
|
57
|
+
}
|
|
58
|
+
configureSdkStorage(sdkStorage);
|
|
59
|
+
process.env.QVAC_PYODIDE_CACHE_DIR = `${sdkStorage.home}/pyodide-cache`;
|
|
60
|
+
const skillCatalog = skillsDir ? await loadSkillCatalog(skillsDir) : undefined;
|
|
61
|
+
const credentialStore = skillCatalog
|
|
62
|
+
? (key, ctx) => harness?.resolveCredential(key, ctx) ?? null
|
|
63
|
+
: undefined;
|
|
64
|
+
const tools = Tools.product({
|
|
65
|
+
sdkHome: sdkStorage.home,
|
|
66
|
+
skillsDir,
|
|
67
|
+
skillCatalog,
|
|
68
|
+
credentialStore
|
|
69
|
+
});
|
|
70
|
+
const plugins = this._plugins(pluginContext(argv, { sdkStorage, skillsDir, skillCatalog, credentialStore }));
|
|
71
|
+
harness = new Harness({
|
|
72
|
+
...modelOptions(argv),
|
|
73
|
+
tools,
|
|
74
|
+
exec: true,
|
|
75
|
+
skillsDir,
|
|
76
|
+
sdkHome: sdkStorage.home,
|
|
77
|
+
modelsDir: sdkStorage.models,
|
|
78
|
+
pluginMode: 'dynamic',
|
|
79
|
+
plugins: admit(plugins, log)
|
|
80
|
+
});
|
|
81
|
+
await harness.ready().catch((err) => log.error(SCOPE, 'harness failed to open', err));
|
|
82
|
+
await addUserPlugins(harness, log);
|
|
83
|
+
sealAddons();
|
|
84
|
+
serveHarness(ipc, harness);
|
|
85
|
+
ready();
|
|
86
|
+
return noop;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function pluginContext(argv, base) {
|
|
90
|
+
const music = argv[9] ? JSON.parse(argv[9]) : undefined;
|
|
91
|
+
return {
|
|
92
|
+
...base,
|
|
93
|
+
pluginOptions: argv[14] ? JSON.parse(argv[14]) : {},
|
|
94
|
+
imageModel: argv[5] ? JSON.parse(argv[5]) : undefined,
|
|
95
|
+
imageClamps: argv[6] ? JSON.parse(argv[6]) : undefined,
|
|
96
|
+
musicModel: (typeof music === 'string' ? musicModelSet(music) : music) ?? undefined,
|
|
97
|
+
musicClamps: argv[10] ? JSON.parse(argv[10]) : undefined,
|
|
98
|
+
knowledge: argv[13] ? JSON.parse(argv[13]) : undefined
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function modelOptions(argv) {
|
|
102
|
+
const embed = JSON.parse(argv[4] || '{}');
|
|
103
|
+
const llm = argv[8] ? JSON.parse(argv[8]) : {};
|
|
104
|
+
return {
|
|
105
|
+
gpuStats: argv[12] ? JSON.parse(argv[12]) : undefined,
|
|
106
|
+
embedDevice: embed.device,
|
|
107
|
+
embedGpuLayers: embed.gpuLayers,
|
|
108
|
+
embedBatchSize: embed.batchSize,
|
|
109
|
+
llmDevice: llm.llmDevice,
|
|
110
|
+
llmGpuLayers: llm.llmGpuLayers,
|
|
111
|
+
contextSize: llm.contextSize,
|
|
112
|
+
kvCacheK: llm.kvCacheK,
|
|
113
|
+
kvCacheV: llm.kvCacheV,
|
|
114
|
+
llmLoad: llm.llmLoad,
|
|
115
|
+
slots: llm.slots,
|
|
116
|
+
completionModelCap: llm.completionModelCap
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function admit(plugins, log) {
|
|
120
|
+
return plugins.filter((plugin) => {
|
|
121
|
+
const reason = invalid(plugin);
|
|
122
|
+
if (reason) {
|
|
123
|
+
log.error(SCOPE, `plugin '${plugin.name}' left out: ${reason}`);
|
|
124
|
+
}
|
|
125
|
+
return !reason;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async function addUserPlugins(harness, log) {
|
|
129
|
+
const leftOut = (name, reason) => log.error(SCOPE, `user plugin '${name}' left out: ${reason}`);
|
|
130
|
+
const plugins = await loadUserPlugins(userConfigDir(), leftOut).catch((err) => {
|
|
131
|
+
log.error(SCOPE, 'user plugins left out', err);
|
|
132
|
+
return [];
|
|
133
|
+
});
|
|
134
|
+
for (const plugin of plugins) {
|
|
135
|
+
try {
|
|
136
|
+
await harness.addPlugin(plugin);
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
leftOut(plugin.name, errorMessage(err));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function openHarnessLog(path) {
|
|
144
|
+
try {
|
|
145
|
+
fs.mkdirSync(dirname(path), { recursive: true });
|
|
146
|
+
return new FileLog(path, { maxSize: LOG_MAX_SIZE, rotate: (p) => `${p}.1` });
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function captureConsole(log) {
|
|
153
|
+
console.log = console.info = (...args) => log.info(SCOPE, ...args);
|
|
154
|
+
console.debug = (...args) => log.debug(SCOPE, ...args);
|
|
155
|
+
console.warn = (...args) => log.warn(SCOPE, ...args);
|
|
156
|
+
console.error = (...args) => log.error(SCOPE, ...args);
|
|
157
|
+
}
|
|
158
|
+
async function alignSdkConsoleWithHost(hostWantsLogs) {
|
|
159
|
+
try {
|
|
160
|
+
const logging = await import('@qvac/sdk/logging');
|
|
161
|
+
logging.setGlobalConsoleOutput(hostWantsLogs);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function invalid(plugin) {
|
|
167
|
+
try {
|
|
168
|
+
return plugin.validate?.() ?? null;
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
return errorMessage(err);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function noop() { }
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import '../../index.ts';
|
|
2
|
+
import '../plugins/index.ts';
|
|
3
|
+
import '../plugins/context.ts';
|
|
4
|
+
import '../helpers/race-abort.ts';
|
|
5
|
+
import type { HarnessPlugin } from '../plugins/index.ts';
|
|
6
|
+
export type LeftOut = (name: string, reason: string) => void;
|
|
7
|
+
export declare function userConfigDir(env?: Record<string, string | undefined>): string;
|
|
8
|
+
export declare function loadUserPlugins(dir: string, leftOut: LeftOut): Promise<HarnessPlugin[]>;
|