@qvac/harness 1.0.0-rc.2 → 1.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/CHANGELOG.md +2280 -1485
- package/README.md +56 -43
- package/dist-lib/index.d.ts +50 -6
- package/dist-lib/index.js +130 -28
- package/dist-lib/lib/agent/delegate.d.ts +3 -2
- package/dist-lib/lib/agent/delegate.js +6 -4
- package/dist-lib/lib/agent/follow.d.ts +5 -0
- package/dist-lib/lib/agent/follow.js +2 -0
- package/dist-lib/lib/agent/resolve.js +22 -17
- package/dist-lib/lib/agent/tool-selection.d.ts +4 -2
- package/dist-lib/lib/agent/tool-selection.js +5 -6
- package/dist-lib/lib/agent/tools.d.ts +1 -0
- package/dist-lib/lib/agent/tools.js +2 -1
- package/dist-lib/lib/capabilities/agent-ports.js +3 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/batching.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +60 -9
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +4 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +35 -6
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +67 -27
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +6 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +61 -16
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +23 -13
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +8 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +61 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +5 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +47 -21
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +30 -5
- package/dist-lib/lib/capabilities/completion-engine/driver.js +27 -11
- package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/durable.js +5 -1
- package/dist-lib/lib/capabilities/completion-engine/index.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/index.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +15 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.js +7 -0
- package/dist-lib/lib/capabilities/completion-engine/metrics.d.ts +9 -2
- package/dist-lib/lib/capabilities/completion-engine/metrics.js +28 -7
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +46 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.js +45 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.js +1 -1
- package/dist-lib/lib/capabilities/completion-engine/ports.js +3 -7
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +23 -3
- package/dist-lib/lib/capabilities/completion-engine/round.js +323 -97
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +10 -3
- package/dist-lib/lib/capabilities/completion-engine/session.js +30 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +4 -3
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +15 -10
- package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +11 -4
- package/dist-lib/lib/capabilities/completion-engine/turns.js +48 -65
- package/dist-lib/lib/capabilities/download.d.ts +9 -7
- package/dist-lib/lib/capabilities/download.js +1 -1
- package/dist-lib/lib/capabilities/enhance.d.ts +1 -1
- package/dist-lib/lib/capabilities/enhance.js +20 -8
- package/dist-lib/lib/capabilities/preview-model-source.d.ts +7 -0
- package/dist-lib/lib/capabilities/preview-model-source.js +83 -23
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +1 -0
- package/dist-lib/lib/capabilities/sdk-tool.js +18 -1
- package/dist-lib/lib/capabilities/tool-plan.d.ts +1 -1
- package/dist-lib/lib/capabilities/tool-plan.js +5 -5
- package/dist-lib/lib/capabilities/tool-prompt-log.js +3 -3
- package/dist-lib/lib/capabilities/tool-turns.d.ts +7 -9
- package/dist-lib/lib/capabilities/tool-turns.js +25 -20
- package/dist-lib/lib/client/index.d.ts +19 -0
- package/dist-lib/lib/client/index.js +262 -0
- package/dist-lib/lib/connect.d.ts +13 -10
- package/dist-lib/lib/connect.js +62 -24
- package/dist-lib/lib/context-window.d.ts +1 -0
- package/dist-lib/lib/context-window.js +3 -3
- package/dist-lib/lib/contract/agent.d.ts +7 -3
- package/dist-lib/lib/contract/completion.d.ts +44 -29
- package/dist-lib/lib/contract/egress-proxy.d.ts +13 -0
- package/dist-lib/lib/contract/egress-proxy.js +1 -0
- package/dist-lib/lib/contract/exec.d.ts +3 -3
- package/dist-lib/lib/contract/hooks.d.ts +4 -1
- package/dist-lib/lib/contract/index.d.ts +1 -0
- package/dist-lib/lib/contract/models.d.ts +6 -4
- package/dist-lib/lib/contract/policy.d.ts +75 -0
- package/dist-lib/lib/contract/policy.js +1 -0
- package/dist-lib/lib/contract/run.d.ts +9 -3
- package/dist-lib/lib/contract/sandbox.d.ts +3 -1
- package/dist-lib/lib/contract/translation.d.ts +20 -0
- package/dist-lib/lib/contract/translation.js +1 -0
- package/dist-lib/lib/contract-types.d.ts +32 -14
- package/dist-lib/lib/embeddings/index.d.ts +7 -1
- package/dist-lib/lib/embeddings/index.js +26 -5
- package/dist-lib/lib/errors.d.ts +266 -0
- package/dist-lib/lib/errors.js +198 -0
- package/dist-lib/lib/fold/index.d.ts +25 -1
- package/dist-lib/lib/fold/index.js +75 -9
- package/dist-lib/lib/guarded-fetch.js +11 -7
- package/dist-lib/lib/hardware/gpu-probe.js +10 -1
- package/dist-lib/lib/helpers/completion-params.d.ts +6 -2
- package/dist-lib/lib/helpers/completion-params.js +10 -1
- package/dist-lib/lib/helpers/engine-error.d.ts +2 -1
- package/dist-lib/lib/helpers/engine-error.js +12 -12
- package/dist-lib/lib/helpers/goal-check.d.ts +4 -0
- package/dist-lib/lib/helpers/goal-check.js +81 -0
- package/dist-lib/lib/helpers/head-tail.js +1 -1
- package/dist-lib/lib/helpers/load-stall.d.ts +1 -1
- package/dist-lib/lib/helpers/load-stall.js +2 -2
- package/dist-lib/lib/helpers/markup-stream-filter.d.ts +4 -1
- package/dist-lib/lib/helpers/markup-stream-filter.js +20 -6
- package/dist-lib/lib/helpers/repeated-reply.js +24 -16
- package/dist-lib/lib/helpers/thinking.d.ts +3 -2
- package/dist-lib/lib/helpers/thinking.js +19 -0
- package/dist-lib/lib/hooks/built-in/arg-repair.js +6 -2
- package/dist-lib/lib/hooks/built-in/policy-rules.d.ts +8 -0
- package/dist-lib/lib/hooks/built-in/policy-rules.js +192 -0
- package/dist-lib/lib/hooks/built-in/sandbox.js +23 -5
- package/dist-lib/lib/hooks/index.d.ts +4 -1
- package/dist-lib/lib/hooks/index.js +9 -4
- package/dist-lib/lib/hooks/run.js +3 -3
- package/dist-lib/lib/lifecycle/index.js +15 -14
- package/dist-lib/lib/lifecycle/machine.js +2 -2
- package/dist-lib/lib/log.d.ts +26 -5
- package/dist-lib/lib/log.js +86 -23
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +4 -2
- package/dist-lib/lib/machine/completion/actions/completion.js +75 -10
- package/dist-lib/lib/machine/completion/actions/prepare.js +1 -1
- package/dist-lib/lib/machine/completion/actions/tools.js +48 -5
- package/dist-lib/lib/machine/completion/context.js +4 -1
- package/dist-lib/lib/machine/completion/guards/retry.d.ts +1 -0
- package/dist-lib/lib/machine/completion/guards/retry.js +8 -2
- package/dist-lib/lib/machine/completion/implementations.d.ts +10 -4
- package/dist-lib/lib/machine/completion/implementations.js +27 -6
- package/dist-lib/lib/machine/completion/machine.d.ts +21 -3
- package/dist-lib/lib/machine/completion/machine.js +33 -4
- package/dist-lib/lib/machine/completion/rules.d.ts +17 -2
- package/dist-lib/lib/machine/completion/rules.js +49 -3
- package/dist-lib/lib/machine/completion/types.d.ts +36 -0
- package/dist-lib/lib/machine/index.d.ts +27 -4
- package/dist-lib/lib/machine/index.js +6 -1
- package/dist-lib/lib/models/context-choice.d.ts +15 -0
- package/dist-lib/lib/models/context-choice.js +55 -0
- package/dist-lib/lib/models/download-gate.d.ts +20 -0
- package/dist-lib/lib/models/download-gate.js +73 -0
- package/dist-lib/lib/models/gguf-header.d.ts +5 -0
- package/dist-lib/lib/models/gguf-header.js +165 -14
- package/dist-lib/lib/models/llm-presets.d.ts +5 -1
- package/dist-lib/lib/models/llm-presets.js +6 -5
- package/dist-lib/lib/models/memory-cap.d.ts +13 -0
- package/dist-lib/lib/models/memory-cap.js +21 -0
- package/dist-lib/lib/models/model-catalog.d.ts +2 -0
- package/dist-lib/lib/models/model-catalog.js +15 -0
- package/dist-lib/lib/models/model-fit.d.ts +1 -1
- package/dist-lib/lib/models/model-fit.js +5 -6
- package/dist-lib/lib/models/model-handle.d.ts +8 -2
- package/dist-lib/lib/models/model-handle.js +14 -3
- package/dist-lib/lib/models/model-list.d.ts +8 -1
- package/dist-lib/lib/models/model-list.js +23 -0
- package/dist-lib/lib/models/model-pool.d.ts +35 -5
- package/dist-lib/lib/models/model-pool.js +121 -43
- package/dist-lib/lib/models/model-source.d.ts +1 -0
- package/dist-lib/lib/models/model-source.js +23 -5
- package/dist-lib/lib/models/sdk-faults.d.ts +1 -0
- package/dist-lib/lib/models/sdk-faults.js +9 -0
- package/dist-lib/lib/no-redirect-fetch-bare.js +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.js +2 -1
- package/dist-lib/lib/office/engine/pptx/picture-area.d.ts +23 -0
- package/dist-lib/lib/office/engine/pptx/picture-area.js +84 -0
- package/dist-lib/lib/office/engine/pptx/presentation.d.ts +2 -0
- package/dist-lib/lib/office/engine/pptx/presentation.js +55 -17
- package/dist-lib/lib/office/engine/pptx/types.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/workbook.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/workbook.js +34 -3
- package/dist-lib/lib/office/extract.js +4 -3
- package/dist-lib/lib/office/index.js +2 -1
- package/dist-lib/lib/plugins/registry.d.ts +3 -0
- package/dist-lib/lib/plugins/registry.js +16 -7
- package/dist-lib/lib/policy/index.d.ts +10 -0
- package/dist-lib/lib/policy/index.js +229 -0
- package/dist-lib/lib/prompt.d.ts +1 -0
- package/dist-lib/lib/prompt.js +7 -1
- package/dist-lib/lib/residency/completion-runtime.d.ts +1 -0
- package/dist-lib/lib/residency/completion-runtime.js +11 -4
- package/dist-lib/lib/residency/index.d.ts +44 -4
- package/dist-lib/lib/residency/index.js +399 -35
- package/dist-lib/lib/resolution-detector.js +3 -3
- package/dist-lib/lib/rpc-session.js +2 -1
- package/dist-lib/lib/sdk-loader.js +17 -11
- package/dist-lib/lib/serve.js +76 -36
- package/dist-lib/lib/sidecar/index.d.ts +29 -0
- package/dist-lib/lib/sidecar/index.js +174 -0
- package/dist-lib/lib/sidecar/user-plugins.d.ts +8 -0
- package/dist-lib/lib/sidecar/user-plugins.js +117 -0
- package/dist-lib/lib/skills-host/index.d.ts +1 -0
- package/dist-lib/lib/skills-host/index.js +8 -4
- package/dist-lib/lib/spawn.d.ts +3 -4
- package/dist-lib/lib/spawn.js +17 -17
- package/dist-lib/lib/spill.d.ts +1 -0
- package/dist-lib/lib/spill.js +12 -8
- package/dist-lib/lib/tools/attachments/staging.js +8 -8
- package/dist-lib/lib/tools/exec/runner.js +2 -1
- package/dist-lib/lib/tools/exec/scope.d.ts +0 -1
- package/dist-lib/lib/tools/exec/scope.js +23 -114
- package/dist-lib/lib/tools/exec/shell-guidance.js +4 -4
- package/dist-lib/lib/tools/exec/shell-line.d.ts +26 -0
- package/dist-lib/lib/tools/exec/shell-line.js +334 -0
- package/dist-lib/lib/tools/exec.d.ts +4 -1
- package/dist-lib/lib/tools/exec.js +87 -26
- package/dist-lib/lib/tools/files/edit-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/edit-file.js +74 -0
- package/dist-lib/lib/tools/files/glob.d.ts +3 -0
- package/dist-lib/lib/tools/files/glob.js +65 -0
- package/dist-lib/lib/tools/files/grep.d.ts +6 -0
- package/dist-lib/lib/tools/files/grep.js +114 -0
- package/dist-lib/lib/tools/files/index.d.ts +3 -0
- package/dist-lib/lib/tools/files/index.js +23 -0
- package/dist-lib/lib/tools/files/list-dir.d.ts +6 -0
- package/dist-lib/lib/tools/files/list-dir.js +136 -0
- package/dist-lib/lib/tools/files/make-dir.d.ts +3 -0
- package/dist-lib/lib/tools/files/make-dir.js +48 -0
- package/dist-lib/lib/tools/files/read-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/read-file.js +105 -0
- package/dist-lib/lib/tools/files/transfer.d.ts +4 -0
- package/dist-lib/lib/tools/files/transfer.js +83 -0
- package/dist-lib/lib/tools/files/trash-file.d.ts +4 -0
- package/dist-lib/lib/tools/files/trash-file.js +62 -0
- package/dist-lib/lib/tools/files/write-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/write-file.js +56 -0
- package/dist-lib/lib/tools/fs/document-text.d.ts +2 -0
- package/dist-lib/lib/tools/fs/document-text.js +38 -0
- package/dist-lib/lib/tools/fs/drive.d.ts +14 -3
- package/dist-lib/lib/tools/fs/drive.js +9 -1
- package/dist-lib/lib/tools/fs/edit-match.d.ts +11 -0
- package/dist-lib/lib/tools/fs/edit-match.js +85 -0
- package/dist-lib/lib/tools/fs/ignore.d.ts +13 -0
- package/dist-lib/lib/tools/fs/ignore.js +104 -0
- package/dist-lib/lib/tools/fs/local.js +28 -5
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +23 -3
- package/dist-lib/lib/tools/fs/remote.d.ts +3 -4
- package/dist-lib/lib/tools/fs/remote.js +23 -13
- package/dist-lib/lib/tools/fs/scope.d.ts +5 -1
- package/dist-lib/lib/tools/fs/scope.js +5 -2
- package/dist-lib/lib/tools/fs/search.d.ts +41 -0
- package/dist-lib/lib/tools/fs/search.js +382 -0
- package/dist-lib/lib/tools/{file-glob.d.ts → fs/targets.d.ts} +1 -5
- package/dist-lib/lib/tools/fs/targets.js +32 -0
- package/dist-lib/lib/tools/fs/tool-path.d.ts +27 -0
- package/dist-lib/lib/tools/fs/tool-path.js +70 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +15 -3
- package/dist-lib/lib/tools/fs/walk.js +118 -24
- package/dist-lib/lib/tools/http-request.js +12 -2
- package/dist-lib/lib/tools/index.js +2 -10
- package/dist-lib/lib/tools/office/ops.js +1 -1
- package/dist-lib/lib/tools/office.js +77 -21
- package/dist-lib/lib/tools/pdf/build.d.ts +5 -1
- package/dist-lib/lib/tools/pdf/build.js +31 -6
- package/dist-lib/lib/tools/pdf.js +17 -2
- package/dist-lib/lib/tools/skill.js +10 -7
- package/dist-lib/lib/tools/skills/bundled-dir.js +4 -4
- package/dist-lib/lib/tools/skills/catalog.d.ts +2 -0
- package/dist-lib/lib/tools/skills/catalog.js +6 -2
- package/dist-lib/lib/tools/skills/cli-argv.js +25 -5
- package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/cli-schema-check.js +3 -0
- package/dist-lib/lib/tools/skills/cli-schema-load.js +10 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +2 -0
- package/dist-lib/lib/tools/skills/cli-schema.js +6 -3
- package/dist-lib/lib/tools/skills/credential-health.js +3 -3
- package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +2 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +4 -0
- package/dist-lib/lib/tools/skills/manifest-parse.d.ts +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +12 -0
- package/dist-lib/lib/tools/skills/mention-name.d.ts +6 -0
- package/dist-lib/lib/tools/skills/mention-name.js +6 -0
- package/dist-lib/lib/tools/skills/mention.d.ts +2 -2
- package/dist-lib/lib/tools/skills/mention.js +11 -4
- package/dist-lib/lib/tools/skills/overlay-crud.js +3 -2
- package/dist-lib/lib/tools/url-guard.d.ts +6 -1
- package/dist-lib/lib/tools/url-guard.js +8 -2
- package/dist-lib/lib/tools/web-fetch.js +10 -4
- package/dist-lib/lib/wire.js +3 -5
- package/dist-lib/plugins/coding/index.d.ts +1 -1
- package/dist-lib/plugins/coding/index.js +2 -4
- package/dist-lib/plugins/coding/session.d.ts +3 -3
- package/dist-lib/plugins/coding/session.js +26 -14
- package/dist-lib/plugins/command-hooks/index.js +5 -3
- package/dist-lib/plugins/egress-proxy/index.d.ts +53 -0
- package/dist-lib/plugins/egress-proxy/index.js +182 -0
- package/dist-lib/plugins/image/edit-image.js +4 -3
- package/dist-lib/plugins/image/generate-image.d.ts +4 -3
- package/dist-lib/plugins/image/generate-image.js +10 -9
- package/dist-lib/plugins/image/index.d.ts +1 -1
- package/dist-lib/plugins/image/index.js +13 -10
- package/dist-lib/plugins/language-hint/index.d.ts +15 -0
- package/dist-lib/plugins/language-hint/index.js +51 -0
- package/dist-lib/plugins/lsp/tool.js +2 -2
- package/dist-lib/plugins/mcp/index.js +6 -3
- package/dist-lib/plugins/music/generate-music.d.ts +4 -2
- package/dist-lib/plugins/music/generate-music.js +7 -4
- package/dist-lib/plugins/music/index.js +12 -9
- package/dist-lib/plugins/obsidian/command.js +2 -2
- package/dist-lib/plugins/obsidian/note-name.js +2 -1
- package/dist-lib/plugins/obsidian/safe-path.js +5 -4
- package/dist-lib/plugins/obsidian/vault-create.js +3 -2
- package/dist-lib/plugins/obsidian/vault-fs.js +2 -2
- package/dist-lib/plugins/obsidian/vault-paths.js +3 -2
- package/dist-lib/plugins/obsidian/vault-read.js +6 -5
- package/dist-lib/plugins/obsidian/vault-write.js +13 -12
- package/dist-lib/plugins/python/guarded-fetch.d.ts +2 -1
- package/dist-lib/plugins/python/guarded-fetch.js +5 -1
- package/dist-lib/plugins/python/interrupt-timer.js +2 -2
- package/dist-lib/plugins/python/loader.js +68 -3
- package/dist-lib/plugins/python/memfs.js +2 -2
- package/dist-lib/plugins/python/pyodide.d.ts +1 -0
- package/dist-lib/plugins/python/pyodide.js +9 -8
- package/dist-lib/plugins/python/python-adapter.js +3 -1
- package/dist-lib/plugins/python/run-session.d.ts +1 -0
- package/dist-lib/plugins/python/run-session.js +19 -8
- package/dist-lib/plugins/python/wheels.js +8 -6
- package/dist-lib/plugins/python/worker/active.js +2 -2
- package/dist-lib/plugins/python/worker/client.js +9 -8
- package/dist-lib/plugins/python/worker/protocol.d.ts +2 -0
- package/dist-lib/plugins/python/worker/serve.js +23 -4
- package/dist-lib/plugins/python/worker/spawn.d.ts +2 -1
- package/dist-lib/plugins/python/worker/spawn.js +2 -1
- package/dist-lib/plugins/run-report/chain.d.ts +2 -0
- package/dist-lib/plugins/run-report/chain.js +73 -0
- package/dist-lib/plugins/run-report/flow-view.js +2 -1
- package/dist-lib/plugins/run-report/flow.d.ts +1 -1
- package/dist-lib/plugins/run-report/flow.js +66 -14
- package/dist-lib/plugins/run-report/index.d.ts +23 -2
- package/dist-lib/plugins/run-report/index.js +27 -12
- package/dist-lib/plugins/run-report/model.d.ts +10 -1
- package/dist-lib/plugins/run-report/model.js +12 -6
- package/dist-lib/plugins/run-report/page.d.ts +9 -0
- package/dist-lib/plugins/run-report/page.js +55 -15
- package/dist-lib/plugins/run-report/script.js +317 -43
- package/dist-lib/plugins/run-report/story.d.ts +2 -1
- package/dist-lib/plugins/run-report/story.js +3 -3
- package/dist-lib/plugins/run-report/style.d.ts +1 -1
- package/dist-lib/plugins/run-report/style.js +126 -0
- package/dist-lib/plugins/run-report/why.js +1 -1
- package/dist-lib/plugins/sandbox-linux/index.d.ts +60 -0
- package/dist-lib/plugins/sandbox-linux/index.js +347 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.d.ts +2 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.js +74 -0
- package/dist-lib/plugins/sandbox-macos/index.d.ts +23 -11
- package/dist-lib/plugins/sandbox-macos/index.js +239 -49
- package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +4 -2
- package/dist-lib/plugins/sandbox-vm/vm-shell.js +9 -4
- package/dist-lib/plugins/sandbox-windows/helper/qvac-sandbox.c +554 -0
- package/dist-lib/plugins/sandbox-windows/index.d.ts +53 -0
- package/dist-lib/plugins/sandbox-windows/index.js +205 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/speech/audio-resample.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-resample.js +7 -8
- package/dist-lib/plugins/speech/audio-transcode-bare.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-bare.js +23 -26
- package/dist-lib/plugins/speech/audio-transcode-node.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-node.js +1 -3
- package/dist-lib/plugins/speech/speech-runtime.js +37 -37
- package/dist-lib/plugins/speech/voice.d.ts +5 -1
- package/dist-lib/plugins/speech/voice.js +100 -31
- package/dist-lib/plugins/translation/index.d.ts +1 -0
- package/dist-lib/plugins/translation/index.js +16 -9
- package/dist-lib/plugins/translation/translate.d.ts +7 -3
- package/dist-lib/plugins/translation/translate.js +64 -58
- package/dist-lib/plugins/weather/geocode.js +2 -1
- package/dist-lib/plugins/weather/lookup.js +5 -4
- package/dist-lib/plugins/web-search/engines/bing.js +2 -1
- package/dist-lib/plugins/web-search/engines/google.js +2 -1
- package/dist-lib/plugins/web-search/fetch-html.d.ts +5 -5
- package/dist-lib/plugins/web-search/fetch-html.js +12 -15
- package/dist-lib/plugins/web-search/tool.js +1 -0
- package/dist-lib/schema/harness.js +48 -7
- package/dist-lib/spec/bind.js +9 -0
- package/dist-lib/spec/calls.js +3 -0
- package/dist-lib/spec/hrpc/hrpc.json +42 -3
- package/dist-lib/spec/hrpc/index.js +44 -8
- package/dist-lib/spec/hrpc/messages.js +297 -202
- package/dist-lib/spec/hyperschema/index.js +297 -202
- package/dist-lib/spec/hyperschema/schema.json +155 -84
- package/dist-lib/spec/hyperschema/types.d.ts +23 -3
- package/package.json +101 -38
- package/patches/@qvac%2Finference@0.22.0.patch +59 -0
- package/patches/pyodide@314.0.2.patch +37 -8
- package/scripts/addon-externals.cjs +10 -5
- package/worker/harness-sidecar.mjs +18 -154
- package/dist-lib/lib/tools/create-documents.d.ts +0 -3
- package/dist-lib/lib/tools/create-documents.js +0 -95
- package/dist-lib/lib/tools/edit-documents.d.ts +0 -3
- package/dist-lib/lib/tools/edit-documents.js +0 -132
- package/dist-lib/lib/tools/exec/shell-argv.d.ts +0 -2
- package/dist-lib/lib/tools/exec/shell-argv.js +0 -61
- package/dist-lib/lib/tools/file-glob.js +0 -118
- package/dist-lib/lib/tools/grep.d.ts +0 -5
- package/dist-lib/lib/tools/grep.js +0 -184
- package/dist-lib/lib/tools/read-files.d.ts +0 -5
- package/dist-lib/lib/tools/read-files.js +0 -160
- package/dist-lib/plugins/coding/write-file.d.ts +0 -3
- package/dist-lib/plugins/coding/write-file.js +0 -52
- package/patches/@qvac%2Finference@0.21.0.patch +0 -67
- package/patches/bare-stow@0.1.5.patch +0 -68
- package/patches/hypercore-blob-server@1.15.0.patch +0 -15
|
@@ -70,6 +70,7 @@ function batchMembers(deps, context) {
|
|
|
70
70
|
for (const call of context.toolQueue) {
|
|
71
71
|
if (members.length === MAX_BATCH ||
|
|
72
72
|
!call.concurrent ||
|
|
73
|
+
call.cutOff ||
|
|
73
74
|
context.failedCalls[call.key] ||
|
|
74
75
|
members.some((member) => member.call.key === call.key)) {
|
|
75
76
|
break;
|
|
@@ -3,6 +3,7 @@ import { Agent } from '../../../agent/index.js';
|
|
|
3
3
|
import { DIRECT_CALL_ID } from '../../tool-turns.js';
|
|
4
4
|
import { approvalGate, trustedSources } from './execution-plan.js';
|
|
5
5
|
import { detachJson } from '../../../helpers/detach-json.js';
|
|
6
|
+
import { ruleInputs } from '../tool-execution.js';
|
|
6
7
|
import { deniedWithoutApprover, gateRejection, policyActivity } from './rejection.js';
|
|
7
8
|
export const directSearch = async function directSearch({ input: deps, context }) {
|
|
8
9
|
return {
|
|
@@ -26,6 +27,7 @@ export async function startDirectSearch(deps, context, query) {
|
|
|
26
27
|
args: { query },
|
|
27
28
|
agentId: context.agentId,
|
|
28
29
|
egress: webSearch.egress,
|
|
30
|
+
...ruleInputs(webSearch, undefined),
|
|
29
31
|
signal: args.signal
|
|
30
32
|
});
|
|
31
33
|
const searchArgs = fold.ok ? detachJson(fold.args) : { query };
|
|
@@ -4,13 +4,15 @@ import { spliceFrom } from '../splice.js';
|
|
|
4
4
|
import { answerOf, callSucceeded, readyPreflightFromFacts, reportFailure, settledFailure } from '../tool-execution.js';
|
|
5
5
|
import { directToolHistory } from '../turns.js';
|
|
6
6
|
import { labelOf } from '../loop.js';
|
|
7
|
-
import { DIRECT_CALL_ID, deliversFile, materializeCompletionHistory, toolResultHistoryEntry, toolResultTurn } from '../../tool-turns.js';
|
|
7
|
+
import { DIRECT_CALL_ID, deliversFile, historyPayload, materializeCompletionHistory, withHookContext, toolResultHistoryEntry, toolResultTurn } from '../../tool-turns.js';
|
|
8
8
|
import { defers, TOOL_SEARCH_TOOL_NAME } from '../../sdk-tool.js';
|
|
9
9
|
import { executionPlan, trustedSources } from './execution-plan.js';
|
|
10
10
|
import { runToolCall } from './execute.js';
|
|
11
11
|
import { toolCaller } from '../tool-caller.js';
|
|
12
12
|
import { loadSkill } from './loading-skill.js';
|
|
13
13
|
import { failureResultRef, storeFailureResult } from '../../../helpers/failure-result.js';
|
|
14
|
+
import { runsCheck } from '../../../helpers/goal-check.js';
|
|
15
|
+
const CHECK_OUTPUT_CHARS = 2000;
|
|
14
16
|
export const executing = async function executing(input) {
|
|
15
17
|
const { emit, input: deps, context } = input;
|
|
16
18
|
const call = context.currentCall;
|
|
@@ -28,9 +30,15 @@ export const executing = async function executing(input) {
|
|
|
28
30
|
const settled = settleCall(input, { ran, direct, emit });
|
|
29
31
|
const { args: callArgs } = plan.resolved;
|
|
30
32
|
const history = direct
|
|
31
|
-
? directToolHistory(context.history,
|
|
33
|
+
? directToolHistory(context.history, {
|
|
34
|
+
args: callArgs,
|
|
35
|
+
output: ran.executed.output,
|
|
36
|
+
resultRef: settled.failed?.resultRef,
|
|
37
|
+
nudge: context.policy.continuationNudge
|
|
38
|
+
})
|
|
32
39
|
: [...context.history, settled.entry];
|
|
33
|
-
const
|
|
40
|
+
const succeeded = settled.settled !== undefined;
|
|
41
|
+
const planned = succeeded && plan.resolved.tool.name === Agent.PLAN_TOOL_NAME;
|
|
34
42
|
return {
|
|
35
43
|
deniedKey: settled.deniedKey,
|
|
36
44
|
webSearch: settled.webSearch,
|
|
@@ -38,10 +46,14 @@ export const executing = async function executing(input) {
|
|
|
38
46
|
source: settled.source,
|
|
39
47
|
failed: settled.failed,
|
|
40
48
|
progressed: settled.progressed,
|
|
49
|
+
unchanged: settled.unchanged,
|
|
50
|
+
settled: settled.settled,
|
|
51
|
+
stableRead: settled.stableRead,
|
|
41
52
|
answer: settled.answer,
|
|
42
53
|
delivered: settled.delivered,
|
|
43
|
-
endedRun:
|
|
54
|
+
endedRun: succeeded && plan.resolved.tool.endsRun === true ? true : undefined,
|
|
44
55
|
durationMs: settled.durationMs,
|
|
56
|
+
checked: settled.checked,
|
|
45
57
|
plan: planned ? Agent.planSteps(callArgs) : undefined,
|
|
46
58
|
leftPlanMode: planned && context.planMode && call.leavesPlan ? true : undefined
|
|
47
59
|
};
|
|
@@ -117,10 +129,30 @@ function withRunPorts({ input: deps, context }, { plan, denied, emit }) {
|
|
|
117
129
|
}
|
|
118
130
|
return plan;
|
|
119
131
|
}
|
|
132
|
+
function silent(output) {
|
|
133
|
+
const text = textsOf(output);
|
|
134
|
+
return (output === null ||
|
|
135
|
+
output === undefined ||
|
|
136
|
+
(text.length > 0 && text.every((each) => each.trim() === '')));
|
|
137
|
+
}
|
|
138
|
+
function textsOf(value) {
|
|
139
|
+
if (typeof value === 'string') {
|
|
140
|
+
return [value];
|
|
141
|
+
}
|
|
142
|
+
return value && typeof value === 'object' ? Object.values(value).flatMap(textsOf) : [];
|
|
143
|
+
}
|
|
120
144
|
export function settleCall({ input: { session }, context }, { ran, direct, emit }) {
|
|
121
145
|
const { plan, denied, landedBefore, executed, durationMs } = ran;
|
|
122
|
-
const { call, key: callKey } = plan.resolved;
|
|
123
|
-
const {
|
|
146
|
+
const { call, key: callKey, args: callArgs } = plan.resolved;
|
|
147
|
+
const { outcome, activity } = executed;
|
|
148
|
+
const succeeded = executed.executed && callSucceeded(executed.output, outcome);
|
|
149
|
+
const digest = succeeded ? session.resultDigest(executed.output) : undefined;
|
|
150
|
+
const prior = context.settledResults[callKey];
|
|
151
|
+
const repeated = digest !== undefined && prior?.digest === digest;
|
|
152
|
+
const unchanged = repeated && !silent(historyPayload(executed.output));
|
|
153
|
+
const output = unchanged && !prior.folded
|
|
154
|
+
? withHookContext(executed.output, context.policy.unchangedMessage.replaceAll('{count}', String(prior.repeats + 2)))
|
|
155
|
+
: executed.output;
|
|
124
156
|
if (outcome.kind !== 'success' && session.landed.length > landedBefore) {
|
|
125
157
|
session.landed.length = landedBefore;
|
|
126
158
|
}
|
|
@@ -142,16 +174,25 @@ export function settleCall({ input: { session }, context }, { ran, direct, emit
|
|
|
142
174
|
}
|
|
143
175
|
: undefined;
|
|
144
176
|
const turn = toolResultTurn(call.name, resultTurnId, output);
|
|
145
|
-
const progressed = executed.executed && callSucceeded(output, outcome);
|
|
146
177
|
return {
|
|
147
178
|
deniedKey: [...denied].find((key) => !context.deniedKeys.includes(key)),
|
|
148
179
|
webSearch: plan.webSearch,
|
|
149
180
|
source: session.outbound.facts('tool-result', turn),
|
|
150
181
|
failed,
|
|
151
|
-
progressed:
|
|
152
|
-
|
|
182
|
+
progressed: succeeded && !repeated ? true : undefined,
|
|
183
|
+
unchanged: unchanged ? true : undefined,
|
|
184
|
+
settled: digest === undefined ? undefined : { key: callKey, digest },
|
|
185
|
+
stableRead: plan.resolved.tool.stableRead && plan.effect === 'read' ? true : undefined,
|
|
186
|
+
answer: succeeded ? answerOf(output) : undefined,
|
|
153
187
|
delivered: outcome.kind === 'success' && deliversFile(output) ? true : undefined,
|
|
154
188
|
durationMs: executed.executed ? durationMs : undefined,
|
|
189
|
+
checked: executed.executed
|
|
190
|
+
? checksRun(context, {
|
|
191
|
+
command: callArgs.command,
|
|
192
|
+
passed: succeeded,
|
|
193
|
+
output: executed.output
|
|
194
|
+
})
|
|
195
|
+
: undefined,
|
|
155
196
|
entry: toolResultHistoryEntry({
|
|
156
197
|
name: call.name,
|
|
157
198
|
id: resultTurnId,
|
|
@@ -160,3 +201,13 @@ export function settleCall({ input: { session }, context }, { ran, direct, emit
|
|
|
160
201
|
})
|
|
161
202
|
};
|
|
162
203
|
}
|
|
204
|
+
function checksRun({ goal }, { command, passed, output }) {
|
|
205
|
+
const ran = typeof command === 'string' && goal
|
|
206
|
+
? goal.checks.filter((check) => runsCheck(command, check.name))
|
|
207
|
+
: [];
|
|
208
|
+
if (!ran.length) {
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
const tail = textsOf(historyPayload(output)).join('\n').trim().slice(-CHECK_OUTPUT_CHARS);
|
|
212
|
+
return ran.map(({ name }) => ({ name, passed, output: tail }));
|
|
213
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Agent } from '../../../agent/index.js';
|
|
1
2
|
import { labelOf } from '../loop.js';
|
|
2
3
|
import { detachJson } from '../../../helpers/detach-json.js';
|
|
3
4
|
import { inspectToolPolicy } from '../tool-execution.js';
|
|
@@ -18,20 +19,19 @@ export function resolvedCall(session, call) {
|
|
|
18
19
|
}
|
|
19
20
|
export function toolContext({ deps, context, name }) {
|
|
20
21
|
const { args, session, commitFacts } = deps;
|
|
21
|
-
const { skillsSelected, enabledSkills, mention } = session.activation;
|
|
22
22
|
return {
|
|
23
23
|
...session.toolContext(session.turnImages, context.metrics.ctxSize ?? args.ctxSize, args.signal),
|
|
24
|
-
skills: context.activated.filter((skill) =>
|
|
24
|
+
skills: context.activated.filter((skill) => Agent.skillIsActive(skill, session.activation)),
|
|
25
25
|
skillsLoadedThisTurn: [...session.loadedThisTurn],
|
|
26
26
|
settings: args.toolConfigs?.[name],
|
|
27
27
|
toolOps: session.grantedOps,
|
|
28
28
|
fsRoots: args.fsRoots ?? [],
|
|
29
29
|
fsWriteRoots: session.writableRoots,
|
|
30
|
-
|
|
30
|
+
policy: session.access,
|
|
31
31
|
toolNames: session.enabled.map((tool) => tool.name),
|
|
32
32
|
knowledge: args.knowledge,
|
|
33
33
|
planMode: context.planMode,
|
|
34
|
-
spill: session.enabled.some((tool) => tool.name === '
|
|
34
|
+
spill: session.enabled.some((tool) => tool.name === 'read_file')
|
|
35
35
|
? runSpill(session.runId)
|
|
36
36
|
: undefined,
|
|
37
37
|
reportBackend: (use) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbortedError } from '../../../helpers/race-abort.js';
|
|
2
2
|
import { copy } from '../../../helpers/copy.js';
|
|
3
|
-
import { inspectToolPolicy } from '../tool-execution.js';
|
|
3
|
+
import { inspectToolPolicy, ruleInputs } from '../tool-execution.js';
|
|
4
4
|
import { toolContext, trustedSources } from './execution-plan.js';
|
|
5
5
|
export function inspectPrepare(source) {
|
|
6
6
|
return async function inspectPrepare({ input: deps, context }) {
|
|
@@ -29,7 +29,8 @@ export function inspectPrepare(source) {
|
|
|
29
29
|
skillNames: session.inContextSkills.map((skill) => skill.name),
|
|
30
30
|
parameters: tool.parameters,
|
|
31
31
|
egress: tool.egress,
|
|
32
|
-
|
|
32
|
+
...ruleInputs(tool, executeContext),
|
|
33
|
+
network: session.access?.network.mode ?? 'on',
|
|
33
34
|
signal: args.signal
|
|
34
35
|
});
|
|
35
36
|
if (args.signal?.aborted) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbortedError } from '../../../helpers/race-abort.js';
|
|
2
|
-
import {
|
|
2
|
+
import { HarnessLog } from '../../../log.js';
|
|
3
3
|
import { Agent } from '../../../agent/index.js';
|
|
4
4
|
import { planToolCall } from '../../tool-plan.js';
|
|
5
5
|
import { approvalGate, resolvedCall, toolContext, trustedSources } from './execution-plan.js';
|
|
@@ -31,16 +31,27 @@ export function inspectCall(deps, context, snapshot) {
|
|
|
31
31
|
loadedFilesThisTurn: session.loadedFilesThisTurn,
|
|
32
32
|
webSearches: context.webSearches,
|
|
33
33
|
context: executeContext,
|
|
34
|
-
|
|
34
|
+
shownSkills: session.inContextSkills
|
|
35
|
+
.filter((skill) => Agent.skillIsActive(skill.name, session.activation))
|
|
36
|
+
.map((skill) => skill.name)
|
|
35
37
|
});
|
|
36
38
|
if (plan.searchCapReached) {
|
|
37
|
-
|
|
39
|
+
HarnessLog.info('tool capped', {
|
|
38
40
|
tool: resolved.call.name,
|
|
39
41
|
count: context.webSearches
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
const unavailableSkill = plan.skillCall && (!plan.toolAvailable || !plan.skillActive);
|
|
43
|
-
const
|
|
45
|
+
const answeredRead = resolved.tool?.stableRead === true &&
|
|
46
|
+
plan.effect === 'read' &&
|
|
47
|
+
context.answeredReads?.includes(snapshot.key) === true;
|
|
48
|
+
if (answeredRead) {
|
|
49
|
+
HarnessLog.info('repeat of a read that already answered; not run again', {
|
|
50
|
+
tool: resolved.call.name
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const hasEarlierRejection = answeredRead ||
|
|
54
|
+
plan.skillAlreadyLoaded ||
|
|
44
55
|
Boolean(plan.skillStatus) ||
|
|
45
56
|
unavailableSkill ||
|
|
46
57
|
plan.searchCapReached ||
|
|
@@ -71,7 +82,14 @@ export function inspectCall(deps, context, snapshot) {
|
|
|
71
82
|
gate
|
|
72
83
|
};
|
|
73
84
|
}
|
|
74
|
-
const rejection = inspectRejection({
|
|
85
|
+
const rejection = inspectRejection({
|
|
86
|
+
context,
|
|
87
|
+
plan,
|
|
88
|
+
execution,
|
|
89
|
+
resource,
|
|
90
|
+
call: snapshot,
|
|
91
|
+
answeredRead
|
|
92
|
+
});
|
|
75
93
|
return {
|
|
76
94
|
call: snapshot,
|
|
77
95
|
toolAvailable: plan.toolAvailable,
|
|
@@ -93,7 +111,9 @@ export function inspectCall(deps, context, snapshot) {
|
|
|
93
111
|
};
|
|
94
112
|
}
|
|
95
113
|
const SKILL_WRITE_DENIED = 'Skill loaders must be read-only; this operation was not run.';
|
|
96
|
-
|
|
114
|
+
const repeatedReadMessage = (name) => `The result of this exact ${name} call is already above. Answer from it now; ` +
|
|
115
|
+
`do not call ${name} again with the same arguments.`;
|
|
116
|
+
function inspectRejection({ context, plan, execution, resource, call, answeredRead }) {
|
|
97
117
|
const effect = plan.effect;
|
|
98
118
|
const source = plan.source;
|
|
99
119
|
const base = { activity: null, effect, source };
|
|
@@ -117,6 +137,15 @@ function inspectRejection({ context, plan, execution, resource, call }) {
|
|
|
117
137
|
activity: policyActivity({ call, effect, resource })
|
|
118
138
|
};
|
|
119
139
|
}
|
|
140
|
+
if (answeredRead) {
|
|
141
|
+
return {
|
|
142
|
+
...base,
|
|
143
|
+
result: { content: repeatedReadMessage(call.name) },
|
|
144
|
+
emitCall: false,
|
|
145
|
+
emitResult: false,
|
|
146
|
+
repeat: { kind: 'success' }
|
|
147
|
+
};
|
|
148
|
+
}
|
|
120
149
|
if (plan.searchCapReached) {
|
|
121
150
|
return {
|
|
122
151
|
...base,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CompletionActorInput } from '../session.ts';
|
|
2
2
|
import { type ToolExecutionPlan } from './execution-plan.ts';
|
|
3
3
|
import type { ToolDonePayload } from '../stages.ts';
|
|
4
4
|
export interface SkillCallPlan extends ToolExecutionPlan {
|
|
@@ -5,6 +5,7 @@ import { readyPreflightFromFacts, reportFailure } from '../tool-execution.js';
|
|
|
5
5
|
import { skillFileKey } from '../../tool-plan.js';
|
|
6
6
|
import { toolResultTurn } from '../../tool-turns.js';
|
|
7
7
|
import { isRecord } from '../../../guards.js';
|
|
8
|
+
import { loadedSkills } from '../session.js';
|
|
8
9
|
import { trustedSources } from './execution-plan.js';
|
|
9
10
|
import { runToolCall } from './execute.js';
|
|
10
11
|
export async function loadSkill({ emit, input: deps, context }, plan) {
|
|
@@ -80,6 +81,7 @@ export async function loadSkill({ emit, input: deps, context }, plan) {
|
|
|
80
81
|
else {
|
|
81
82
|
session.loadedFilesThisTurn.add(fileKey);
|
|
82
83
|
}
|
|
84
|
+
session.reselectTools?.(new Set([...loadedSkills(context, session), skillName]));
|
|
83
85
|
return {
|
|
84
86
|
history: spliceFrom(context.history, history),
|
|
85
87
|
source: session.outbound.facts('skill', turn),
|
|
@@ -2,11 +2,12 @@ import { Agent } from '../../../agent/index.js';
|
|
|
2
2
|
import { spliceFrom } from '../splice.js';
|
|
3
3
|
import { AbortedError } from '../../../helpers/race-abort.js';
|
|
4
4
|
import { annotateLastUserTime, lastUserContent } from '../../../prompt.js';
|
|
5
|
-
import { explicitWebSearchQuery, knowledgeLastUser, lastUserImages, modelTurns,
|
|
5
|
+
import { explicitWebSearchQuery, knowledgeLastUser, lastUserImages, modelTurns, withPromptContext } from '../turns.js';
|
|
6
6
|
import { HookHalt } from '../../../helpers/engine-error.js';
|
|
7
|
+
import { stripControlTokens } from '../../../helpers/control-tokens.js';
|
|
7
8
|
import { skillInContext } from '../../skill-entry.js';
|
|
8
9
|
import { meetsMinCapabilityProfile, modelNameToCapabilityProfile } from '../../../models/model-catalog-constants.js';
|
|
9
|
-
import { renderedTools, toSdkTools, withToolSearch } from '../../sdk-tool.js';
|
|
10
|
+
import { deferredForRun, defers, renderedTools, TOOL_SEARCH_TOOL_NAME, toSdkTools, withToolSearch } from '../../sdk-tool.js';
|
|
10
11
|
import { loadedSkillFilesFrom, loadedSkillsFrom } from '../../tool-turns.js';
|
|
11
12
|
import { promptPrefixHash } from '../../prompt-prefix.js';
|
|
12
13
|
import { promptUsageParts } from '../../usage-breakdown.js';
|
|
@@ -14,20 +15,44 @@ import { logToolPrompt } from '../../tool-prompt-log.js';
|
|
|
14
15
|
import { toolContext } from './execution-plan.js';
|
|
15
16
|
import { knowledgeSearch } from './retrieving.js';
|
|
16
17
|
import { detachJson } from '../../../helpers/detach-json.js';
|
|
18
|
+
import { GOAL_CHECKS_ASK } from '../../../helpers/goal-check.js';
|
|
17
19
|
function offeredTools(tools, model) {
|
|
18
20
|
const profile = model ? modelNameToCapabilityProfile(model) : undefined;
|
|
19
21
|
return tools.filter(({ minCapabilityProfile: min }) => !min || (profile !== undefined && meetsMinCapabilityProfile(profile, min)));
|
|
20
22
|
}
|
|
23
|
+
function promptForWholeTools(ports, tools) {
|
|
24
|
+
const deferred = new Set(tools.filter(defers).map((tool) => tool.name));
|
|
25
|
+
return {
|
|
26
|
+
...ports,
|
|
27
|
+
systemPrompt: (input) => {
|
|
28
|
+
const whole = input.toolNames.filter((name) => !deferred.has(name));
|
|
29
|
+
const searching = whole.length < input.toolNames.length;
|
|
30
|
+
return ports.systemPrompt({
|
|
31
|
+
...input,
|
|
32
|
+
toolNames: searching ? [...whole, TOOL_SEARCH_TOOL_NAME] : whole
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function takesCommand(tools) {
|
|
38
|
+
return tools.some((tool) => 'command' in tool.parameters.properties);
|
|
39
|
+
}
|
|
40
|
+
function checksAsk({ goal }, checkable) {
|
|
41
|
+
return goal && checkable && !goal.checks.length
|
|
42
|
+
? [{ role: 'user', content: GOAL_CHECKS_ASK }]
|
|
43
|
+
: [];
|
|
44
|
+
}
|
|
21
45
|
export function preparing(source) {
|
|
22
46
|
return ({ input, context, reconstruct }) => prepare({ input, context, reconstruct, source });
|
|
23
47
|
}
|
|
24
48
|
async function prepare({ input, context, reconstruct, source }) {
|
|
25
49
|
const { args, session } = input;
|
|
26
|
-
const { model, agent, thinkingDefault, generationParams: generationParamsOverride, responseFormat, messages: storedMessages, tools: allTools = [], skillCatalog = [], signal, fsRoots = [], fsWriteRoots = [] } = args;
|
|
50
|
+
const { model, agent, thinkingDefault, generationParams: generationParamsOverride, responseFormat, messages: storedMessages, tools: allTools = [], skillCatalog = [], signal, fsRoots = [], fsWriteRoots = [], deferTools } = args;
|
|
27
51
|
if (signal?.aborted) {
|
|
28
52
|
throw new AbortedError();
|
|
29
53
|
}
|
|
30
54
|
const messages = modelTurns(storedMessages, context.policy.continuationNudge);
|
|
55
|
+
const userText = args.typedText === undefined ? lastUserContent(messages) : stripControlTokens(args.typedText);
|
|
31
56
|
let promptContext;
|
|
32
57
|
if (!session.runStarted && !reconstruct) {
|
|
33
58
|
await session.pipeline.onRunStart({
|
|
@@ -49,34 +74,37 @@ async function prepare({ input, context, reconstruct, source }) {
|
|
|
49
74
|
}
|
|
50
75
|
const hits = reconstruct ? [] : await knowledgeHits(input, context, messages);
|
|
51
76
|
const turnImages = lastUserImages(messages);
|
|
52
|
-
const loadedSkills = new Set([
|
|
53
|
-
...loadedSkillsFrom(messages),
|
|
54
|
-
...preloadedSkillsFrom(storedMessages),
|
|
55
|
-
...context.activated
|
|
56
|
-
]);
|
|
77
|
+
const loadedSkills = new Set([...loadedSkillsFrom(messages), ...context.activated]);
|
|
57
78
|
const loadedSkillFiles = loadedSkillFilesFrom(messages);
|
|
58
79
|
const inContextSkills = skillCatalog.filter(skillInContext);
|
|
80
|
+
const offered = offeredTools(allTools, model);
|
|
81
|
+
const tools = deferTools ? offered.map(deferredForRun) : offered;
|
|
59
82
|
const resolved = Agent.resolve({
|
|
60
83
|
agent,
|
|
61
84
|
model,
|
|
85
|
+
capabilityProfile: model ? modelNameToCapabilityProfile(model) : undefined,
|
|
62
86
|
thinkingDefault,
|
|
63
87
|
generationParams: generationParamsOverride,
|
|
64
88
|
responseFormat,
|
|
65
89
|
messages,
|
|
66
|
-
|
|
90
|
+
userText,
|
|
91
|
+
tools,
|
|
67
92
|
skills: inContextSkills,
|
|
68
93
|
loadedSkills,
|
|
69
94
|
fsRoots,
|
|
70
95
|
fsWriteRoots,
|
|
71
96
|
planning: context.plan.length > 0 || context.goal !== null,
|
|
72
|
-
planMode: context.planMode
|
|
73
|
-
|
|
97
|
+
planMode: context.planMode,
|
|
98
|
+
policy: session.access
|
|
99
|
+
}, deferTools ? promptForWholeTools(session.agentPorts, tools) : session.agentPorts);
|
|
74
100
|
const { system, activation, activeSkills, mention, grantedOps } = resolved;
|
|
75
101
|
const enabled = withToolSearch(resolved.enabled);
|
|
76
102
|
const sdkTools = toSdkTools(enabled);
|
|
77
103
|
const { skillsSelected } = activation;
|
|
78
|
-
const
|
|
79
|
-
|
|
104
|
+
const sent = reconstruct ? context.history[0] : undefined;
|
|
105
|
+
let systemContent = sent && 'role' in sent && sent.role === 'system' ? sent.content : system.text;
|
|
106
|
+
let systemParts = system;
|
|
107
|
+
const promptPrefix = promptPrefixHash({ system: systemContent, tools: renderedTools(sdkTools) });
|
|
80
108
|
const promptParts = promptUsageParts({ system, toolSchemas: renderedTools(sdkTools) });
|
|
81
109
|
const logSelection = (prefix) => {
|
|
82
110
|
logToolPrompt({
|
|
@@ -99,20 +127,33 @@ async function prepare({ input, context, reconstruct, source }) {
|
|
|
99
127
|
session.reselectTools = (loaded) => {
|
|
100
128
|
const reselected = withToolSearch(resolved.select(loaded));
|
|
101
129
|
const names = reselected.map((tool) => tool.name).join();
|
|
102
|
-
|
|
103
|
-
|
|
130
|
+
const changed = names !== session.enabled.map((tool) => tool.name).join();
|
|
131
|
+
if (changed) {
|
|
132
|
+
session.enabled = reselected;
|
|
133
|
+
session.sdkTools = toSdkTools(reselected);
|
|
134
|
+
session.promptParts = promptUsageParts({
|
|
135
|
+
system: systemParts,
|
|
136
|
+
toolSchemas: renderedTools(session.sdkTools)
|
|
137
|
+
});
|
|
104
138
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
session.promptParts = promptUsageParts({
|
|
109
|
-
system,
|
|
110
|
-
toolSchemas: renderedTools(session.sdkTools)
|
|
139
|
+
const prefix = promptPrefixHash({
|
|
140
|
+
system: systemContent,
|
|
141
|
+
tools: renderedTools(session.sdkTools)
|
|
111
142
|
});
|
|
112
|
-
|
|
143
|
+
if (changed) {
|
|
144
|
+
logSelection(prefix);
|
|
145
|
+
}
|
|
113
146
|
return prefix;
|
|
114
147
|
};
|
|
115
|
-
|
|
148
|
+
session.preloadSystem = (skill) => {
|
|
149
|
+
systemParts = resolved.systemFor(new Set([...loadedSkills, skill]));
|
|
150
|
+
systemContent = systemParts.text;
|
|
151
|
+
return systemContent;
|
|
152
|
+
};
|
|
153
|
+
const turns = [
|
|
154
|
+
...withPromptContext(knowledgeLastUser(messages, hits), promptContext),
|
|
155
|
+
...checksAsk(context, takesCommand(enabled))
|
|
156
|
+
];
|
|
116
157
|
const initialHistory = systemContent
|
|
117
158
|
? [{ role: 'system', content: systemContent }, ...turns]
|
|
118
159
|
: turns;
|
|
@@ -129,7 +170,8 @@ async function prepare({ input, context, reconstruct, source }) {
|
|
|
129
170
|
deniedKeys: [...context.deniedKeys],
|
|
130
171
|
sources,
|
|
131
172
|
availableTools: enabled.map((tool) => tool.name),
|
|
132
|
-
promptPrefix
|
|
173
|
+
promptPrefix,
|
|
174
|
+
checkable: context.goal ? takesCommand(enabled) : undefined
|
|
133
175
|
};
|
|
134
176
|
prepareSession(session, {
|
|
135
177
|
enabled,
|
|
@@ -153,9 +195,7 @@ async function prepare({ input, context, reconstruct, source }) {
|
|
|
153
195
|
const effect = call && tool
|
|
154
196
|
? tool.effect(detachJson(call.args), toolContext({ deps: input, context, name: tool.name }))
|
|
155
197
|
: null;
|
|
156
|
-
const searchQuery = (skillPreloaded) => context.directSearchDone
|
|
157
|
-
? null
|
|
158
|
-
: explicitWebSearchQuery(lastUserContent(messages), enabled, { skillPreloaded });
|
|
198
|
+
const searchQuery = (skillPreloaded) => context.directSearchDone ? null : explicitWebSearchQuery(userText, enabled, { skillPreloaded });
|
|
159
199
|
return {
|
|
160
200
|
...round,
|
|
161
201
|
step: call && {
|
|
@@ -46,7 +46,12 @@ export const rejecting = async function rejecting({ emit, input: { session }, co
|
|
|
46
46
|
}
|
|
47
47
|
const turn = toolResultTurn(call.name, call.id, result);
|
|
48
48
|
const history = context.execution?.kind === 'direct'
|
|
49
|
-
? directToolHistory(context.history,
|
|
49
|
+
? directToolHistory(context.history, {
|
|
50
|
+
args: call.args,
|
|
51
|
+
output: result,
|
|
52
|
+
resultRef: rejected.resultRef,
|
|
53
|
+
nudge: context.policy.continuationNudge
|
|
54
|
+
})
|
|
50
55
|
: [
|
|
51
56
|
...context.history,
|
|
52
57
|
toolResultHistoryEntry({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Agent } from '../../../agent/index.js';
|
|
2
2
|
import { spliceFrom } from '../splice.js';
|
|
3
3
|
import { AbortedError } from '../../../helpers/race-abort.js';
|
|
4
|
-
import {
|
|
4
|
+
import { HarnessLog } from '../../../log.js';
|
|
5
5
|
import { MALFORMED_CALL_ID, stripToolCallMarkup } from '../../../helpers/tool-call-markup.js';
|
|
6
6
|
import { toolResultTurn } from '../../tool-turns.js';
|
|
7
7
|
import { unloadedTools } from '../../sdk-tool.js';
|
|
@@ -9,19 +9,27 @@ import { assistantToolTurn } from '../turns.js';
|
|
|
9
9
|
import { resolveToolCalls } from '../tool-execution.js';
|
|
10
10
|
import { toolContext } from './execution-plan.js';
|
|
11
11
|
import { detachJson } from '../../../helpers/detach-json.js';
|
|
12
|
+
import { CompletionMachine } from '../../../machine/index.js';
|
|
12
13
|
const REISSUE_HINT = 'Re-issue the tool call with complete, valid markup.';
|
|
13
|
-
const
|
|
14
|
+
const REPEATED_CALL_ID = 'call-repeated';
|
|
15
|
+
const NARRATED_INTENT = /\b(?:I['’]ll|I will|Now I|Let me(?! know)|Next,? I)\b/i;
|
|
16
|
+
const PARAGRAPH = /(?<!:\s*)\n\s*\n(?!\s*(?:[-*+]|\d+[.)])\s)|(?<=[.!?]\s*)\n\s*\n/;
|
|
17
|
+
const SENTENCE = /(?<=[.!?])(?<!(?:^|\n)\s*\d+\.)\s+/;
|
|
14
18
|
const CODE = /```[\s\S]*?(?:```|$)|`[^`\n]*`/g;
|
|
15
19
|
const QUESTION = /\?(?![\w=&%/])/;
|
|
16
20
|
const ASKS = /\bplease\s+(?:provide|tell|give|share|send|specify|confirm|let me know)\b|\b(?:tell|send|show)\s+me\b|\bgive\s+me\b(?!\s+(?:just\s+)?(?:a|an|one|two|\d+|a few|a couple(?:\s+of)?|some)\s+(?:moment|sec(?:ond)?|minute|min|bit|while|tick)s?\s*(?:[,.;!…—–]|\s-|$|(?:to|while|and|so|as|then)\b))|\blet me know\b/i;
|
|
17
21
|
function narratedIntent(spoken) {
|
|
18
|
-
const prose = spoken.replace(CODE, '');
|
|
19
|
-
|
|
22
|
+
const prose = spoken.replace(CODE, '').trimEnd();
|
|
23
|
+
const tail = prose.split(PARAGRAPH).at(-1) ?? '';
|
|
24
|
+
const sentences = tail.split(SENTENCE).slice(-2);
|
|
25
|
+
return (sentences.some((sentence) => NARRATED_INTENT.test(sentence)) &&
|
|
26
|
+
!QUESTION.test(prose) &&
|
|
27
|
+
!ASKS.test(prose));
|
|
20
28
|
}
|
|
21
29
|
export const resolving = async function resolving({ input: deps, context }) {
|
|
22
30
|
const { args, session } = deps;
|
|
23
31
|
const round = context.lastRound;
|
|
24
|
-
const toolCalls = round.toolCalls.map((call) => ({
|
|
32
|
+
const toolCalls = firstOfEach(round.toolCalls, session).map((call) => ({
|
|
25
33
|
id: call.id,
|
|
26
34
|
name: call.name,
|
|
27
35
|
arguments: call.arguments,
|
|
@@ -35,27 +43,46 @@ export const resolving = async function resolving({ input: deps, context }) {
|
|
|
35
43
|
agentId: context.agentId,
|
|
36
44
|
pipeline: session.pipeline,
|
|
37
45
|
skillNames: session.inContextSkills.map((skill) => skill.name),
|
|
38
|
-
|
|
46
|
+
network: session.access?.network.mode ?? 'on',
|
|
39
47
|
toolContext: (name) => toolContext({ deps, context, name }),
|
|
40
48
|
signal: args.signal
|
|
41
49
|
});
|
|
42
50
|
if (args.signal?.aborted) {
|
|
43
51
|
throw new AbortedError();
|
|
44
52
|
}
|
|
45
|
-
|
|
53
|
+
const repeated = toolCalls.length < round.toolCalls.length;
|
|
54
|
+
return resolvedOutput({ context, round, resolved, repeated, deps });
|
|
46
55
|
};
|
|
56
|
+
function firstOfEach(calls, session) {
|
|
57
|
+
const seen = new Set();
|
|
58
|
+
return calls.filter((call) => {
|
|
59
|
+
const key = session.callKey(call.name, call.arguments);
|
|
60
|
+
const first = !seen.has(key);
|
|
61
|
+
seen.add(key);
|
|
62
|
+
return first;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
47
65
|
function answerFacts({ round, context, session }) {
|
|
48
66
|
const replay = round.replay ? stripToolCallMarkup(round.replay) : '';
|
|
49
67
|
const spoken = round.contentText.trim();
|
|
50
|
-
const
|
|
68
|
+
const cutOff = session.enabled.length > 0 && !replay && CompletionMachine.atContextBoundary(round);
|
|
69
|
+
const narrated = session.enabled.length && !replay && !cutOff && narratedIntent(spoken) ? spoken : undefined;
|
|
51
70
|
if (narrated) {
|
|
52
|
-
|
|
71
|
+
HarnessLog.info('round narrated a tool call', { round: context.round });
|
|
53
72
|
}
|
|
54
|
-
|
|
73
|
+
if (cutOff) {
|
|
74
|
+
HarnessLog.info('round cut off at the context window', { round: context.round });
|
|
75
|
+
}
|
|
76
|
+
const answer = {
|
|
77
|
+
calls: [],
|
|
78
|
+
response: replay || round.contentText,
|
|
79
|
+
narrated,
|
|
80
|
+
cutOff: cutOff ? true : undefined
|
|
81
|
+
};
|
|
55
82
|
if (!round.toolErrors?.length) {
|
|
56
83
|
return answer;
|
|
57
84
|
}
|
|
58
|
-
|
|
85
|
+
HarnessLog.info('round made malformed tool calls', {
|
|
59
86
|
round: context.round,
|
|
60
87
|
errors: round.toolErrors.map((error) => error.code)
|
|
61
88
|
});
|
|
@@ -64,8 +91,8 @@ function answerFacts({ round, context, session }) {
|
|
|
64
91
|
function malformedCallTurns({ round, context, session }) {
|
|
65
92
|
const errors = round.toolErrors ?? [];
|
|
66
93
|
const said = [round.contentText.trim(), ...errors.map((error) => error.raw ?? '')];
|
|
67
|
-
const error = round
|
|
68
|
-
? context.policy
|
|
94
|
+
const error = CompletionMachine.cutShort(round)
|
|
95
|
+
? CompletionMachine.cutOffMessage(context.policy, round)
|
|
69
96
|
: [
|
|
70
97
|
...errors.map(({ code, message }) => `${code}: ${message}`),
|
|
71
98
|
reissueHint(errors, unloadedTools(session.enabled, context.history))
|
|
@@ -83,14 +110,31 @@ function reissueHint(errors, unloaded) {
|
|
|
83
110
|
? `Load ${named.join(', ')} first: call tool_search with the tool's name, then call the tool.`
|
|
84
111
|
: REISSUE_HINT;
|
|
85
112
|
}
|
|
86
|
-
function
|
|
113
|
+
function repeatedCallTurn(context) {
|
|
114
|
+
const guidance = { guidance: context.policy.repeatedCallMessage };
|
|
115
|
+
return { role: 'tool', content: toolResultTurn('tool_call', REPEATED_CALL_ID, guidance) };
|
|
116
|
+
}
|
|
117
|
+
function cutTailTurn(context, round) {
|
|
118
|
+
const error = { error: CompletionMachine.cutOffMessage(context.policy, round) };
|
|
119
|
+
return { role: 'tool', content: toolResultTurn('tool_call', MALFORMED_CALL_ID, error) };
|
|
120
|
+
}
|
|
121
|
+
function cutCallId(round) {
|
|
122
|
+
return CompletionMachine.cutShort(round) && !round.toolErrors?.length
|
|
123
|
+
? round.toolCalls.at(-1)?.id
|
|
124
|
+
: undefined;
|
|
125
|
+
}
|
|
126
|
+
function resolvedOutput({ context, round, resolved, repeated, deps }) {
|
|
87
127
|
const { session } = deps;
|
|
128
|
+
const cutId = cutCallId(round);
|
|
129
|
+
const cutTail = CompletionMachine.cutShort(round) && Boolean(round.toolErrors?.length);
|
|
88
130
|
const history = [
|
|
89
131
|
...context.history,
|
|
90
132
|
{
|
|
91
133
|
role: 'assistant',
|
|
92
134
|
content: assistantToolTurn(round.contentText, resolved.map(({ call, args: callArgs }) => ({ name: call.name, arguments: callArgs })))
|
|
93
|
-
}
|
|
135
|
+
},
|
|
136
|
+
...(cutTail ? [cutTailTurn(context, round)] : []),
|
|
137
|
+
...(repeated ? [repeatedCallTurn(context)] : [])
|
|
94
138
|
];
|
|
95
139
|
return {
|
|
96
140
|
calls: resolved.map(({ call, tool, args: callArgs, rawCall, intent, rejection, permission }) => ({
|
|
@@ -111,7 +155,8 @@ function resolvedOutput({ context, round, resolved, deps }) {
|
|
|
111
155
|
: undefined,
|
|
112
156
|
leavesPlan: context.planMode && tool?.name === Agent.PLAN_TOOL_NAME && callArgs.submit === true
|
|
113
157
|
? true
|
|
114
|
-
: undefined
|
|
158
|
+
: undefined,
|
|
159
|
+
cutOff: call.id === cutId ? true : undefined
|
|
115
160
|
})),
|
|
116
161
|
history: spliceFrom(context.history, history)
|
|
117
162
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbortedError } from '../../../helpers/race-abort.js';
|
|
2
2
|
import { isFailureResultReference } from '../../../helpers/failure-result.js';
|
|
3
|
-
import {
|
|
3
|
+
import { HarnessLog } from '../../../log.js';
|
|
4
4
|
import { errorMessage } from '../../../guards.js';
|
|
5
5
|
import { spliceFrom } from '../splice.js';
|
|
6
6
|
import { knowledgeLastUser } from '../turns.js';
|
|
@@ -43,7 +43,7 @@ export function knowledgeSearch({ args, services, operations }, { id, text }) {
|
|
|
43
43
|
if (args.signal?.aborted || error instanceof AbortedError) {
|
|
44
44
|
throw error;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
HarnessLog.info('knowledge search failed', { err: errorMessage(error) });
|
|
47
47
|
return [];
|
|
48
48
|
}
|
|
49
49
|
};
|