@qvac/harness 1.0.0-rc.3 → 1.0.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/CHANGELOG.md +2302 -1485
- package/README.md +44 -31
- package/dist-lib/index.d.ts +51 -6
- package/dist-lib/index.js +130 -28
- package/dist-lib/lib/agent/delegate.d.ts +3 -2
- package/dist-lib/lib/agent/delegate.js +6 -4
- package/dist-lib/lib/agent/follow.d.ts +5 -0
- package/dist-lib/lib/agent/follow.js +2 -0
- package/dist-lib/lib/agent/resolve.js +22 -17
- package/dist-lib/lib/agent/tool-selection.d.ts +4 -2
- package/dist-lib/lib/agent/tool-selection.js +5 -6
- package/dist-lib/lib/agent/tools.d.ts +1 -0
- package/dist-lib/lib/agent/tools.js +2 -1
- package/dist-lib/lib/capabilities/agent-ports.js +3 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/batching.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +60 -9
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +4 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +35 -6
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +104 -40
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +6 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +61 -16
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +22 -13
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +23 -13
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +8 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +61 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +5 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +50 -22
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +33 -6
- package/dist-lib/lib/capabilities/completion-engine/driver.js +28 -13
- package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/durable.js +5 -1
- package/dist-lib/lib/capabilities/completion-engine/engine.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/engine.js +14 -1
- package/dist-lib/lib/capabilities/completion-engine/index.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/index.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +16 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.js +7 -0
- package/dist-lib/lib/capabilities/completion-engine/metrics.d.ts +9 -2
- package/dist-lib/lib/capabilities/completion-engine/metrics.js +28 -7
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +46 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.js +45 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.js +1 -1
- package/dist-lib/lib/capabilities/completion-engine/ports.js +3 -7
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +23 -3
- package/dist-lib/lib/capabilities/completion-engine/round.js +323 -97
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +10 -3
- package/dist-lib/lib/capabilities/completion-engine/session.js +30 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +4 -3
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +15 -10
- package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +14 -9
- package/dist-lib/lib/capabilities/completion-engine/turns.js +63 -86
- package/dist-lib/lib/capabilities/download.d.ts +9 -7
- package/dist-lib/lib/capabilities/download.js +1 -1
- package/dist-lib/lib/capabilities/enhance.d.ts +1 -1
- package/dist-lib/lib/capabilities/enhance.js +20 -8
- package/dist-lib/lib/capabilities/preview-model-source.d.ts +7 -0
- package/dist-lib/lib/capabilities/preview-model-source.js +83 -23
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +1 -0
- package/dist-lib/lib/capabilities/sdk-tool.js +18 -1
- package/dist-lib/lib/capabilities/tool-plan.d.ts +1 -1
- package/dist-lib/lib/capabilities/tool-plan.js +5 -5
- package/dist-lib/lib/capabilities/tool-prompt-log.js +3 -3
- package/dist-lib/lib/capabilities/tool-turns.d.ts +7 -9
- package/dist-lib/lib/capabilities/tool-turns.js +25 -20
- package/dist-lib/lib/client/index.d.ts +19 -0
- package/dist-lib/lib/client/index.js +262 -0
- package/dist-lib/lib/connect.d.ts +13 -10
- package/dist-lib/lib/connect.js +68 -26
- package/dist-lib/lib/context-window.d.ts +1 -0
- package/dist-lib/lib/context-window.js +3 -3
- package/dist-lib/lib/contract/agent.d.ts +7 -3
- package/dist-lib/lib/contract/completion.d.ts +51 -30
- package/dist-lib/lib/contract/drive.d.ts +4 -0
- package/dist-lib/lib/contract/drive.js +1 -0
- package/dist-lib/lib/contract/egress-proxy.d.ts +13 -0
- package/dist-lib/lib/contract/egress-proxy.js +1 -0
- package/dist-lib/lib/contract/exec.d.ts +3 -3
- package/dist-lib/lib/contract/hooks.d.ts +4 -1
- package/dist-lib/lib/contract/index.d.ts +3 -0
- package/dist-lib/lib/contract/managed-skills.d.ts +1 -0
- package/dist-lib/lib/contract/managed-skills.js +1 -0
- package/dist-lib/lib/contract/models.d.ts +6 -4
- package/dist-lib/lib/contract/policy.d.ts +75 -0
- package/dist-lib/lib/contract/policy.js +1 -0
- package/dist-lib/lib/contract/run.d.ts +15 -3
- package/dist-lib/lib/contract/sandbox.d.ts +3 -1
- package/dist-lib/lib/contract/translation.d.ts +20 -0
- package/dist-lib/lib/contract/translation.js +1 -0
- package/dist-lib/lib/contract-types.d.ts +35 -15
- package/dist-lib/lib/embeddings/index.d.ts +7 -1
- package/dist-lib/lib/embeddings/index.js +26 -5
- package/dist-lib/lib/errors.d.ts +266 -0
- package/dist-lib/lib/errors.js +198 -0
- package/dist-lib/lib/fold/index.d.ts +25 -1
- package/dist-lib/lib/fold/index.js +75 -9
- package/dist-lib/lib/guarded-fetch.js +11 -7
- package/dist-lib/lib/hardware/gpu-probe.js +10 -1
- package/dist-lib/lib/helpers/completion-params.d.ts +6 -2
- package/dist-lib/lib/helpers/completion-params.js +10 -1
- package/dist-lib/lib/helpers/engine-error.d.ts +2 -1
- package/dist-lib/lib/helpers/engine-error.js +12 -12
- package/dist-lib/lib/helpers/goal-check.d.ts +4 -0
- package/dist-lib/lib/helpers/goal-check.js +81 -0
- package/dist-lib/lib/helpers/head-tail.js +1 -1
- package/dist-lib/lib/helpers/load-stall.d.ts +1 -1
- package/dist-lib/lib/helpers/load-stall.js +2 -2
- package/dist-lib/lib/helpers/markup-stream-filter.d.ts +4 -1
- package/dist-lib/lib/helpers/markup-stream-filter.js +20 -6
- package/dist-lib/lib/helpers/repeated-reply.js +24 -16
- package/dist-lib/lib/helpers/thinking.d.ts +3 -2
- package/dist-lib/lib/helpers/thinking.js +19 -0
- package/dist-lib/lib/hooks/built-in/arg-repair.js +6 -2
- package/dist-lib/lib/hooks/built-in/policy-rules.d.ts +8 -0
- package/dist-lib/lib/hooks/built-in/policy-rules.js +192 -0
- package/dist-lib/lib/hooks/built-in/sandbox.js +23 -5
- package/dist-lib/lib/hooks/index.d.ts +4 -1
- package/dist-lib/lib/hooks/index.js +9 -4
- package/dist-lib/lib/hooks/run.js +3 -3
- package/dist-lib/lib/lifecycle/index.js +15 -14
- package/dist-lib/lib/lifecycle/machine.js +2 -2
- package/dist-lib/lib/log.d.ts +26 -5
- package/dist-lib/lib/log.js +86 -23
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +4 -2
- package/dist-lib/lib/machine/completion/actions/completion.js +78 -12
- package/dist-lib/lib/machine/completion/actions/prepare.js +1 -1
- package/dist-lib/lib/machine/completion/actions/tools.js +48 -5
- package/dist-lib/lib/machine/completion/context.js +5 -1
- package/dist-lib/lib/machine/completion/guards/retry.d.ts +1 -0
- package/dist-lib/lib/machine/completion/guards/retry.js +8 -2
- package/dist-lib/lib/machine/completion/implementations.d.ts +10 -4
- package/dist-lib/lib/machine/completion/implementations.js +43 -10
- package/dist-lib/lib/machine/completion/machine.d.ts +23 -3
- package/dist-lib/lib/machine/completion/machine.js +33 -4
- package/dist-lib/lib/machine/completion/rules.d.ts +17 -2
- package/dist-lib/lib/machine/completion/rules.js +49 -3
- package/dist-lib/lib/machine/completion/types.d.ts +43 -1
- package/dist-lib/lib/machine/index.d.ts +29 -4
- package/dist-lib/lib/machine/index.js +6 -1
- package/dist-lib/lib/models/context-choice.d.ts +15 -0
- package/dist-lib/lib/models/context-choice.js +55 -0
- package/dist-lib/lib/models/download-gate.d.ts +20 -0
- package/dist-lib/lib/models/download-gate.js +73 -0
- package/dist-lib/lib/models/gguf-header.d.ts +5 -0
- package/dist-lib/lib/models/gguf-header.js +165 -14
- package/dist-lib/lib/models/llm-presets.d.ts +5 -1
- package/dist-lib/lib/models/llm-presets.js +6 -5
- package/dist-lib/lib/models/memory-cap.d.ts +13 -0
- package/dist-lib/lib/models/memory-cap.js +21 -0
- package/dist-lib/lib/models/model-catalog.d.ts +2 -0
- package/dist-lib/lib/models/model-catalog.js +15 -0
- package/dist-lib/lib/models/model-fit.d.ts +1 -1
- package/dist-lib/lib/models/model-fit.js +5 -6
- package/dist-lib/lib/models/model-handle.d.ts +8 -2
- package/dist-lib/lib/models/model-handle.js +14 -3
- package/dist-lib/lib/models/model-list.d.ts +8 -1
- package/dist-lib/lib/models/model-list.js +23 -0
- package/dist-lib/lib/models/model-pool.d.ts +35 -5
- package/dist-lib/lib/models/model-pool.js +121 -43
- package/dist-lib/lib/models/model-source.d.ts +1 -0
- package/dist-lib/lib/models/model-source.js +23 -5
- package/dist-lib/lib/models/sdk-faults.d.ts +1 -0
- package/dist-lib/lib/models/sdk-faults.js +9 -0
- package/dist-lib/lib/no-redirect-fetch-bare.js +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.js +2 -1
- package/dist-lib/lib/office/engine/pptx/picture-area.d.ts +23 -0
- package/dist-lib/lib/office/engine/pptx/picture-area.js +84 -0
- package/dist-lib/lib/office/engine/pptx/presentation.d.ts +2 -0
- package/dist-lib/lib/office/engine/pptx/presentation.js +55 -17
- package/dist-lib/lib/office/engine/pptx/types.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/workbook.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/workbook.js +34 -3
- package/dist-lib/lib/office/extract.js +4 -3
- package/dist-lib/lib/office/index.js +2 -1
- package/dist-lib/lib/plugins/registry.d.ts +3 -0
- package/dist-lib/lib/plugins/registry.js +16 -7
- package/dist-lib/lib/policy/index.d.ts +10 -0
- package/dist-lib/lib/policy/index.js +229 -0
- package/dist-lib/lib/prompt.d.ts +1 -0
- package/dist-lib/lib/prompt.js +7 -1
- package/dist-lib/lib/residency/completion-runtime.d.ts +1 -0
- package/dist-lib/lib/residency/completion-runtime.js +11 -4
- package/dist-lib/lib/residency/index.d.ts +44 -4
- package/dist-lib/lib/residency/index.js +399 -35
- package/dist-lib/lib/resolution-detector.js +3 -3
- package/dist-lib/lib/rpc-session.js +2 -1
- package/dist-lib/lib/sdk-loader.js +17 -11
- package/dist-lib/lib/serve.js +83 -38
- package/dist-lib/lib/sidecar/index.d.ts +29 -0
- package/dist-lib/lib/sidecar/index.js +174 -0
- package/dist-lib/lib/sidecar/user-plugins.d.ts +8 -0
- package/dist-lib/lib/sidecar/user-plugins.js +117 -0
- package/dist-lib/lib/skills-host/index.d.ts +1 -0
- package/dist-lib/lib/skills-host/index.js +8 -4
- package/dist-lib/lib/spawn.d.ts +3 -4
- package/dist-lib/lib/spawn.js +17 -17
- package/dist-lib/lib/spill.d.ts +1 -0
- package/dist-lib/lib/spill.js +12 -8
- package/dist-lib/lib/tools/attachments/staging.js +8 -8
- package/dist-lib/lib/tools/exec/runner.js +2 -1
- package/dist-lib/lib/tools/exec/scope.d.ts +0 -1
- package/dist-lib/lib/tools/exec/scope.js +23 -114
- package/dist-lib/lib/tools/exec/shell-guidance.js +4 -4
- package/dist-lib/lib/tools/exec/shell-line.d.ts +26 -0
- package/dist-lib/lib/tools/exec/shell-line.js +334 -0
- package/dist-lib/lib/tools/exec.d.ts +4 -1
- package/dist-lib/lib/tools/exec.js +87 -26
- package/dist-lib/lib/tools/files/edit-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/edit-file.js +74 -0
- package/dist-lib/lib/tools/files/glob.d.ts +3 -0
- package/dist-lib/lib/tools/files/glob.js +65 -0
- package/dist-lib/lib/tools/files/grep.d.ts +6 -0
- package/dist-lib/lib/tools/files/grep.js +114 -0
- package/dist-lib/lib/tools/files/index.d.ts +3 -0
- package/dist-lib/lib/tools/files/index.js +23 -0
- package/dist-lib/lib/tools/files/list-dir.d.ts +6 -0
- package/dist-lib/lib/tools/files/list-dir.js +136 -0
- package/dist-lib/lib/tools/files/make-dir.d.ts +3 -0
- package/dist-lib/lib/tools/files/make-dir.js +48 -0
- package/dist-lib/lib/tools/files/read-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/read-file.js +105 -0
- package/dist-lib/lib/tools/files/transfer.d.ts +4 -0
- package/dist-lib/lib/tools/files/transfer.js +83 -0
- package/dist-lib/lib/tools/files/trash-file.d.ts +4 -0
- package/dist-lib/lib/tools/files/trash-file.js +62 -0
- package/dist-lib/lib/tools/files/write-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/write-file.js +56 -0
- package/dist-lib/lib/tools/fs/document-text.d.ts +2 -0
- package/dist-lib/lib/tools/fs/document-text.js +38 -0
- package/dist-lib/lib/tools/fs/drive.d.ts +14 -3
- package/dist-lib/lib/tools/fs/drive.js +9 -1
- package/dist-lib/lib/tools/fs/edit-match.d.ts +11 -0
- package/dist-lib/lib/tools/fs/edit-match.js +85 -0
- package/dist-lib/lib/tools/fs/ignore.d.ts +13 -0
- package/dist-lib/lib/tools/fs/ignore.js +104 -0
- package/dist-lib/lib/tools/fs/local.js +28 -5
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +23 -3
- package/dist-lib/lib/tools/fs/remote.d.ts +3 -4
- package/dist-lib/lib/tools/fs/remote.js +23 -13
- package/dist-lib/lib/tools/fs/scope.d.ts +5 -1
- package/dist-lib/lib/tools/fs/scope.js +5 -2
- package/dist-lib/lib/tools/fs/search.d.ts +41 -0
- package/dist-lib/lib/tools/fs/search.js +382 -0
- package/dist-lib/lib/tools/{file-glob.d.ts → fs/targets.d.ts} +1 -5
- package/dist-lib/lib/tools/fs/targets.js +32 -0
- package/dist-lib/lib/tools/fs/tool-path.d.ts +27 -0
- package/dist-lib/lib/tools/fs/tool-path.js +70 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +15 -3
- package/dist-lib/lib/tools/fs/walk.js +118 -24
- package/dist-lib/lib/tools/http-request.js +12 -2
- package/dist-lib/lib/tools/index.js +2 -10
- package/dist-lib/lib/tools/office/ops.js +1 -1
- package/dist-lib/lib/tools/office.js +77 -21
- package/dist-lib/lib/tools/pdf/build.d.ts +5 -1
- package/dist-lib/lib/tools/pdf/build.js +31 -6
- package/dist-lib/lib/tools/pdf.js +17 -2
- package/dist-lib/lib/tools/skill.js +10 -7
- package/dist-lib/lib/tools/skills/bundled-dir.js +4 -4
- package/dist-lib/lib/tools/skills/catalog.d.ts +2 -0
- package/dist-lib/lib/tools/skills/catalog.js +6 -2
- package/dist-lib/lib/tools/skills/cli-argv.js +25 -5
- package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/cli-schema-check.js +3 -0
- package/dist-lib/lib/tools/skills/cli-schema-load.js +10 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +2 -0
- package/dist-lib/lib/tools/skills/cli-schema.js +6 -3
- package/dist-lib/lib/tools/skills/credential-health.js +3 -3
- package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +2 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +4 -0
- package/dist-lib/lib/tools/skills/manifest-parse.d.ts +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +12 -0
- package/dist-lib/lib/tools/skills/mention-name.d.ts +6 -0
- package/dist-lib/lib/tools/skills/mention-name.js +6 -0
- package/dist-lib/lib/tools/skills/mention.d.ts +2 -2
- package/dist-lib/lib/tools/skills/mention.js +11 -4
- package/dist-lib/lib/tools/skills/overlay-crud.js +3 -2
- package/dist-lib/lib/tools/url-guard.d.ts +6 -1
- package/dist-lib/lib/tools/url-guard.js +8 -2
- package/dist-lib/lib/tools/web-fetch.js +10 -4
- package/dist-lib/lib/wire.js +8 -5
- package/dist-lib/plugins/coding/index.d.ts +1 -1
- package/dist-lib/plugins/coding/index.js +2 -4
- package/dist-lib/plugins/coding/session.d.ts +3 -3
- package/dist-lib/plugins/coding/session.js +26 -14
- package/dist-lib/plugins/command-hooks/index.js +5 -3
- package/dist-lib/plugins/egress-proxy/index.d.ts +53 -0
- package/dist-lib/plugins/egress-proxy/index.js +182 -0
- package/dist-lib/plugins/image/edit-image.js +4 -3
- package/dist-lib/plugins/image/generate-image.d.ts +4 -3
- package/dist-lib/plugins/image/generate-image.js +10 -9
- package/dist-lib/plugins/image/index.d.ts +1 -1
- package/dist-lib/plugins/image/index.js +13 -10
- package/dist-lib/plugins/language-hint/index.d.ts +15 -0
- package/dist-lib/plugins/language-hint/index.js +51 -0
- package/dist-lib/plugins/lsp/tool.js +2 -2
- package/dist-lib/plugins/mcp/index.js +6 -3
- package/dist-lib/plugins/music/generate-music.d.ts +4 -2
- package/dist-lib/plugins/music/generate-music.js +7 -4
- package/dist-lib/plugins/music/index.js +12 -9
- package/dist-lib/plugins/obsidian/command.js +2 -2
- package/dist-lib/plugins/obsidian/note-name.js +2 -1
- package/dist-lib/plugins/obsidian/safe-path.js +5 -4
- package/dist-lib/plugins/obsidian/vault-create.js +3 -2
- package/dist-lib/plugins/obsidian/vault-fs.js +2 -2
- package/dist-lib/plugins/obsidian/vault-paths.js +3 -2
- package/dist-lib/plugins/obsidian/vault-read.js +6 -5
- package/dist-lib/plugins/obsidian/vault-write.js +13 -12
- package/dist-lib/plugins/python/guarded-fetch.d.ts +2 -1
- package/dist-lib/plugins/python/guarded-fetch.js +5 -1
- package/dist-lib/plugins/python/interrupt-timer.js +2 -2
- package/dist-lib/plugins/python/loader.js +68 -3
- package/dist-lib/plugins/python/memfs.js +2 -2
- package/dist-lib/plugins/python/pyodide.d.ts +1 -0
- package/dist-lib/plugins/python/pyodide.js +9 -8
- package/dist-lib/plugins/python/python-adapter.js +3 -1
- package/dist-lib/plugins/python/run-session.d.ts +1 -0
- package/dist-lib/plugins/python/run-session.js +19 -8
- package/dist-lib/plugins/python/wheels.js +8 -6
- package/dist-lib/plugins/python/worker/active.js +2 -2
- package/dist-lib/plugins/python/worker/client.js +9 -8
- package/dist-lib/plugins/python/worker/protocol.d.ts +2 -0
- package/dist-lib/plugins/python/worker/serve.js +23 -4
- package/dist-lib/plugins/python/worker/spawn.d.ts +2 -1
- package/dist-lib/plugins/python/worker/spawn.js +2 -1
- package/dist-lib/plugins/run-report/chain.d.ts +2 -0
- package/dist-lib/plugins/run-report/chain.js +73 -0
- package/dist-lib/plugins/run-report/flow-view.js +2 -1
- package/dist-lib/plugins/run-report/flow.d.ts +1 -1
- package/dist-lib/plugins/run-report/flow.js +66 -14
- package/dist-lib/plugins/run-report/index.d.ts +23 -2
- package/dist-lib/plugins/run-report/index.js +27 -12
- package/dist-lib/plugins/run-report/model.d.ts +10 -1
- package/dist-lib/plugins/run-report/model.js +12 -6
- package/dist-lib/plugins/run-report/page.d.ts +9 -0
- package/dist-lib/plugins/run-report/page.js +55 -15
- package/dist-lib/plugins/run-report/script.js +317 -43
- package/dist-lib/plugins/run-report/story.d.ts +2 -1
- package/dist-lib/plugins/run-report/story.js +3 -3
- package/dist-lib/plugins/run-report/style.d.ts +1 -1
- package/dist-lib/plugins/run-report/style.js +126 -0
- package/dist-lib/plugins/run-report/why.js +1 -1
- package/dist-lib/plugins/sandbox-linux/index.d.ts +60 -0
- package/dist-lib/plugins/sandbox-linux/index.js +347 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.d.ts +2 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.js +74 -0
- package/dist-lib/plugins/sandbox-macos/index.d.ts +23 -11
- package/dist-lib/plugins/sandbox-macos/index.js +239 -49
- package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +4 -2
- package/dist-lib/plugins/sandbox-vm/vm-shell.js +9 -4
- package/dist-lib/plugins/sandbox-windows/helper/qvac-sandbox.c +554 -0
- package/dist-lib/plugins/sandbox-windows/index.d.ts +53 -0
- package/dist-lib/plugins/sandbox-windows/index.js +205 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/speech/audio-resample.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-resample.js +7 -8
- package/dist-lib/plugins/speech/audio-transcode-bare.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-bare.js +23 -26
- package/dist-lib/plugins/speech/audio-transcode-node.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-node.js +1 -3
- package/dist-lib/plugins/speech/speech-runtime.js +37 -37
- package/dist-lib/plugins/speech/voice.d.ts +5 -1
- package/dist-lib/plugins/speech/voice.js +100 -31
- package/dist-lib/plugins/translation/index.d.ts +1 -0
- package/dist-lib/plugins/translation/index.js +16 -9
- package/dist-lib/plugins/translation/translate.d.ts +7 -3
- package/dist-lib/plugins/translation/translate.js +64 -58
- package/dist-lib/plugins/weather/geocode.js +2 -1
- package/dist-lib/plugins/weather/lookup.js +5 -4
- package/dist-lib/plugins/web-search/engines/bing.js +2 -1
- package/dist-lib/plugins/web-search/engines/google.js +2 -1
- package/dist-lib/plugins/web-search/fetch-html.d.ts +5 -5
- package/dist-lib/plugins/web-search/fetch-html.js +12 -15
- package/dist-lib/plugins/web-search/tool.js +1 -0
- package/dist-lib/schema/harness.js +52 -9
- package/dist-lib/spec/bind.js +9 -0
- package/dist-lib/spec/calls.js +3 -0
- package/dist-lib/spec/hrpc/hrpc.json +42 -3
- package/dist-lib/spec/hrpc/index.js +44 -8
- package/dist-lib/spec/hrpc/messages.js +310 -205
- package/dist-lib/spec/hyperschema/index.js +310 -205
- package/dist-lib/spec/hyperschema/schema.json +164 -84
- package/dist-lib/spec/hyperschema/types.d.ts +25 -4
- package/package.json +98 -26
- package/patches/@qvac%2Finference@0.22.0.patch +59 -0
- package/patches/pyodide@314.0.2.patch +37 -8
- package/scripts/addon-externals.cjs +10 -5
- package/worker/harness-sidecar.mjs +18 -154
- package/bench/README.md +0 -94
- package/bench/bfcl/checker.ts +0 -313
- package/bench/bfcl/data.ts +0 -93
- package/bench/bfcl/observe.ts +0 -93
- package/bench/bfcl/run.ts +0 -213
- package/bench/bfcl/tools.ts +0 -72
- package/bench/bridge/bridge.ts +0 -392
- package/bench/bridge/openai.ts +0 -150
- package/bench/bridge/python/qvac_bench/__init__.py +0 -3
- package/bench/bridge/python/qvac_bench/airline.py +0 -42
- package/bench/bridge/python/qvac_bench/approval.py +0 -26
- package/bench/bridge/python/qvac_bench/bfcl_multi_turn.py +0 -152
- package/bench/bridge/python/qvac_bench/client.py +0 -88
- package/bench/bridge/python/qvac_bench/harbor_agent.py +0 -85
- package/bench/bridge/python/qvac_bench/session.py +0 -107
- package/bench/bridge/python/qvac_bench/speed.py +0 -30
- package/bench/bridge/python/qvac_bench/tau2_agent.py +0 -106
- package/bench/bridge/python/qvac_bench/tools.py +0 -11
- package/bench/bridge/python/run_bfcl_multi_turn.py +0 -95
- package/bench/bridge/python/run_tau2.py +0 -150
- package/bench/bridge/python/smoke.py +0 -47
- package/bench/bridge/python/test_airline.py +0 -28
- package/bench/bridge/python/test_approval.py +0 -57
- package/bench/bridge/python/test_bfcl_multi_turn.py +0 -185
- package/bench/bridge/python/test_harbor_agent.py +0 -107
- package/bench/bridge/serve.ts +0 -52
- package/bench/bridge/transcript.ts +0 -52
- package/bench/bun-tsconfig.json +0 -15
- package/bench/cpu-main.mjs +0 -216
- package/bench/cpu.ts +0 -457
- package/bench/evidence/2026-09-28-review15.md +0 -225
- package/bench/evidence/redact-bun1.3.14.json +0 -92
- package/bench/evidence/redact-node24.11.json +0 -92
- package/bench/graph-metrics.ts +0 -43
- package/bench/harness.ts +0 -73
- package/bench/issue129-matrix.mjs +0 -722
- package/bench/redact-adversarial.ts +0 -256
- package/bench/repeat-cpu.mjs +0 -281
- package/bench/report.ts +0 -1075
- package/bench/skill-eval/harness.ts +0 -30
- package/bench/skill-eval/laws.ts +0 -37
- package/bench/skill-eval/mermaid/client.ts +0 -132
- package/bench/skill-eval/mermaid/validate.mjs +0 -115
- package/bench/skill-eval/pack.ts +0 -61
- package/bench/skill-eval/packs/diagrams/cases.ts +0 -281
- package/bench/skill-eval/packs/diagrams/index.ts +0 -50
- package/bench/skill-eval/packs/diagrams/score.ts +0 -74
- package/bench/skill-eval/packs/index.ts +0 -5
- package/bench/skill-eval/packs/weather/cases.ts +0 -279
- package/bench/skill-eval/packs/weather/fixtures/wttr.json +0 -566
- package/bench/skill-eval/packs/weather/fixtures.ts +0 -84
- package/bench/skill-eval/packs/weather/index.ts +0 -55
- package/bench/skill-eval/packs/weather/score.ts +0 -92
- package/bench/skill-eval/report.ts +0 -194
- package/bench/skill-eval/run.ts +0 -316
- package/bench/speed.ts +0 -80
- package/dist-lib/lib/tools/create-documents.d.ts +0 -3
- package/dist-lib/lib/tools/create-documents.js +0 -95
- package/dist-lib/lib/tools/edit-documents.d.ts +0 -3
- package/dist-lib/lib/tools/edit-documents.js +0 -132
- package/dist-lib/lib/tools/exec/shell-argv.d.ts +0 -2
- package/dist-lib/lib/tools/exec/shell-argv.js +0 -61
- package/dist-lib/lib/tools/file-glob.js +0 -118
- package/dist-lib/lib/tools/grep.d.ts +0 -5
- package/dist-lib/lib/tools/grep.js +0 -184
- package/dist-lib/lib/tools/read-files.d.ts +0 -5
- package/dist-lib/lib/tools/read-files.js +0 -160
- package/dist-lib/plugins/coding/write-file.d.ts +0 -3
- package/dist-lib/plugins/coding/write-file.js +0 -52
- package/patches/@qvac%2Finference@0.21.0.patch +0 -67
- package/patches/bare-stow@0.1.5.patch +0 -68
- package/patches/hypercore-blob-server@1.15.0.patch +0 -15
|
@@ -1,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,25 +1,34 @@
|
|
|
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
|
-
import {
|
|
7
|
-
export const retrieving = async function retrieving({ input, context }) {
|
|
8
|
-
const { history } = context;
|
|
6
|
+
import { turnText } from '../turns.js';
|
|
7
|
+
export const retrieving = async function retrieving({ input, context, emit }) {
|
|
8
|
+
const { history, edgeInputs } = context;
|
|
9
9
|
const at = history.findLastIndex((entry) => !isFailureResultReference(entry) && entry.role === 'user');
|
|
10
10
|
const turn = history[at];
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const hits = turn && !isFailureResultReference(turn)
|
|
12
|
+
? await knowledgeSearch(input, {
|
|
13
|
+
id: `${context.runId}:round-${context.round}:input:knowledge`,
|
|
14
|
+
text: turn.content
|
|
15
|
+
})
|
|
16
|
+
: [];
|
|
17
|
+
const excerpts = hits.map((hit) => hit.text);
|
|
18
|
+
for (const [index, queued] of edgeInputs.entries()) {
|
|
19
|
+
const added = index === edgeInputs.length - 1 && excerpts.length ? { excerpts } : {};
|
|
20
|
+
const turnContext = { ...queued.context, ...added };
|
|
21
|
+
if (Object.keys(turnContext).length > 0) {
|
|
22
|
+
emit(queued.id === undefined
|
|
23
|
+
? { type: 'context', context: turnContext, round: context.round }
|
|
24
|
+
: { type: 'context', id: queued.id, context: turnContext, round: context.round });
|
|
25
|
+
}
|
|
13
26
|
}
|
|
14
|
-
|
|
15
|
-
id: `${context.runId}:round-${context.round}:input:knowledge`,
|
|
16
|
-
text: turn.content
|
|
17
|
-
});
|
|
18
|
-
if (hits.length === 0) {
|
|
27
|
+
if (!turn || isFailureResultReference(turn) || hits.length === 0) {
|
|
19
28
|
return {};
|
|
20
29
|
}
|
|
21
30
|
const next = [...history];
|
|
22
|
-
next[at] =
|
|
31
|
+
next[at] = { ...turn, content: turnText(turn.content, { excerpts }) };
|
|
23
32
|
return {
|
|
24
33
|
history: spliceFrom(history, next),
|
|
25
34
|
sources: hits.map((hit) => input.session.outbound.facts('tool-result', hit.text))
|
|
@@ -43,7 +52,7 @@ export function knowledgeSearch({ args, services, operations }, { id, text }) {
|
|
|
43
52
|
if (args.signal?.aborted || error instanceof AbortedError) {
|
|
44
53
|
throw error;
|
|
45
54
|
}
|
|
46
|
-
|
|
55
|
+
HarnessLog.info('knowledge search failed', { err: errorMessage(error) });
|
|
47
56
|
return [];
|
|
48
57
|
}
|
|
49
58
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { spliceFrom } from '../splice.js';
|
|
2
|
-
import { annotateCompletionHistoryLastUserTime,
|
|
2
|
+
import { annotateCompletionHistoryLastUserTime, directToolHistory, withLastUserNote } from '../turns.js';
|
|
3
3
|
import { labelOf, skillEmojiFrom } from '../loop.js';
|
|
4
|
-
import {
|
|
4
|
+
import { loadedSkills } from '../session.js';
|
|
5
|
+
import { PRELOAD_ID_PREFIX } from '../../tool-turns.js';
|
|
5
6
|
import { Agent } from '../../../agent/index.js';
|
|
6
7
|
import { errorMessage, isRecord } from '../../../guards.js';
|
|
7
|
-
|
|
8
|
+
import { isFailureResultReference } from '../../../helpers/failure-result.js';
|
|
8
9
|
export const skillStep = {
|
|
9
10
|
label: 'Skill loading',
|
|
10
11
|
propose({ session }, { preload }) {
|
|
@@ -12,7 +13,7 @@ export const skillStep = {
|
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
14
15
|
return {
|
|
15
|
-
id: `${
|
|
16
|
+
id: `${PRELOAD_ID_PREFIX}${preload.name}`,
|
|
16
17
|
tool: Agent.SKILL_TOOL_NAME,
|
|
17
18
|
args: { name: preload.name },
|
|
18
19
|
done: session.loadedThisTurn.has(preload.name)
|
|
@@ -24,9 +25,7 @@ export const skillStep = {
|
|
|
24
25
|
settle({ deps, context, step, result, announce }) {
|
|
25
26
|
const { session } = deps;
|
|
26
27
|
const name = skillOf(step);
|
|
27
|
-
|
|
28
|
-
announce();
|
|
29
|
-
}
|
|
28
|
+
announce();
|
|
30
29
|
if (!hasContent(result)) {
|
|
31
30
|
return {
|
|
32
31
|
failure: fail({
|
|
@@ -40,13 +39,18 @@ export const skillStep = {
|
|
|
40
39
|
const content = String(result.content);
|
|
41
40
|
session.loadedThisTurn.add(name);
|
|
42
41
|
session.skillIcon = skillEmojiFrom(session.inContextSkills, name) ?? session.skillIcon;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const history =
|
|
42
|
+
const typed = withSystem(annotateCompletionHistoryLastUserTime(context.history, new Date(session.startedAt)), session.preloadSystem?.(name));
|
|
43
|
+
session.reselectTools?.(new Set([...loadedSkills(context, session), name]));
|
|
44
|
+
const history = directToolHistory(typed, {
|
|
45
|
+
tool: step.tool,
|
|
46
|
+
id: step.id,
|
|
47
|
+
args: step.args,
|
|
48
|
+
output: result,
|
|
49
|
+
nudge: context.policy.continuationNudge
|
|
50
|
+
});
|
|
46
51
|
return {
|
|
47
52
|
history: spliceFrom(context.history, history),
|
|
48
53
|
source: session.outbound.facts('skill', content),
|
|
49
|
-
cacheable: false,
|
|
50
54
|
activate: name
|
|
51
55
|
};
|
|
52
56
|
},
|
|
@@ -55,15 +59,21 @@ export const skillStep = {
|
|
|
55
59
|
function fail({ deps, context, step, error }) {
|
|
56
60
|
const { history } = context;
|
|
57
61
|
const message = `Skill "${skillOf(step)}" could not be loaded: ${error}`;
|
|
58
|
-
const guided =
|
|
62
|
+
const guided = withLastUserNote(history, message);
|
|
59
63
|
const startedAt = new Date(deps.session.startedAt);
|
|
60
64
|
return {
|
|
61
65
|
error: message,
|
|
62
66
|
history: spliceFrom(history, annotateCompletionHistoryLastUserTime(guided, startedAt))
|
|
63
67
|
};
|
|
64
68
|
}
|
|
69
|
+
function withSystem(history, text) {
|
|
70
|
+
const [first, ...rest] = history;
|
|
71
|
+
return text !== undefined && first && !isFailureResultReference(first) && first.role === 'system'
|
|
72
|
+
? [{ ...first, content: text }, ...rest]
|
|
73
|
+
: history;
|
|
74
|
+
}
|
|
65
75
|
function skillOf(step) {
|
|
66
|
-
return step.id.slice(
|
|
76
|
+
return step.id.slice(PRELOAD_ID_PREFIX.length);
|
|
67
77
|
}
|
|
68
78
|
function hasContent(value) {
|
|
69
79
|
return isRecord(value) && 'content' in value;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { CompletionEvent, CompletionSdk } from '../../../contract/index.ts';
|
|
2
|
-
import { type RecoveredRound, type RoundArgs } from '../round.ts';
|
|
2
|
+
import { type RecoveredRound, type RoundArgs, type RoundKind } from '../round.ts';
|
|
3
|
+
import { type ModelRoundPort } from '../model-round.ts';
|
|
4
|
+
import type { Session } from '../session.ts';
|
|
3
5
|
interface ForwardStreamOptions<Result> {
|
|
4
6
|
stream: AsyncGenerator<CompletionEvent, Result> | Generator<CompletionEvent, Result>;
|
|
5
7
|
emit: (event: CompletionEvent) => void;
|
|
6
8
|
}
|
|
7
9
|
interface RunRoundOptions {
|
|
8
10
|
sdk: CompletionSdk | undefined;
|
|
9
|
-
|
|
11
|
+
modelRound?: ModelRoundPort | undefined;
|
|
12
|
+
kind: RoundKind;
|
|
13
|
+
args: Omit<RoundArgs, 'live' | 'knownTools'>;
|
|
14
|
+
session: Pick<Session, 'liveRound' | 'enabled' | 'runId'>;
|
|
10
15
|
emit: (event: CompletionEvent) => void;
|
|
11
16
|
}
|
|
12
17
|
export interface AssembleAnswerOptions {
|
|
@@ -16,6 +21,6 @@ export interface AssembleAnswerOptions {
|
|
|
16
21
|
emit: (event: CompletionEvent) => void;
|
|
17
22
|
}
|
|
18
23
|
export declare function forwardStream<Result>({ stream, emit }: ForwardStreamOptions<Result>): Promise<Result>;
|
|
19
|
-
export declare function runRound({ sdk, args, emit }: RunRoundOptions): Promise<RecoveredRound>;
|
|
24
|
+
export declare function runRound({ sdk, modelRound, kind, args, session, emit }: RunRoundOptions): Promise<RecoveredRound>;
|
|
20
25
|
export declare function assembleAnswer({ contentText, replay, landed, emit }: AssembleAnswerOptions): Promise<string>;
|
|
21
26
|
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { reportUnnamedWrites } from '../loop.js';
|
|
2
|
-
import { runRecoveredRound } from '../round.js';
|
|
2
|
+
import { recordWholeRound, runRecoveredRound } from '../round.js';
|
|
3
|
+
import { ModelRound } from '../model-round.js';
|
|
3
4
|
import { AbortedError } from '../../../helpers/race-abort.js';
|
|
5
|
+
import { HarnessLog } from '../../../log.js';
|
|
6
|
+
const BOUNDARY_UNFLAGGED = "length stop without contextBoundary: the host's @qvac/inference patch lacks the contextBoundary hunk";
|
|
7
|
+
let boundaryUnflaggedLogged = false;
|
|
4
8
|
export async function forwardStream({ stream, emit }) {
|
|
5
9
|
try {
|
|
6
10
|
while (true) {
|
|
@@ -15,19 +19,73 @@ export async function forwardStream({ stream, emit }) {
|
|
|
15
19
|
await Promise.resolve(stream.return(undefined)).catch(noop);
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
|
-
export async function runRound({ sdk, args, emit }) {
|
|
22
|
+
export async function runRound({ sdk, modelRound, kind, args, session, emit }) {
|
|
19
23
|
if (args.signal?.aborted)
|
|
20
24
|
throw new AbortedError();
|
|
25
|
+
const live = { round: args.round, kind, startedAt: Date.now(), rawChars: 0, reasoningDeltas: 0 };
|
|
26
|
+
session.liveRound = live;
|
|
21
27
|
try {
|
|
22
|
-
|
|
28
|
+
const round = modelRound
|
|
29
|
+
? await remoteRound({
|
|
30
|
+
port: modelRound,
|
|
31
|
+
kind,
|
|
32
|
+
args: { ...args, live },
|
|
33
|
+
runId: session.runId,
|
|
34
|
+
emit
|
|
35
|
+
})
|
|
36
|
+
: await forwardStream({
|
|
37
|
+
stream: runRecoveredRound(sdk, { ...args, live, knownTools: session.enabled }),
|
|
38
|
+
emit
|
|
39
|
+
});
|
|
40
|
+
session.liveRound = null;
|
|
41
|
+
logUnflaggedBoundary(round.final, args.round, kind);
|
|
42
|
+
return round;
|
|
23
43
|
}
|
|
24
44
|
catch (error) {
|
|
25
45
|
if (error instanceof AbortedError || args.signal?.aborted) {
|
|
26
46
|
throw new AbortedError();
|
|
27
47
|
}
|
|
48
|
+
session.liveRound = null;
|
|
28
49
|
throw error;
|
|
29
50
|
}
|
|
30
51
|
}
|
|
52
|
+
async function remoteRound({ port, kind, args, runId, emit }) {
|
|
53
|
+
const params = await recordWholeRound(args);
|
|
54
|
+
const result = await ModelRound.run(port, {
|
|
55
|
+
runId,
|
|
56
|
+
round: args.round,
|
|
57
|
+
kind,
|
|
58
|
+
attempt: 0,
|
|
59
|
+
modelId: params.modelId,
|
|
60
|
+
history: params.history,
|
|
61
|
+
tools: params.tools,
|
|
62
|
+
generationParams: params.generationParams,
|
|
63
|
+
responseFormat: params.responseFormat,
|
|
64
|
+
toolDialect: params.toolDialect,
|
|
65
|
+
cacheKey: args.cacheKey,
|
|
66
|
+
promptPrefix: args.promptPrefix,
|
|
67
|
+
continuationNudge: args.continuationNudge,
|
|
68
|
+
deliveredNudge: args.deliveredNudge
|
|
69
|
+
}, { signal: args.signal, emit });
|
|
70
|
+
return {
|
|
71
|
+
contentText: result.contentText,
|
|
72
|
+
final: result.final,
|
|
73
|
+
history: args.history,
|
|
74
|
+
cacheable: true,
|
|
75
|
+
unproven: null,
|
|
76
|
+
replay: null,
|
|
77
|
+
cut: result.cut
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function logUnflaggedBoundary(final, round, kind) {
|
|
81
|
+
if (boundaryUnflaggedLogged || final.stopReason !== 'length')
|
|
82
|
+
return;
|
|
83
|
+
if (final.stats?.contextBoundary !== undefined)
|
|
84
|
+
return;
|
|
85
|
+
boundaryUnflaggedLogged = true;
|
|
86
|
+
const log = HarnessLog.enabled('info') ? HarnessLog.info : HarnessLog.diag;
|
|
87
|
+
log(BOUNDARY_UNFLAGGED, { round, kind });
|
|
88
|
+
}
|
|
31
89
|
export async function assembleAnswer({ contentText, replay, landed, emit }) {
|
|
32
90
|
let response = replay || contentText;
|
|
33
91
|
if (replay) {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CompletionArgs } from '../loop.ts';
|
|
2
|
+
import { type RoundFold } from '../round.ts';
|
|
3
|
+
import { type CompletionActor, type Session } from '../session.ts';
|
|
2
4
|
import type { RoundDonePayload } from '../stages.ts';
|
|
5
|
+
import { type CompletionContext } from '../../../machine/index.ts';
|
|
3
6
|
export declare const streaming: CompletionActor<RoundDonePayload>;
|
|
7
|
+
export declare function roundFold(args: CompletionArgs, session: Session, context: CompletionContext): RoundFold;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { spliceFrom } from '../splice.js';
|
|
2
2
|
import { carriesRunOnlyText } from '../turns.js';
|
|
3
3
|
import { runRound } from './stream.js';
|
|
4
|
+
import { foldTokens } from '../round.js';
|
|
4
5
|
import { truncateAtControlToken } from '../../../helpers/control-tokens.js';
|
|
5
6
|
import { clipRawCall, recoverMarkupToolCalls, recoverPrintedSkillLoad, recoverSkillNamedCall, stripToolResponseBlocks } from '../../../helpers/tool-call-markup.js';
|
|
6
7
|
import { unquoteArg } from '../../../helpers/model-args.js';
|
|
7
8
|
import { Agent } from '../../../agent/index.js';
|
|
8
9
|
import { loadedTools, unloadedTools } from '../../sdk-tool.js';
|
|
9
|
-
import {
|
|
10
|
+
import { HarnessLog } from '../../../log.js';
|
|
10
11
|
import { toolDialectFor } from '../../../models/model-catalog.js';
|
|
12
|
+
import { loadedSkills } from '../session.js';
|
|
13
|
+
import { CompletionMachine } from '../../../machine/index.js';
|
|
11
14
|
export const streaming = async function streaming({ emit, input: { sdk, args, session, operations }, context }) {
|
|
12
15
|
const { recovered, promptPrefix, thinkingText, durationMs } = await generateStreamingRound({
|
|
13
16
|
sdk,
|
|
@@ -34,10 +37,13 @@ export const streaming = async function streaming({ emit, input: { sdk, args, se
|
|
|
34
37
|
stopReason: recovered.final.stopReason,
|
|
35
38
|
durationMs,
|
|
36
39
|
ctxSize: recovered.ctxSize,
|
|
40
|
+
overflows: recovered.overflows,
|
|
41
|
+
reasoningDeltas: recovered.reasoningDeltas,
|
|
37
42
|
promptPrefix,
|
|
38
43
|
replay: recovered.replay,
|
|
39
44
|
history: recovered.history ? spliceFrom(context.history, recovered.history) : undefined,
|
|
40
|
-
cacheable: recovered.cacheable
|
|
45
|
+
cacheable: recovered.cacheable,
|
|
46
|
+
cut: recovered.cut
|
|
41
47
|
};
|
|
42
48
|
};
|
|
43
49
|
function roundCalls({ recovered, session, context }) {
|
|
@@ -45,11 +51,20 @@ function roundCalls({ recovered, session, context }) {
|
|
|
45
51
|
const calls = recoverToolCalls({ recovered, session, round: context.round });
|
|
46
52
|
const callable = calls.filter((call) => !unloaded.has(call.name));
|
|
47
53
|
const refused = calls.filter((call) => unloaded.has(call.name)).map(notLoaded);
|
|
54
|
+
const toolCalls = identifyToolCalls(callable, session.runId, context.round);
|
|
55
|
+
const sdkErrors = recovered.final.toolErrors ?? [];
|
|
56
|
+
if (!callable.length) {
|
|
57
|
+
return { toolCalls, toolErrors: roundToolErrors([...sdkErrors, ...refused]) };
|
|
58
|
+
}
|
|
59
|
+
const cut = CompletionMachine.cutShort({
|
|
60
|
+
stopReason: recovered.final.stopReason,
|
|
61
|
+
cut: recovered.cut
|
|
62
|
+
});
|
|
63
|
+
const tail = calls.at(-1);
|
|
64
|
+
const unloadedTail = !sdkErrors.length && tail && unloaded.has(tail.name) ? [notLoaded(tail)] : [];
|
|
48
65
|
return {
|
|
49
|
-
toolCalls
|
|
50
|
-
toolErrors:
|
|
51
|
-
? undefined
|
|
52
|
-
: roundToolErrors([...(recovered.final.toolErrors ?? []), ...refused])
|
|
66
|
+
toolCalls,
|
|
67
|
+
toolErrors: cut ? roundToolErrors([...sdkErrors, ...unloadedTail]) : undefined
|
|
53
68
|
};
|
|
54
69
|
}
|
|
55
70
|
function notLoaded(call) {
|
|
@@ -69,6 +84,9 @@ async function generateStreamingRound({ sdk, args, session, operations, context,
|
|
|
69
84
|
let thinkingText = '';
|
|
70
85
|
const recovered = await runRound({
|
|
71
86
|
sdk,
|
|
87
|
+
modelRound: args.modelRound,
|
|
88
|
+
kind: 'streaming',
|
|
89
|
+
session,
|
|
72
90
|
args: prepared.args,
|
|
73
91
|
emit: (event) => {
|
|
74
92
|
if (event.type === 'thinking') {
|
|
@@ -85,19 +103,17 @@ async function generateStreamingRound({ sdk, args, session, operations, context,
|
|
|
85
103
|
return { recovered, promptPrefix: prepared.promptPrefix, thinkingText, durationMs };
|
|
86
104
|
}
|
|
87
105
|
function logRoundStats({ round, durationMs, recovered }) {
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
function roundLoadedSkills(context, session) {
|
|
91
|
-
return new Set([...context.activated, ...session.loadedThisTurn]);
|
|
106
|
+
HarnessLog.debug('round stats', Object.assign({ round, wallMs: durationMs }, recovered.final.stats));
|
|
92
107
|
}
|
|
93
108
|
function prepareStreamingRound({ args, session, operations, context }) {
|
|
94
109
|
const { modelId, acquireRound, responseFormat, signal } = args;
|
|
95
|
-
const cacheKey =
|
|
110
|
+
const cacheKey = !args.replaysContext && carriesRunOnlyText(context.history)
|
|
111
|
+
? undefined
|
|
112
|
+
: (context.cacheKey ?? undefined);
|
|
96
113
|
const model = args.model;
|
|
97
114
|
const toolDialect = model ? toolDialectFor(model) : undefined;
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
hlog('round start', {
|
|
115
|
+
const promptPrefix = session.reselectTools?.(loadedSkills(context, session)) ?? context.promptPrefix;
|
|
116
|
+
HarnessLog.debug('round start', {
|
|
101
117
|
round: context.round,
|
|
102
118
|
turns: context.history.length,
|
|
103
119
|
tools: session.sdkTools?.length ?? 0,
|
|
@@ -123,17 +139,29 @@ function prepareStreamingRound({ args, session, operations, context }) {
|
|
|
123
139
|
promptPrefix,
|
|
124
140
|
capture: args.captureInferenceCalls === true,
|
|
125
141
|
recordRequest: operations.recordRequest,
|
|
126
|
-
fold:
|
|
127
|
-
messages: args.messages,
|
|
128
|
-
nudge: context.policy.continuationNudge,
|
|
129
|
-
ctxSize: args.ctxSize,
|
|
130
|
-
instructions: (messages) => session.pipeline.preFold({ runId: session.runId, agentId: context.agentId, messages })
|
|
131
|
-
}
|
|
142
|
+
fold: roundFold(args, session, context)
|
|
132
143
|
},
|
|
133
144
|
promptPrefix,
|
|
134
145
|
startedAt
|
|
135
146
|
};
|
|
136
147
|
}
|
|
148
|
+
export function roundFold(args, session, context) {
|
|
149
|
+
const { lastRound } = context;
|
|
150
|
+
return {
|
|
151
|
+
messages: args.messages,
|
|
152
|
+
nudge: context.policy.continuationNudge,
|
|
153
|
+
ctxSize: args.ctxSize,
|
|
154
|
+
cacheKey: carriesRunOnlyText(context.history) ? undefined : args.cacheKey,
|
|
155
|
+
instructions: (messages) => session.pipeline.preFold({ runId: session.runId, agentId: context.agentId, messages }),
|
|
156
|
+
reading: lastRound
|
|
157
|
+
? {
|
|
158
|
+
cacheTokens: foldTokens(lastRound.stats, lastRound.cacheable),
|
|
159
|
+
ctxSize: lastRound.ctxSize ?? context.metrics.ctxSize,
|
|
160
|
+
cutOff: CompletionMachine.atContextBoundary(lastRound)
|
|
161
|
+
}
|
|
162
|
+
: undefined
|
|
163
|
+
};
|
|
164
|
+
}
|
|
137
165
|
function roundGenerationParams(context, session, responseFormat) {
|
|
138
166
|
const owesCall = context.narrated || (context.malformed && context.lastRound?.stopReason !== 'length');
|
|
139
167
|
if (!owesCall ||
|
|
@@ -175,7 +203,7 @@ function recoverPrintedSkill(markup, session, round) {
|
|
|
175
203
|
return [];
|
|
176
204
|
}
|
|
177
205
|
if (rescued.length) {
|
|
178
|
-
|
|
206
|
+
HarnessLog.info('recovered printed skill load', { round });
|
|
179
207
|
}
|
|
180
208
|
return rescued;
|
|
181
209
|
}
|
|
@@ -190,7 +218,7 @@ function recoverNamedSkill(markup, session, round) {
|
|
|
190
218
|
session.nudgedSkills.add(unquoteArg(call.arguments.name));
|
|
191
219
|
}
|
|
192
220
|
if (calls.length) {
|
|
193
|
-
|
|
221
|
+
HarnessLog.info('recovered skill-named call', { round });
|
|
194
222
|
}
|
|
195
223
|
return calls;
|
|
196
224
|
}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { spliceFrom } from '../splice.js';
|
|
2
2
|
import { carriesRunOnlyText } from '../turns.js';
|
|
3
3
|
import { runRound } from './stream.js';
|
|
4
|
+
import { roundFold } from './streaming.js';
|
|
4
5
|
import { degenerateAnswer } from '../../../helpers/run-outcome.js';
|
|
5
6
|
import { stripToolCallMarkup } from '../../../helpers/tool-call-markup.js';
|
|
6
7
|
import { promptPrefixHash } from '../../prompt-prefix.js';
|
|
7
8
|
import { materializeCompletionHistory } from '../../tool-turns.js';
|
|
9
|
+
import { CompletionMachine } from '../../../machine/index.js';
|
|
8
10
|
import { isFailureResultReference } from '../../../helpers/failure-result.js';
|
|
11
|
+
export const WRAP_UP_PREDICT = 4096;
|
|
9
12
|
export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session, operations }, context }) {
|
|
10
13
|
const { modelId, acquireRound, signal } = args;
|
|
11
|
-
const cacheKey =
|
|
14
|
+
const cacheKey = !args.replaysContext && carriesRunOnlyText(context.history)
|
|
15
|
+
? undefined
|
|
16
|
+
: (context.cacheKey ?? undefined);
|
|
12
17
|
const promptPrefix = promptPrefixHash({ system: systemMessage(context), tools: undefined });
|
|
13
18
|
const startedAt = Date.now();
|
|
14
19
|
const recovered = await runRound({
|
|
15
20
|
sdk,
|
|
21
|
+
modelRound: args.modelRound,
|
|
22
|
+
kind: 'wrap-up',
|
|
23
|
+
session,
|
|
16
24
|
args: {
|
|
17
25
|
modelId,
|
|
18
26
|
acquireRound,
|
|
@@ -21,21 +29,32 @@ export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session,
|
|
|
21
29
|
continuationNudge: context.policy.continuationNudge,
|
|
22
30
|
deliveredNudge: context.policy.deliveredNudge,
|
|
23
31
|
tools: undefined,
|
|
24
|
-
generationParams: session.generationParams,
|
|
32
|
+
generationParams: wrapUpParams(session.generationParams),
|
|
25
33
|
cacheKey,
|
|
26
34
|
signal,
|
|
27
35
|
round: context.roundsSent,
|
|
28
36
|
promptPrefix,
|
|
29
37
|
capture: args.captureInferenceCalls === true,
|
|
30
|
-
recordRequest: operations.recordRequest
|
|
38
|
+
recordRequest: operations.recordRequest,
|
|
39
|
+
fold: roundFold(args, session, context)
|
|
31
40
|
},
|
|
32
41
|
emit
|
|
33
42
|
});
|
|
34
43
|
const durationMs = Date.now() - startedAt;
|
|
35
|
-
const
|
|
44
|
+
const cutOff = CompletionMachine.atContextBoundary(recovered.final);
|
|
45
|
+
const replay = !cutOff && recovered.replay?.trim() ? stripToolCallMarkup(recovered.replay) : '';
|
|
46
|
+
const contentText = !cutOff && recovered.contentText.trim() ? recovered.contentText : '';
|
|
47
|
+
if (cutOff) {
|
|
48
|
+
emit({
|
|
49
|
+
type: 'round-reset',
|
|
50
|
+
runId: session.runId,
|
|
51
|
+
round: context.roundsSent,
|
|
52
|
+
replacedTypes: ['content', 'thinking']
|
|
53
|
+
});
|
|
54
|
+
}
|
|
36
55
|
const fallbackResponse = degenerateAnswer(wrapOutcome(context), materializeCompletionHistory(context.history, context.failureResults), { ...previewFinishedRound(session.runOutcomes.snapshot()), delivered: context.delivered });
|
|
37
56
|
return {
|
|
38
|
-
contentText
|
|
57
|
+
contentText,
|
|
39
58
|
thinkingText: '',
|
|
40
59
|
promptPrefix,
|
|
41
60
|
toolCalls: [],
|
|
@@ -43,12 +62,20 @@ export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session,
|
|
|
43
62
|
stopReason: recovered.final.stopReason,
|
|
44
63
|
durationMs,
|
|
45
64
|
ctxSize: recovered.ctxSize,
|
|
65
|
+
overflows: recovered.overflows,
|
|
66
|
+
reasoningDeltas: recovered.reasoningDeltas,
|
|
46
67
|
replay,
|
|
47
68
|
history: recovered.history ? spliceFrom(context.history, recovered.history) : undefined,
|
|
48
69
|
cacheable: recovered.cacheable,
|
|
49
|
-
response: replay ||
|
|
70
|
+
response: replay || contentText || fallbackResponse
|
|
50
71
|
};
|
|
51
72
|
};
|
|
73
|
+
function wrapUpParams(params) {
|
|
74
|
+
if (!params)
|
|
75
|
+
return undefined;
|
|
76
|
+
const reasoning = Math.max(params.reasoning_budget ?? 0, 0);
|
|
77
|
+
return { predict: reasoning + WRAP_UP_PREDICT, ...params };
|
|
78
|
+
}
|
|
52
79
|
function previewFinishedRound(state) {
|
|
53
80
|
return {
|
|
54
81
|
latestFailure: state.hasRoundResult ? state.roundFailure : state.latestFailure,
|