@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
|
@@ -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,15 @@ 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
110
|
const cacheKey = carriesRunOnlyText(context.history) ? undefined : (context.cacheKey ?? undefined);
|
|
96
111
|
const model = args.model;
|
|
97
112
|
const toolDialect = model ? toolDialectFor(model) : undefined;
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
hlog('round start', {
|
|
113
|
+
const promptPrefix = session.reselectTools?.(loadedSkills(context, session)) ?? context.promptPrefix;
|
|
114
|
+
HarnessLog.debug('round start', {
|
|
101
115
|
round: context.round,
|
|
102
116
|
turns: context.history.length,
|
|
103
117
|
tools: session.sdkTools?.length ?? 0,
|
|
@@ -123,17 +137,29 @@ function prepareStreamingRound({ args, session, operations, context }) {
|
|
|
123
137
|
promptPrefix,
|
|
124
138
|
capture: args.captureInferenceCalls === true,
|
|
125
139
|
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
|
-
}
|
|
140
|
+
fold: roundFold(args, session, context)
|
|
132
141
|
},
|
|
133
142
|
promptPrefix,
|
|
134
143
|
startedAt
|
|
135
144
|
};
|
|
136
145
|
}
|
|
146
|
+
export function roundFold(args, session, context) {
|
|
147
|
+
const { lastRound } = context;
|
|
148
|
+
return {
|
|
149
|
+
messages: args.messages,
|
|
150
|
+
nudge: context.policy.continuationNudge,
|
|
151
|
+
ctxSize: args.ctxSize,
|
|
152
|
+
cacheKey: carriesRunOnlyText(context.history) ? undefined : args.cacheKey,
|
|
153
|
+
instructions: (messages) => session.pipeline.preFold({ runId: session.runId, agentId: context.agentId, messages }),
|
|
154
|
+
reading: lastRound
|
|
155
|
+
? {
|
|
156
|
+
cacheTokens: foldTokens(lastRound.stats, lastRound.cacheable),
|
|
157
|
+
ctxSize: lastRound.ctxSize ?? context.metrics.ctxSize,
|
|
158
|
+
cutOff: CompletionMachine.atContextBoundary(lastRound)
|
|
159
|
+
}
|
|
160
|
+
: undefined
|
|
161
|
+
};
|
|
162
|
+
}
|
|
137
163
|
function roundGenerationParams(context, session, responseFormat) {
|
|
138
164
|
const owesCall = context.narrated || (context.malformed && context.lastRound?.stopReason !== 'length');
|
|
139
165
|
if (!owesCall ||
|
|
@@ -175,7 +201,7 @@ function recoverPrintedSkill(markup, session, round) {
|
|
|
175
201
|
return [];
|
|
176
202
|
}
|
|
177
203
|
if (rescued.length) {
|
|
178
|
-
|
|
204
|
+
HarnessLog.info('recovered printed skill load', { round });
|
|
179
205
|
}
|
|
180
206
|
return rescued;
|
|
181
207
|
}
|
|
@@ -190,7 +216,7 @@ function recoverNamedSkill(markup, session, round) {
|
|
|
190
216
|
session.nudgedSkills.add(unquoteArg(call.arguments.name));
|
|
191
217
|
}
|
|
192
218
|
if (calls.length) {
|
|
193
|
-
|
|
219
|
+
HarnessLog.info('recovered skill-named call', { round });
|
|
194
220
|
}
|
|
195
221
|
return calls;
|
|
196
222
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
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
14
|
const cacheKey = carriesRunOnlyText(context.history) ? undefined : (context.cacheKey ?? undefined);
|
|
@@ -13,6 +16,9 @@ export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session,
|
|
|
13
16
|
const startedAt = Date.now();
|
|
14
17
|
const recovered = await runRound({
|
|
15
18
|
sdk,
|
|
19
|
+
modelRound: args.modelRound,
|
|
20
|
+
kind: 'wrap-up',
|
|
21
|
+
session,
|
|
16
22
|
args: {
|
|
17
23
|
modelId,
|
|
18
24
|
acquireRound,
|
|
@@ -21,21 +27,32 @@ export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session,
|
|
|
21
27
|
continuationNudge: context.policy.continuationNudge,
|
|
22
28
|
deliveredNudge: context.policy.deliveredNudge,
|
|
23
29
|
tools: undefined,
|
|
24
|
-
generationParams: session.generationParams,
|
|
30
|
+
generationParams: wrapUpParams(session.generationParams),
|
|
25
31
|
cacheKey,
|
|
26
32
|
signal,
|
|
27
33
|
round: context.roundsSent,
|
|
28
34
|
promptPrefix,
|
|
29
35
|
capture: args.captureInferenceCalls === true,
|
|
30
|
-
recordRequest: operations.recordRequest
|
|
36
|
+
recordRequest: operations.recordRequest,
|
|
37
|
+
fold: roundFold(args, session, context)
|
|
31
38
|
},
|
|
32
39
|
emit
|
|
33
40
|
});
|
|
34
41
|
const durationMs = Date.now() - startedAt;
|
|
35
|
-
const
|
|
42
|
+
const cutOff = CompletionMachine.atContextBoundary(recovered.final);
|
|
43
|
+
const replay = !cutOff && recovered.replay?.trim() ? stripToolCallMarkup(recovered.replay) : '';
|
|
44
|
+
const contentText = !cutOff && recovered.contentText.trim() ? recovered.contentText : '';
|
|
45
|
+
if (cutOff) {
|
|
46
|
+
emit({
|
|
47
|
+
type: 'round-reset',
|
|
48
|
+
runId: session.runId,
|
|
49
|
+
round: context.roundsSent,
|
|
50
|
+
replacedTypes: ['content', 'thinking']
|
|
51
|
+
});
|
|
52
|
+
}
|
|
36
53
|
const fallbackResponse = degenerateAnswer(wrapOutcome(context), materializeCompletionHistory(context.history, context.failureResults), { ...previewFinishedRound(session.runOutcomes.snapshot()), delivered: context.delivered });
|
|
37
54
|
return {
|
|
38
|
-
contentText
|
|
55
|
+
contentText,
|
|
39
56
|
thinkingText: '',
|
|
40
57
|
promptPrefix,
|
|
41
58
|
toolCalls: [],
|
|
@@ -43,12 +60,20 @@ export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session,
|
|
|
43
60
|
stopReason: recovered.final.stopReason,
|
|
44
61
|
durationMs,
|
|
45
62
|
ctxSize: recovered.ctxSize,
|
|
63
|
+
overflows: recovered.overflows,
|
|
64
|
+
reasoningDeltas: recovered.reasoningDeltas,
|
|
46
65
|
replay,
|
|
47
66
|
history: recovered.history ? spliceFrom(context.history, recovered.history) : undefined,
|
|
48
67
|
cacheable: recovered.cacheable,
|
|
49
|
-
response: replay ||
|
|
68
|
+
response: replay || contentText || fallbackResponse
|
|
50
69
|
};
|
|
51
70
|
};
|
|
71
|
+
function wrapUpParams(params) {
|
|
72
|
+
if (!params)
|
|
73
|
+
return undefined;
|
|
74
|
+
const reasoning = Math.max(params.reasoning_budget ?? 0, 0);
|
|
75
|
+
return { predict: reasoning + WRAP_UP_PREDICT, ...params };
|
|
76
|
+
}
|
|
52
77
|
function previewFinishedRound(state) {
|
|
53
78
|
return {
|
|
54
79
|
latestFailure: state.hasRoundResult ? state.roundFailure : state.latestFailure,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { randomBytes, createHmac } from 'crypto';
|
|
3
3
|
import { createRunBudget, runToolContext, reportLandedWrites } from './loop.js';
|
|
4
|
-
import { metricsEvent } from './metrics.js';
|
|
4
|
+
import { cancelledRound, metricsEvent } from './metrics.js';
|
|
5
5
|
import { usageBreakdown } from '../usage-breakdown.js';
|
|
6
6
|
import { CompletionMachine } from '../../machine/index.js';
|
|
7
7
|
import { HookHalt, rehydrateError, tagError } from '../../helpers/engine-error.js';
|
|
@@ -10,13 +10,13 @@ import { runEngine } from './engine.js';
|
|
|
10
10
|
import { didDrainTimeOut, raceDrain } from '../../helpers/drain.js';
|
|
11
11
|
import { RunLog } from '../../run-log/index.js';
|
|
12
12
|
import { stableStringify } from '../../helpers/stable-stringify.js';
|
|
13
|
-
import { checkGoal, checkMaxToolRounds, FILE_DELIVERED_NUDGE, GOAL_CONTINUATION_NUDGE, GOAL_ROUNDS, MAX_TOOL_ROUNDS, TOOL_CONTINUATION_NUDGE, TOOL_CUT_OFF_MESSAGE, TOOL_DENIED_MESSAGE } from '../tool-turns.js';
|
|
13
|
+
import { checkGoal, checkMaxToolRounds, FILE_DELIVERED_NUDGE, GOAL_CONTINUATION_NUDGE, GOAL_ROUNDS, MAX_TOOL_ROUNDS, TOOL_CONTEXT_BOUNDARY_MESSAGE, TOOL_CONTINUATION_NUDGE, TOOL_CUT_OFF_MESSAGE, TOOL_DENIED_MESSAGE, TOOL_REPEATED_MESSAGE, TOOL_ROUND_CUT_MESSAGE, TOOL_UNCHANGED_MESSAGE } from '../tool-turns.js';
|
|
14
14
|
import { createSession } from './session.js';
|
|
15
15
|
import { captureFacts } from './durable.js';
|
|
16
16
|
import { completionPorts } from './ports.js';
|
|
17
17
|
import { detachJson } from '../../helpers/detach-json.js';
|
|
18
18
|
import { AbortedError } from '../../helpers/race-abort.js';
|
|
19
|
-
import {
|
|
19
|
+
import { HarnessLog } from '../../log.js';
|
|
20
20
|
import { isRecord } from '../../guards.js';
|
|
21
21
|
import { removeRun } from '../../spill.js';
|
|
22
22
|
import { Agent } from '../../agent/index.js';
|
|
@@ -300,14 +300,24 @@ function isAgent(value) {
|
|
|
300
300
|
optionalNullableNumber('imageHeight') &&
|
|
301
301
|
optionalEnum('approvalMode', ['ask', 'skip-all']) &&
|
|
302
302
|
optionalStringArray('disabledToolsets') &&
|
|
303
|
-
(value.
|
|
303
|
+
(value.policy === undefined || value.policy === null || isRecord(value.policy)) &&
|
|
304
304
|
(value.plan === undefined || value.plan === null || typeof value.plan === 'boolean') &&
|
|
305
305
|
optionalNullableString('model'));
|
|
306
306
|
}
|
|
307
307
|
function isGenerationParams(value) {
|
|
308
308
|
return (isRecord(value) &&
|
|
309
|
-
(value.reasoning_budget ===
|
|
310
|
-
|
|
309
|
+
(value.reasoning_budget === undefined ||
|
|
310
|
+
(Number.isInteger(value.reasoning_budget) && Number(value.reasoning_budget) >= -1)) &&
|
|
311
|
+
[
|
|
312
|
+
'temp',
|
|
313
|
+
'top_p',
|
|
314
|
+
'top_k',
|
|
315
|
+
'presence_penalty',
|
|
316
|
+
'repeat_penalty',
|
|
317
|
+
'frequency_penalty',
|
|
318
|
+
'predict',
|
|
319
|
+
'seed'
|
|
320
|
+
].every((key) => value[key] === undefined || typeof value[key] === 'number'));
|
|
311
321
|
}
|
|
312
322
|
function isResponseFormat(value) {
|
|
313
323
|
if (!isRecord(value)) {
|
|
@@ -345,6 +355,10 @@ function runPolicy({ maxToolRounds, goal, wording }) {
|
|
|
345
355
|
deliveredNudge: wording?.fileDelivered ?? FILE_DELIVERED_NUDGE,
|
|
346
356
|
deniedMessage: wording?.toolDenied ?? TOOL_DENIED_MESSAGE,
|
|
347
357
|
cutOffMessage: wording?.toolCutOff ?? TOOL_CUT_OFF_MESSAGE,
|
|
358
|
+
contextBoundaryMessage: wording?.toolContextBoundary ?? TOOL_CONTEXT_BOUNDARY_MESSAGE,
|
|
359
|
+
roundCutMessage: wording?.toolRoundCut ?? TOOL_ROUND_CUT_MESSAGE,
|
|
360
|
+
repeatedCallMessage: wording?.toolRepeated ?? TOOL_REPEATED_MESSAGE,
|
|
361
|
+
unchangedMessage: wording?.toolUnchanged ?? TOOL_UNCHANGED_MESSAGE,
|
|
348
362
|
goalNudge: wording?.goalContinuation ?? GOAL_CONTINUATION_NUDGE
|
|
349
363
|
};
|
|
350
364
|
}
|
|
@@ -463,6 +477,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
463
477
|
session: null,
|
|
464
478
|
final: null
|
|
465
479
|
};
|
|
480
|
+
args.roundCut?.((note) => completionState.session?.liveRound?.cut?.(note));
|
|
466
481
|
let full = detachedRequest(completionArgs(prepared.savedArgs, args));
|
|
467
482
|
let reachedPause = false;
|
|
468
483
|
const engine = runEngine({
|
|
@@ -472,7 +487,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
472
487
|
recovery: args.recovery,
|
|
473
488
|
request: options.redact ? options.redact(prepared.identity) : prepared.identity,
|
|
474
489
|
requestDigest: prepared.requestDigest,
|
|
475
|
-
budget: boot?.metadata?.budget ?? createRunBudget(now(), goal?.ms),
|
|
490
|
+
budget: boot?.metadata?.budget ?? createRunBudget(now(), goal?.ms ?? args.budgetMs),
|
|
476
491
|
signal: args.signal,
|
|
477
492
|
input: args.input && pipeline.hasPhase('promptSubmit')
|
|
478
493
|
? submittedInput(args.input, pipeline, { runId, agentId: full.agent?.id ?? null })
|
|
@@ -579,11 +594,12 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
579
594
|
const snapshot = result.snapshot;
|
|
580
595
|
const facts = completionOutputFacts(snapshot.context.durable);
|
|
581
596
|
const landed = facts?.confirmedWrites ?? [];
|
|
582
|
-
const runMetrics = function* () {
|
|
597
|
+
const runMetrics = function* (cancelled = null) {
|
|
583
598
|
const usage = facts?.promptParts
|
|
584
599
|
? usageBreakdown(facts.promptParts, snapshot.context.metrics.cacheTokens, full.model)
|
|
585
600
|
: null;
|
|
586
|
-
const
|
|
601
|
+
const { outcome } = snapshot.context;
|
|
602
|
+
const metrics = metricsEvent({ ...snapshot.context.metrics, backends: facts?.backends }, Date.now() - wallStart, { usage, outcome: outcome === 'failed' ? null : outcome, cancelled });
|
|
587
603
|
if (metrics) {
|
|
588
604
|
yield { ...metrics, runId };
|
|
589
605
|
}
|
|
@@ -595,7 +611,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
595
611
|
'tag' in result.error &&
|
|
596
612
|
result.error.tag === 'aborted') {
|
|
597
613
|
reachedPause = true;
|
|
598
|
-
yield* runMetrics();
|
|
614
|
+
yield* runMetrics(cancelledRound(completionState.session?.liveRound));
|
|
599
615
|
throw new AbortedError();
|
|
600
616
|
}
|
|
601
617
|
throw rehydrateError(tagError(result.error));
|
|
@@ -631,7 +647,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
631
647
|
});
|
|
632
648
|
if (didDrainTimeOut(await raceDrain(runEnd))) {
|
|
633
649
|
options.onDetached?.(runEnd, runId);
|
|
634
|
-
|
|
650
|
+
HarnessLog.info('runEnd hook still running after completion closed', { runId });
|
|
635
651
|
}
|
|
636
652
|
}
|
|
637
653
|
}
|
|
@@ -9,6 +9,7 @@ interface CapabilityPolicy {
|
|
|
9
9
|
skills: string[];
|
|
10
10
|
skillContent: (readonly [string, string | null])[];
|
|
11
11
|
grantedOps: (readonly [string, string[]])[];
|
|
12
|
+
access?: string;
|
|
12
13
|
}
|
|
13
14
|
export declare function capabilityPolicy(session: Session): CapabilityPolicy;
|
|
14
15
|
export declare function schemaDigest(parameters: object): string;
|
|
@@ -11,7 +11,7 @@ function rootIdentity(root) {
|
|
|
11
11
|
}
|
|
12
12
|
export function capabilityPolicy(session) {
|
|
13
13
|
const context = session.toolContext();
|
|
14
|
-
|
|
14
|
+
const policy = {
|
|
15
15
|
behaviorDigest: session.behaviorDigest,
|
|
16
16
|
roots: (context.fsRoots ?? []).map(rootIdentity).sort(),
|
|
17
17
|
writeRoots: session.writableRoots.map(rootIdentity).sort(),
|
|
@@ -23,6 +23,10 @@ export function capabilityPolicy(session) {
|
|
|
23
23
|
.map(([bin, validators]) => [bin, validators.map((validator) => validator.fingerprint).sort()])
|
|
24
24
|
.sort(([left], [right]) => left.localeCompare(right))
|
|
25
25
|
};
|
|
26
|
+
if (session.accessDigest) {
|
|
27
|
+
policy.access = session.accessDigest;
|
|
28
|
+
}
|
|
29
|
+
return policy;
|
|
26
30
|
}
|
|
27
31
|
const schemaDigests = new WeakMap();
|
|
28
32
|
export function schemaDigest(parameters) {
|
|
@@ -16,7 +16,7 @@ export interface CompletionEngineOptions {
|
|
|
16
16
|
bootRequest?: unknown;
|
|
17
17
|
}
|
|
18
18
|
export declare class CompletionEngine {
|
|
19
|
-
static
|
|
19
|
+
static WRAP_UP_PREDICT: number;
|
|
20
20
|
runtime: CompletionRuntime;
|
|
21
21
|
hooks: readonly HarnessHook[];
|
|
22
22
|
outbound: OutboundGuard;
|
|
@@ -28,3 +28,4 @@ export declare class CompletionEngine {
|
|
|
28
28
|
}
|
|
29
29
|
export type { CompletionArgs } from './loop.ts';
|
|
30
30
|
export type { CompletionRun, CompletionRuntime } from './driver.ts';
|
|
31
|
+
export type { ModelRoundEvent, ModelRoundIo, ModelRoundPort, ModelRoundRequest, ModelRoundResult } from './model-round.ts';
|
|
@@ -4,9 +4,9 @@ import { RunLog } from '../../run-log/index.js';
|
|
|
4
4
|
import { outboundGuard } from '../../tools/outbound-guard.js';
|
|
5
5
|
import { defaultAgentPorts } from '../agent-ports.js';
|
|
6
6
|
import { driveCompletion } from './driver.js';
|
|
7
|
-
import {
|
|
7
|
+
import { WRAP_UP_PREDICT } from './actors/wrap-up.js';
|
|
8
8
|
export class CompletionEngine {
|
|
9
|
-
static
|
|
9
|
+
static WRAP_UP_PREDICT = WRAP_UP_PREDICT;
|
|
10
10
|
runtime;
|
|
11
11
|
hooks;
|
|
12
12
|
outbound;
|