@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,22 +1,21 @@
|
|
|
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';
|
|
8
|
-
import { promptWithContext } from './turns.js';
|
|
9
8
|
import { runEngine } from './engine.js';
|
|
10
9
|
import { didDrainTimeOut, raceDrain } from '../../helpers/drain.js';
|
|
11
10
|
import { RunLog } from '../../run-log/index.js';
|
|
12
11
|
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';
|
|
12
|
+
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
13
|
import { createSession } from './session.js';
|
|
15
14
|
import { captureFacts } from './durable.js';
|
|
16
15
|
import { completionPorts } from './ports.js';
|
|
17
16
|
import { detachJson } from '../../helpers/detach-json.js';
|
|
18
17
|
import { AbortedError } from '../../helpers/race-abort.js';
|
|
19
|
-
import {
|
|
18
|
+
import { HarnessLog } from '../../log.js';
|
|
20
19
|
import { isRecord } from '../../guards.js';
|
|
21
20
|
import { removeRun } from '../../spill.js';
|
|
22
21
|
import { Agent } from '../../agent/index.js';
|
|
@@ -77,7 +76,7 @@ async function* submittedInput(input, pipeline, { runId, agentId }) {
|
|
|
77
76
|
yield { reason: submitted.rejection.error };
|
|
78
77
|
continue;
|
|
79
78
|
}
|
|
80
|
-
yield { ...item,
|
|
79
|
+
yield submitted.context === undefined ? item : { ...item, notes: submitted.context };
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
function hookManifest(hooks) {
|
|
@@ -300,14 +299,24 @@ function isAgent(value) {
|
|
|
300
299
|
optionalNullableNumber('imageHeight') &&
|
|
301
300
|
optionalEnum('approvalMode', ['ask', 'skip-all']) &&
|
|
302
301
|
optionalStringArray('disabledToolsets') &&
|
|
303
|
-
(value.
|
|
302
|
+
(value.policy === undefined || value.policy === null || isRecord(value.policy)) &&
|
|
304
303
|
(value.plan === undefined || value.plan === null || typeof value.plan === 'boolean') &&
|
|
305
304
|
optionalNullableString('model'));
|
|
306
305
|
}
|
|
307
306
|
function isGenerationParams(value) {
|
|
308
307
|
return (isRecord(value) &&
|
|
309
|
-
(value.reasoning_budget ===
|
|
310
|
-
|
|
308
|
+
(value.reasoning_budget === undefined ||
|
|
309
|
+
(Number.isInteger(value.reasoning_budget) && Number(value.reasoning_budget) >= -1)) &&
|
|
310
|
+
[
|
|
311
|
+
'temp',
|
|
312
|
+
'top_p',
|
|
313
|
+
'top_k',
|
|
314
|
+
'presence_penalty',
|
|
315
|
+
'repeat_penalty',
|
|
316
|
+
'frequency_penalty',
|
|
317
|
+
'predict',
|
|
318
|
+
'seed'
|
|
319
|
+
].every((key) => value[key] === undefined || typeof value[key] === 'number'));
|
|
311
320
|
}
|
|
312
321
|
function isResponseFormat(value) {
|
|
313
322
|
if (!isRecord(value)) {
|
|
@@ -345,6 +354,10 @@ function runPolicy({ maxToolRounds, goal, wording }) {
|
|
|
345
354
|
deliveredNudge: wording?.fileDelivered ?? FILE_DELIVERED_NUDGE,
|
|
346
355
|
deniedMessage: wording?.toolDenied ?? TOOL_DENIED_MESSAGE,
|
|
347
356
|
cutOffMessage: wording?.toolCutOff ?? TOOL_CUT_OFF_MESSAGE,
|
|
357
|
+
contextBoundaryMessage: wording?.toolContextBoundary ?? TOOL_CONTEXT_BOUNDARY_MESSAGE,
|
|
358
|
+
roundCutMessage: wording?.toolRoundCut ?? TOOL_ROUND_CUT_MESSAGE,
|
|
359
|
+
repeatedCallMessage: wording?.toolRepeated ?? TOOL_REPEATED_MESSAGE,
|
|
360
|
+
unchangedMessage: wording?.toolUnchanged ?? TOOL_UNCHANGED_MESSAGE,
|
|
348
361
|
goalNudge: wording?.goalContinuation ?? GOAL_CONTINUATION_NUDGE
|
|
349
362
|
};
|
|
350
363
|
}
|
|
@@ -463,6 +476,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
463
476
|
session: null,
|
|
464
477
|
final: null
|
|
465
478
|
};
|
|
479
|
+
args.roundCut?.((note) => completionState.session?.liveRound?.cut?.(note));
|
|
466
480
|
let full = detachedRequest(completionArgs(prepared.savedArgs, args));
|
|
467
481
|
let reachedPause = false;
|
|
468
482
|
const engine = runEngine({
|
|
@@ -472,7 +486,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
472
486
|
recovery: args.recovery,
|
|
473
487
|
request: options.redact ? options.redact(prepared.identity) : prepared.identity,
|
|
474
488
|
requestDigest: prepared.requestDigest,
|
|
475
|
-
budget: boot?.metadata?.budget ?? createRunBudget(now(), goal?.ms),
|
|
489
|
+
budget: boot?.metadata?.budget ?? createRunBudget(now(), goal?.ms ?? args.budgetMs),
|
|
476
490
|
signal: args.signal,
|
|
477
491
|
input: args.input && pipeline.hasPhase('promptSubmit')
|
|
478
492
|
? submittedInput(args.input, pipeline, { runId, agentId: full.agent?.id ?? null })
|
|
@@ -579,11 +593,12 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
579
593
|
const snapshot = result.snapshot;
|
|
580
594
|
const facts = completionOutputFacts(snapshot.context.durable);
|
|
581
595
|
const landed = facts?.confirmedWrites ?? [];
|
|
582
|
-
const runMetrics = function* () {
|
|
596
|
+
const runMetrics = function* (cancelled = null) {
|
|
583
597
|
const usage = facts?.promptParts
|
|
584
598
|
? usageBreakdown(facts.promptParts, snapshot.context.metrics.cacheTokens, full.model)
|
|
585
599
|
: null;
|
|
586
|
-
const
|
|
600
|
+
const { outcome } = snapshot.context;
|
|
601
|
+
const metrics = metricsEvent({ ...snapshot.context.metrics, backends: facts?.backends }, Date.now() - wallStart, { usage, outcome: outcome === 'failed' ? null : outcome, cancelled });
|
|
587
602
|
if (metrics) {
|
|
588
603
|
yield { ...metrics, runId };
|
|
589
604
|
}
|
|
@@ -595,7 +610,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
595
610
|
'tag' in result.error &&
|
|
596
611
|
result.error.tag === 'aborted') {
|
|
597
612
|
reachedPause = true;
|
|
598
|
-
yield* runMetrics();
|
|
613
|
+
yield* runMetrics(cancelledRound(completionState.session?.liveRound));
|
|
599
614
|
throw new AbortedError();
|
|
600
615
|
}
|
|
601
616
|
throw rehydrateError(tagError(result.error));
|
|
@@ -631,7 +646,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
631
646
|
});
|
|
632
647
|
if (didDrainTimeOut(await raceDrain(runEnd))) {
|
|
633
648
|
options.onDetached?.(runEnd, runId);
|
|
634
|
-
|
|
649
|
+
HarnessLog.info('runEnd hook still running after completion closed', { runId });
|
|
635
650
|
}
|
|
636
651
|
}
|
|
637
652
|
}
|
|
@@ -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) {
|
|
@@ -5,7 +5,10 @@ import type { EnginePorts, InvokeTracker } from './ports.ts';
|
|
|
5
5
|
import type { Operation, RunBudget, RunInput } from '../../contract/index.ts';
|
|
6
6
|
import { type CompletionContext, CompletionMachine, type EngineEvent } from '../../machine/index.ts';
|
|
7
7
|
export type CompletionSnapshot = SnapshotFrom<ReturnType<typeof CompletionMachine.create>>;
|
|
8
|
-
export
|
|
8
|
+
export interface SubmittedInput extends RunInput {
|
|
9
|
+
notes?: string;
|
|
10
|
+
}
|
|
11
|
+
export type EngineInput = SubmittedInput | {
|
|
9
12
|
reason: string;
|
|
10
13
|
};
|
|
11
14
|
export interface EngineRun {
|
|
@@ -8,6 +8,7 @@ import { isRecord } from '../../guards.js';
|
|
|
8
8
|
import { createCompletionActors, createInvokeTracker } from './actors.js';
|
|
9
9
|
import { replayFinalRound, replaySuccessOutput } from './replay-output.js';
|
|
10
10
|
import { AbortedError, rehydrateError, tagError } from '../../helpers/engine-error.js';
|
|
11
|
+
import { turnText } from './turns.js';
|
|
11
12
|
import { CompletionMachine } from '../../machine/index.js';
|
|
12
13
|
function readRestoredSnapshot(value) {
|
|
13
14
|
if (!isRecord(value) || Array.isArray(value))
|
|
@@ -192,7 +193,7 @@ async function* drive({ journal, run, machine, invokes, now, durable, onDetached
|
|
|
192
193
|
notify();
|
|
193
194
|
}
|
|
194
195
|
else {
|
|
195
|
-
actor.send(
|
|
196
|
+
actor.send(inputMessage(item));
|
|
196
197
|
}
|
|
197
198
|
return pumping;
|
|
198
199
|
}).catch(noop);
|
|
@@ -373,6 +374,18 @@ async function pumpInput(input, deliver) {
|
|
|
373
374
|
}
|
|
374
375
|
}
|
|
375
376
|
}
|
|
377
|
+
function inputMessage({ mode, id, text, notes }) {
|
|
378
|
+
return notes === undefined
|
|
379
|
+
? { type: 'INPUT', mode, id, text }
|
|
380
|
+
: {
|
|
381
|
+
type: 'INPUT',
|
|
382
|
+
mode,
|
|
383
|
+
id,
|
|
384
|
+
text,
|
|
385
|
+
context: { notes },
|
|
386
|
+
content: turnText(text, { notes })
|
|
387
|
+
};
|
|
388
|
+
}
|
|
376
389
|
function noop() { }
|
|
377
390
|
function settling(snapshot) {
|
|
378
391
|
const value = snapshot.value;
|
|
@@ -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;
|
|
@@ -2,8 +2,9 @@ import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
|
2
2
|
import type { RecoveryResolution } from '../../run-log/index.ts';
|
|
3
3
|
import type { KnowledgeGrant } from '../../contract/knowledge.ts';
|
|
4
4
|
import type { ToolCallDisplay } from '../../contract/index.ts';
|
|
5
|
-
import type { AgentConfig, CompletionEvent, ApproveFn, AskUserFn, AttachFn, DriveRoot, FetchAttachmentFn, LlmGenerationParams, Message, ProgressFn, ResponseFormat, RunBudget, RunGoal, RunInput, RoundModelLease, ToolDefinition, ToolExecuteContext } from '../../contract/index.ts';
|
|
5
|
+
import type { AgentConfig, AccessPolicy, CompiledPolicy, CompletionEvent, ApproveFn, AskUserFn, AttachFn, DriveRoot, FetchAttachmentFn, LlmGenerationParams, Message, ProgressFn, ResponseFormat, RunBudget, RunGoal, RunInput, RoundModelLease, ToolDefinition, ToolExecuteContext } from '../../contract/index.ts';
|
|
6
6
|
import type { CompletionSkillEntry } from '../skill-entry.ts';
|
|
7
|
+
import type { ModelRoundPort } from './model-round.ts';
|
|
7
8
|
export interface CompletionArgs {
|
|
8
9
|
runId?: string;
|
|
9
10
|
parentRunId?: string;
|
|
@@ -12,14 +13,18 @@ export interface CompletionArgs {
|
|
|
12
13
|
lockOwner?: object;
|
|
13
14
|
modelId: string;
|
|
14
15
|
acquireRound?: (signal?: BareAbortSignal) => Promise<RoundModelLease>;
|
|
16
|
+
modelRound?: ModelRoundPort;
|
|
15
17
|
model?: string;
|
|
16
18
|
agent?: AgentConfig;
|
|
17
19
|
ctxSize?: number;
|
|
18
20
|
cacheKey?: string;
|
|
21
|
+
replaysContext?: boolean;
|
|
22
|
+
session?: string;
|
|
19
23
|
thinkingDefault?: string;
|
|
20
24
|
generationParams?: LlmGenerationParams;
|
|
21
25
|
responseFormat?: ResponseFormat;
|
|
22
26
|
messages: Message[];
|
|
27
|
+
typedText?: string;
|
|
23
28
|
requestMessages?: Message[];
|
|
24
29
|
tools?: ToolDefinition[];
|
|
25
30
|
skillCatalog?: readonly CompletionSkillEntry[];
|
|
@@ -30,20 +35,29 @@ export interface CompletionArgs {
|
|
|
30
35
|
askUser?: AskUserFn;
|
|
31
36
|
signal?: BareAbortSignal;
|
|
32
37
|
input?: AsyncIterable<RunInput>;
|
|
38
|
+
roundCut?: (cut: (note: string) => void) => void;
|
|
33
39
|
toolConfigs?: Record<string, Record<string, unknown>>;
|
|
34
40
|
fsRoots?: readonly DriveRoot[];
|
|
35
41
|
fsWriteRoots?: readonly DriveRoot[];
|
|
42
|
+
policy?: AccessPolicy;
|
|
43
|
+
access?: CompiledPolicy;
|
|
36
44
|
captureInferenceCalls?: boolean;
|
|
37
45
|
now?: () => number;
|
|
38
46
|
maxToolRounds?: number;
|
|
47
|
+
budgetMs?: number;
|
|
39
48
|
knowledge?: KnowledgeGrant;
|
|
40
49
|
planMode?: boolean;
|
|
50
|
+
deferTools?: boolean;
|
|
41
51
|
goal?: RunGoal;
|
|
42
52
|
wording?: {
|
|
43
53
|
toolContinuation?: string;
|
|
44
54
|
fileDelivered?: string;
|
|
45
55
|
toolDenied?: string;
|
|
46
56
|
toolCutOff?: string;
|
|
57
|
+
toolRoundCut?: string;
|
|
58
|
+
toolContextBoundary?: string;
|
|
59
|
+
toolRepeated?: string;
|
|
60
|
+
toolUnchanged?: string;
|
|
47
61
|
goalContinuation?: string;
|
|
48
62
|
};
|
|
49
63
|
}
|
|
@@ -55,4 +69,4 @@ export declare function createRunBudget(startedAt: number, ms?: number): RunBudg
|
|
|
55
69
|
export type ToolContextFactory = (turnImages?: {
|
|
56
70
|
path: string;
|
|
57
71
|
}[], ctxSize?: number, signal?: BareAbortSignal) => ToolExecuteContext;
|
|
58
|
-
export declare function runToolContext(args: Pick<CompletionArgs, 'agent' | 'attach' | 'fetchAttachment' | 'progress' | 'askUser' | 'signal' | 'fsRoots' | 'fsWriteRoots'>, runBudget: RunBudget): ToolContextFactory;
|
|
72
|
+
export declare function runToolContext(args: Pick<CompletionArgs, 'agent' | 'attach' | 'fetchAttachment' | 'progress' | 'askUser' | 'signal' | 'fsRoots' | 'fsWriteRoots' | 'session' | 'cacheKey'>, runBudget: RunBudget): ToolContextFactory;
|
|
@@ -30,6 +30,7 @@ export function createRunBudget(startedAt, ms) {
|
|
|
30
30
|
export function runToolContext(args, runBudget) {
|
|
31
31
|
const { agent, attach, fetchAttachment, progress, askUser, signal } = args;
|
|
32
32
|
const image = imageSettingsFrom(agent);
|
|
33
|
+
const session = args.session ?? sessionOf(args.cacheKey);
|
|
33
34
|
return (turnImages = [], ctxSize, invocationSignal) => {
|
|
34
35
|
const context = {
|
|
35
36
|
agentId: agent?.id ?? null,
|
|
@@ -39,6 +40,9 @@ export function runToolContext(args, runBudget) {
|
|
|
39
40
|
runBudget,
|
|
40
41
|
signal: invocationSignal ?? signal
|
|
41
42
|
};
|
|
43
|
+
if (session) {
|
|
44
|
+
context.session = session;
|
|
45
|
+
}
|
|
42
46
|
if (image) {
|
|
43
47
|
context.image = image;
|
|
44
48
|
}
|
|
@@ -60,3 +64,6 @@ export function runToolContext(args, runBudget) {
|
|
|
60
64
|
return context;
|
|
61
65
|
};
|
|
62
66
|
}
|
|
67
|
+
function sessionOf(cacheKey) {
|
|
68
|
+
return cacheKey?.split('/')[0] || undefined;
|
|
69
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { CompletionContext } from '../../machine/index.ts';
|
|
2
|
-
import type { MetricsEvent } from '../../contract/index.ts';
|
|
2
|
+
import type { MetricsEvent, RoundSpeed, RunOutcome } from '../../contract/index.ts';
|
|
3
3
|
import type { UsageBreakdown } from '../usage-breakdown.ts';
|
|
4
|
-
|
|
4
|
+
import type { LiveRound } from './round.ts';
|
|
5
|
+
export interface RunEnd {
|
|
6
|
+
usage?: UsageBreakdown | null;
|
|
7
|
+
outcome?: RunOutcome | null;
|
|
8
|
+
cancelled?: RoundSpeed | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function metricsEvent(state: CompletionContext['metrics'], wallMs: number, { usage, outcome, cancelled }?: RunEnd): MetricsEvent | null;
|
|
11
|
+
export declare function cancelledRound(live: LiveRound | null | undefined): RoundSpeed | null;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
export function metricsEvent(state, wallMs, usage) {
|
|
2
|
-
if (!state.tokens) {
|
|
1
|
+
export function metricsEvent(state, wallMs, { usage, outcome, cancelled } = {}) {
|
|
2
|
+
if (!state.tokens && !cancelled) {
|
|
3
3
|
return null;
|
|
4
4
|
}
|
|
5
|
+
const rounds = cancelled ? [...state.rounds, cancelled] : state.rounds;
|
|
5
6
|
const event = {
|
|
6
7
|
type: 'metrics',
|
|
7
8
|
totalTokens: state.tokens,
|
|
8
9
|
durationMs: wallMs,
|
|
9
|
-
modelMs: sum(
|
|
10
|
+
modelMs: sum(rounds),
|
|
10
11
|
toolMs: sum(state.tools),
|
|
11
12
|
timeToFirstToken: state.ttft,
|
|
12
|
-
promptTokensPerSecond: prefillRate(
|
|
13
|
+
promptTokensPerSecond: prefillRate(rounds),
|
|
13
14
|
tokensPerSecond: state.decodeMs > 0 ? (state.timedTokens / state.decodeMs) * 1000 : undefined,
|
|
14
15
|
promptTokens: state.promptTokens,
|
|
15
16
|
cacheTokens: state.cacheTokens,
|
|
16
|
-
rounds
|
|
17
|
+
rounds,
|
|
17
18
|
tools: state.tools
|
|
18
19
|
};
|
|
19
20
|
if (state.ctxSize) {
|
|
@@ -25,11 +26,31 @@ export function metricsEvent(state, wallMs, usage) {
|
|
|
25
26
|
if (usage) {
|
|
26
27
|
event.usage = usage;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
const stopReason = cancelled ? cancelled.stopReason : state.stopReason;
|
|
30
|
+
if (stopReason) {
|
|
31
|
+
event.stopReason = stopReason;
|
|
32
|
+
}
|
|
33
|
+
if (outcome) {
|
|
34
|
+
event.outcome = outcome;
|
|
30
35
|
}
|
|
31
36
|
return event;
|
|
32
37
|
}
|
|
38
|
+
export function cancelledRound(live) {
|
|
39
|
+
if (!live) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const record = {
|
|
43
|
+
round: live.round,
|
|
44
|
+
durationMs: Date.now() - live.startedAt,
|
|
45
|
+
stopReason: 'cancelled',
|
|
46
|
+
rawContentChars: live.rawChars,
|
|
47
|
+
kind: live.kind
|
|
48
|
+
};
|
|
49
|
+
if (live.reasoningDeltas > 0) {
|
|
50
|
+
record.reasoningDeltas = live.reasoningDeltas;
|
|
51
|
+
}
|
|
52
|
+
return record;
|
|
53
|
+
}
|
|
33
54
|
function sum(records) {
|
|
34
55
|
return records.reduce((total, record) => total + record.durationMs, 0);
|
|
35
56
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { CompletionFinal, Tool as SdkTool, ToolDialect } from '@qvac/sdk';
|
|
2
|
+
import { type AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
3
|
+
import type { TextEvent } from '../../helpers/thinking.ts';
|
|
4
|
+
import type { LlmGenerationParams, Message, ResponseFormat, RunLifecycleEvent } from '../../contract/index.ts';
|
|
5
|
+
export interface ModelRoundRequest {
|
|
6
|
+
runId: string;
|
|
7
|
+
round: number;
|
|
8
|
+
kind: 'streaming' | 'wrap-up';
|
|
9
|
+
attempt: number;
|
|
10
|
+
modelId: string;
|
|
11
|
+
history: Message[];
|
|
12
|
+
tools?: SdkTool[] | undefined;
|
|
13
|
+
generationParams?: Partial<LlmGenerationParams> | undefined;
|
|
14
|
+
responseFormat?: ResponseFormat | undefined;
|
|
15
|
+
toolDialect?: ToolDialect | undefined;
|
|
16
|
+
cacheKey?: string | undefined;
|
|
17
|
+
promptPrefix: string;
|
|
18
|
+
continuationNudge: string;
|
|
19
|
+
deliveredNudge: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ModelRoundResult {
|
|
22
|
+
contentText: string;
|
|
23
|
+
final: CompletionFinal;
|
|
24
|
+
cut?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
export type ModelRoundEvent = TextEvent;
|
|
27
|
+
type RoundReset = Extract<RunLifecycleEvent, {
|
|
28
|
+
type: 'round-reset';
|
|
29
|
+
}>;
|
|
30
|
+
export interface ModelRoundIo {
|
|
31
|
+
signal: BareAbortSignal;
|
|
32
|
+
emit(event: ModelRoundEvent): void;
|
|
33
|
+
retake(): (event: ModelRoundEvent) => void;
|
|
34
|
+
}
|
|
35
|
+
export type ModelRoundPort = (request: ModelRoundRequest, io: ModelRoundIo) => Promise<ModelRoundResult>;
|
|
36
|
+
interface RunOptions {
|
|
37
|
+
signal?: BareAbortSignal | undefined;
|
|
38
|
+
emit(event: ModelRoundEvent | RoundReset): void;
|
|
39
|
+
}
|
|
40
|
+
export declare class ModelRound {
|
|
41
|
+
port: ModelRoundPort;
|
|
42
|
+
constructor(port: ModelRoundPort);
|
|
43
|
+
run(request: ModelRoundRequest, options: RunOptions): Promise<ModelRoundResult>;
|
|
44
|
+
static run(port: ModelRoundPort, request: ModelRoundRequest, { signal, emit }: RunOptions): Promise<ModelRoundResult>;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AbortController } from 'bare-abort-controller';
|
|
2
|
+
import { raceAbort } from '../../helpers/race-abort.js';
|
|
3
|
+
export class ModelRound {
|
|
4
|
+
port;
|
|
5
|
+
constructor(port) {
|
|
6
|
+
this.port = port;
|
|
7
|
+
}
|
|
8
|
+
run(request, options) {
|
|
9
|
+
return ModelRound.run(this.port, request, options);
|
|
10
|
+
}
|
|
11
|
+
static async run(port, request, { signal = new AbortController().signal, emit }) {
|
|
12
|
+
let taker = 0;
|
|
13
|
+
let open = true;
|
|
14
|
+
const live = () => open && !signal.aborted;
|
|
15
|
+
const emitter = (generation) => (event) => {
|
|
16
|
+
if (generation === taker && live()) {
|
|
17
|
+
emit(event);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const sent = port(request, {
|
|
21
|
+
signal,
|
|
22
|
+
emit: emitter(0),
|
|
23
|
+
retake: () => {
|
|
24
|
+
if (!live())
|
|
25
|
+
return noop;
|
|
26
|
+
taker++;
|
|
27
|
+
emit({
|
|
28
|
+
type: 'round-reset',
|
|
29
|
+
runId: request.runId,
|
|
30
|
+
round: request.round,
|
|
31
|
+
replacedTypes: ['content', 'thinking']
|
|
32
|
+
});
|
|
33
|
+
return emitter(taker);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
sent.catch(noop);
|
|
37
|
+
try {
|
|
38
|
+
return await raceAbort(sent, signal);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
open = false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const noop = () => { };
|
|
@@ -223,7 +223,7 @@ export function bindOperations(deps, context, stage) {
|
|
|
223
223
|
};
|
|
224
224
|
let preToolCount = 0;
|
|
225
225
|
pipeline.runPreToolFold = async (payload) => {
|
|
226
|
-
const { signal: _signal, egress: _egress, ...durable } = payload;
|
|
226
|
+
const { signal: _signal, egress: _egress, command: _command, paths: _paths, ...durable } = payload;
|
|
227
227
|
return runHookOperation({
|
|
228
228
|
deps,
|
|
229
229
|
base,
|
|
@@ -21,7 +21,7 @@ import { wrapUp } from './actors/wrap-up.js';
|
|
|
21
21
|
import { toolContext } from './actors/execution-plan.js';
|
|
22
22
|
import { capabilityPolicy, captureFacts, restoreFacts, schemaDigest } from './durable.js';
|
|
23
23
|
import { bindOperations, toolOperationFacts } from './operations.js';
|
|
24
|
-
import {} from './session.js';
|
|
24
|
+
import { loadedSkills } from './session.js';
|
|
25
25
|
import { errorMessage, isRecord } from '../../guards.js';
|
|
26
26
|
import { detachJson } from '../../helpers/detach-json.js';
|
|
27
27
|
const prepareSource = skillStep;
|
|
@@ -168,11 +168,7 @@ function detachEventPayload(event) {
|
|
|
168
168
|
case 'inference-call':
|
|
169
169
|
return { ...event, call: detachJson(event.call) };
|
|
170
170
|
case 'inference-sent':
|
|
171
|
-
return {
|
|
172
|
-
...event,
|
|
173
|
-
messages: detachJson(event.messages),
|
|
174
|
-
tokens: detachJson(event.tokens)
|
|
175
|
-
};
|
|
171
|
+
return { ...event, tokens: detachJson(event.tokens) };
|
|
176
172
|
case 'metrics':
|
|
177
173
|
return {
|
|
178
174
|
...event,
|
|
@@ -230,7 +226,7 @@ async function rebuildSession(deps, cx) {
|
|
|
230
226
|
restoreFacts(invocation.input, durable);
|
|
231
227
|
}
|
|
232
228
|
const session = deps.session;
|
|
233
|
-
session.reselectTools?.(
|
|
229
|
+
session.reselectTools?.(loadedSkills(context, session));
|
|
234
230
|
const missing = context.availableTools.filter((name) => !session.enabled.some((tool) => tool.name === name));
|
|
235
231
|
const changed = durable?.tools
|
|
236
232
|
.filter((saved) => {
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import type { CompletionFinal, Tool as SdkTool, ToolDialect } from '@qvac/sdk';
|
|
1
|
+
import type { CompletionFinal, CompletionStats, Tool as SdkTool, ToolDialect } from '@qvac/sdk';
|
|
2
2
|
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
3
|
+
import { type KnownTool } from '../../helpers/tool-call-markup.ts';
|
|
3
4
|
import { type TextEvent } from '../../helpers/thinking.ts';
|
|
4
5
|
import type { CompletionHistoryEntry, LlmGenerationParams } from '../../contract/index.ts';
|
|
5
|
-
import type { CompletionSdk, InferenceCallEvent, InferenceSentEvent, FoldEvent, Message, ResponseFormat, RoundModelLease, RunLifecycleEvent } from '../../contract/index.ts';
|
|
6
|
+
import type { CompletionSdk, InferenceCallEvent, InferenceSentEvent, FoldEvent, Message, ResponseFormat, RoundModelLease, RoundSpeed, RunLifecycleEvent } from '../../contract/index.ts';
|
|
6
7
|
import { type FailureTurn } from '../tool-turns.ts';
|
|
8
|
+
import { type CompletionParams } from '../../helpers/completion-params.ts';
|
|
7
9
|
import type { ModelRequest } from '../../run-log/index.ts';
|
|
8
10
|
import { type FailureResultValue } from '../../helpers/failure-result.ts';
|
|
9
|
-
|
|
11
|
+
import { type FoldReading } from '../../fold/index.ts';
|
|
12
|
+
export declare function foldTokens(stats: CompletionStats | undefined, cacheable: boolean | undefined): number | undefined;
|
|
10
13
|
export interface RecoveredRound {
|
|
11
14
|
contentText: string;
|
|
12
15
|
final: CompletionFinal;
|
|
@@ -14,7 +17,10 @@ export interface RecoveredRound {
|
|
|
14
17
|
cacheable: boolean;
|
|
15
18
|
unproven: string | null;
|
|
16
19
|
replay: string | null;
|
|
20
|
+
reasoningDeltas?: number | undefined;
|
|
17
21
|
ctxSize?: number | undefined;
|
|
22
|
+
overflows?: number | undefined;
|
|
23
|
+
cut?: string | undefined;
|
|
18
24
|
}
|
|
19
25
|
export interface RoundArgs {
|
|
20
26
|
modelId: string;
|
|
@@ -33,21 +39,35 @@ export interface RoundArgs {
|
|
|
33
39
|
runId?: string | undefined;
|
|
34
40
|
promptPrefix: string;
|
|
35
41
|
capture: boolean;
|
|
42
|
+
knownTools?: ReadonlyArray<KnownTool> | undefined;
|
|
36
43
|
unforced?: {
|
|
37
44
|
generationParams: LlmGenerationParams | undefined;
|
|
38
45
|
} | undefined;
|
|
39
46
|
recordRequest?: ((request: ModelRequest, failures: readonly FailureTurn[]) => Promise<void>) | undefined;
|
|
40
47
|
fold?: RoundFold | undefined;
|
|
48
|
+
live: LiveRound;
|
|
41
49
|
}
|
|
50
|
+
export interface LiveRound {
|
|
51
|
+
readonly round: number;
|
|
52
|
+
readonly kind: RoundKind;
|
|
53
|
+
readonly startedAt: number;
|
|
54
|
+
rawChars: number;
|
|
55
|
+
reasoningDeltas: number;
|
|
56
|
+
cut?: ((note: string) => void) | undefined;
|
|
57
|
+
}
|
|
58
|
+
export type RoundKind = NonNullable<RoundSpeed['kind']>;
|
|
42
59
|
export interface RoundFold {
|
|
43
60
|
messages: readonly Message[];
|
|
44
61
|
nudge: string;
|
|
45
62
|
ctxSize?: number | undefined;
|
|
63
|
+
cacheKey?: string | undefined;
|
|
46
64
|
instructions?: ((messages: readonly Message[]) => Promise<string | undefined>) | undefined;
|
|
65
|
+
reading?: FoldReading | undefined;
|
|
47
66
|
}
|
|
48
67
|
type RoundReset = Extract<RunLifecycleEvent, {
|
|
49
68
|
type: 'round-reset';
|
|
50
69
|
}>;
|
|
51
70
|
type RoundEvent = TextEvent | InferenceCallEvent | InferenceSentEvent | RoundReset | FoldEvent;
|
|
52
71
|
export declare function runRecoveredRound(sdk: CompletionSdk | undefined, args: RoundArgs): AsyncGenerator<RoundEvent, RecoveredRound>;
|
|
72
|
+
export declare function recordWholeRound(args: RoundArgs): Promise<CompletionParams>;
|
|
53
73
|
export {};
|