@qvac/harness 1.0.0-rc.3 → 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 +44 -31
- 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 +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
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import '../../index.js';
|
|
10
|
+
import '../plugins/index.js';
|
|
11
|
+
import '../plugins/context.js';
|
|
12
|
+
import '../helpers/race-abort.js';
|
|
13
|
+
import fs from 'fs';
|
|
14
|
+
import { homedir } from 'os';
|
|
15
|
+
import { join } from 'path';
|
|
16
|
+
import process from 'process';
|
|
17
|
+
import { pathToFileURL } from 'url';
|
|
18
|
+
import { errorMessage, isRecord } from '../guards.js';
|
|
19
|
+
export function userConfigDir(env = process.env) {
|
|
20
|
+
return join(env['HOME'] ?? env['USERPROFILE'] ?? homedir(), '.config', 'qv-ac');
|
|
21
|
+
}
|
|
22
|
+
export async function loadUserPlugins(dir, leftOut) {
|
|
23
|
+
const entries = await readConfig(join(dir, 'config.json'), leftOut);
|
|
24
|
+
if (entries.length === 0) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const imports = await sharedImports();
|
|
28
|
+
const plugins = [];
|
|
29
|
+
for (const listed of entries) {
|
|
30
|
+
try {
|
|
31
|
+
plugins.push(await userPlugin(join(dir, 'plugins'), entryOf(listed), imports));
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
leftOut(isRecord(listed) ? String(listed['name']) : String(listed), errorMessage(err));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return plugins;
|
|
38
|
+
}
|
|
39
|
+
async function readConfig(path, leftOut) {
|
|
40
|
+
let text;
|
|
41
|
+
try {
|
|
42
|
+
text = await fs.promises.readFile(path, 'utf8');
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const config = JSON.parse(text);
|
|
49
|
+
const plugins = isRecord(config) ? config['plugins'] : undefined;
|
|
50
|
+
if (!Array.isArray(plugins)) {
|
|
51
|
+
throw new Error('plugins: a list of names or { name, options, read }');
|
|
52
|
+
}
|
|
53
|
+
return plugins;
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
leftOut(path, errorMessage(err));
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function entryOf(listed) {
|
|
61
|
+
if (typeof listed === 'string') {
|
|
62
|
+
return { name: listed };
|
|
63
|
+
}
|
|
64
|
+
if (!isRecord(listed) || typeof listed['name'] !== 'string') {
|
|
65
|
+
throw new Error('an entry is a name or { name, options, read }');
|
|
66
|
+
}
|
|
67
|
+
const read = listed['read'];
|
|
68
|
+
if (read !== undefined && !(Array.isArray(read) && read.every((r) => typeof r === 'string'))) {
|
|
69
|
+
throw new Error('read: a list of tool names');
|
|
70
|
+
}
|
|
71
|
+
return { name: listed['name'], options: listed['options'], read };
|
|
72
|
+
}
|
|
73
|
+
async function userPlugin(pluginsDir, { name, options, read = [] }, imports) {
|
|
74
|
+
const self = Reflect.get(import.meta, 'cache')[import.meta.url];
|
|
75
|
+
const Module = Reflect.get(self, 'constructor');
|
|
76
|
+
const url = Module.resolveSync(`./${name}`, pathToFileURL(pluginsDir + '/'), 'import', {
|
|
77
|
+
referrer: self
|
|
78
|
+
});
|
|
79
|
+
const made = (await Module.load(url, { referrer: self, imports })).exports.default;
|
|
80
|
+
const context = { options };
|
|
81
|
+
const plugin = typeof made === 'function' ? await made(context) : made;
|
|
82
|
+
if (!isPlugin(plugin)) {
|
|
83
|
+
throw new Error('its default export is not a plugin, nor a function that returns one');
|
|
84
|
+
}
|
|
85
|
+
if (plugin.addons && Object.keys(plugin.addons).length > 0) {
|
|
86
|
+
throw new Error('declares addons, which a user plugin may not load');
|
|
87
|
+
}
|
|
88
|
+
plugin.read = read;
|
|
89
|
+
return plugin;
|
|
90
|
+
}
|
|
91
|
+
const BUILTINS = ['fs', 'os', 'crypto', 'process', 'url', 'path', 'events'];
|
|
92
|
+
async function sharedImports() {
|
|
93
|
+
const raceAbort = import.meta.resolve('../helpers/race-abort.ts');
|
|
94
|
+
const targets = {
|
|
95
|
+
...Object.fromEntries(BUILTINS.map((name) => [name, import.meta.resolve(name)])),
|
|
96
|
+
'@qvac/harness': import.meta.resolve('../../index.ts'),
|
|
97
|
+
'@qvac/harness/plugins': import.meta.resolve('../plugins/index.ts'),
|
|
98
|
+
'@qvac/harness/plugins/context': import.meta.resolve('../plugins/context.ts'),
|
|
99
|
+
'@qvac/harness/race-abort': raceAbort,
|
|
100
|
+
'@qvac/harness/lib/helpers/race-abort.ts': raceAbort,
|
|
101
|
+
'@qvac/sdk': import.meta.resolve('#sdk')
|
|
102
|
+
};
|
|
103
|
+
const imports = {};
|
|
104
|
+
for (const [specifier, href] of Object.entries(targets)) {
|
|
105
|
+
imports[specifier] = await reexport(href);
|
|
106
|
+
}
|
|
107
|
+
return imports;
|
|
108
|
+
}
|
|
109
|
+
async function reexport(href) {
|
|
110
|
+
const target = await import(__rewriteRelativeImportExtension(href));
|
|
111
|
+
const from = JSON.stringify(href);
|
|
112
|
+
const source = `export * from ${from}\n` + ('default' in target ? `export { default } from ${from}\n` : '');
|
|
113
|
+
return `data:text/javascript,${encodeURIComponent(source)}`;
|
|
114
|
+
}
|
|
115
|
+
function isPlugin(value) {
|
|
116
|
+
return (isRecord(value) && typeof value['name'] === 'string' && typeof value['setup'] === 'function');
|
|
117
|
+
}
|
|
@@ -39,6 +39,7 @@ export declare class SkillsHost {
|
|
|
39
39
|
setCredentials(entries: ReadonlyArray<CredentialEntry>): void;
|
|
40
40
|
setSkillSettings(entries: ReadonlyArray<SkillSettingEntry>): void;
|
|
41
41
|
skillSettings(skill: string, agentId?: string | null): Record<string, string>;
|
|
42
|
+
skillEnv(skill: string): Readonly<Record<string, string>> | undefined;
|
|
42
43
|
listManagedSkills(): Promise<ManagedSkill[]>;
|
|
43
44
|
readSkillFile(name: string): Promise<SkillFileContent | null>;
|
|
44
45
|
writeSkillFile(name: string, content: string): Promise<SkillWriteResult>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import process from 'process';
|
|
2
|
+
import { HarnessError } from '../errors.js';
|
|
2
3
|
import { errorMessage } from '../guards.js';
|
|
3
|
-
import {
|
|
4
|
+
import { HarnessLog } from '../log.js';
|
|
4
5
|
import { modelNameToCapabilityProfile } from '../models/model-catalog.js';
|
|
5
6
|
import { probeBinVersions } from '../tools/skills/bin-check.js';
|
|
6
7
|
import { ensureBundledSkillsDir } from '../tools/skills/bundled-dir.js';
|
|
@@ -86,6 +87,9 @@ export class SkillsHost {
|
|
|
86
87
|
...(agentId ? this._settings.get(settingsScopeKey(skill, agentId)) : undefined)
|
|
87
88
|
};
|
|
88
89
|
}
|
|
90
|
+
skillEnv(skill) {
|
|
91
|
+
return this._allSkills.find((entry) => entry.name === skill)?.env;
|
|
92
|
+
}
|
|
89
93
|
async listManagedSkills() {
|
|
90
94
|
return listManagedSkills(await this._baseDir(), await ensureSkillsOverlayDir());
|
|
91
95
|
}
|
|
@@ -178,7 +182,7 @@ export class SkillsHost {
|
|
|
178
182
|
async _overlayDir() {
|
|
179
183
|
const overlay = await ensureSkillsOverlayDir();
|
|
180
184
|
if (!overlay) {
|
|
181
|
-
throw new
|
|
185
|
+
throw new HarnessError('NO_SKILLS_OVERLAY');
|
|
182
186
|
}
|
|
183
187
|
return overlay;
|
|
184
188
|
}
|
|
@@ -200,11 +204,11 @@ export class SkillsHost {
|
|
|
200
204
|
return;
|
|
201
205
|
}
|
|
202
206
|
this._watcher = watchSkillsOverlay(overlay, () => {
|
|
203
|
-
this._reload().catch((err) =>
|
|
207
|
+
this._reload().catch((err) => HarnessLog.warn('overlay reload failed', { err: errorMessage(err) }));
|
|
204
208
|
});
|
|
205
209
|
}
|
|
206
210
|
catch (err) {
|
|
207
|
-
|
|
211
|
+
HarnessLog.warn('overlay watch unavailable', { err: errorMessage(err) });
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
214
|
async _probeBinVersions(platform, refresh) {
|
package/dist-lib/lib/spawn.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { SdkStorage } from './storage.ts';
|
|
|
2
2
|
import { type StowIpc, type StowRunner } from 'bare-supervisor/stow';
|
|
3
3
|
import type { ChildSpec } from 'bare-supervisor';
|
|
4
4
|
import { type RemoteHarness } from './connect.ts';
|
|
5
|
+
import { type HostLogger } from './log.ts';
|
|
5
6
|
import { type EmbedDevice } from './models/embed-config.ts';
|
|
6
7
|
import type { LlamaLoadKnobs } from './models/model-pool.ts';
|
|
7
8
|
import type { ImageClamps, ImageModelSet, MusicClamps, MusicModelStages } from './models/model-catalog.ts';
|
|
@@ -9,10 +10,7 @@ export type MusicModelArg = string | (MusicModelStages & {
|
|
|
9
10
|
inferenceSteps?: number;
|
|
10
11
|
useGpu?: boolean;
|
|
11
12
|
});
|
|
12
|
-
export
|
|
13
|
-
info(...args: unknown[]): void;
|
|
14
|
-
warn(...args: unknown[]): void;
|
|
15
|
-
}
|
|
13
|
+
export type Logger = HostLogger;
|
|
16
14
|
export interface HarnessLlmConfig {
|
|
17
15
|
llmDevice?: 'cpu' | 'gpu';
|
|
18
16
|
llmGpuLayers?: number;
|
|
@@ -51,6 +49,7 @@ export interface HarnessPluginOptions {
|
|
|
51
49
|
mcp?: {
|
|
52
50
|
servers?: HarnessMcpServer[];
|
|
53
51
|
};
|
|
52
|
+
[name: string]: unknown;
|
|
54
53
|
}
|
|
55
54
|
export interface HarnessChildOptions {
|
|
56
55
|
runner: StowRunner;
|
package/dist-lib/lib/spawn.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { HarnessError } from './errors.js';
|
|
1
2
|
import stowChild, {} from 'bare-supervisor/stow';
|
|
2
3
|
import { connectHarness } from './connect.js';
|
|
3
|
-
import {
|
|
4
|
+
import { HarnessLog } from './log.js';
|
|
4
5
|
import { createEmbedConfig } from './models/embed-config.js';
|
|
5
6
|
export function harnessChild(entry, opts) {
|
|
6
7
|
if (opts.logger) {
|
|
7
|
-
|
|
8
|
+
HarnessLog.toHost(opts.logger);
|
|
8
9
|
}
|
|
9
10
|
const { runner, skillsDir, gpuStats, wheelsDir, sdkStorage, embedDevice, embedGpuLayers, embedBatchSize, imageModel, imageClamps, musicModel, musicClamps, llm, knowledge, pluginOptions, onIpc, logger = null, ...spec } = opts;
|
|
10
11
|
const embedConfig = createEmbedConfig({
|
|
@@ -21,7 +22,7 @@ export function harnessChild(entry, opts) {
|
|
|
21
22
|
JSON.stringify(embedConfig),
|
|
22
23
|
imageModel ? JSON.stringify(imageModel) : '',
|
|
23
24
|
imageClamps ? JSON.stringify(imageClamps) : '',
|
|
24
|
-
logger
|
|
25
|
+
logSlot(logger),
|
|
25
26
|
llm ? JSON.stringify(llm) : '',
|
|
26
27
|
musicModel ? JSON.stringify(musicModel) : '',
|
|
27
28
|
musicClamps ? JSON.stringify(musicClamps) : '',
|
|
@@ -40,7 +41,7 @@ export function harnessChild(entry, opts) {
|
|
|
40
41
|
export function spawnHarness(opts) {
|
|
41
42
|
const logger = opts.logger ?? null;
|
|
42
43
|
if (logger) {
|
|
43
|
-
|
|
44
|
+
HarnessLog.toHost(logger);
|
|
44
45
|
}
|
|
45
46
|
const embedConfig = createEmbedConfig({
|
|
46
47
|
device: opts.embedDevice,
|
|
@@ -48,16 +49,14 @@ export function spawnHarness(opts) {
|
|
|
48
49
|
batchSize: opts.embedBatchSize
|
|
49
50
|
});
|
|
50
51
|
return connectHarness(async () => {
|
|
51
|
-
const { default:
|
|
52
|
-
const
|
|
53
|
-
const IPC = Reflect.get(stowHost, 'IPC');
|
|
54
|
-
const sidecar = new Sidecar(opts.entry, [
|
|
52
|
+
const { default: launch } = await import('bare-supervisor/runner/sidecar');
|
|
53
|
+
const { ipc, exit } = launch(opts.entry, [
|
|
55
54
|
opts.skillsDir ?? '',
|
|
56
55
|
JSON.stringify(opts.sdkStorage),
|
|
57
56
|
JSON.stringify(embedConfig),
|
|
58
57
|
opts.imageModel ? JSON.stringify(opts.imageModel) : '',
|
|
59
58
|
opts.imageClamps ? JSON.stringify(opts.imageClamps) : '',
|
|
60
|
-
logger
|
|
59
|
+
logSlot(logger),
|
|
61
60
|
opts.llm ? JSON.stringify(opts.llm) : '',
|
|
62
61
|
opts.musicModel ? JSON.stringify(opts.musicModel) : '',
|
|
63
62
|
opts.musicClamps ? JSON.stringify(opts.musicClamps) : '',
|
|
@@ -65,17 +64,18 @@ export function spawnHarness(opts) {
|
|
|
65
64
|
opts.gpuStats === undefined ? '' : JSON.stringify(opts.gpuStats),
|
|
66
65
|
opts.knowledge ? JSON.stringify(opts.knowledge) : '',
|
|
67
66
|
opts.pluginOptions ? JSON.stringify(opts.pluginOptions) : ''
|
|
68
|
-
]);
|
|
69
|
-
|
|
70
|
-
sidecar.stderr.on('data', (data) => logger?.warn('harness', data.toString().trimEnd()));
|
|
71
|
-
const ipc = new IPC(sidecar);
|
|
72
|
-
const died = new Promise((resolve) => {
|
|
73
|
-
sidecar.once('exit', (code) => resolve(`harness exited (${code}) before ready`));
|
|
74
|
-
});
|
|
67
|
+
], logger);
|
|
68
|
+
const died = exit.then((code) => new HarnessError('HARNESS_EXITED_BEFORE_READY', [code]));
|
|
75
69
|
const failure = await Promise.race([ipc.ready.then(() => null), died]);
|
|
76
70
|
if (failure) {
|
|
77
|
-
throw
|
|
71
|
+
throw failure;
|
|
78
72
|
}
|
|
79
73
|
return ipc;
|
|
80
74
|
});
|
|
81
75
|
}
|
|
76
|
+
function logSlot(logger) {
|
|
77
|
+
if (!logger)
|
|
78
|
+
return '';
|
|
79
|
+
const level = logger.getLevel?.();
|
|
80
|
+
return HarnessLog.isLevel(level) ? level : '1';
|
|
81
|
+
}
|
package/dist-lib/lib/spill.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export interface SpillOptions {
|
|
|
7
7
|
readonly maxBytes?: number;
|
|
8
8
|
}
|
|
9
9
|
export declare function runSpill(runId: string, { root, maxBytes }?: SpillOptions): ToolSpill | undefined;
|
|
10
|
+
export declare function reserveSpillFile(dir: string, name: string, stream: string): Promise<string>;
|
|
10
11
|
export declare function removeRun(runId: string, root?: string): Promise<void>;
|
|
11
12
|
export declare function sweepSpill(now?: number, root?: string): void;
|
package/dist-lib/lib/spill.js
CHANGED
|
@@ -16,22 +16,26 @@ export function runSpill(runId, { root = SPILL_DIR, maxBytes = SPILL_MAX_BYTES }
|
|
|
16
16
|
}
|
|
17
17
|
return {
|
|
18
18
|
dir,
|
|
19
|
-
sink: (stream) => createSink(
|
|
19
|
+
sink: (stream) => createSink(dir, stream, maxBytes)
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
export async function reserveSpillFile(dir, name, stream) {
|
|
23
|
+
await fs.promises.mkdir(dir, { recursive: true, mode: 0o700 });
|
|
24
|
+
await fs.promises.mkdir(path.join(dir, name), { mode: 0o700 });
|
|
25
|
+
return path.join(dir, name, `${stream}.txt`);
|
|
26
|
+
}
|
|
27
|
+
function createSink(dir, stream, maxBytes) {
|
|
28
|
+
let file = null;
|
|
23
29
|
let written = 0;
|
|
24
30
|
let failed = false;
|
|
25
31
|
let closed = false;
|
|
26
32
|
let pending = Promise.resolve();
|
|
27
|
-
const append = (bytes
|
|
33
|
+
const append = (bytes) => async () => {
|
|
28
34
|
if (failed)
|
|
29
35
|
return;
|
|
30
36
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
await fs.promises.appendFile(file, bytes, { mode: 0o600, flag: first ? 'wx' : 'a' });
|
|
37
|
+
file ??= await reserveSpillFile(dir, b4a.toHex(randomBytes(8)), stream);
|
|
38
|
+
await fs.promises.appendFile(file, bytes, { mode: 0o600, flag: 'a' });
|
|
35
39
|
}
|
|
36
40
|
catch {
|
|
37
41
|
failed = true;
|
|
@@ -42,7 +46,7 @@ function createSink(file, maxBytes) {
|
|
|
42
46
|
if (closed || written >= maxBytes || !text)
|
|
43
47
|
return;
|
|
44
48
|
const bytes = b4a.from(text).subarray(0, maxBytes - written);
|
|
45
|
-
pending = pending.then(append(bytes
|
|
49
|
+
pending = pending.then(append(bytes));
|
|
46
50
|
written += bytes.byteLength;
|
|
47
51
|
},
|
|
48
52
|
async close() {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { HarnessError } from '../../errors.js';
|
|
3
4
|
import { errorMessage } from '../../guards.js';
|
|
4
|
-
import {
|
|
5
|
+
import { HarnessLog } from '../../log.js';
|
|
5
6
|
import { checkOutputBytes, MAX_INPUT_TOTAL_BYTES, RUN_OUTPUT_BUDGET_BYTES } from './output-policy.js';
|
|
6
7
|
const STAGE_TIMEOUT_MS = 60_000;
|
|
7
|
-
const STAGE_TIMEOUT_MESSAGE = `staging attachments timed out after ${STAGE_TIMEOUT_MS}ms`;
|
|
8
8
|
const OVER_BUDGET_ERROR = 'inputs exceed maximum total size';
|
|
9
9
|
const NO_UPLOAD_ERROR = 'no uploaded image in this chat — attach an image or pass an attachmentId';
|
|
10
10
|
const DOCUMENT_INPUT = /\.(pdf|docx?|xlsx?|xlsm|pptx?|csv|tsv|txt|md|markdown|rtf|odt|ods|odp|epub|jsonl?|xhtml|html?|xml|ya?ml|log|zip)$/i;
|
|
11
11
|
const NO_DOCUMENT_ERROR = 'an id-less input stages an uploaded image, and this path names a document — pass its ' +
|
|
12
12
|
'attachmentId, which the [Attached file "…"] line on the user\'s message carries';
|
|
13
|
-
function bounded(work, ms
|
|
13
|
+
function bounded(work, ms) {
|
|
14
14
|
let timer;
|
|
15
15
|
const bound = new Promise((_, reject) => {
|
|
16
|
-
timer = setTimeout(() => reject(new
|
|
16
|
+
timer = setTimeout(() => reject(new HarnessError('ATTACHMENT_STAGING_TIMED_OUT', [STAGE_TIMEOUT_MS])), ms);
|
|
17
17
|
});
|
|
18
18
|
return Promise.race([work, bound]).finally(() => {
|
|
19
19
|
if (timer) {
|
|
@@ -54,14 +54,14 @@ async function probeUpload(fetchAttachment, input, { index, turnImages, signal,
|
|
|
54
54
|
if (DOCUMENT_INPUT.test(input.path)) {
|
|
55
55
|
return { error: NO_DOCUMENT_ERROR };
|
|
56
56
|
}
|
|
57
|
-
const bytes = await bounded(uploadedBytes(fetchAttachment, index, { turnImages, signal }), deadline - Date.now()
|
|
57
|
+
const bytes = await bounded(uploadedBytes(fetchAttachment, index, { turnImages, signal }), deadline - Date.now());
|
|
58
58
|
if ('error' in bytes) {
|
|
59
59
|
return bytes;
|
|
60
60
|
}
|
|
61
61
|
return { size: bytes.byteLength, bytes };
|
|
62
62
|
}
|
|
63
63
|
async function probeAttachment(fetchAttachment, id, { signal, deadline }) {
|
|
64
|
-
const head = await bounded(fetchAttachment({ attachmentId: id, meta: true, signal }), deadline - Date.now()
|
|
64
|
+
const head = await bounded(fetchAttachment({ attachmentId: id, meta: true, signal }), deadline - Date.now());
|
|
65
65
|
if (!head) {
|
|
66
66
|
return { error: `attachment ${id} not found in this chat` };
|
|
67
67
|
}
|
|
@@ -90,7 +90,7 @@ export async function stageInputs(fetchAttachment, inputs, opts = {}) {
|
|
|
90
90
|
}
|
|
91
91
|
total += probe.size;
|
|
92
92
|
if (total > MAX_INPUT_TOTAL_BYTES) {
|
|
93
|
-
|
|
93
|
+
HarnessLog.warn('input attachments over budget; skipping blob download', {
|
|
94
94
|
total,
|
|
95
95
|
cap: MAX_INPUT_TOTAL_BYTES,
|
|
96
96
|
count: inputs.length
|
|
@@ -111,7 +111,7 @@ export async function stageInputs(fetchAttachment, inputs, opts = {}) {
|
|
|
111
111
|
for (const { index, input } of pending) {
|
|
112
112
|
const id = input.attachmentId;
|
|
113
113
|
try {
|
|
114
|
-
const fetched = await bounded(fetchAttachment({ attachmentId: id, signal }), deadline - Date.now()
|
|
114
|
+
const fetched = await bounded(fetchAttachment({ attachmentId: id, signal }), deadline - Date.now());
|
|
115
115
|
if (!fetched || !hasBytes(fetched)) {
|
|
116
116
|
return { error: `attachment ${id} not found in this chat` };
|
|
117
117
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import process from 'process';
|
|
3
|
+
import { HarnessError } from '../../errors.js';
|
|
3
4
|
import { headTail, joinHeadTail } from '../../helpers/head-tail.js';
|
|
4
5
|
import { AbortedError } from '../../helpers/race-abort.js';
|
|
5
6
|
export const DEFAULT_TIMEOUT_MS = 120_000;
|
|
@@ -108,7 +109,7 @@ export function runCommand(command, options) {
|
|
|
108
109
|
};
|
|
109
110
|
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
110
111
|
const timer = setTimeout(() => {
|
|
111
|
-
finish(() => reject(new
|
|
112
|
+
finish(() => reject(new HarnessError('COMMAND_TIMED_OUT', [timeoutMs])));
|
|
112
113
|
terminateProcessTree(child, options.killProcess);
|
|
113
114
|
}, timeoutMs);
|
|
114
115
|
child.stdout?.on('data', (chunk) => appendOutput(stdout, chunk));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare function bareBin(token: string): string | null;
|
|
2
|
-
export declare function firstCommandToken(command: string): string;
|
|
3
2
|
export declare function escapeLiteralDollars(command: string): string;
|
|
4
3
|
export declare const SHELL_EXPANSION_ERROR: string;
|
|
5
4
|
export declare function sanitizeCommand(command: string): string | null;
|
|
@@ -1,61 +1,9 @@
|
|
|
1
|
+
import { ShellLine } from './shell-line.js';
|
|
1
2
|
export function bareBin(token) {
|
|
2
3
|
if (!token || /[/\\~$]/.test(token))
|
|
3
4
|
return null;
|
|
4
5
|
return token.replace(/\.exe$/i, '').toLowerCase();
|
|
5
6
|
}
|
|
6
|
-
export function firstCommandToken(command) {
|
|
7
|
-
const chars = [...command];
|
|
8
|
-
let i = 0;
|
|
9
|
-
while (i < chars.length && (chars[i] === ' ' || chars[i] === '\t')) {
|
|
10
|
-
i++;
|
|
11
|
-
}
|
|
12
|
-
let token = '';
|
|
13
|
-
while (i < chars.length) {
|
|
14
|
-
const c = chars[i];
|
|
15
|
-
if (c === '"' || c === "'") {
|
|
16
|
-
const quote = c;
|
|
17
|
-
i++;
|
|
18
|
-
while (i < chars.length && chars[i] !== quote) {
|
|
19
|
-
token += chars[i];
|
|
20
|
-
i++;
|
|
21
|
-
}
|
|
22
|
-
i++;
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
if (c === ' ' || c === '\t' || c === '\n') {
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
if (c === ';' || c === '&' || c === '|' || c === '>' || c === '<' || c === '`') {
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
token += c;
|
|
32
|
-
i++;
|
|
33
|
-
}
|
|
34
|
-
return token;
|
|
35
|
-
}
|
|
36
|
-
function isPad(c) {
|
|
37
|
-
return c === ' ' || c === '\t' || c === '\n';
|
|
38
|
-
}
|
|
39
|
-
function skipDoubleQuoted(chars, open) {
|
|
40
|
-
let i = open + 1;
|
|
41
|
-
while (i < chars.length && chars[i] !== '"') {
|
|
42
|
-
if (chars[i] === '\\') {
|
|
43
|
-
if (chars[i + 1] === '\n') {
|
|
44
|
-
return 'command must not use line continuations';
|
|
45
|
-
}
|
|
46
|
-
i += 2;
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (chars[i] === '`') {
|
|
50
|
-
return 'command must not use backtick substitution';
|
|
51
|
-
}
|
|
52
|
-
if (chars[i] === '$') {
|
|
53
|
-
return SHELL_EXPANSION_ERROR;
|
|
54
|
-
}
|
|
55
|
-
i++;
|
|
56
|
-
}
|
|
57
|
-
return i + 1;
|
|
58
|
-
}
|
|
59
7
|
const EXPANDS = /[A-Za-z_{(?#@*!$-]/;
|
|
60
8
|
export function escapeLiteralDollars(command) {
|
|
61
9
|
const chars = [...command];
|
|
@@ -87,66 +35,27 @@ export function escapeLiteralDollars(command) {
|
|
|
87
35
|
}
|
|
88
36
|
export const SHELL_EXPANSION_ERROR = 'command must not use shell expansion: $ outside single quotes is expanded by the shell. ' +
|
|
89
37
|
"Put text containing $ (prices, amounts) in single quotes, e.g. content='Total: $1,348'";
|
|
38
|
+
const REFUSED = {
|
|
39
|
+
chain: 'command must not chain with ;',
|
|
40
|
+
ampersand: 'command must not use & or &&',
|
|
41
|
+
pipe: 'command must not use pipes',
|
|
42
|
+
'redirect-output': 'command must not redirect output',
|
|
43
|
+
'redirect-input': 'command must not redirect input',
|
|
44
|
+
newline: 'command must not span multiple lines',
|
|
45
|
+
expansion: SHELL_EXPANSION_ERROR,
|
|
46
|
+
backtick: 'command must not use backtick substitution',
|
|
47
|
+
continuation: 'command must not use line continuations',
|
|
48
|
+
'process-substitution': 'command must not use process substitution',
|
|
49
|
+
subshell: 'command must not use ( ) subshells: run the program directly',
|
|
50
|
+
group: 'command must not use { } groups: run the program directly',
|
|
51
|
+
negation: 'command must not negate with !: run the program directly',
|
|
52
|
+
keyword: 'command must not use shell keywords (if, for, while, case): run one program per call',
|
|
53
|
+
function: 'command must not define shell functions: run the program directly',
|
|
54
|
+
eval: 'command must not run eval, ., source, trap or a builtin given $ or `: run the program directly',
|
|
55
|
+
comment: 'command must not carry a # comment: drop it, or quote a literal #',
|
|
56
|
+
unterminated: 'command must close every quote it opens'
|
|
57
|
+
};
|
|
90
58
|
export function sanitizeCommand(command) {
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
while (i < chars.length) {
|
|
94
|
-
const c = chars[i];
|
|
95
|
-
if (c === '\n') {
|
|
96
|
-
i++;
|
|
97
|
-
while (i < chars.length && isPad(chars[i])) {
|
|
98
|
-
i++;
|
|
99
|
-
}
|
|
100
|
-
if (i < chars.length) {
|
|
101
|
-
return 'command must not span multiple lines';
|
|
102
|
-
}
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
if (c === "'") {
|
|
106
|
-
i++;
|
|
107
|
-
while (i < chars.length && chars[i] !== "'") {
|
|
108
|
-
i++;
|
|
109
|
-
}
|
|
110
|
-
i++;
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
if (c === '"') {
|
|
114
|
-
const end = skipDoubleQuoted(chars, i);
|
|
115
|
-
if (typeof end === 'string') {
|
|
116
|
-
return end;
|
|
117
|
-
}
|
|
118
|
-
i = end;
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
if (c === '\\') {
|
|
122
|
-
if (chars[i + 1] === '\n') {
|
|
123
|
-
return 'command must not use line continuations';
|
|
124
|
-
}
|
|
125
|
-
i += 2;
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
if (c === '`') {
|
|
129
|
-
return 'command must not use backtick substitution';
|
|
130
|
-
}
|
|
131
|
-
if (c === '$') {
|
|
132
|
-
return SHELL_EXPANSION_ERROR;
|
|
133
|
-
}
|
|
134
|
-
if (c === ';') {
|
|
135
|
-
return 'command must not chain with ;';
|
|
136
|
-
}
|
|
137
|
-
if (c === '&') {
|
|
138
|
-
return 'command must not use & or &&';
|
|
139
|
-
}
|
|
140
|
-
if (c === '|') {
|
|
141
|
-
return 'command must not use pipes';
|
|
142
|
-
}
|
|
143
|
-
if (c === '>') {
|
|
144
|
-
return 'command must not redirect output';
|
|
145
|
-
}
|
|
146
|
-
if (c === '<') {
|
|
147
|
-
return 'command must not redirect input';
|
|
148
|
-
}
|
|
149
|
-
i++;
|
|
150
|
-
}
|
|
151
|
-
return null;
|
|
59
|
+
const first = ShellLine.parse(command).constructs[0];
|
|
60
|
+
return first ? REFUSED[first.kind] : null;
|
|
152
61
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { pipInstallTargets, unwrapPythonSource, withoutProgramDir } from './python-source.js';
|
|
2
|
-
import { bareBin
|
|
3
|
-
import {
|
|
2
|
+
import { bareBin } from './scope.js';
|
|
3
|
+
import { ShellLine } from './shell-line.js';
|
|
4
4
|
import { isTranscoder, TRANSCODE_ERROR, VIDEO_TOOLS_ERROR, videoTool } from './video-tools.js';
|
|
5
5
|
const INTERPRETER = /^(python[\d.]*|py)$/;
|
|
6
6
|
const PIP = /^pip[\d.]*$/;
|
|
@@ -11,7 +11,7 @@ export const LANGUAGE_UNAVAILABLE_ERROR = 'That language is not available here,
|
|
|
11
11
|
export const PIP_UNAVAILABLE_ERROR = 'pip is not available here, and no exec call installs Python packages. Use a shell command, ' +
|
|
12
12
|
'or tell the user it cannot be done.';
|
|
13
13
|
export function commandBin(command) {
|
|
14
|
-
return bareBin(
|
|
14
|
+
return (bareBin((ShellLine.parse(command).commands[0]?.argv[0] ?? '').replace(/^.*[/\\]/, '')) ?? '');
|
|
15
15
|
}
|
|
16
16
|
export function dashModule(command) {
|
|
17
17
|
return /^\s*(?:python[\d.]*|py)\s+-m\s+([\w.-]+)/.exec(withoutProgramDir(command))?.[1] ?? null;
|
|
@@ -99,7 +99,7 @@ export function savesDownload(command) {
|
|
|
99
99
|
if (bin !== 'curl' && bin !== 'wget') {
|
|
100
100
|
return false;
|
|
101
101
|
}
|
|
102
|
-
return writesFile(
|
|
102
|
+
return writesFile(ShellLine.parse(command).commands[0]?.argv ?? [], bin === 'curl');
|
|
103
103
|
}
|
|
104
104
|
export function shellOnlyError(command) {
|
|
105
105
|
if (runsPip(command)) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type ShellConstructKind = 'chain' | 'ampersand' | 'pipe' | 'redirect-output' | 'redirect-input' | 'newline' | 'expansion' | 'backtick' | 'continuation' | 'process-substitution' | 'subshell' | 'group' | 'negation' | 'keyword' | 'function' | 'eval' | 'comment' | 'unterminated';
|
|
2
|
+
export interface ShellConstruct {
|
|
3
|
+
readonly kind: ShellConstructKind;
|
|
4
|
+
readonly at: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ShellRedirect {
|
|
7
|
+
readonly fd: string;
|
|
8
|
+
readonly op: string;
|
|
9
|
+
readonly target: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ShellCommand {
|
|
12
|
+
readonly argv: string[];
|
|
13
|
+
readonly expands: boolean[];
|
|
14
|
+
readonly assignments: string[];
|
|
15
|
+
readonly redirects: ShellRedirect[];
|
|
16
|
+
}
|
|
17
|
+
export declare class ShellLine {
|
|
18
|
+
#private;
|
|
19
|
+
readonly commands: ShellCommand[];
|
|
20
|
+
readonly ops: string[];
|
|
21
|
+
readonly constructs: ShellConstruct[];
|
|
22
|
+
readonly unjudgeable: string | null;
|
|
23
|
+
constructor(line: string);
|
|
24
|
+
static parse(line: string): ShellLine;
|
|
25
|
+
static escape(value: string): string;
|
|
26
|
+
}
|