@qvac/harness 1.0.0-rc.3 → 1.0.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/CHANGELOG.md +2302 -1485
- package/README.md +44 -31
- package/dist-lib/index.d.ts +51 -6
- package/dist-lib/index.js +130 -28
- package/dist-lib/lib/agent/delegate.d.ts +3 -2
- package/dist-lib/lib/agent/delegate.js +6 -4
- package/dist-lib/lib/agent/follow.d.ts +5 -0
- package/dist-lib/lib/agent/follow.js +2 -0
- package/dist-lib/lib/agent/resolve.js +22 -17
- package/dist-lib/lib/agent/tool-selection.d.ts +4 -2
- package/dist-lib/lib/agent/tool-selection.js +5 -6
- package/dist-lib/lib/agent/tools.d.ts +1 -0
- package/dist-lib/lib/agent/tools.js +2 -1
- package/dist-lib/lib/capabilities/agent-ports.js +3 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/batching.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +60 -9
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +4 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +35 -6
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +104 -40
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +6 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +61 -16
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +22 -13
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +23 -13
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +8 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +61 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +5 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +50 -22
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +33 -6
- package/dist-lib/lib/capabilities/completion-engine/driver.js +28 -13
- package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/durable.js +5 -1
- package/dist-lib/lib/capabilities/completion-engine/engine.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/engine.js +14 -1
- package/dist-lib/lib/capabilities/completion-engine/index.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/index.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +16 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.js +7 -0
- package/dist-lib/lib/capabilities/completion-engine/metrics.d.ts +9 -2
- package/dist-lib/lib/capabilities/completion-engine/metrics.js +28 -7
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +46 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.js +45 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.js +1 -1
- package/dist-lib/lib/capabilities/completion-engine/ports.js +3 -7
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +23 -3
- package/dist-lib/lib/capabilities/completion-engine/round.js +323 -97
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +10 -3
- package/dist-lib/lib/capabilities/completion-engine/session.js +30 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +4 -3
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +15 -10
- package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +14 -9
- package/dist-lib/lib/capabilities/completion-engine/turns.js +63 -86
- package/dist-lib/lib/capabilities/download.d.ts +9 -7
- package/dist-lib/lib/capabilities/download.js +1 -1
- package/dist-lib/lib/capabilities/enhance.d.ts +1 -1
- package/dist-lib/lib/capabilities/enhance.js +20 -8
- package/dist-lib/lib/capabilities/preview-model-source.d.ts +7 -0
- package/dist-lib/lib/capabilities/preview-model-source.js +83 -23
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +1 -0
- package/dist-lib/lib/capabilities/sdk-tool.js +18 -1
- package/dist-lib/lib/capabilities/tool-plan.d.ts +1 -1
- package/dist-lib/lib/capabilities/tool-plan.js +5 -5
- package/dist-lib/lib/capabilities/tool-prompt-log.js +3 -3
- package/dist-lib/lib/capabilities/tool-turns.d.ts +7 -9
- package/dist-lib/lib/capabilities/tool-turns.js +25 -20
- package/dist-lib/lib/client/index.d.ts +19 -0
- package/dist-lib/lib/client/index.js +262 -0
- package/dist-lib/lib/connect.d.ts +13 -10
- package/dist-lib/lib/connect.js +68 -26
- package/dist-lib/lib/context-window.d.ts +1 -0
- package/dist-lib/lib/context-window.js +3 -3
- package/dist-lib/lib/contract/agent.d.ts +7 -3
- package/dist-lib/lib/contract/completion.d.ts +51 -30
- package/dist-lib/lib/contract/drive.d.ts +4 -0
- package/dist-lib/lib/contract/drive.js +1 -0
- package/dist-lib/lib/contract/egress-proxy.d.ts +13 -0
- package/dist-lib/lib/contract/egress-proxy.js +1 -0
- package/dist-lib/lib/contract/exec.d.ts +3 -3
- package/dist-lib/lib/contract/hooks.d.ts +4 -1
- package/dist-lib/lib/contract/index.d.ts +3 -0
- package/dist-lib/lib/contract/managed-skills.d.ts +1 -0
- package/dist-lib/lib/contract/managed-skills.js +1 -0
- package/dist-lib/lib/contract/models.d.ts +6 -4
- package/dist-lib/lib/contract/policy.d.ts +75 -0
- package/dist-lib/lib/contract/policy.js +1 -0
- package/dist-lib/lib/contract/run.d.ts +15 -3
- package/dist-lib/lib/contract/sandbox.d.ts +3 -1
- package/dist-lib/lib/contract/translation.d.ts +20 -0
- package/dist-lib/lib/contract/translation.js +1 -0
- package/dist-lib/lib/contract-types.d.ts +35 -15
- package/dist-lib/lib/embeddings/index.d.ts +7 -1
- package/dist-lib/lib/embeddings/index.js +26 -5
- package/dist-lib/lib/errors.d.ts +266 -0
- package/dist-lib/lib/errors.js +198 -0
- package/dist-lib/lib/fold/index.d.ts +25 -1
- package/dist-lib/lib/fold/index.js +75 -9
- package/dist-lib/lib/guarded-fetch.js +11 -7
- package/dist-lib/lib/hardware/gpu-probe.js +10 -1
- package/dist-lib/lib/helpers/completion-params.d.ts +6 -2
- package/dist-lib/lib/helpers/completion-params.js +10 -1
- package/dist-lib/lib/helpers/engine-error.d.ts +2 -1
- package/dist-lib/lib/helpers/engine-error.js +12 -12
- package/dist-lib/lib/helpers/goal-check.d.ts +4 -0
- package/dist-lib/lib/helpers/goal-check.js +81 -0
- package/dist-lib/lib/helpers/head-tail.js +1 -1
- package/dist-lib/lib/helpers/load-stall.d.ts +1 -1
- package/dist-lib/lib/helpers/load-stall.js +2 -2
- package/dist-lib/lib/helpers/markup-stream-filter.d.ts +4 -1
- package/dist-lib/lib/helpers/markup-stream-filter.js +20 -6
- package/dist-lib/lib/helpers/repeated-reply.js +24 -16
- package/dist-lib/lib/helpers/thinking.d.ts +3 -2
- package/dist-lib/lib/helpers/thinking.js +19 -0
- package/dist-lib/lib/hooks/built-in/arg-repair.js +6 -2
- package/dist-lib/lib/hooks/built-in/policy-rules.d.ts +8 -0
- package/dist-lib/lib/hooks/built-in/policy-rules.js +192 -0
- package/dist-lib/lib/hooks/built-in/sandbox.js +23 -5
- package/dist-lib/lib/hooks/index.d.ts +4 -1
- package/dist-lib/lib/hooks/index.js +9 -4
- package/dist-lib/lib/hooks/run.js +3 -3
- package/dist-lib/lib/lifecycle/index.js +15 -14
- package/dist-lib/lib/lifecycle/machine.js +2 -2
- package/dist-lib/lib/log.d.ts +26 -5
- package/dist-lib/lib/log.js +86 -23
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +4 -2
- package/dist-lib/lib/machine/completion/actions/completion.js +78 -12
- package/dist-lib/lib/machine/completion/actions/prepare.js +1 -1
- package/dist-lib/lib/machine/completion/actions/tools.js +48 -5
- package/dist-lib/lib/machine/completion/context.js +5 -1
- package/dist-lib/lib/machine/completion/guards/retry.d.ts +1 -0
- package/dist-lib/lib/machine/completion/guards/retry.js +8 -2
- package/dist-lib/lib/machine/completion/implementations.d.ts +10 -4
- package/dist-lib/lib/machine/completion/implementations.js +43 -10
- package/dist-lib/lib/machine/completion/machine.d.ts +23 -3
- package/dist-lib/lib/machine/completion/machine.js +33 -4
- package/dist-lib/lib/machine/completion/rules.d.ts +17 -2
- package/dist-lib/lib/machine/completion/rules.js +49 -3
- package/dist-lib/lib/machine/completion/types.d.ts +43 -1
- package/dist-lib/lib/machine/index.d.ts +29 -4
- package/dist-lib/lib/machine/index.js +6 -1
- package/dist-lib/lib/models/context-choice.d.ts +15 -0
- package/dist-lib/lib/models/context-choice.js +55 -0
- package/dist-lib/lib/models/download-gate.d.ts +20 -0
- package/dist-lib/lib/models/download-gate.js +73 -0
- package/dist-lib/lib/models/gguf-header.d.ts +5 -0
- package/dist-lib/lib/models/gguf-header.js +165 -14
- package/dist-lib/lib/models/llm-presets.d.ts +5 -1
- package/dist-lib/lib/models/llm-presets.js +6 -5
- package/dist-lib/lib/models/memory-cap.d.ts +13 -0
- package/dist-lib/lib/models/memory-cap.js +21 -0
- package/dist-lib/lib/models/model-catalog.d.ts +2 -0
- package/dist-lib/lib/models/model-catalog.js +15 -0
- package/dist-lib/lib/models/model-fit.d.ts +1 -1
- package/dist-lib/lib/models/model-fit.js +5 -6
- package/dist-lib/lib/models/model-handle.d.ts +8 -2
- package/dist-lib/lib/models/model-handle.js +14 -3
- package/dist-lib/lib/models/model-list.d.ts +8 -1
- package/dist-lib/lib/models/model-list.js +23 -0
- package/dist-lib/lib/models/model-pool.d.ts +35 -5
- package/dist-lib/lib/models/model-pool.js +121 -43
- package/dist-lib/lib/models/model-source.d.ts +1 -0
- package/dist-lib/lib/models/model-source.js +23 -5
- package/dist-lib/lib/models/sdk-faults.d.ts +1 -0
- package/dist-lib/lib/models/sdk-faults.js +9 -0
- package/dist-lib/lib/no-redirect-fetch-bare.js +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.js +2 -1
- package/dist-lib/lib/office/engine/pptx/picture-area.d.ts +23 -0
- package/dist-lib/lib/office/engine/pptx/picture-area.js +84 -0
- package/dist-lib/lib/office/engine/pptx/presentation.d.ts +2 -0
- package/dist-lib/lib/office/engine/pptx/presentation.js +55 -17
- package/dist-lib/lib/office/engine/pptx/types.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/workbook.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/workbook.js +34 -3
- package/dist-lib/lib/office/extract.js +4 -3
- package/dist-lib/lib/office/index.js +2 -1
- package/dist-lib/lib/plugins/registry.d.ts +3 -0
- package/dist-lib/lib/plugins/registry.js +16 -7
- package/dist-lib/lib/policy/index.d.ts +10 -0
- package/dist-lib/lib/policy/index.js +229 -0
- package/dist-lib/lib/prompt.d.ts +1 -0
- package/dist-lib/lib/prompt.js +7 -1
- package/dist-lib/lib/residency/completion-runtime.d.ts +1 -0
- package/dist-lib/lib/residency/completion-runtime.js +11 -4
- package/dist-lib/lib/residency/index.d.ts +44 -4
- package/dist-lib/lib/residency/index.js +399 -35
- package/dist-lib/lib/resolution-detector.js +3 -3
- package/dist-lib/lib/rpc-session.js +2 -1
- package/dist-lib/lib/sdk-loader.js +17 -11
- package/dist-lib/lib/serve.js +83 -38
- package/dist-lib/lib/sidecar/index.d.ts +29 -0
- package/dist-lib/lib/sidecar/index.js +174 -0
- package/dist-lib/lib/sidecar/user-plugins.d.ts +8 -0
- package/dist-lib/lib/sidecar/user-plugins.js +117 -0
- package/dist-lib/lib/skills-host/index.d.ts +1 -0
- package/dist-lib/lib/skills-host/index.js +8 -4
- package/dist-lib/lib/spawn.d.ts +3 -4
- package/dist-lib/lib/spawn.js +17 -17
- package/dist-lib/lib/spill.d.ts +1 -0
- package/dist-lib/lib/spill.js +12 -8
- package/dist-lib/lib/tools/attachments/staging.js +8 -8
- package/dist-lib/lib/tools/exec/runner.js +2 -1
- package/dist-lib/lib/tools/exec/scope.d.ts +0 -1
- package/dist-lib/lib/tools/exec/scope.js +23 -114
- package/dist-lib/lib/tools/exec/shell-guidance.js +4 -4
- package/dist-lib/lib/tools/exec/shell-line.d.ts +26 -0
- package/dist-lib/lib/tools/exec/shell-line.js +334 -0
- package/dist-lib/lib/tools/exec.d.ts +4 -1
- package/dist-lib/lib/tools/exec.js +87 -26
- package/dist-lib/lib/tools/files/edit-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/edit-file.js +74 -0
- package/dist-lib/lib/tools/files/glob.d.ts +3 -0
- package/dist-lib/lib/tools/files/glob.js +65 -0
- package/dist-lib/lib/tools/files/grep.d.ts +6 -0
- package/dist-lib/lib/tools/files/grep.js +114 -0
- package/dist-lib/lib/tools/files/index.d.ts +3 -0
- package/dist-lib/lib/tools/files/index.js +23 -0
- package/dist-lib/lib/tools/files/list-dir.d.ts +6 -0
- package/dist-lib/lib/tools/files/list-dir.js +136 -0
- package/dist-lib/lib/tools/files/make-dir.d.ts +3 -0
- package/dist-lib/lib/tools/files/make-dir.js +48 -0
- package/dist-lib/lib/tools/files/read-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/read-file.js +105 -0
- package/dist-lib/lib/tools/files/transfer.d.ts +4 -0
- package/dist-lib/lib/tools/files/transfer.js +83 -0
- package/dist-lib/lib/tools/files/trash-file.d.ts +4 -0
- package/dist-lib/lib/tools/files/trash-file.js +62 -0
- package/dist-lib/lib/tools/files/write-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/write-file.js +56 -0
- package/dist-lib/lib/tools/fs/document-text.d.ts +2 -0
- package/dist-lib/lib/tools/fs/document-text.js +38 -0
- package/dist-lib/lib/tools/fs/drive.d.ts +14 -3
- package/dist-lib/lib/tools/fs/drive.js +9 -1
- package/dist-lib/lib/tools/fs/edit-match.d.ts +11 -0
- package/dist-lib/lib/tools/fs/edit-match.js +85 -0
- package/dist-lib/lib/tools/fs/ignore.d.ts +13 -0
- package/dist-lib/lib/tools/fs/ignore.js +104 -0
- package/dist-lib/lib/tools/fs/local.js +28 -5
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +23 -3
- package/dist-lib/lib/tools/fs/remote.d.ts +3 -4
- package/dist-lib/lib/tools/fs/remote.js +23 -13
- package/dist-lib/lib/tools/fs/scope.d.ts +5 -1
- package/dist-lib/lib/tools/fs/scope.js +5 -2
- package/dist-lib/lib/tools/fs/search.d.ts +41 -0
- package/dist-lib/lib/tools/fs/search.js +382 -0
- package/dist-lib/lib/tools/{file-glob.d.ts → fs/targets.d.ts} +1 -5
- package/dist-lib/lib/tools/fs/targets.js +32 -0
- package/dist-lib/lib/tools/fs/tool-path.d.ts +27 -0
- package/dist-lib/lib/tools/fs/tool-path.js +70 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +15 -3
- package/dist-lib/lib/tools/fs/walk.js +118 -24
- package/dist-lib/lib/tools/http-request.js +12 -2
- package/dist-lib/lib/tools/index.js +2 -10
- package/dist-lib/lib/tools/office/ops.js +1 -1
- package/dist-lib/lib/tools/office.js +77 -21
- package/dist-lib/lib/tools/pdf/build.d.ts +5 -1
- package/dist-lib/lib/tools/pdf/build.js +31 -6
- package/dist-lib/lib/tools/pdf.js +17 -2
- package/dist-lib/lib/tools/skill.js +10 -7
- package/dist-lib/lib/tools/skills/bundled-dir.js +4 -4
- package/dist-lib/lib/tools/skills/catalog.d.ts +2 -0
- package/dist-lib/lib/tools/skills/catalog.js +6 -2
- package/dist-lib/lib/tools/skills/cli-argv.js +25 -5
- package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/cli-schema-check.js +3 -0
- package/dist-lib/lib/tools/skills/cli-schema-load.js +10 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +2 -0
- package/dist-lib/lib/tools/skills/cli-schema.js +6 -3
- package/dist-lib/lib/tools/skills/credential-health.js +3 -3
- package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +2 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +4 -0
- package/dist-lib/lib/tools/skills/manifest-parse.d.ts +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +12 -0
- package/dist-lib/lib/tools/skills/mention-name.d.ts +6 -0
- package/dist-lib/lib/tools/skills/mention-name.js +6 -0
- package/dist-lib/lib/tools/skills/mention.d.ts +2 -2
- package/dist-lib/lib/tools/skills/mention.js +11 -4
- package/dist-lib/lib/tools/skills/overlay-crud.js +3 -2
- package/dist-lib/lib/tools/url-guard.d.ts +6 -1
- package/dist-lib/lib/tools/url-guard.js +8 -2
- package/dist-lib/lib/tools/web-fetch.js +10 -4
- package/dist-lib/lib/wire.js +8 -5
- package/dist-lib/plugins/coding/index.d.ts +1 -1
- package/dist-lib/plugins/coding/index.js +2 -4
- package/dist-lib/plugins/coding/session.d.ts +3 -3
- package/dist-lib/plugins/coding/session.js +26 -14
- package/dist-lib/plugins/command-hooks/index.js +5 -3
- package/dist-lib/plugins/egress-proxy/index.d.ts +53 -0
- package/dist-lib/plugins/egress-proxy/index.js +182 -0
- package/dist-lib/plugins/image/edit-image.js +4 -3
- package/dist-lib/plugins/image/generate-image.d.ts +4 -3
- package/dist-lib/plugins/image/generate-image.js +10 -9
- package/dist-lib/plugins/image/index.d.ts +1 -1
- package/dist-lib/plugins/image/index.js +13 -10
- package/dist-lib/plugins/language-hint/index.d.ts +15 -0
- package/dist-lib/plugins/language-hint/index.js +51 -0
- package/dist-lib/plugins/lsp/tool.js +2 -2
- package/dist-lib/plugins/mcp/index.js +6 -3
- package/dist-lib/plugins/music/generate-music.d.ts +4 -2
- package/dist-lib/plugins/music/generate-music.js +7 -4
- package/dist-lib/plugins/music/index.js +12 -9
- package/dist-lib/plugins/obsidian/command.js +2 -2
- package/dist-lib/plugins/obsidian/note-name.js +2 -1
- package/dist-lib/plugins/obsidian/safe-path.js +5 -4
- package/dist-lib/plugins/obsidian/vault-create.js +3 -2
- package/dist-lib/plugins/obsidian/vault-fs.js +2 -2
- package/dist-lib/plugins/obsidian/vault-paths.js +3 -2
- package/dist-lib/plugins/obsidian/vault-read.js +6 -5
- package/dist-lib/plugins/obsidian/vault-write.js +13 -12
- package/dist-lib/plugins/python/guarded-fetch.d.ts +2 -1
- package/dist-lib/plugins/python/guarded-fetch.js +5 -1
- package/dist-lib/plugins/python/interrupt-timer.js +2 -2
- package/dist-lib/plugins/python/loader.js +68 -3
- package/dist-lib/plugins/python/memfs.js +2 -2
- package/dist-lib/plugins/python/pyodide.d.ts +1 -0
- package/dist-lib/plugins/python/pyodide.js +9 -8
- package/dist-lib/plugins/python/python-adapter.js +3 -1
- package/dist-lib/plugins/python/run-session.d.ts +1 -0
- package/dist-lib/plugins/python/run-session.js +19 -8
- package/dist-lib/plugins/python/wheels.js +8 -6
- package/dist-lib/plugins/python/worker/active.js +2 -2
- package/dist-lib/plugins/python/worker/client.js +9 -8
- package/dist-lib/plugins/python/worker/protocol.d.ts +2 -0
- package/dist-lib/plugins/python/worker/serve.js +23 -4
- package/dist-lib/plugins/python/worker/spawn.d.ts +2 -1
- package/dist-lib/plugins/python/worker/spawn.js +2 -1
- package/dist-lib/plugins/run-report/chain.d.ts +2 -0
- package/dist-lib/plugins/run-report/chain.js +73 -0
- package/dist-lib/plugins/run-report/flow-view.js +2 -1
- package/dist-lib/plugins/run-report/flow.d.ts +1 -1
- package/dist-lib/plugins/run-report/flow.js +66 -14
- package/dist-lib/plugins/run-report/index.d.ts +23 -2
- package/dist-lib/plugins/run-report/index.js +27 -12
- package/dist-lib/plugins/run-report/model.d.ts +10 -1
- package/dist-lib/plugins/run-report/model.js +12 -6
- package/dist-lib/plugins/run-report/page.d.ts +9 -0
- package/dist-lib/plugins/run-report/page.js +55 -15
- package/dist-lib/plugins/run-report/script.js +317 -43
- package/dist-lib/plugins/run-report/story.d.ts +2 -1
- package/dist-lib/plugins/run-report/story.js +3 -3
- package/dist-lib/plugins/run-report/style.d.ts +1 -1
- package/dist-lib/plugins/run-report/style.js +126 -0
- package/dist-lib/plugins/run-report/why.js +1 -1
- package/dist-lib/plugins/sandbox-linux/index.d.ts +60 -0
- package/dist-lib/plugins/sandbox-linux/index.js +347 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.d.ts +2 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.js +74 -0
- package/dist-lib/plugins/sandbox-macos/index.d.ts +23 -11
- package/dist-lib/plugins/sandbox-macos/index.js +239 -49
- package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +4 -2
- package/dist-lib/plugins/sandbox-vm/vm-shell.js +9 -4
- package/dist-lib/plugins/sandbox-windows/helper/qvac-sandbox.c +554 -0
- package/dist-lib/plugins/sandbox-windows/index.d.ts +53 -0
- package/dist-lib/plugins/sandbox-windows/index.js +205 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/speech/audio-resample.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-resample.js +7 -8
- package/dist-lib/plugins/speech/audio-transcode-bare.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-bare.js +23 -26
- package/dist-lib/plugins/speech/audio-transcode-node.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-node.js +1 -3
- package/dist-lib/plugins/speech/speech-runtime.js +37 -37
- package/dist-lib/plugins/speech/voice.d.ts +5 -1
- package/dist-lib/plugins/speech/voice.js +100 -31
- package/dist-lib/plugins/translation/index.d.ts +1 -0
- package/dist-lib/plugins/translation/index.js +16 -9
- package/dist-lib/plugins/translation/translate.d.ts +7 -3
- package/dist-lib/plugins/translation/translate.js +64 -58
- package/dist-lib/plugins/weather/geocode.js +2 -1
- package/dist-lib/plugins/weather/lookup.js +5 -4
- package/dist-lib/plugins/web-search/engines/bing.js +2 -1
- package/dist-lib/plugins/web-search/engines/google.js +2 -1
- package/dist-lib/plugins/web-search/fetch-html.d.ts +5 -5
- package/dist-lib/plugins/web-search/fetch-html.js +12 -15
- package/dist-lib/plugins/web-search/tool.js +1 -0
- package/dist-lib/schema/harness.js +52 -9
- package/dist-lib/spec/bind.js +9 -0
- package/dist-lib/spec/calls.js +3 -0
- package/dist-lib/spec/hrpc/hrpc.json +42 -3
- package/dist-lib/spec/hrpc/index.js +44 -8
- package/dist-lib/spec/hrpc/messages.js +310 -205
- package/dist-lib/spec/hyperschema/index.js +310 -205
- package/dist-lib/spec/hyperschema/schema.json +164 -84
- package/dist-lib/spec/hyperschema/types.d.ts +25 -4
- package/package.json +98 -26
- package/patches/@qvac%2Finference@0.22.0.patch +59 -0
- package/patches/pyodide@314.0.2.patch +37 -8
- package/scripts/addon-externals.cjs +10 -5
- package/worker/harness-sidecar.mjs +18 -154
- package/bench/README.md +0 -94
- package/bench/bfcl/checker.ts +0 -313
- package/bench/bfcl/data.ts +0 -93
- package/bench/bfcl/observe.ts +0 -93
- package/bench/bfcl/run.ts +0 -213
- package/bench/bfcl/tools.ts +0 -72
- package/bench/bridge/bridge.ts +0 -392
- package/bench/bridge/openai.ts +0 -150
- package/bench/bridge/python/qvac_bench/__init__.py +0 -3
- package/bench/bridge/python/qvac_bench/airline.py +0 -42
- package/bench/bridge/python/qvac_bench/approval.py +0 -26
- package/bench/bridge/python/qvac_bench/bfcl_multi_turn.py +0 -152
- package/bench/bridge/python/qvac_bench/client.py +0 -88
- package/bench/bridge/python/qvac_bench/harbor_agent.py +0 -85
- package/bench/bridge/python/qvac_bench/session.py +0 -107
- package/bench/bridge/python/qvac_bench/speed.py +0 -30
- package/bench/bridge/python/qvac_bench/tau2_agent.py +0 -106
- package/bench/bridge/python/qvac_bench/tools.py +0 -11
- package/bench/bridge/python/run_bfcl_multi_turn.py +0 -95
- package/bench/bridge/python/run_tau2.py +0 -150
- package/bench/bridge/python/smoke.py +0 -47
- package/bench/bridge/python/test_airline.py +0 -28
- package/bench/bridge/python/test_approval.py +0 -57
- package/bench/bridge/python/test_bfcl_multi_turn.py +0 -185
- package/bench/bridge/python/test_harbor_agent.py +0 -107
- package/bench/bridge/serve.ts +0 -52
- package/bench/bridge/transcript.ts +0 -52
- package/bench/bun-tsconfig.json +0 -15
- package/bench/cpu-main.mjs +0 -216
- package/bench/cpu.ts +0 -457
- package/bench/evidence/2026-09-28-review15.md +0 -225
- package/bench/evidence/redact-bun1.3.14.json +0 -92
- package/bench/evidence/redact-node24.11.json +0 -92
- package/bench/graph-metrics.ts +0 -43
- package/bench/harness.ts +0 -73
- package/bench/issue129-matrix.mjs +0 -722
- package/bench/redact-adversarial.ts +0 -256
- package/bench/repeat-cpu.mjs +0 -281
- package/bench/report.ts +0 -1075
- package/bench/skill-eval/harness.ts +0 -30
- package/bench/skill-eval/laws.ts +0 -37
- package/bench/skill-eval/mermaid/client.ts +0 -132
- package/bench/skill-eval/mermaid/validate.mjs +0 -115
- package/bench/skill-eval/pack.ts +0 -61
- package/bench/skill-eval/packs/diagrams/cases.ts +0 -281
- package/bench/skill-eval/packs/diagrams/index.ts +0 -50
- package/bench/skill-eval/packs/diagrams/score.ts +0 -74
- package/bench/skill-eval/packs/index.ts +0 -5
- package/bench/skill-eval/packs/weather/cases.ts +0 -279
- package/bench/skill-eval/packs/weather/fixtures/wttr.json +0 -566
- package/bench/skill-eval/packs/weather/fixtures.ts +0 -84
- package/bench/skill-eval/packs/weather/index.ts +0 -55
- package/bench/skill-eval/packs/weather/score.ts +0 -92
- package/bench/skill-eval/report.ts +0 -194
- package/bench/skill-eval/run.ts +0 -316
- package/bench/speed.ts +0 -80
- package/dist-lib/lib/tools/create-documents.d.ts +0 -3
- package/dist-lib/lib/tools/create-documents.js +0 -95
- package/dist-lib/lib/tools/edit-documents.d.ts +0 -3
- package/dist-lib/lib/tools/edit-documents.js +0 -132
- package/dist-lib/lib/tools/exec/shell-argv.d.ts +0 -2
- package/dist-lib/lib/tools/exec/shell-argv.js +0 -61
- package/dist-lib/lib/tools/file-glob.js +0 -118
- package/dist-lib/lib/tools/grep.d.ts +0 -5
- package/dist-lib/lib/tools/grep.js +0 -184
- package/dist-lib/lib/tools/read-files.d.ts +0 -5
- package/dist-lib/lib/tools/read-files.js +0 -160
- package/dist-lib/plugins/coding/write-file.d.ts +0 -3
- package/dist-lib/plugins/coding/write-file.js +0 -52
- package/patches/@qvac%2Finference@0.21.0.patch +0 -67
- package/patches/bare-stow@0.1.5.patch +0 -68
- package/patches/hypercore-blob-server@1.15.0.patch +0 -15
|
@@ -12,6 +12,7 @@ import * as fit from './fit.js';
|
|
|
12
12
|
import * as template from './template.js';
|
|
13
13
|
import * as slides from './slides.js';
|
|
14
14
|
import * as notes from './notes.js';
|
|
15
|
+
import { fitted, framed, pictureArea } from './picture-area.js';
|
|
15
16
|
import { pick, describe, layoutName, layoutType, BODY_TYPES } from './read.js';
|
|
16
17
|
import { SHAPE_ORDER, shapesOf, placeholderFrom, pictureElement, textBoxElement, tableElement, chartFrameElement, setBackground, nextShapeId } from './shapes.js';
|
|
17
18
|
const { a: A, p: P, r: R, p14: P14 } = xml.ns;
|
|
@@ -154,16 +155,19 @@ function checkSlideText(doc, at, opts) {
|
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
|
-
function
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
158
|
+
function roleOf(shape) {
|
|
159
|
+
const { el, kind, placeholder } = shape;
|
|
160
|
+
if (kind === 'picture') {
|
|
161
|
+
return 'picture';
|
|
162
|
+
}
|
|
163
|
+
if (el.localName !== 'sp' || !placeholder || !BODY_TYPES.has(placeholder)) {
|
|
164
|
+
return 'other';
|
|
165
|
+
}
|
|
166
|
+
const txBody = xml.child(el, P, 'txBody');
|
|
167
|
+
if (txBody && text.readParagraphs(txBody).some((p) => p.text.trim())) {
|
|
168
|
+
return placeholder === 'subTitle' ? 'other' : 'body';
|
|
169
|
+
}
|
|
170
|
+
return placeholder === 'obj' ? 'slot' : 'blank';
|
|
167
171
|
}
|
|
168
172
|
function tableBody(tc) {
|
|
169
173
|
const existing = xml.child(tc, A, 'txBody');
|
|
@@ -366,6 +370,9 @@ export class Presentation {
|
|
|
366
370
|
const layoutDoc = this.package.xml(layout);
|
|
367
371
|
const doc = slideFromLayout(layoutDoc);
|
|
368
372
|
checkSlideText(doc, at, opts);
|
|
373
|
+
if (opts.image !== undefined) {
|
|
374
|
+
probe(opts.image);
|
|
375
|
+
}
|
|
369
376
|
this.insertSlide({ doc, layout, at, ids: all.map((e) => e.id), before: all[at]?.el ?? null });
|
|
370
377
|
if (opts.title !== undefined) {
|
|
371
378
|
this.setText({ slide: at, shape: 'title' }, opts.title);
|
|
@@ -373,14 +380,25 @@ export class Presentation {
|
|
|
373
380
|
if (opts.body !== undefined) {
|
|
374
381
|
this.setText({ slide: at, shape: 'body' }, opts.body);
|
|
375
382
|
}
|
|
376
|
-
|
|
383
|
+
if (opts.image !== undefined) {
|
|
384
|
+
this.addPicture(at, opts.image);
|
|
385
|
+
}
|
|
386
|
+
const shapes = shapesOf(this.package.xml(slides.slideAt(this.deck, at).part));
|
|
387
|
+
return { index: at, layout: layoutName(layoutDoc), shapes: shapes.map(describe) };
|
|
377
388
|
}
|
|
378
389
|
addPicture(slide, bytes, opts = {}) {
|
|
379
390
|
const entry = slides.slideAt(this.deck, slide);
|
|
380
|
-
const
|
|
391
|
+
const area = this.pictureArea(entry.part, opts);
|
|
392
|
+
const box = this.pictureBox(probe(bytes), opts, area.box);
|
|
381
393
|
const { rId } = media.addImage(this.package, bytes, { source: entry.part, dir: '../media' });
|
|
382
394
|
const doc = this.package.xml(entry.part);
|
|
383
395
|
const id = nextShapeId(doc);
|
|
396
|
+
for (const shape of area.cleared) {
|
|
397
|
+
xml.remove(shape.el);
|
|
398
|
+
}
|
|
399
|
+
if (area.beside) {
|
|
400
|
+
this.narrow(entry.part, area.beside);
|
|
401
|
+
}
|
|
384
402
|
this.spTree(entry.part).appendChild(pictureElement(doc, { id, rId, box, name: opts.name, description: opts.description }));
|
|
385
403
|
this.package.touch(entry.part);
|
|
386
404
|
return { id, ...box };
|
|
@@ -722,14 +740,34 @@ export class Presentation {
|
|
|
722
740
|
}
|
|
723
741
|
return box;
|
|
724
742
|
}
|
|
725
|
-
|
|
743
|
+
narrow(part, { shape, box }) {
|
|
744
|
+
writeXfrm(shape.el, box);
|
|
745
|
+
const txBody = xml.child(shape.el, P, 'txBody');
|
|
746
|
+
const estimate = txBody ? this.estimate(part, shape.el, txBody) : null;
|
|
747
|
+
if (txBody && estimate?.overflow) {
|
|
748
|
+
applyAutofit(txBody, estimate);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
pictureArea(part, opts) {
|
|
752
|
+
if (opts.x !== undefined || opts.y !== undefined) {
|
|
753
|
+
return { box: framed(this.slideSize), cleared: [], beside: null };
|
|
754
|
+
}
|
|
755
|
+
const shapes = shapesOf(this.package.xml(part)).flatMap((shape) => {
|
|
756
|
+
if (shape.group !== null || SKIPPED_PLACEHOLDERS.has(shape.placeholder ?? '')) {
|
|
757
|
+
return [];
|
|
758
|
+
}
|
|
759
|
+
const box = inherit.box({ pkg: this.package, slide: part, el: shape.el });
|
|
760
|
+
return box ? [{ el: shape.el, box, role: roleOf(shape) }] : [];
|
|
761
|
+
});
|
|
762
|
+
return pictureArea(this.slideSize, shapes);
|
|
763
|
+
}
|
|
764
|
+
pictureBox(info, opts, area) {
|
|
726
765
|
checkPlacement(opts);
|
|
727
|
-
const slide = this.slideSize;
|
|
728
766
|
const ratio = info.height / info.width;
|
|
729
767
|
let { width, height } = opts;
|
|
730
768
|
if (width === undefined && height === undefined) {
|
|
731
769
|
const natural = { width: info.width * EMU_PER_PIXEL, height: info.height * EMU_PER_PIXEL };
|
|
732
|
-
const scale = Math.min(1,
|
|
770
|
+
const scale = Math.min(1, area.width / natural.width, area.height / natural.height);
|
|
733
771
|
width = Math.round(natural.width * scale);
|
|
734
772
|
height = Math.round(natural.height * scale);
|
|
735
773
|
}
|
|
@@ -742,8 +780,8 @@ export class Presentation {
|
|
|
742
780
|
if (!width || !height) {
|
|
743
781
|
throw new DocsError('INVALID_BOX', 'the picture would have no visible size');
|
|
744
782
|
}
|
|
745
|
-
const x = opts.x ?? Math.max(0, Math.round((
|
|
746
|
-
const y = opts.y ?? Math.max(0, Math.round((
|
|
783
|
+
const x = opts.x ?? Math.max(0, area.x + Math.round((area.width - width) / 2));
|
|
784
|
+
const y = opts.y ?? Math.max(0, area.y + Math.round((area.height - height) / 2));
|
|
747
785
|
return { x, y, width, height };
|
|
748
786
|
}
|
|
749
787
|
}
|
|
@@ -2,6 +2,7 @@ import { Package } from '../opc/package.js';
|
|
|
2
2
|
import * as xml from '../xml.js';
|
|
3
3
|
import * as media from '../opc/media.js';
|
|
4
4
|
import { probe } from '../image.js';
|
|
5
|
+
import { points } from '../units.js';
|
|
5
6
|
import * as refs from './refs.js';
|
|
6
7
|
import * as formula from './formula.js';
|
|
7
8
|
import { Sheet, SHEET_ORDER } from './sheet.js';
|
|
@@ -170,6 +171,12 @@ function pictureAnchor(doc, anchor, spec) {
|
|
|
170
171
|
root.appendChild(d('clientData'));
|
|
171
172
|
return root;
|
|
172
173
|
}
|
|
174
|
+
function markerCell(marker) {
|
|
175
|
+
return {
|
|
176
|
+
row: Number(xml.text(xml.child(marker, XDR, 'row'))),
|
|
177
|
+
col: Number(xml.text(xml.child(marker, XDR, 'col')))
|
|
178
|
+
};
|
|
179
|
+
}
|
|
173
180
|
function nextDrawingId(doc) {
|
|
174
181
|
return (Math.max(0, ...xml.descendants(doc, XDR, 'cNvPr').map((el) => Number(el.getAttribute('id')) || 0)) + 1);
|
|
175
182
|
}
|
|
@@ -421,7 +428,7 @@ export class Workbook {
|
|
|
421
428
|
const target = this.sheet(sheet);
|
|
422
429
|
const info = probe(bytes);
|
|
423
430
|
const o = isRecord(opts) ? opts : {};
|
|
424
|
-
const at =
|
|
431
|
+
const at = o.cell === undefined ? this.besideData(target) : refs.parse(o.cell);
|
|
425
432
|
const size = imageSize(o, info);
|
|
426
433
|
const drawing = this.ensureDrawing(target);
|
|
427
434
|
const { rId } = media.addImage(this.package, bytes, { source: drawing, dir: '../media' });
|
|
@@ -791,7 +798,8 @@ export class Workbook {
|
|
|
791
798
|
const from = xml.child(anchor, XDR, 'from');
|
|
792
799
|
const info = chart.readChart(this.package.xml(rel.part));
|
|
793
800
|
if (from) {
|
|
794
|
-
|
|
801
|
+
const { row, col } = markerCell(from);
|
|
802
|
+
info.cell = refs.cell(row, col);
|
|
795
803
|
}
|
|
796
804
|
out.push(info);
|
|
797
805
|
}
|
|
@@ -823,7 +831,30 @@ export class Workbook {
|
|
|
823
831
|
}
|
|
824
832
|
besideData(sheet) {
|
|
825
833
|
const used = sheet.usedRange();
|
|
826
|
-
|
|
834
|
+
const col = used ? used.right + 2 : 0;
|
|
835
|
+
return { row: Math.max(used ? used.top : 0, ...this.rowsBelowDrawings(sheet, col)), col };
|
|
836
|
+
}
|
|
837
|
+
rowsBelowDrawings(sheet, col) {
|
|
838
|
+
const drawing = this.drawingOf(sheet);
|
|
839
|
+
if (!drawing) {
|
|
840
|
+
return [];
|
|
841
|
+
}
|
|
842
|
+
const format = xml.child(sheet.root, X, 'sheetFormatPr');
|
|
843
|
+
const rowHeight = points(Number(format?.getAttribute('defaultRowHeight') ?? 15));
|
|
844
|
+
return xml.children(this.package.root(drawing), XDR).flatMap((anchor) => {
|
|
845
|
+
const from = xml.child(anchor, XDR, 'from');
|
|
846
|
+
if (!from || markerCell(from).col !== col) {
|
|
847
|
+
return [];
|
|
848
|
+
}
|
|
849
|
+
const to = xml.child(anchor, XDR, 'to');
|
|
850
|
+
if (to) {
|
|
851
|
+
return [markerCell(to).row + 2];
|
|
852
|
+
}
|
|
853
|
+
const ext = xml.child(anchor, XDR, 'ext');
|
|
854
|
+
return ext
|
|
855
|
+
? [markerCell(from).row + Math.ceil(Number(ext.getAttribute('cy')) / rowHeight) + 1]
|
|
856
|
+
: [];
|
|
857
|
+
});
|
|
827
858
|
}
|
|
828
859
|
drawingOf(sheet) {
|
|
829
860
|
const ref = xml.child(sheet.root, X, 'drawing');
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import { HarnessError } from '../errors.js';
|
|
1
2
|
import { errorMessage } from '../guards.js';
|
|
2
3
|
const MAX_OFFICE_BYTES = 20 * 1024 * 1024;
|
|
3
4
|
export function extractWith(bytes, { fileName, signal, extract }) {
|
|
4
5
|
if (bytes.byteLength > MAX_OFFICE_BYTES) {
|
|
5
|
-
throw new
|
|
6
|
+
throw new HarnessError('OFFICE_TOO_LARGE', [bytes.byteLength, MAX_OFFICE_BYTES]);
|
|
6
7
|
}
|
|
7
8
|
if (signal?.aborted) {
|
|
8
|
-
throw new
|
|
9
|
+
throw new HarnessError('OFFICE_EXTRACTION_ABORTED', [fileName]);
|
|
9
10
|
}
|
|
10
11
|
try {
|
|
11
12
|
return extract(bytes);
|
|
12
13
|
}
|
|
13
14
|
catch (err) {
|
|
14
|
-
throw new
|
|
15
|
+
throw new HarnessError('OFFICE_EXTRACTION_FAILED', [fileName, errorMessage(err)]);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
export function cellText(value) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
+
import { HarnessError } from '../errors.js';
|
|
2
3
|
import { extractDocxText } from '../docx/index.js';
|
|
3
4
|
import { pptx, xlsx } from './engine/index.js';
|
|
4
5
|
import { cellText, extractWith } from './extract.js';
|
|
@@ -89,5 +90,5 @@ export async function extractOfficeText(bytes, fileName, options = {}) {
|
|
|
89
90
|
if (extract) {
|
|
90
91
|
return extractWith(bytes, { fileName, signal: options.signal, extract });
|
|
91
92
|
}
|
|
92
|
-
throw new
|
|
93
|
+
throw new HarnessError('OFFICE_UNSUPPORTED_DOCUMENT', [fileName]);
|
|
93
94
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AddonLoaders, ToolDefinition, ToolExecuteContext, ToolFetch } from '../contract/index.ts';
|
|
2
2
|
import type { KnowledgeService } from '../contract/knowledge.ts';
|
|
3
3
|
import type { SandboxService } from '../contract/sandbox.ts';
|
|
4
|
+
import type { EgressProxyService } from '../contract/egress-proxy.ts';
|
|
4
5
|
import type { EmbedHost, ModelHost } from '../contract/models.ts';
|
|
5
6
|
import type { SpeechService } from '../contract/speech.ts';
|
|
6
7
|
import type { HarnessHook, SkillReadiness } from '../contract/index.ts';
|
|
@@ -14,6 +15,7 @@ declare module './context.ts' {
|
|
|
14
15
|
embed: EmbedHost;
|
|
15
16
|
knowledge: KnowledgeService;
|
|
16
17
|
sandbox: SandboxService;
|
|
18
|
+
'egress-proxy': EgressProxyService;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
export interface PluginContext {
|
|
@@ -44,6 +46,7 @@ export interface HarnessPlugin {
|
|
|
44
46
|
api: number;
|
|
45
47
|
provides?: readonly string[];
|
|
46
48
|
needs?: readonly string[];
|
|
49
|
+
wants?: readonly string[];
|
|
47
50
|
addons?: AddonLoaders;
|
|
48
51
|
read?: readonly string[];
|
|
49
52
|
validate?(): string | null;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { HarnessError } from '../errors.js';
|
|
2
|
+
import { Policy } from '../policy/index.js';
|
|
1
3
|
import { canonicalDenyRoots, defaultRealpath } from '../tools/fs/scope.js';
|
|
2
4
|
import { TOOLSETS } from '../tools/toolsets.js';
|
|
3
5
|
import { loadAddons } from './addons.js';
|
|
@@ -55,7 +57,8 @@ function startOrder(plugins, providers, core) {
|
|
|
55
57
|
const placed = new Set();
|
|
56
58
|
const pending = [...plugins];
|
|
57
59
|
while (pending.length > 0) {
|
|
58
|
-
const index = pending.findIndex((plugin) => (plugin.needs ?? []).every((service) => core.has(service) || placed.has(providers.get(service) ?? ''))
|
|
60
|
+
const index = pending.findIndex((plugin) => (plugin.needs ?? []).every((service) => core.has(service) || placed.has(providers.get(service) ?? '')) &&
|
|
61
|
+
(plugin.wants ?? []).every((service) => !providers.has(service) || placed.has(providers.get(service) ?? '')));
|
|
59
62
|
if (index === -1) {
|
|
60
63
|
fail(pending[0].name, 'is part of a dependency cycle');
|
|
61
64
|
}
|
|
@@ -76,7 +79,11 @@ function contextFor(plugin, ctx, { onDispose, fetch, deniedRoots }) {
|
|
|
76
79
|
}
|
|
77
80
|
function servicesFor(plugin, ctx) {
|
|
78
81
|
const view = {};
|
|
79
|
-
for (const name of [
|
|
82
|
+
for (const name of [
|
|
83
|
+
...(plugin.needs ?? []),
|
|
84
|
+
...(plugin.wants ?? []),
|
|
85
|
+
...(plugin.provides ?? [])
|
|
86
|
+
]) {
|
|
80
87
|
view[name] = { enumerable: true, get: () => Reflect.get(ctx, name) };
|
|
81
88
|
}
|
|
82
89
|
return Object.create(null, view);
|
|
@@ -100,10 +107,10 @@ function ruledTool(tool, plugin, policy) {
|
|
|
100
107
|
effect: granted ? tool.effect : () => 'write'
|
|
101
108
|
};
|
|
102
109
|
}
|
|
103
|
-
const offline = () => Promise.reject(new
|
|
104
|
-
const unfetched = () => Promise.reject(new
|
|
110
|
+
const offline = () => Promise.reject(new HarnessError('FETCH_REFUSED', ['the run has the network off']));
|
|
111
|
+
const unfetched = () => Promise.reject(new HarnessError('FETCH_REFUSED', ['the host gave the plugins no fetch']));
|
|
105
112
|
const anywhere = () => Promise.resolve(true);
|
|
106
|
-
function declaredHosts(targets) {
|
|
113
|
+
function declaredHosts(targets, allowed) {
|
|
107
114
|
const hostnames = new Set();
|
|
108
115
|
for (const target of typeof targets === 'string' ? [targets] : (targets ?? [])) {
|
|
109
116
|
try {
|
|
@@ -112,7 +119,7 @@ function declaredHosts(targets) {
|
|
|
112
119
|
catch {
|
|
113
120
|
}
|
|
114
121
|
}
|
|
115
|
-
return (host) => Promise.resolve(hostnames.has(host));
|
|
122
|
+
return (host) => Promise.resolve(hostnames.has(host) && (!allowed || Policy.allowsHost(allowed, host)));
|
|
116
123
|
}
|
|
117
124
|
function withFetch(tool, fetchFor) {
|
|
118
125
|
const { egress, execute } = tool;
|
|
@@ -123,7 +130,9 @@ function withFetch(tool, fetchFor) {
|
|
|
123
130
|
...tool,
|
|
124
131
|
execute: (args, ctx = {}) => execute(args, {
|
|
125
132
|
...ctx,
|
|
126
|
-
fetch: ctx.
|
|
133
|
+
fetch: ctx.policy?.network.mode === 'off'
|
|
134
|
+
? offline
|
|
135
|
+
: fetchFor(ctx.signal, declaredHosts(egress(args), Policy.hostsOf(ctx.policy)))
|
|
127
136
|
})
|
|
128
137
|
};
|
|
129
138
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AccessPolicy, CompiledPolicy, PolicyGrants, PolicyProvider, RunRoots } from '../contract/policy.ts';
|
|
2
|
+
export declare class Policy {
|
|
3
|
+
static narrow(...layers: readonly (AccessPolicy | null | undefined)[]): AccessPolicy;
|
|
4
|
+
static compile(policy: AccessPolicy | null | undefined, grants?: PolicyGrants): CompiledPolicy;
|
|
5
|
+
static enforceable(policy: CompiledPolicy, { enforces }: PolicyProvider): string | null;
|
|
6
|
+
static refusal(policy: CompiledPolicy, providers: readonly PolicyProvider[]): string | null;
|
|
7
|
+
static forRun(layers: readonly (AccessPolicy | null | undefined)[], { fsRoots, fsWriteRoots, deny }: RunRoots, providers: readonly PolicyProvider[]): CompiledPolicy | undefined;
|
|
8
|
+
static hostsOf(policy: CompiledPolicy | undefined): readonly string[] | undefined;
|
|
9
|
+
static allowsHost(hosts: readonly string[], host: string): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
const PRESETS = {
|
|
3
|
+
'read-only': { files: { write: [] }, network: { mode: 'off' } },
|
|
4
|
+
'workspace-write': { network: { mode: 'off' } },
|
|
5
|
+
full: {}
|
|
6
|
+
};
|
|
7
|
+
const ORDER = ['off', 'hosts', 'on'];
|
|
8
|
+
const DECISIONS = ['allow', 'ask', 'deny'];
|
|
9
|
+
const RULE_KEYS = ['decision', 'tool', 'command', 'paths', 'hosts'];
|
|
10
|
+
const UNBOUNDED = bounds({});
|
|
11
|
+
export class Policy {
|
|
12
|
+
static narrow(...layers) {
|
|
13
|
+
return policyOf(layers.reduce((acc, layer) => (layer ? intersect(acc, bounds(layer)) : acc), UNBOUNDED));
|
|
14
|
+
}
|
|
15
|
+
static compile(policy, grants = {}) {
|
|
16
|
+
const own = bounds(policy ?? {});
|
|
17
|
+
const outside = (grant, roots) => roots !== null && !roots.some((root) => inside(grant, root));
|
|
18
|
+
const read = (grants.read ?? []).find((grant) => outside(grant, own.read));
|
|
19
|
+
if (read !== undefined) {
|
|
20
|
+
throw new Error(`a granted folder is outside the policy's files.read: ${read}`);
|
|
21
|
+
}
|
|
22
|
+
const write = (grants.write ?? []).find((grant) => outside(grant, own.write));
|
|
23
|
+
if (write !== undefined) {
|
|
24
|
+
throw new Error(`a granted write folder is outside the policy's files.write: ${write}`);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
files: {
|
|
28
|
+
read: own.read ?? 'all',
|
|
29
|
+
write: unique(grants.write ?? []),
|
|
30
|
+
deny: unique([...own.deny, ...(grants.deny ?? [])])
|
|
31
|
+
},
|
|
32
|
+
network: networkOf(own),
|
|
33
|
+
sockets: own.sockets ?? 'all',
|
|
34
|
+
exec: { allow: own.allow ?? 'all', deny: own.execDeny },
|
|
35
|
+
env: own.env ?? 'all',
|
|
36
|
+
rules: own.rules
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
static enforceable(policy, { enforces }) {
|
|
40
|
+
if ((policy.exec.allow !== 'all' || policy.exec.deny.length > 0) && !enforces?.exec) {
|
|
41
|
+
return 'cannot enforce exec.allow or exec.deny';
|
|
42
|
+
}
|
|
43
|
+
if (policy.env !== 'all' && !enforces?.env) {
|
|
44
|
+
return 'cannot enforce an env allowlist';
|
|
45
|
+
}
|
|
46
|
+
if (enforces?.files === 'workspace-only' && policy.files.read !== 'all') {
|
|
47
|
+
return 'confines writes only, so it cannot enforce a files.read list';
|
|
48
|
+
}
|
|
49
|
+
if (policy.network.mode === 'hosts' && !enforces) {
|
|
50
|
+
return 'runs lines on the host, so it cannot enforce network.mode hosts';
|
|
51
|
+
}
|
|
52
|
+
if (enforces?.network === 'on-off' && policy.network.mode === 'hosts') {
|
|
53
|
+
return 'cannot enforce network.mode hosts without the egress-proxy plugin';
|
|
54
|
+
}
|
|
55
|
+
const { localhost, bind } = policy.network;
|
|
56
|
+
const partial = !localhost || !bind || policy.sockets !== 'all';
|
|
57
|
+
const bounded = enforces?.network === 'on-off' || enforces?.network === 'hosts';
|
|
58
|
+
if (bounded && policy.network.mode === 'on' && partial) {
|
|
59
|
+
return 'turns the network on or off, so it cannot enforce localhost, bind or sockets under network.mode on';
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
static refusal(policy, providers) {
|
|
64
|
+
if (!ORDER.includes(policy.network.mode)) {
|
|
65
|
+
return `network.mode ${policy.network.mode} is refused: it is not off, hosts or on`;
|
|
66
|
+
}
|
|
67
|
+
for (const provider of providers) {
|
|
68
|
+
const refused = Policy.enforceable(policy, provider);
|
|
69
|
+
if (refused) {
|
|
70
|
+
return `${provider.name} ${refused}`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const malformed = policy.rules.findIndex((rule) => !wellFormed(rule));
|
|
74
|
+
return malformed === -1
|
|
75
|
+
? null
|
|
76
|
+
: `policy rule ${malformed} is malformed: it needs a decision (allow, ask or deny), a non-empty tool, command, paths or hosts, and no other key`;
|
|
77
|
+
}
|
|
78
|
+
static forRun(layers, { fsRoots = [], fsWriteRoots = [], deny = [] }, providers) {
|
|
79
|
+
if (!layers.some(Boolean)) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const access = Policy.compile(Policy.narrow(...layers), {
|
|
83
|
+
read: local(fsRoots),
|
|
84
|
+
write: local(fsWriteRoots),
|
|
85
|
+
deny
|
|
86
|
+
});
|
|
87
|
+
const refused = Policy.refusal(access, providers);
|
|
88
|
+
if (refused) {
|
|
89
|
+
throw new Error(`the run's policy is refused: ${refused}`);
|
|
90
|
+
}
|
|
91
|
+
return access;
|
|
92
|
+
}
|
|
93
|
+
static hostsOf(policy) {
|
|
94
|
+
return policy?.network.mode === 'hosts' ? policy.network.hosts : undefined;
|
|
95
|
+
}
|
|
96
|
+
static allowsHost(hosts, host) {
|
|
97
|
+
const name = hostName(host);
|
|
98
|
+
return hosts.some((entry) => covers(hostName(entry), name));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function wellFormed(rule) {
|
|
102
|
+
if (typeof rule !== 'object' || rule === null || !DECISIONS.includes(rule.decision)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (Object.keys(rule).some((key) => !RULE_KEYS.includes(key))) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
const { tool, command, paths, hosts } = rule;
|
|
109
|
+
const lists = [command, paths, hosts];
|
|
110
|
+
if (tool === undefined && lists.every((list) => list === undefined)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
return ((tool === undefined || (typeof tool === 'string' && tool !== '')) &&
|
|
114
|
+
lists.every((list) => list === undefined || strings(list)));
|
|
115
|
+
}
|
|
116
|
+
function strings(list) {
|
|
117
|
+
return (Array.isArray(list) &&
|
|
118
|
+
list.length > 0 &&
|
|
119
|
+
list.every((each) => typeof each === 'string' && each !== ''));
|
|
120
|
+
}
|
|
121
|
+
function local(roots) {
|
|
122
|
+
return roots.flatMap((root) => (root.kind === 'local' ? [root.root] : []));
|
|
123
|
+
}
|
|
124
|
+
function bounds(layer) {
|
|
125
|
+
const preset = layer.preset ? PRESETS[layer.preset] : {};
|
|
126
|
+
const read = layer.files?.read ?? preset.files?.read ?? 'all';
|
|
127
|
+
const write = layer.files?.write ?? preset.files?.write;
|
|
128
|
+
const network = layer.network ?? preset.network ?? { mode: 'on' };
|
|
129
|
+
const mode = ORDER.includes(network.mode) ? network.mode : 'off';
|
|
130
|
+
const open = mode === 'on';
|
|
131
|
+
return {
|
|
132
|
+
read: read === 'all' ? null : unique(read.map(normal)),
|
|
133
|
+
write: write ? unique(write.map(normal)) : null,
|
|
134
|
+
deny: unique((layer.files?.deny ?? preset.files?.deny ?? []).map(normal)),
|
|
135
|
+
mode,
|
|
136
|
+
hosts: open ? null : unique((network.hosts ?? []).map(hostName)),
|
|
137
|
+
localhost: network.localhost ?? open,
|
|
138
|
+
bind: network.bind ?? open,
|
|
139
|
+
sockets: socketsOf(layer.sockets, open),
|
|
140
|
+
allow: layer.exec?.allow ? unique(layer.exec.allow) : null,
|
|
141
|
+
execDeny: unique(layer.exec?.deny ?? []),
|
|
142
|
+
env: layer.env ? unique(layer.env) : null,
|
|
143
|
+
rules: layer.rules ?? []
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function socketsOf(sockets, open) {
|
|
147
|
+
if (sockets) {
|
|
148
|
+
return unique(sockets.map(normal));
|
|
149
|
+
}
|
|
150
|
+
return open ? null : [];
|
|
151
|
+
}
|
|
152
|
+
function intersect(a, b) {
|
|
153
|
+
return {
|
|
154
|
+
read: within(a.read, b.read),
|
|
155
|
+
write: within(a.write, b.write),
|
|
156
|
+
deny: unique([...a.deny, ...b.deny]),
|
|
157
|
+
mode: ORDER[Math.min(ORDER.indexOf(a.mode), ORDER.indexOf(b.mode))],
|
|
158
|
+
hosts: coveredHosts(a.hosts, b.hosts),
|
|
159
|
+
localhost: a.localhost && b.localhost,
|
|
160
|
+
bind: a.bind && b.bind,
|
|
161
|
+
sockets: within(a.sockets, b.sockets),
|
|
162
|
+
allow: common(a.allow, b.allow),
|
|
163
|
+
execDeny: unique([...a.execDeny, ...b.execDeny]),
|
|
164
|
+
env: common(a.env, b.env),
|
|
165
|
+
rules: [...a.rules, ...b.rules]
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function policyOf(own) {
|
|
169
|
+
return {
|
|
170
|
+
files: { read: own.read ?? 'all', write: own.write ?? undefined, deny: own.deny },
|
|
171
|
+
network: networkOf(own),
|
|
172
|
+
sockets: own.sockets ?? undefined,
|
|
173
|
+
exec: { allow: own.allow ?? undefined, deny: own.execDeny },
|
|
174
|
+
env: own.env ?? undefined,
|
|
175
|
+
rules: own.rules
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function networkOf(own) {
|
|
179
|
+
return {
|
|
180
|
+
mode: own.mode,
|
|
181
|
+
hosts: own.mode === 'hosts' ? (own.hosts ?? []) : [],
|
|
182
|
+
localhost: own.localhost,
|
|
183
|
+
bind: own.bind
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function within(a, b) {
|
|
187
|
+
if (a === null || b === null) {
|
|
188
|
+
return a ?? b;
|
|
189
|
+
}
|
|
190
|
+
return unique([
|
|
191
|
+
...a.filter((each) => b.some((root) => inside(each, root))),
|
|
192
|
+
...b.filter((each) => a.some((root) => inside(each, root)))
|
|
193
|
+
]).sort();
|
|
194
|
+
}
|
|
195
|
+
function coveredHosts(a, b) {
|
|
196
|
+
if (a === null || b === null) {
|
|
197
|
+
return a ?? b;
|
|
198
|
+
}
|
|
199
|
+
return unique([
|
|
200
|
+
...a.filter((each) => b.some((entry) => covers(entry, each))),
|
|
201
|
+
...b.filter((each) => a.some((entry) => covers(entry, each)))
|
|
202
|
+
]).sort();
|
|
203
|
+
}
|
|
204
|
+
function covers(entry, host) {
|
|
205
|
+
return host === entry || (entry.startsWith('*.') && host.endsWith(entry.slice(1)));
|
|
206
|
+
}
|
|
207
|
+
function hostName(host) {
|
|
208
|
+
return host
|
|
209
|
+
.toLowerCase()
|
|
210
|
+
.replace(/^\[(.*)\]$/, '$1')
|
|
211
|
+
.replace(/\.$/, '');
|
|
212
|
+
}
|
|
213
|
+
function common(a, b) {
|
|
214
|
+
if (a === null || b === null) {
|
|
215
|
+
return a ?? b;
|
|
216
|
+
}
|
|
217
|
+
return a.filter((each) => b.includes(each));
|
|
218
|
+
}
|
|
219
|
+
function inside(child, root) {
|
|
220
|
+
const relative = path.relative(normal(root), normal(child));
|
|
221
|
+
return (relative === '' ||
|
|
222
|
+
(relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative)));
|
|
223
|
+
}
|
|
224
|
+
function normal(root) {
|
|
225
|
+
return path.resolve(root);
|
|
226
|
+
}
|
|
227
|
+
function unique(items) {
|
|
228
|
+
return [...new Set(items)];
|
|
229
|
+
}
|
package/dist-lib/lib/prompt.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare function annotateLastUserTime<T extends {
|
|
|
6
6
|
role: string;
|
|
7
7
|
content: string;
|
|
8
8
|
}>(turns: ReadonlyArray<T>, now?: Date): T[];
|
|
9
|
+
export declare function toolGuidelines(name: string): string[];
|
|
9
10
|
export interface SystemPromptInput {
|
|
10
11
|
bio?: string | null | undefined;
|
|
11
12
|
toolNames?: ReadonlyArray<string>;
|
package/dist-lib/lib/prompt.js
CHANGED
|
@@ -51,13 +51,19 @@ export function annotateLastUserTime(turns, now) {
|
|
|
51
51
|
}
|
|
52
52
|
return result;
|
|
53
53
|
}
|
|
54
|
+
export function toolGuidelines(name) {
|
|
55
|
+
if (name === 'exec') {
|
|
56
|
+
return [EXEC_FILE_GUIDELINE, EXEC_ATTACHED_IMAGE_GUIDELINE];
|
|
57
|
+
}
|
|
58
|
+
return name === 'web_search' || name === 'web_fetch' ? [CITATION_GUIDELINE] : [];
|
|
59
|
+
}
|
|
54
60
|
function buildGuidelines(active) {
|
|
55
61
|
const lines = [...BASE_GUIDELINES];
|
|
56
62
|
if (active.size > 0) {
|
|
57
63
|
lines.push(...TOOL_GUIDELINES);
|
|
58
64
|
}
|
|
59
65
|
if (active.has('exec')) {
|
|
60
|
-
lines.push(
|
|
66
|
+
lines.push(...toolGuidelines('exec'));
|
|
61
67
|
}
|
|
62
68
|
if (active.has('skill')) {
|
|
63
69
|
lines.push(...SKILL_GUIDELINES);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { HarnessError } from '../errors.js';
|
|
1
2
|
import { createLocalRoots } from '../tools/fs/local.js';
|
|
2
3
|
import { createRemoteRoots } from '../tools/fs/remote.js';
|
|
3
4
|
import { isResident, modelKey, resolveCtxSize } from '../models/model-pool.js';
|
|
4
|
-
import {
|
|
5
|
+
import { HarnessLog } from '../log.js';
|
|
5
6
|
export async function prepareCompletionRuntime(residency, request) {
|
|
6
7
|
const model = request.model ?? '';
|
|
7
8
|
const agent = request.agent;
|
|
@@ -14,7 +15,7 @@ export async function prepareCompletionRuntime(residency, request) {
|
|
|
14
15
|
}
|
|
15
16
|
const key = modelKey(model, loadOpts);
|
|
16
17
|
const resident = isResident(residency.pool, key);
|
|
17
|
-
|
|
18
|
+
HarnessLog.info('completion start', { model, resident, projection: Boolean(projectionModel) });
|
|
18
19
|
const acquireRound = async (invocationSignal) => {
|
|
19
20
|
const pool = residency.pool;
|
|
20
21
|
const lease = await residency.acquireLease({
|
|
@@ -39,10 +40,16 @@ export async function prepareCompletionRuntime(residency, request) {
|
|
|
39
40
|
try {
|
|
40
41
|
const sdk = await residency.sdk.load();
|
|
41
42
|
if (residency.gate.suspended || residency.gate.draining) {
|
|
42
|
-
throw new
|
|
43
|
+
throw new HarnessError('HARNESS_SUSPENDED');
|
|
43
44
|
}
|
|
44
45
|
residency.gate.assertNotClosing();
|
|
45
|
-
return {
|
|
46
|
+
return {
|
|
47
|
+
modelId: lease.modelId,
|
|
48
|
+
ctxSize: lease.ctxSize,
|
|
49
|
+
slots: lease.slots,
|
|
50
|
+
sdk,
|
|
51
|
+
release: lease.release
|
|
52
|
+
};
|
|
46
53
|
}
|
|
47
54
|
catch (error) {
|
|
48
55
|
lease.release();
|