@qvac/harness 1.0.0-rc.3 → 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 +44 -31
- 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 +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,256 +0,0 @@
|
|
|
1
|
-
import process from 'process'
|
|
2
|
-
import { CompletionEngine } from '../lib/capabilities/completion-engine/index.ts'
|
|
3
|
-
import type { CompletionSdk, ToolDefinition } from '../lib/contract/index.ts'
|
|
4
|
-
import { isRecord } from '../lib/guards.ts'
|
|
5
|
-
import { RunLog, type EngineBoot, type EngineStep, type RunRecord } from '../lib/run-log/index.ts'
|
|
6
|
-
|
|
7
|
-
const SIZES = [100_000, 500_000, 1_000_000]
|
|
8
|
-
const PATTERNS = {
|
|
9
|
-
prose: 'A pagination cursor remains ordinary free text. ',
|
|
10
|
-
jwtPrefix: 'eyJ-',
|
|
11
|
-
markup: '<parameter=',
|
|
12
|
-
punctuation: 'the hyphen-token\\path stays byte-for-byte plain text - '
|
|
13
|
-
} as const
|
|
14
|
-
const SECRET = 'credential-value-must-not-be-persisted'
|
|
15
|
-
const SAMPLES = 3
|
|
16
|
-
const WARMUPS = 1
|
|
17
|
-
const encoder = new TextEncoder()
|
|
18
|
-
|
|
19
|
-
function runtimeInfo() {
|
|
20
|
-
const bun = Reflect.get(globalThis, 'Bun')
|
|
21
|
-
if (bun && typeof bun === 'object' && 'version' in bun && typeof bun.version === 'string') {
|
|
22
|
-
return { runtime: 'bun', version: bun.version }
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return { runtime: 'node', version: process.version }
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function stressText(pattern: string, bytes: number): string {
|
|
29
|
-
return pattern.repeat(Math.ceil(bytes / pattern.length)).slice(0, bytes)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function hasPair(value: unknown, key: string, expected: unknown): boolean {
|
|
33
|
-
if (Array.isArray(value)) {
|
|
34
|
-
return value.some((entry) => hasPair(entry, key, expected))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!isRecord(value)) return false
|
|
38
|
-
|
|
39
|
-
return Object.entries(value).some(
|
|
40
|
-
([childKey, child]) =>
|
|
41
|
-
(childKey === key && (child === expected || (isRecord(child) && child.$ === expected))) ||
|
|
42
|
-
hasPair(child, key, expected)
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function sdkFor(payload: string): CompletionSdk {
|
|
47
|
-
let round = 0
|
|
48
|
-
return {
|
|
49
|
-
completion: ({ tools }) => {
|
|
50
|
-
const toolCalls =
|
|
51
|
-
round === 0 && tools
|
|
52
|
-
? [
|
|
53
|
-
{
|
|
54
|
-
id: 'sensitive-call',
|
|
55
|
-
name: 'credential_tool',
|
|
56
|
-
arguments: { credential: SECRET, password: 739184, token: 1024, note: payload }
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
: []
|
|
60
|
-
const contentText = round++ === 0 ? '' : 'done'
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
tokenStream: (async function* () {
|
|
64
|
-
if (contentText) {
|
|
65
|
-
yield contentText
|
|
66
|
-
}
|
|
67
|
-
})(),
|
|
68
|
-
final: Promise.resolve({ contentText, toolCalls, raw: { fullText: contentText } })
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function createTool(execute: (args: Record<string, unknown>) => void): ToolDefinition {
|
|
75
|
-
return {
|
|
76
|
-
name: 'credential_tool',
|
|
77
|
-
description: 'Use the credential without displaying it',
|
|
78
|
-
parameters: {
|
|
79
|
-
type: 'object',
|
|
80
|
-
properties: {
|
|
81
|
-
credential: { type: 'string', sensitive: true },
|
|
82
|
-
password: { type: 'number' },
|
|
83
|
-
token: { type: 'number' },
|
|
84
|
-
note: { type: 'string' }
|
|
85
|
-
},
|
|
86
|
-
required: ['credential', 'note']
|
|
87
|
-
},
|
|
88
|
-
toolset: null,
|
|
89
|
-
autoApprove: true,
|
|
90
|
-
effect: () => 'read',
|
|
91
|
-
execute: (args) => {
|
|
92
|
-
execute(args)
|
|
93
|
-
return Promise.resolve({ content: payloadForResult(args) })
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function payloadForResult(args: Record<string, unknown>): string {
|
|
99
|
-
return typeof args.note === 'string' ? args.note : ''
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
interface Observation {
|
|
103
|
-
records: RunRecord[]
|
|
104
|
-
boot: EngineBoot
|
|
105
|
-
executedSecret: boolean
|
|
106
|
-
executedPassword: boolean
|
|
107
|
-
executedToken: boolean
|
|
108
|
-
sawRedactedCredential: boolean
|
|
109
|
-
sawRedactedPassword: boolean
|
|
110
|
-
sawTypedToken: boolean
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function createObservation() {
|
|
114
|
-
const state: Observation = {
|
|
115
|
-
records: [],
|
|
116
|
-
boot: RunLog.createEngineBoot(),
|
|
117
|
-
executedSecret: false,
|
|
118
|
-
executedPassword: false,
|
|
119
|
-
executedToken: false,
|
|
120
|
-
sawRedactedCredential: false,
|
|
121
|
-
sawRedactedPassword: false,
|
|
122
|
-
sawTypedToken: false
|
|
123
|
-
}
|
|
124
|
-
const tool = createTool((args) => {
|
|
125
|
-
state.executedSecret = args.credential === SECRET
|
|
126
|
-
state.executedPassword = args.password === 739184
|
|
127
|
-
state.executedToken = args.token === 1024
|
|
128
|
-
})
|
|
129
|
-
const onStep = (step: EngineStep) => observeStep(state, step)
|
|
130
|
-
|
|
131
|
-
return { state, tool, onStep }
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function observeStep(state: Observation, step: EngineStep): Promise<void> {
|
|
135
|
-
const next = RunLog.applyEngineStep(state.boot, step)
|
|
136
|
-
if (step.expectedLength !== state.records.length) {
|
|
137
|
-
throw new Error('noncontiguous host step')
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
for (const record of step.records) {
|
|
141
|
-
if (hasPair(record, 'credential', SECRET)) {
|
|
142
|
-
throw new Error('A schema-marked credential reached typed durable fields')
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (hasPair(record, 'password', 739184)) {
|
|
146
|
-
throw new Error('A numeric password reached typed durable fields')
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
state.sawRedactedCredential ||= hasPair(record, 'credential', '[redacted]')
|
|
150
|
-
state.sawRedactedPassword ||= hasPair(record, 'password', '[redacted]')
|
|
151
|
-
state.sawTypedToken ||= hasPair(record, 'token', 1024)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
state.records.push(...step.records)
|
|
155
|
-
state.boot = next
|
|
156
|
-
|
|
157
|
-
return Promise.resolve()
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function assertObservation(state: Observation, label: string, payload: string): void {
|
|
161
|
-
if (!state.executedSecret) {
|
|
162
|
-
throw new Error('The tool did not receive its unredacted credential')
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (!state.executedPassword || !state.executedToken) {
|
|
166
|
-
throw new Error('Numeric tool arguments changed at runtime')
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const metadata = state.records.find((record) => record.type === 'metadata')
|
|
170
|
-
if (!metadata || !isRecord(metadata.request)) {
|
|
171
|
-
throw new Error('Missing request metadata')
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const messages = metadata.request.messages
|
|
175
|
-
if (!Array.isArray(messages) || !isRecord(messages[0]) || messages[0].content !== payload) {
|
|
176
|
-
throw new Error(`Free text changed for ${label}/${payload.length}`)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (!state.sawRedactedCredential) {
|
|
180
|
-
throw new Error('The schema-marked tool argument was not redacted')
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (!state.sawRedactedPassword) {
|
|
184
|
-
throw new Error('A numeric password was not redacted')
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (!state.sawTypedToken) {
|
|
188
|
-
throw new Error('An ambiguous token count was over-redacted')
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
async function runOne(label: string, payload: string, sample: number): Promise<number> {
|
|
193
|
-
const { state, tool, onStep } = createObservation()
|
|
194
|
-
const started = process.cpuUsage()
|
|
195
|
-
for await (const _event of CompletionEngine.run(
|
|
196
|
-
sdkFor(payload),
|
|
197
|
-
{
|
|
198
|
-
runId: `redact-${label}-${payload.length}-${sample}`,
|
|
199
|
-
modelId: 'benchmark-model',
|
|
200
|
-
messages: [{ role: 'user', content: payload }],
|
|
201
|
-
tools: [tool]
|
|
202
|
-
},
|
|
203
|
-
{ onStep, requestDigestKey: new Uint8Array(32).fill(7) }
|
|
204
|
-
)) {
|
|
205
|
-
// Consume the real completion iterator; the durable callback is the production redaction path.
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const usage = process.cpuUsage(started)
|
|
209
|
-
assertObservation(state, label, payload)
|
|
210
|
-
|
|
211
|
-
return (usage.user + usage.system) / 1000
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function median(values: number[]): number {
|
|
215
|
-
const ordered = [...values].sort((left, right) => left - right)
|
|
216
|
-
return ordered[Math.floor(ordered.length / 2)]
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
async function main(): Promise<void> {
|
|
220
|
-
const results: Array<Record<string, number | string>> = []
|
|
221
|
-
for (const [label, pattern] of Object.entries(PATTERNS)) {
|
|
222
|
-
for (const size of SIZES) {
|
|
223
|
-
const payload = stressText(pattern, size)
|
|
224
|
-
for (let sample = 0; sample < WARMUPS; sample++) {
|
|
225
|
-
await runOne(label, payload, -sample - 1)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const times: number[] = []
|
|
229
|
-
for (let sample = 0; sample < SAMPLES; sample++) {
|
|
230
|
-
times.push(await runOne(label, payload, sample))
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
results.push({
|
|
234
|
-
pattern: label,
|
|
235
|
-
bytes: encoder.encode(payload).byteLength,
|
|
236
|
-
samples: SAMPLES,
|
|
237
|
-
medianCpuMs: median(times),
|
|
238
|
-
maxCpuMs: Math.max(...times)
|
|
239
|
-
})
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
console.log(
|
|
244
|
-
JSON.stringify({
|
|
245
|
-
...runtimeInfo(),
|
|
246
|
-
adapter: 'completion() production redactor + schema registration + awaited host onStep',
|
|
247
|
-
warmups: WARMUPS,
|
|
248
|
-
results
|
|
249
|
-
})
|
|
250
|
-
)
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
main().catch((error) => {
|
|
254
|
-
console.error(error)
|
|
255
|
-
process.exitCode = 1
|
|
256
|
-
})
|
package/bench/repeat-cpu.mjs
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import { fileURLToPath } from 'node:url'
|
|
4
|
-
|
|
5
|
-
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
6
|
-
const engineBench = path.join(root, 'bench/cpu.ts')
|
|
7
|
-
const mainBench = path.join(root, 'bench/cpu-main.mjs')
|
|
8
|
-
const bunConfig = path.join(root, 'bench/bun-tsconfig.json')
|
|
9
|
-
const options = parseOptions(process.argv.slice(2))
|
|
10
|
-
const bench = options.driver === 'main' ? mainBench : engineBench
|
|
11
|
-
|
|
12
|
-
const command =
|
|
13
|
-
options.runtime === 'bun'
|
|
14
|
-
? { executable: 'bun', prefix: [`--tsconfig-override=${bunConfig}`] }
|
|
15
|
-
: { executable: process.execPath, prefix: ['--experimental-strip-types'] }
|
|
16
|
-
|
|
17
|
-
const samples = []
|
|
18
|
-
for (let i = 0; i < options.processes; i++) {
|
|
19
|
-
const args = [
|
|
20
|
-
...command.prefix,
|
|
21
|
-
bench,
|
|
22
|
-
String(options.runs),
|
|
23
|
-
`--spacing=${options.spacing}`,
|
|
24
|
-
`--workload=${options.workload}`,
|
|
25
|
-
'--json'
|
|
26
|
-
]
|
|
27
|
-
if (options.driver === 'engine') {
|
|
28
|
-
args.splice(args.length - 1, 0, `--mode=${options.mode}`)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const child = spawnSync(command.executable, args, {
|
|
32
|
-
cwd: root,
|
|
33
|
-
encoding: 'utf8'
|
|
34
|
-
})
|
|
35
|
-
if (child.error) {
|
|
36
|
-
throw child.error
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (child.status !== 0) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
`${command.executable} exited with ${child.status}:\n${child.stderr || child.stdout}`
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const lines = child.stdout.trim().split('\n')
|
|
46
|
-
const result = JSON.parse(lines.at(-1))
|
|
47
|
-
validateChildReport(result, i + 1)
|
|
48
|
-
samples.push({ process: i + 1, ...result })
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
validateProcessReports(samples)
|
|
52
|
-
|
|
53
|
-
const keys = new Map()
|
|
54
|
-
for (const sample of samples) {
|
|
55
|
-
for (const result of sample.results) {
|
|
56
|
-
const key = [result.workload, result.mode, result.spacing ?? ''].join(':')
|
|
57
|
-
if (!keys.has(key)) {
|
|
58
|
-
keys.set(key, [])
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
keys.get(key).push(result)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const medians = [...keys].map(([key, results]) => {
|
|
66
|
-
const first = results[0]
|
|
67
|
-
const aggregate = { workload: first.workload, mode: first.mode, spacing: first.spacing }
|
|
68
|
-
|
|
69
|
-
const cpuSamples = results.flatMap((result) => result.cpuSamplesMs)
|
|
70
|
-
aggregate.rawSampleCount = cpuSamples.length
|
|
71
|
-
aggregate.cpuMs = median(cpuSamples)
|
|
72
|
-
aggregate.processMedianMs = median(results.map((result) => result.cpuMs))
|
|
73
|
-
if (typeof first.usPerToken === 'number' && first.cpuMs > 0) {
|
|
74
|
-
aggregate.usPerToken = aggregate.cpuMs * (first.usPerToken / first.cpuMs)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
for (const metric of ['logBytes', 'records', 'contentEvents']) {
|
|
78
|
-
const values = results.map((result) => result[metric]).filter(Number.isFinite)
|
|
79
|
-
if (values.length) {
|
|
80
|
-
aggregate[metric] = median(values)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return { key, ...aggregate }
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
console.log(
|
|
88
|
-
JSON.stringify({
|
|
89
|
-
runtime: samples[0].runtime,
|
|
90
|
-
version: samples[0].version,
|
|
91
|
-
driver: options.driver,
|
|
92
|
-
revision: options.revision,
|
|
93
|
-
processes: options.processes,
|
|
94
|
-
runsPerProcess: options.runs,
|
|
95
|
-
reduction: 'pooled median of all raw cpuSamplesMs; process medians are reported separately',
|
|
96
|
-
workload: options.workload,
|
|
97
|
-
samples,
|
|
98
|
-
medians
|
|
99
|
-
})
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
function validateOptions(options) {
|
|
103
|
-
if (!['node', 'bun'].includes(options.runtime)) {
|
|
104
|
-
throw new Error('runtime must be node or bun')
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (!['engine', 'main'].includes(options.driver)) {
|
|
108
|
-
throw new Error('driver must be engine or main')
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (!['tools', 'stream', 'all'].includes(options.workload)) {
|
|
112
|
-
throw new Error('workload must be tools, stream or all')
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (!['immediate', 'timeout', 'all'].includes(options.spacing)) {
|
|
116
|
-
throw new Error('spacing must be immediate, timeout or all')
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (!['plain', 'bench', 'production', 'all'].includes(options.mode)) {
|
|
120
|
-
throw new Error('mode must be plain, bench, production or all')
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
for (const key of ['processes', 'runs']) {
|
|
124
|
-
if (!Number.isInteger(options[key]) || options[key] < 1) {
|
|
125
|
-
throw new Error(`${key} must be a positive integer`)
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return options
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function expectedResultKeys() {
|
|
133
|
-
const workloads = options.workload === 'all' ? ['tools', 'stream'] : [options.workload]
|
|
134
|
-
let modes
|
|
135
|
-
if (options.driver === 'main') {
|
|
136
|
-
modes = ['main']
|
|
137
|
-
} else if (options.mode === 'all') {
|
|
138
|
-
modes = ['plain', 'bench', 'production']
|
|
139
|
-
} else {
|
|
140
|
-
modes = [options.mode]
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const spacings = options.spacing === 'all' ? ['immediate', 'timeout'] : [options.spacing]
|
|
144
|
-
const expected = []
|
|
145
|
-
|
|
146
|
-
for (const mode of modes) {
|
|
147
|
-
for (const workload of workloads) {
|
|
148
|
-
const workloadSpacings = workload === 'tools' ? [''] : spacings
|
|
149
|
-
for (const spacing of workloadSpacings) {
|
|
150
|
-
expected.push([workload, mode, spacing].join(':'))
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return expected.sort()
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function resultKey(result) {
|
|
159
|
-
return [result.workload, result.mode, result.spacing ?? ''].join(':')
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function validateChildReport(report, processNumber) {
|
|
163
|
-
if (!report || report.runtime !== options.runtime || typeof report.version !== 'string') {
|
|
164
|
-
throw new Error(`process ${processNumber} reported an unexpected runtime identity`)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (report.runs !== options.runs || !Array.isArray(report.results)) {
|
|
168
|
-
throw new Error(`process ${processNumber} reported an unexpected run count or results list`)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const expectedKeys = expectedResultKeys()
|
|
172
|
-
const actualKeys = report.results.map(resultKey)
|
|
173
|
-
if (
|
|
174
|
-
actualKeys.length !== expectedKeys.length ||
|
|
175
|
-
new Set(actualKeys).size !== actualKeys.length ||
|
|
176
|
-
actualKeys.sort().join('\n') !== expectedKeys.join('\n')
|
|
177
|
-
) {
|
|
178
|
-
throw new Error(
|
|
179
|
-
`process ${processNumber} returned an incomplete or inconsistent workload matrix`
|
|
180
|
-
)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
for (const result of report.results) {
|
|
184
|
-
if (
|
|
185
|
-
result.runs !== options.runs ||
|
|
186
|
-
!Array.isArray(result.cpuSamplesMs) ||
|
|
187
|
-
result.cpuSamplesMs.length !== options.runs ||
|
|
188
|
-
!result.cpuSamplesMs.every((sample) => Number.isFinite(sample) && sample >= 0)
|
|
189
|
-
) {
|
|
190
|
-
throw new Error(
|
|
191
|
-
`process ${processNumber} result ${resultKey(result)} did not preserve ${options.runs} finite raw CPU samples`
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (result.cpuMs !== median(result.cpuSamplesMs)) {
|
|
196
|
-
throw new Error(
|
|
197
|
-
`process ${processNumber} result ${resultKey(result)} has an invalid process median`
|
|
198
|
-
)
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function validateProcessReports(samples) {
|
|
204
|
-
const expectedKeys = expectedResultKeys()
|
|
205
|
-
const referenceVersion = samples[0].version
|
|
206
|
-
|
|
207
|
-
for (const sample of samples) {
|
|
208
|
-
if (sample.version !== referenceVersion) {
|
|
209
|
-
throw new Error('benchmark processes reported different runtime versions')
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const keys = sample.results.map(resultKey).sort()
|
|
213
|
-
if (keys.join('\n') !== expectedKeys.join('\n')) {
|
|
214
|
-
throw new Error('benchmark processes returned different workload matrices')
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function applyOption(options, arg) {
|
|
220
|
-
const [key, value] = arg.split('=', 2)
|
|
221
|
-
const values = {
|
|
222
|
-
'--runtime': () => {
|
|
223
|
-
options.runtime = value
|
|
224
|
-
},
|
|
225
|
-
'--driver': () => {
|
|
226
|
-
options.driver = value
|
|
227
|
-
},
|
|
228
|
-
'--processes': () => {
|
|
229
|
-
options.processes = Number(value)
|
|
230
|
-
},
|
|
231
|
-
'--runs': () => {
|
|
232
|
-
options.runs = Number(value)
|
|
233
|
-
},
|
|
234
|
-
'--mode': () => {
|
|
235
|
-
options.mode = value
|
|
236
|
-
},
|
|
237
|
-
'--spacing': () => {
|
|
238
|
-
options.spacing = value
|
|
239
|
-
},
|
|
240
|
-
'--workload': () => {
|
|
241
|
-
options.workload = value
|
|
242
|
-
},
|
|
243
|
-
'--revision': () => {
|
|
244
|
-
options.revision = value
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
const setValue = values[key]
|
|
248
|
-
if (!setValue) {
|
|
249
|
-
throw new Error(`Unknown option: ${arg}`)
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
setValue()
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function parseOptions(args) {
|
|
256
|
-
const options = {
|
|
257
|
-
runtime: 'node',
|
|
258
|
-
driver: 'engine',
|
|
259
|
-
processes: 3,
|
|
260
|
-
runs: 3,
|
|
261
|
-
mode: 'all',
|
|
262
|
-
spacing: 'all',
|
|
263
|
-
workload: 'all',
|
|
264
|
-
revision: ''
|
|
265
|
-
}
|
|
266
|
-
for (const arg of args) {
|
|
267
|
-
applyOption(options, arg)
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return validateOptions(options)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function median(values) {
|
|
274
|
-
if (values.length === 0) {
|
|
275
|
-
throw new Error('Cannot calculate a median without samples')
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const sorted = [...values].sort((a, b) => a - b)
|
|
279
|
-
|
|
280
|
-
return sorted[Math.floor(sorted.length / 2)]
|
|
281
|
-
}
|