@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
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { harnessClient } from '../../spec/calls.js';
|
|
2
|
+
import HRPC from '../../spec/hrpc/index.js';
|
|
3
|
+
import { encode } from '../../spec/hrpc/messages.js';
|
|
4
|
+
import { errorMessage, isRecord } from '../guards.js';
|
|
5
|
+
import { addonTaskType } from '../models/model-task.js';
|
|
6
|
+
import { pushQueue } from '../queue.js';
|
|
7
|
+
import { settleOnClose } from '../rpc-session.js';
|
|
8
|
+
import { fromDownloadWire, fromWire } from '../wire.js';
|
|
9
|
+
const NO_ATTACHMENTS = 'this client carries no attachments';
|
|
10
|
+
export class HarnessClient {
|
|
11
|
+
_transport;
|
|
12
|
+
_opening = null;
|
|
13
|
+
_closed = false;
|
|
14
|
+
constructor(transport) {
|
|
15
|
+
this._transport = transport;
|
|
16
|
+
}
|
|
17
|
+
async *completion(context) {
|
|
18
|
+
const { client } = await this._open();
|
|
19
|
+
const signal = context.signal;
|
|
20
|
+
if (signal?.aborted) {
|
|
21
|
+
yield { type: 'aborted' };
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const duplex = client.completion();
|
|
25
|
+
let runId;
|
|
26
|
+
let failure = null;
|
|
27
|
+
let closed = false;
|
|
28
|
+
let done = false;
|
|
29
|
+
let emittedAborted = false;
|
|
30
|
+
const send = (frame) => {
|
|
31
|
+
if (closed)
|
|
32
|
+
return;
|
|
33
|
+
try {
|
|
34
|
+
encode('@harness/completion-frame', frame);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
failure ??= new Error(`cannot encode ${String(frame.type)} frame: ${errorMessage(err)}`);
|
|
38
|
+
duplex.destroy(failure);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
duplex.write(frame);
|
|
42
|
+
};
|
|
43
|
+
const onAbort = () => duplex.destroy();
|
|
44
|
+
signal?.addEventListener?.('abort', onAbort, { once: true });
|
|
45
|
+
try {
|
|
46
|
+
send({
|
|
47
|
+
type: 'start',
|
|
48
|
+
payload: { recoveryEvents: true },
|
|
49
|
+
model: context.model,
|
|
50
|
+
agent: context.agent,
|
|
51
|
+
cacheKey: context.cacheKey,
|
|
52
|
+
thinkingDefault: context.thinkingDefault,
|
|
53
|
+
toolConfigs: context.toolConfigs,
|
|
54
|
+
generationParams: context.generationParams,
|
|
55
|
+
responseFormat: context.responseFormat,
|
|
56
|
+
maxToolRounds: context.maxToolRounds || undefined,
|
|
57
|
+
messages: context.messages
|
|
58
|
+
});
|
|
59
|
+
if (failure) {
|
|
60
|
+
throw failure;
|
|
61
|
+
}
|
|
62
|
+
for await (const event of frames(duplex)) {
|
|
63
|
+
if (event.type === 'done') {
|
|
64
|
+
done = true;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
if (answered(event, context, send)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const wire = fromWire(event);
|
|
71
|
+
if (wire.type === 'run-started' || wire.type === 'run-resumed') {
|
|
72
|
+
runId = event.runId ?? runId;
|
|
73
|
+
}
|
|
74
|
+
if (wire.type === 'aborted' || wire.type === 'paused') {
|
|
75
|
+
emittedAborted = true;
|
|
76
|
+
}
|
|
77
|
+
yield wire;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
if (failure) {
|
|
82
|
+
throw failure;
|
|
83
|
+
}
|
|
84
|
+
if (!signal?.aborted) {
|
|
85
|
+
throw new Error(`harness died mid-run: ${errorMessage(err)}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
closed = true;
|
|
90
|
+
signal?.removeEventListener?.('abort', onAbort);
|
|
91
|
+
duplex.destroy();
|
|
92
|
+
}
|
|
93
|
+
if (signal?.aborted) {
|
|
94
|
+
if (!emittedAborted) {
|
|
95
|
+
yield { type: 'aborted', runId };
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!done) {
|
|
100
|
+
throw new Error('harness closed mid-run');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async *download(context) {
|
|
104
|
+
const { client } = await this._open();
|
|
105
|
+
const signal = context.signal;
|
|
106
|
+
if (signal?.aborted) {
|
|
107
|
+
yield { type: 'aborted' };
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const stream = client.download({
|
|
111
|
+
model: context.model,
|
|
112
|
+
addon: context.addon,
|
|
113
|
+
seed: context.seed
|
|
114
|
+
});
|
|
115
|
+
let emittedAborted = false;
|
|
116
|
+
const onAbort = () => stream.destroy();
|
|
117
|
+
signal?.addEventListener?.('abort', onAbort, { once: true });
|
|
118
|
+
try {
|
|
119
|
+
for await (const event of frames(stream)) {
|
|
120
|
+
const wire = fromDownloadWire(event);
|
|
121
|
+
if (wire.type === 'aborted') {
|
|
122
|
+
emittedAborted = true;
|
|
123
|
+
}
|
|
124
|
+
yield wire;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
if (!signal?.aborted) {
|
|
129
|
+
throw new Error(`harness died mid-download: ${errorMessage(err)}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
signal?.removeEventListener?.('abort', onAbort);
|
|
134
|
+
stream.destroy();
|
|
135
|
+
}
|
|
136
|
+
if (signal?.aborted && !emittedAborted) {
|
|
137
|
+
yield { type: 'aborted' };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async list(options = {}) {
|
|
141
|
+
const { client } = await this._open();
|
|
142
|
+
const response = await client.listModels({
|
|
143
|
+
type: options.type,
|
|
144
|
+
cachedOnly: options.cachedOnly,
|
|
145
|
+
fullRegistry: options.fullRegistry
|
|
146
|
+
});
|
|
147
|
+
return (response.models ?? []).map(({ actualSize, label, fit, fitBasis, fitEvidence, ...row }) => ({
|
|
148
|
+
...row,
|
|
149
|
+
actualSize: actualSize || undefined,
|
|
150
|
+
label: label || undefined,
|
|
151
|
+
taskType: addonTaskType(row.type),
|
|
152
|
+
fit: (fit || undefined),
|
|
153
|
+
fitBasis: (fitBasis || undefined),
|
|
154
|
+
fitEvidence: (fitEvidence || undefined)
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
close() {
|
|
158
|
+
this._closed = true;
|
|
159
|
+
void this._opening?.then((session) => session.stream.destroy(), () => { });
|
|
160
|
+
}
|
|
161
|
+
_open() {
|
|
162
|
+
if (this._closed) {
|
|
163
|
+
return Promise.reject(new Error('harness client closed'));
|
|
164
|
+
}
|
|
165
|
+
this._opening ??= this._connect();
|
|
166
|
+
return this._opening.then((session) => {
|
|
167
|
+
if (session.dead)
|
|
168
|
+
throw new Error('harness connection closed');
|
|
169
|
+
return session;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
async _connect() {
|
|
173
|
+
const stream = await this._transport();
|
|
174
|
+
const session = {
|
|
175
|
+
client: harnessClient(settleOnClose(new HRPC(stream))),
|
|
176
|
+
stream,
|
|
177
|
+
dead: false
|
|
178
|
+
};
|
|
179
|
+
stream.on('close', () => {
|
|
180
|
+
session.dead = true;
|
|
181
|
+
});
|
|
182
|
+
if (this._closed) {
|
|
183
|
+
stream.destroy();
|
|
184
|
+
}
|
|
185
|
+
return session;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async function* frames(stream) {
|
|
189
|
+
const queue = pushQueue();
|
|
190
|
+
let error = null;
|
|
191
|
+
stream.on('data', (frame) => queue.push(frame));
|
|
192
|
+
stream.on('end', () => queue.end());
|
|
193
|
+
stream.on('close', () => queue.end());
|
|
194
|
+
stream.on('error', (err) => {
|
|
195
|
+
error = err;
|
|
196
|
+
queue.end();
|
|
197
|
+
});
|
|
198
|
+
yield* queue;
|
|
199
|
+
if (error) {
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function answered(event, context, send) {
|
|
204
|
+
const callId = event.callId;
|
|
205
|
+
switch (event.type) {
|
|
206
|
+
case 'approval-ask':
|
|
207
|
+
void Promise.resolve()
|
|
208
|
+
.then(() => context.approve?.(approvalCall(event)))
|
|
209
|
+
.then((approved) => approved === true, () => false)
|
|
210
|
+
.then((approved) => send({ type: 'decision', callId, approved }));
|
|
211
|
+
return true;
|
|
212
|
+
case 'question-ask':
|
|
213
|
+
answerQuestion(event, context.askUser, send);
|
|
214
|
+
return true;
|
|
215
|
+
case 'attach-ask':
|
|
216
|
+
send({ type: 'attach-result', callId, message: NO_ATTACHMENTS });
|
|
217
|
+
return true;
|
|
218
|
+
case 'fetch-ask':
|
|
219
|
+
send({ type: 'fetch-result', callId, message: NO_ATTACHMENTS });
|
|
220
|
+
return true;
|
|
221
|
+
case 'progress':
|
|
222
|
+
context.progress?.(event.cleared ? null : { percentage: event.percentage ?? 0 });
|
|
223
|
+
return true;
|
|
224
|
+
default:
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function answerQuestion(event, askUser, send) {
|
|
229
|
+
const callId = event.callId;
|
|
230
|
+
if (!askUser) {
|
|
231
|
+
send({ type: 'question-result', callId, message: 'the host cannot ask questions' });
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
void Promise.resolve()
|
|
235
|
+
.then(() => askUser({
|
|
236
|
+
question: event.question ?? '',
|
|
237
|
+
options: Array.isArray(event.options) ? event.options.map(String) : undefined
|
|
238
|
+
}))
|
|
239
|
+
.then((answer) => send({ type: 'question-result', callId, answer: answer ?? '' }), (err) => send({ type: 'question-result', callId, message: errorMessage(err) }));
|
|
240
|
+
}
|
|
241
|
+
function approvalCall(event) {
|
|
242
|
+
const identity = isRecord(event.payload) ? event.payload : {};
|
|
243
|
+
const approval = {
|
|
244
|
+
name: event.name ?? '',
|
|
245
|
+
arguments: isRecord(event.arguments) ? event.arguments : {},
|
|
246
|
+
resource: event.resource ?? null,
|
|
247
|
+
effect: event.effect === 'read' ? 'read' : 'write',
|
|
248
|
+
intent: event.intent || null,
|
|
249
|
+
display: isToolCallDisplay(event.display) ? event.display : null,
|
|
250
|
+
quote: event.question || null
|
|
251
|
+
};
|
|
252
|
+
if (typeof identity.callId === 'string') {
|
|
253
|
+
approval.callId = identity.callId;
|
|
254
|
+
}
|
|
255
|
+
if (typeof identity.round === 'number') {
|
|
256
|
+
approval.round = identity.round;
|
|
257
|
+
}
|
|
258
|
+
return approval;
|
|
259
|
+
}
|
|
260
|
+
function isToolCallDisplay(value) {
|
|
261
|
+
return isRecord(value) && typeof value.label === 'string';
|
|
262
|
+
}
|
|
@@ -3,7 +3,7 @@ import { type Transport } from './rpc-session.ts';
|
|
|
3
3
|
import { type KvCacheDeletionResult } from './capabilities/kv-cache.ts';
|
|
4
4
|
import type { CustomModelEntry } from './models/model-catalog.ts';
|
|
5
5
|
import { type ModelSourcePreview, type PreviewModelSourceContext } from './capabilities/preview-model-source.ts';
|
|
6
|
-
import type { CapabilityInfo, CompletionContext, CredentialEntry, DetectedLanguage, DetectLanguageContext, DownloadContext, EmbedContext, HarnessContract, HarnessDiagnostics, HarnessEvent, HarnessInfo, InfraModel, InvokeContext, ListModelsOptions, ModelInfo, ResolvedSkillCatalogEntry, SkillsOptions, SkillWriteResult, SpeakContext, SpeakResult, SpeakStreamContext, ToolCatalogEntry, TranscribeContext, LoadModelContext, LoadModelResult, UnloadModelContext, UnloadModelResult, WarmModelContext } from './contract-types.ts';
|
|
6
|
+
import type { CapabilityInfo, CompletionContext, CredentialEntry, DetectedLanguage, DetectLanguageContext, DownloadContext, EmbedContext, HarnessContract, HarnessDiagnostics, HarnessEvent, HarnessInfo, HostContext, InfraModel, InvokeContext, ListModelsOptions, ModelInfo, ResolvedSkillCatalogEntry, SkillsOptions, SkillWriteResult, SpeakContext, SpeakResult, SpeakStreamContext, ToolCatalogEntry, TranscribeContext, LoadModelContext, LoadModelResult, MemoryUsage, UnloadModelContext, UnloadModelResult, WarmModelContext, DownloadsAllowedOptions } from './contract-types.ts';
|
|
7
7
|
import type { KnowledgeArtifact, KnowledgeHit, KnowledgeQuery, KnowledgeRemoved, KnowledgeStatus, KnowledgeUpsertResult } from './contract/knowledge.ts';
|
|
8
8
|
import { type EmbedDevice } from './models/embed-config.ts';
|
|
9
9
|
import type { DeleteModelSummary } from './models/model-delete.ts';
|
|
@@ -30,21 +30,24 @@ export declare class RemoteHarness extends EventEmitter implements HarnessContra
|
|
|
30
30
|
constructor(transport: Transport, options?: ConnectOptions);
|
|
31
31
|
private _ensure;
|
|
32
32
|
private _open;
|
|
33
|
-
completion(context: CompletionContext | import('./contract-types.ts').ResumeCompletionContext): AsyncIterable<HarnessEvent>;
|
|
33
|
+
completion(context: HostContext<CompletionContext | import('./contract-types.ts').ResumeCompletionContext>): AsyncIterable<HarnessEvent>;
|
|
34
34
|
private _hop;
|
|
35
|
-
invoke(context: InvokeContext): AsyncIterable<HarnessEvent>;
|
|
35
|
+
invoke(context: HostContext<InvokeContext>): AsyncIterable<HarnessEvent>;
|
|
36
36
|
private _run;
|
|
37
|
-
download(context: DownloadContext): AsyncIterable<HarnessEvent>;
|
|
38
|
-
embed(context: EmbedContext): Promise<number[][]>;
|
|
39
|
-
transcribe(context: TranscribeContext): Promise<string>;
|
|
37
|
+
download(context: HostContext<DownloadContext>): AsyncIterable<HarnessEvent>;
|
|
38
|
+
embed(context: HostContext<EmbedContext>): Promise<number[][]>;
|
|
39
|
+
transcribe(context: HostContext<TranscribeContext>): Promise<string>;
|
|
40
40
|
detectLanguage(context: DetectLanguageContext): Promise<DetectedLanguage[]>;
|
|
41
|
-
speak(context: SpeakContext): Promise<SpeakResult>;
|
|
42
|
-
speakStream(context: SpeakStreamContext): AsyncIterable<SpeakResult>;
|
|
41
|
+
speak(context: HostContext<SpeakContext>): Promise<SpeakResult>;
|
|
42
|
+
speakStream(context: HostContext<SpeakStreamContext>): AsyncIterable<SpeakResult>;
|
|
43
43
|
getEmbeddingDevice(): Promise<EmbedDevice>;
|
|
44
44
|
setEmbeddingDevice(device: EmbedDevice): Promise<void>;
|
|
45
45
|
setCredentials(entries: ReadonlyArray<CredentialEntry>): Promise<void>;
|
|
46
46
|
setSkillSettings(entries: ReadonlyArray<SkillSettingEntry>): Promise<void>;
|
|
47
47
|
setModelIdleTimeout(ms: number): Promise<void>;
|
|
48
|
+
setModelMemoryCap(percent: number): Promise<void>;
|
|
49
|
+
memoryUsage(): Promise<MemoryUsage>;
|
|
50
|
+
setDownloadsAllowed({ allowed }: DownloadsAllowedOptions): Promise<void>;
|
|
48
51
|
listManagedSkills(): Promise<ManagedSkill[]>;
|
|
49
52
|
readSkillFile(name: string): Promise<SkillFileContent | null>;
|
|
50
53
|
writeSkillFile(name: string, content: string): Promise<SkillWriteResult>;
|
|
@@ -54,8 +57,8 @@ export declare class RemoteHarness extends EventEmitter implements HarnessContra
|
|
|
54
57
|
previewModelSource(context: PreviewModelSourceContext): Promise<ModelSourcePreview>;
|
|
55
58
|
skills(agentId?: string | null, modelName?: string | null, options?: SkillsOptions): Promise<ResolvedSkillCatalogEntry[]>;
|
|
56
59
|
tools(): Promise<ToolCatalogEntry[]>;
|
|
57
|
-
warmModel(context: WarmModelContext): Promise<void>;
|
|
58
|
-
loadModel(context: LoadModelContext): Promise<LoadModelResult>;
|
|
60
|
+
warmModel(context: HostContext<WarmModelContext>): Promise<void>;
|
|
61
|
+
loadModel(context: HostContext<LoadModelContext>): Promise<LoadModelResult>;
|
|
59
62
|
unloadModel(context: UnloadModelContext): Promise<UnloadModelResult>;
|
|
60
63
|
knowledgeUpsert(artifact: KnowledgeArtifact): Promise<KnowledgeUpsertResult>;
|
|
61
64
|
knowledgeRemove(artifactId: string): Promise<KnowledgeRemoved>;
|
package/dist-lib/lib/connect.js
CHANGED
|
@@ -3,6 +3,7 @@ import { randomBytes } from 'crypto';
|
|
|
3
3
|
import EventEmitter from 'events';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
+
import { HarnessError } from './errors.js';
|
|
6
7
|
import { settleOnClose } from './rpc-session.js';
|
|
7
8
|
import { harnessClient } from '../spec/calls.js';
|
|
8
9
|
import HRPC from '../spec/hrpc/index.js';
|
|
@@ -12,7 +13,7 @@ import { checkGoal, checkMaxToolRounds } from './capabilities/tool-turns.js';
|
|
|
12
13
|
import { Agent } from './agent/index.js';
|
|
13
14
|
import { readModelSourcePreview } from './capabilities/preview-model-source.js';
|
|
14
15
|
import { RunLog } from './run-log/index.js';
|
|
15
|
-
import {
|
|
16
|
+
import { HarnessLog } from './log.js';
|
|
16
17
|
import { assertEmbedDevice } from './models/embed-config.js';
|
|
17
18
|
import { addonTaskType } from './models/model-task.js';
|
|
18
19
|
import { errorCode, errorMessage, isRecord } from './guards.js';
|
|
@@ -104,7 +105,7 @@ export class RemoteHarness extends EventEmitter {
|
|
|
104
105
|
await session.client.setCustomModels({ models: this._customModels });
|
|
105
106
|
}
|
|
106
107
|
catch (err) {
|
|
107
|
-
|
|
108
|
+
HarnessLog.warn('custom model restore failed', { message: errorMessage(err) });
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
return session;
|
|
@@ -135,12 +136,21 @@ export class RemoteHarness extends EventEmitter {
|
|
|
135
136
|
if (context.planMode) {
|
|
136
137
|
payload.planMode = true;
|
|
137
138
|
}
|
|
139
|
+
if (context.deferTools) {
|
|
140
|
+
payload.deferTools = true;
|
|
141
|
+
}
|
|
138
142
|
if (context.parentRunId) {
|
|
139
143
|
payload.parentRunId = context.parentRunId;
|
|
140
144
|
}
|
|
141
145
|
if (context.goal) {
|
|
142
146
|
payload.goal = checkGoal({ ...context.goal }, context.responseFormat);
|
|
143
147
|
}
|
|
148
|
+
if (context.typedText !== undefined) {
|
|
149
|
+
payload.typedText = context.typedText;
|
|
150
|
+
}
|
|
151
|
+
if (context.maxToolRounds !== undefined && context.maxToolRounds !== 0) {
|
|
152
|
+
payload.maxToolRounds = checkMaxToolRounds(context.maxToolRounds);
|
|
153
|
+
}
|
|
144
154
|
yield* this._run({
|
|
145
155
|
type: 'start',
|
|
146
156
|
runId,
|
|
@@ -148,13 +158,11 @@ export class RemoteHarness extends EventEmitter {
|
|
|
148
158
|
model: context.model,
|
|
149
159
|
agent: context.agent ? knobs(context.agent) : undefined,
|
|
150
160
|
cacheKey: context.cacheKey,
|
|
161
|
+
session: context.session,
|
|
151
162
|
thinkingDefault: context.thinkingDefault,
|
|
152
163
|
generationParams: context.generationParams,
|
|
153
164
|
responseFormat: context.responseFormat,
|
|
154
165
|
captureInferenceCalls: context.captureInferenceCalls,
|
|
155
|
-
maxToolRounds: context.maxToolRounds === undefined || context.maxToolRounds === 0
|
|
156
|
-
? undefined
|
|
157
|
-
: checkMaxToolRounds(context.maxToolRounds),
|
|
158
166
|
messages: context.messages?.map(({ role, content, attachments, toolCalls, toolCallId, name, id }) => ({
|
|
159
167
|
role,
|
|
160
168
|
content,
|
|
@@ -326,11 +334,11 @@ export class RemoteHarness extends EventEmitter {
|
|
|
326
334
|
});
|
|
327
335
|
}).catch(noop);
|
|
328
336
|
}
|
|
329
|
-
|
|
337
|
+
HarnessLog.debug('client wire open', { model: context.model, capability: open.capability });
|
|
330
338
|
for await (const event of frames(duplex)) {
|
|
331
339
|
received++;
|
|
332
340
|
if (event.type !== 'content' && event.type !== 'thinking') {
|
|
333
|
-
|
|
341
|
+
HarnessLog.debug('client frame', { type: event.type, n: received });
|
|
334
342
|
}
|
|
335
343
|
if (event.type === 'run-started' || event.type === 'run-resumed') {
|
|
336
344
|
activeRunId = event.runId ?? activeRunId;
|
|
@@ -352,7 +360,7 @@ export class RemoteHarness extends EventEmitter {
|
|
|
352
360
|
send({ type: 'decision', callId, approved: false });
|
|
353
361
|
}
|
|
354
362
|
})
|
|
355
|
-
.catch((err) =>
|
|
363
|
+
.catch((err) => HarnessLog.warn('approval reply failed', { callId, message: errorMessage(err) }));
|
|
356
364
|
continue;
|
|
357
365
|
}
|
|
358
366
|
if (event.type === 'attach-ask') {
|
|
@@ -371,7 +379,7 @@ export class RemoteHarness extends EventEmitter {
|
|
|
371
379
|
});
|
|
372
380
|
}
|
|
373
381
|
})
|
|
374
|
-
.catch((err) =>
|
|
382
|
+
.catch((err) => HarnessLog.warn('attach reply failed', { callId, message: errorMessage(err) }));
|
|
375
383
|
continue;
|
|
376
384
|
}
|
|
377
385
|
if (event.type === 'fetch-ask') {
|
|
@@ -388,7 +396,7 @@ export class RemoteHarness extends EventEmitter {
|
|
|
388
396
|
}
|
|
389
397
|
send({ type: 'fetch-result', callId, message: errorMessage(err) });
|
|
390
398
|
})
|
|
391
|
-
.catch((err) =>
|
|
399
|
+
.catch((err) => HarnessLog.warn('fetch reply failed', { callId, message: errorMessage(err) }));
|
|
392
400
|
continue;
|
|
393
401
|
}
|
|
394
402
|
if (event.type === 'drive-ask') {
|
|
@@ -411,7 +419,7 @@ export class RemoteHarness extends EventEmitter {
|
|
|
411
419
|
});
|
|
412
420
|
}
|
|
413
421
|
})
|
|
414
|
-
.catch((err) =>
|
|
422
|
+
.catch((err) => HarnessLog.warn('drive reply failed', { callId, message: errorMessage(err) }));
|
|
415
423
|
continue;
|
|
416
424
|
}
|
|
417
425
|
if (event.type === 'run-log-append') {
|
|
@@ -435,7 +443,7 @@ export class RemoteHarness extends EventEmitter {
|
|
|
435
443
|
});
|
|
436
444
|
}
|
|
437
445
|
})
|
|
438
|
-
.catch((err) =>
|
|
446
|
+
.catch((err) => HarnessLog.warn('run-log reply failed', { callId, message: errorMessage(err) }));
|
|
439
447
|
continue;
|
|
440
448
|
}
|
|
441
449
|
if (event.type === 'question-ask') {
|
|
@@ -459,7 +467,7 @@ export class RemoteHarness extends EventEmitter {
|
|
|
459
467
|
}
|
|
460
468
|
yield wire;
|
|
461
469
|
}
|
|
462
|
-
|
|
470
|
+
HarnessLog.info('client wire ended', { received });
|
|
463
471
|
}
|
|
464
472
|
catch (err) {
|
|
465
473
|
if (failure) {
|
|
@@ -477,7 +485,7 @@ export class RemoteHarness extends EventEmitter {
|
|
|
477
485
|
throw died(`harness died mid-run: ${errorMessage(err)}`);
|
|
478
486
|
}
|
|
479
487
|
finally {
|
|
480
|
-
|
|
488
|
+
HarnessLog.debug('client run end', { received, aborted: Boolean(context.signal?.aborted) });
|
|
481
489
|
context.signal?.removeEventListener?.('abort', onAbort);
|
|
482
490
|
clearTimeout(pauseTimer);
|
|
483
491
|
duplex?.destroy();
|
|
@@ -494,7 +502,10 @@ export class RemoteHarness extends EventEmitter {
|
|
|
494
502
|
]);
|
|
495
503
|
}
|
|
496
504
|
catch (err) {
|
|
497
|
-
|
|
505
|
+
HarnessLog.info('host run-log release failed', {
|
|
506
|
+
runId: leasedRunId,
|
|
507
|
+
message: errorMessage(err)
|
|
508
|
+
});
|
|
498
509
|
}
|
|
499
510
|
finally {
|
|
500
511
|
clearTimeout(timer);
|
|
@@ -624,6 +635,18 @@ export class RemoteHarness extends EventEmitter {
|
|
|
624
635
|
const { client } = await this._ensure();
|
|
625
636
|
await client.setModelIdleTimeout({ ms });
|
|
626
637
|
}
|
|
638
|
+
async setModelMemoryCap(percent) {
|
|
639
|
+
const { client } = await this._ensure();
|
|
640
|
+
await client.setModelMemoryCap({ percent });
|
|
641
|
+
}
|
|
642
|
+
async memoryUsage() {
|
|
643
|
+
const { client } = await this._ensure();
|
|
644
|
+
return await client.memoryUsage({});
|
|
645
|
+
}
|
|
646
|
+
async setDownloadsAllowed({ allowed }) {
|
|
647
|
+
const { client } = await this._ensure();
|
|
648
|
+
await client.setDownloadsAllowed({ allowed });
|
|
649
|
+
}
|
|
627
650
|
async listManagedSkills() {
|
|
628
651
|
const { client } = await this._ensure();
|
|
629
652
|
const response = await client.listManagedSkills({});
|
|
@@ -699,6 +722,7 @@ export class RemoteHarness extends EventEmitter {
|
|
|
699
722
|
}));
|
|
700
723
|
return {
|
|
701
724
|
name: skill.name,
|
|
725
|
+
displayName: skill.displayName || undefined,
|
|
702
726
|
description: skill.description,
|
|
703
727
|
tools: skill.tools ?? [],
|
|
704
728
|
credentials: skill.credentials ?? [],
|
|
@@ -792,9 +816,10 @@ export class RemoteHarness extends EventEmitter {
|
|
|
792
816
|
cachedOnly: options.cachedOnly,
|
|
793
817
|
fullRegistry: options.fullRegistry
|
|
794
818
|
});
|
|
795
|
-
return (response.models ?? []).map(({ actualSize, label, fit, fitBasis, fitEvidence, ...row }) => ({
|
|
819
|
+
return (response.models ?? []).map(({ actualSize, memoryBytes, label, fit, fitBasis, fitEvidence, ...row }) => ({
|
|
796
820
|
...row,
|
|
797
821
|
actualSize: actualSize || undefined,
|
|
822
|
+
memoryBytes: memoryBytes || undefined,
|
|
798
823
|
label: label || undefined,
|
|
799
824
|
taskType: addonTaskType(row.type),
|
|
800
825
|
fit: (fit || undefined),
|
|
@@ -945,10 +970,10 @@ function abortable(promise, signal) {
|
|
|
945
970
|
return new Promise((resolve, reject) => {
|
|
946
971
|
if (signal.aborted) {
|
|
947
972
|
promise.then(noop, noop);
|
|
948
|
-
reject(new
|
|
973
|
+
reject(new HarnessError('EMBED_ABORTED'));
|
|
949
974
|
return;
|
|
950
975
|
}
|
|
951
|
-
const onAbort = () => reject(new
|
|
976
|
+
const onAbort = () => reject(new HarnessError('EMBED_ABORTED'));
|
|
952
977
|
signal.addEventListener?.('abort', onAbort, { once: true });
|
|
953
978
|
promise.then(resolve, reject).finally(() => signal.removeEventListener?.('abort', onAbort));
|
|
954
979
|
});
|
|
@@ -972,7 +997,7 @@ function knobs(agent) {
|
|
|
972
997
|
imageHeight: agent.imageHeight ?? undefined,
|
|
973
998
|
approvalMode: agent.approvalMode ?? undefined,
|
|
974
999
|
disabledToolsets: agent.disabledToolsets ?? undefined,
|
|
975
|
-
|
|
1000
|
+
policy: agent.policy ?? undefined,
|
|
976
1001
|
handoffs: agent.handoffs?.map(({ id, description }) => ({ id, description })),
|
|
977
1002
|
plan: agent.plan ?? undefined,
|
|
978
1003
|
model: agent.model ?? undefined
|
|
@@ -1083,6 +1108,7 @@ const DriveRequestSchema = z.discriminatedUnion('op', [
|
|
|
1083
1108
|
driveKey: z.string(),
|
|
1084
1109
|
folder: z.string(),
|
|
1085
1110
|
skip: z.array(z.string()),
|
|
1111
|
+
recursive: z.boolean(),
|
|
1086
1112
|
limit: z.number(),
|
|
1087
1113
|
cursor: z.string().nullable()
|
|
1088
1114
|
}),
|
|
@@ -1092,6 +1118,18 @@ const DriveRequestSchema = z.discriminatedUnion('op', [
|
|
|
1092
1118
|
key: z.string(),
|
|
1093
1119
|
path: z.string(),
|
|
1094
1120
|
executable: z.boolean().optional()
|
|
1121
|
+
}),
|
|
1122
|
+
z.looseObject({
|
|
1123
|
+
op: z.literal('search'),
|
|
1124
|
+
driveKey: z.string(),
|
|
1125
|
+
folder: z.string(),
|
|
1126
|
+
queries: z.array(z.string()),
|
|
1127
|
+
regex: z.boolean(),
|
|
1128
|
+
caseSensitive: z.boolean(),
|
|
1129
|
+
includeIgnored: z.boolean(),
|
|
1130
|
+
maxMatches: z.number(),
|
|
1131
|
+
maxEntries: z.number(),
|
|
1132
|
+
maxMs: z.number()
|
|
1095
1133
|
})
|
|
1096
1134
|
]);
|
|
1097
1135
|
async function bridgeDrive(event, context) {
|
|
@@ -1128,7 +1166,7 @@ function answerQuestion(event, { askUser, reply }) {
|
|
|
1128
1166
|
options: Array.isArray(event.options) ? event.options.map(String) : undefined
|
|
1129
1167
|
}))
|
|
1130
1168
|
.then((answer) => reply({ type: 'question-result', callId, answer: answer ?? '' }), (err) => reply({ type: 'question-result', callId, message: errorMessage(err) }))
|
|
1131
|
-
.catch((err) =>
|
|
1169
|
+
.catch((err) => HarnessLog.warn('question reply failed', { callId, message: errorMessage(err) }));
|
|
1132
1170
|
}
|
|
1133
1171
|
async function bridgeRunLog({ event, context, runId, generation }) {
|
|
1134
1172
|
if (!context.runLog || !generation) {
|
|
@@ -1167,7 +1205,7 @@ function releaseLateHostLease(pending, runLog, runId) {
|
|
|
1167
1205
|
}
|
|
1168
1206
|
await runLog.release(runId, lease.generation);
|
|
1169
1207
|
})
|
|
1170
|
-
.catch((err) =>
|
|
1208
|
+
.catch((err) => HarnessLog.info('aborted run-log begin cleanup failed', {
|
|
1171
1209
|
runId,
|
|
1172
1210
|
message: errorMessage(err)
|
|
1173
1211
|
}));
|
|
@@ -1256,15 +1294,15 @@ async function* frames(stream) {
|
|
|
1256
1294
|
let error = null;
|
|
1257
1295
|
stream.on('data', (frame) => queue.push(frame));
|
|
1258
1296
|
stream.on('end', () => {
|
|
1259
|
-
|
|
1297
|
+
HarnessLog.debug('client stream event', { event: 'end' });
|
|
1260
1298
|
queue.end();
|
|
1261
1299
|
});
|
|
1262
1300
|
stream.on('close', () => {
|
|
1263
|
-
|
|
1301
|
+
HarnessLog.debug('client stream event', { event: 'close' });
|
|
1264
1302
|
queue.end();
|
|
1265
1303
|
});
|
|
1266
1304
|
stream.on('error', (err) => {
|
|
1267
|
-
|
|
1305
|
+
HarnessLog.warn('client stream event', { event: 'error', err: err.message });
|
|
1268
1306
|
error = err;
|
|
1269
1307
|
queue.end();
|
|
1270
1308
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Message } from './contract/index.ts';
|
|
2
2
|
export declare const TOOL_RESULT_TRUNCATION_MARKER = "\n[tool result truncated for context]\n";
|
|
3
|
+
export declare const TOOL_SEARCH_RESULT = "{\"tool_search\":";
|
|
3
4
|
export declare function compactedFrom(message: Message): Message | undefined;
|
|
4
5
|
export interface ContextCandidate {
|
|
5
6
|
history: Message[];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { Fold } from './fold/index.js';
|
|
1
2
|
export const TOOL_RESULT_TRUNCATION_MARKER = '\n[tool result truncated for context]\n';
|
|
2
|
-
const TOOL_SEARCH_RESULT = '{"tool_search":';
|
|
3
|
+
export const TOOL_SEARCH_RESULT = '{"tool_search":';
|
|
3
4
|
const compactedSources = new WeakMap();
|
|
4
5
|
export function compactedFrom(message) {
|
|
5
6
|
return compactedSources.get(message);
|
|
6
7
|
}
|
|
7
8
|
export function contextCandidates(history, ...nudges) {
|
|
8
|
-
const isBoundary = (message) => message
|
|
9
|
-
!nudges.some((nudge) => message.content === nudge || message.content.startsWith(`${nudge}\nPlan:\n`));
|
|
9
|
+
const isBoundary = (message) => Fold.isTurn(message, nudges);
|
|
10
10
|
const { prefix, turns } = splitTurns(history, isBoundary);
|
|
11
11
|
if (!turns.length) {
|
|
12
12
|
return [{ history, droppedTurns: 0 }];
|
|
@@ -2,6 +2,7 @@ import type { LlmGenerationParams } from '../models/llm-presets.ts';
|
|
|
2
2
|
import type { DriveRoot } from '../tools/fs/scope.ts';
|
|
3
3
|
import type { CliValidator } from '../tools/skills/cli-schema-types.ts';
|
|
4
4
|
import type { AgentConfig, ResponseFormat, ToolDefinition } from './completion.ts';
|
|
5
|
+
import type { CompiledPolicy } from './policy.ts';
|
|
5
6
|
import type { Message } from './run.ts';
|
|
6
7
|
export type { LlmGenerationParams };
|
|
7
8
|
export interface AgentSkill {
|
|
@@ -22,7 +23,6 @@ export interface SkillActivation {
|
|
|
22
23
|
loadedSkills: ReadonlySet<string>;
|
|
23
24
|
}
|
|
24
25
|
export interface AgentPolicy {
|
|
25
|
-
readonly sandbox: boolean;
|
|
26
26
|
readonly skipApprovals: boolean;
|
|
27
27
|
}
|
|
28
28
|
export interface AgentPorts<Skill extends AgentSkill = AgentSkill> {
|
|
@@ -32,16 +32,18 @@ export interface AgentPorts<Skill extends AgentSkill = AgentSkill> {
|
|
|
32
32
|
toolNames: readonly string[];
|
|
33
33
|
skills: readonly Skill[];
|
|
34
34
|
}): SystemPromptParts;
|
|
35
|
-
mention(
|
|
36
|
-
implicitSkill(
|
|
35
|
+
mention(text: string, skills: readonly Skill[]): Skill | null;
|
|
36
|
+
implicitSkill(text: string, skills: readonly Skill[]): Skill | null;
|
|
37
37
|
}
|
|
38
38
|
export interface AgentRequest<Skill extends AgentSkill = AgentSkill> {
|
|
39
39
|
readonly agent: AgentConfig | undefined;
|
|
40
40
|
readonly model: string | undefined;
|
|
41
|
+
readonly capabilityProfile?: string | undefined;
|
|
41
42
|
readonly thinkingDefault?: string | undefined;
|
|
42
43
|
readonly generationParams?: LlmGenerationParams | undefined;
|
|
43
44
|
readonly responseFormat?: ResponseFormat | undefined;
|
|
44
45
|
readonly messages: readonly Message[];
|
|
46
|
+
readonly userText: string;
|
|
45
47
|
readonly tools: readonly ToolDefinition[];
|
|
46
48
|
readonly skills: readonly Skill[];
|
|
47
49
|
readonly loadedSkills: ReadonlySet<string>;
|
|
@@ -49,6 +51,7 @@ export interface AgentRequest<Skill extends AgentSkill = AgentSkill> {
|
|
|
49
51
|
readonly fsWriteRoots: readonly DriveRoot[];
|
|
50
52
|
readonly planning?: boolean;
|
|
51
53
|
readonly planMode?: boolean;
|
|
54
|
+
readonly policy?: CompiledPolicy;
|
|
52
55
|
}
|
|
53
56
|
export interface ResolvedAgent<Skill extends AgentSkill = AgentSkill> {
|
|
54
57
|
readonly enabled: ToolDefinition[];
|
|
@@ -62,4 +65,5 @@ export interface ResolvedAgent<Skill extends AgentSkill = AgentSkill> {
|
|
|
62
65
|
readonly generationParams: LlmGenerationParams | undefined;
|
|
63
66
|
readonly policy: AgentPolicy;
|
|
64
67
|
select(loadedSkills: ReadonlySet<string>): ToolDefinition[];
|
|
68
|
+
systemFor(loadedSkills: ReadonlySet<string>): SystemPromptParts;
|
|
65
69
|
}
|