@qvac/harness 1.0.0-rc.2 → 1.0.0-rc.20
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 +3050 -1485
- package/README.md +110 -46
- package/dist-lib/index.d.ts +60 -15
- package/dist-lib/index.js +228 -35
- 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 +11 -2
- package/dist-lib/lib/agent/resolve.js +29 -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 +2 -0
- package/dist-lib/lib/agent/tools.js +2 -1
- package/dist-lib/lib/capabilities/agent-ports.d.ts +1 -1
- package/dist-lib/lib/capabilities/agent-ports.js +11 -4
- 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.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +129 -12
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +54 -10
- 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 +10 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +137 -50
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +69 -17
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +33 -16
- package/dist-lib/lib/capabilities/completion-engine/actors/run-prepare.js +36 -22
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +50 -12
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +80 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +5 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +95 -35
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +55 -16
- package/dist-lib/lib/capabilities/completion-engine/driver.js +58 -15
- package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +3 -1
- package/dist-lib/lib/capabilities/completion-engine/durable.js +12 -2
- 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 +5 -1
- package/dist-lib/lib/capabilities/completion-engine/index.js +5 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +25 -3
- package/dist-lib/lib/capabilities/completion-engine/loop.js +13 -2
- 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 +63 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.js +99 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.js +30 -10
- package/dist-lib/lib/capabilities/completion-engine/ports.js +6 -9
- package/dist-lib/lib/capabilities/completion-engine/prepare-step.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +38 -6
- package/dist-lib/lib/capabilities/completion-engine/round.js +393 -116
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +12 -4
- package/dist-lib/lib/capabilities/completion-engine/session.js +31 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +5 -4
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +32 -12
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.d.ts +24 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.js +15 -0
- package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +17 -9
- package/dist-lib/lib/capabilities/completion-engine/turns.js +96 -87
- package/dist-lib/lib/capabilities/detect-language.d.ts +2 -1
- package/dist-lib/lib/capabilities/detect-language.js +14 -2
- package/dist-lib/lib/capabilities/download.d.ts +10 -8
- 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 +23 -11
- package/dist-lib/lib/capabilities/kv-cache.d.ts +1 -1
- 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/prompt-prefix.d.ts +3 -1
- package/dist-lib/lib/capabilities/prompt-prefix.js +8 -0
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +13 -4
- package/dist-lib/lib/capabilities/sdk-tool.js +59 -7
- package/dist-lib/lib/capabilities/skill-entry.d.ts +13 -1
- package/dist-lib/lib/capabilities/skill-entry.js +33 -2
- package/dist-lib/lib/capabilities/tool-failed-note.d.ts +1 -0
- package/dist-lib/lib/capabilities/tool-failed-note.js +1 -0
- package/dist-lib/lib/capabilities/tool-plan.d.ts +5 -1
- package/dist-lib/lib/capabilities/tool-plan.js +20 -5
- package/dist-lib/lib/capabilities/tool-prompt-log.d.ts +1 -1
- package/dist-lib/lib/capabilities/tool-prompt-log.js +3 -3
- package/dist-lib/lib/capabilities/tool-turns.d.ts +20 -9
- package/dist-lib/lib/capabilities/tool-turns.js +77 -49
- package/dist-lib/lib/capabilities/usage-breakdown.d.ts +1 -0
- package/dist-lib/lib/capabilities/usage-breakdown.js +4 -1
- package/dist-lib/lib/client/index.d.ts +19 -0
- package/dist-lib/lib/client/index.js +263 -0
- package/dist-lib/lib/connect.d.ts +19 -10
- package/dist-lib/lib/connect.js +239 -32
- package/dist-lib/lib/context-window.d.ts +2 -0
- package/dist-lib/lib/context-window.js +9 -3
- package/dist-lib/lib/contract/agent.d.ts +13 -3
- package/dist-lib/lib/contract/completion.d.ts +77 -31
- 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 +4 -3
- package/dist-lib/lib/contract/hooks.d.ts +4 -1
- package/dist-lib/lib/contract/index.d.ts +4 -0
- package/dist-lib/lib/contract/knowledge.d.ts +10 -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/media.d.ts +58 -0
- package/dist-lib/lib/contract/media.js +1 -0
- package/dist-lib/lib/contract/models.d.ts +12 -6
- package/dist-lib/lib/contract/ocr.d.ts +13 -0
- package/dist-lib/lib/contract/ocr.js +1 -0
- 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 +28 -3
- package/dist-lib/lib/contract/sandbox.d.ts +3 -1
- package/dist-lib/lib/contract/speech.d.ts +1 -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 +46 -16
- 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 +278 -0
- package/dist-lib/lib/errors.js +212 -0
- package/dist-lib/lib/fold/index.d.ts +26 -1
- package/dist-lib/lib/fold/index.js +76 -9
- package/dist-lib/lib/guarded-fetch.js +11 -7
- package/dist-lib/lib/guards.d.ts +2 -0
- package/dist-lib/lib/guards.js +7 -0
- package/dist-lib/lib/hardware/capability-probe.js +10 -7
- package/dist-lib/lib/hardware/cpu-placement.d.ts +8 -0
- package/dist-lib/lib/hardware/cpu-placement.js +48 -0
- package/dist-lib/lib/hardware/gpu-probe-addon.js +26 -11
- package/dist-lib/lib/hardware/gpu-probe.js +10 -1
- package/dist-lib/lib/hardware/gpu-stats.native.cjs +17 -1
- package/dist-lib/lib/helpers/completion-params.d.ts +7 -2
- package/dist-lib/lib/helpers/completion-params.js +26 -2
- package/dist-lib/lib/helpers/control-tokens.d.ts +3 -0
- package/dist-lib/lib/helpers/control-tokens.js +25 -0
- 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 +44 -0
- package/dist-lib/lib/helpers/goal-check.js +407 -0
- package/dist-lib/lib/helpers/head-tail.js +1 -1
- package/dist-lib/lib/helpers/html-helpers.js +9 -6
- 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/require-peers.d.ts +3 -0
- package/dist-lib/lib/helpers/require-peers.js +23 -0
- package/dist-lib/lib/helpers/run-outcome.d.ts +2 -0
- package/dist-lib/lib/helpers/run-outcome.js +6 -2
- package/dist-lib/lib/helpers/spawn-path.d.ts +1 -0
- package/dist-lib/lib/helpers/spawn-path.js +2 -1
- 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 +11 -6
- package/dist-lib/lib/machine/completion/actions/completion.js +251 -35
- package/dist-lib/lib/machine/completion/actions/prepare.js +1 -1
- package/dist-lib/lib/machine/completion/actions/tools.js +122 -6
- package/dist-lib/lib/machine/completion/context.js +11 -1
- package/dist-lib/lib/machine/completion/guards/retry.d.ts +3 -1
- package/dist-lib/lib/machine/completion/guards/retry.js +9 -2
- package/dist-lib/lib/machine/completion/implementations.d.ts +16 -7
- package/dist-lib/lib/machine/completion/implementations.js +59 -15
- package/dist-lib/lib/machine/completion/machine.d.ts +36 -7
- package/dist-lib/lib/machine/completion/machine.js +58 -9
- package/dist-lib/lib/machine/completion/rules.d.ts +23 -2
- package/dist-lib/lib/machine/completion/rules.js +91 -6
- package/dist-lib/lib/machine/completion/types.d.ts +77 -1
- package/dist-lib/lib/machine/index.d.ts +48 -9
- package/dist-lib/lib/machine/index.js +11 -1
- package/dist-lib/lib/media-host.d.ts +12 -0
- package/dist-lib/lib/media-host.js +52 -0
- package/dist-lib/lib/media-port.d.ts +20 -0
- package/dist-lib/lib/media-port.js +77 -0
- package/dist-lib/lib/media-wire.d.ts +8 -0
- package/dist-lib/lib/media-wire.js +111 -0
- package/dist-lib/lib/models/context-choice.d.ts +15 -0
- package/dist-lib/lib/models/context-choice.js +62 -0
- package/dist-lib/lib/models/context.d.ts +1 -1
- package/dist-lib/lib/models/custom-model-cache.d.ts +1 -0
- package/dist-lib/lib/models/custom-model-cache.js +3 -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 +11 -0
- package/dist-lib/lib/models/gguf-header.js +203 -15
- package/dist-lib/lib/models/gpu-selection.d.ts +6 -1
- package/dist-lib/lib/models/gpu-selection.js +29 -5
- package/dist-lib/lib/models/kv-cache.d.ts +2 -0
- package/dist-lib/lib/models/kv-cache.js +8 -0
- package/dist-lib/lib/models/llm-presets.d.ts +6 -1
- package/dist-lib/lib/models/llm-presets.js +33 -6
- package/dist-lib/lib/models/load-requests.d.ts +9 -0
- package/dist-lib/lib/models/load-requests.js +42 -0
- 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-constants.d.ts +2 -2
- package/dist-lib/lib/models/model-catalog-constants.js +3 -4
- package/dist-lib/lib/models/model-catalog.d.ts +7 -3
- package/dist-lib/lib/models/model-catalog.js +44 -11
- package/dist-lib/lib/models/model-delete.d.ts +1 -1
- package/dist-lib/lib/models/model-fit.d.ts +2 -2
- package/dist-lib/lib/models/model-fit.js +5 -6
- package/dist-lib/lib/models/model-handle.d.ts +9 -2
- package/dist-lib/lib/models/model-handle.js +14 -3
- package/dist-lib/lib/models/model-list.d.ts +9 -2
- package/dist-lib/lib/models/model-list.js +23 -0
- package/dist-lib/lib/models/model-pool.d.ts +42 -7
- package/dist-lib/lib/models/model-pool.js +139 -49
- package/dist-lib/lib/models/model-source.d.ts +3 -2
- package/dist-lib/lib/models/model-source.js +23 -5
- package/dist-lib/lib/models/opencl-cache.js +2 -2
- 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/models/tool-dialect.d.ts +1 -1
- package/dist-lib/lib/models/tts-model-default.d.ts +2 -1
- package/dist-lib/lib/models/tts-model-default.js +8 -6
- package/dist-lib/lib/no-redirect-fetch-bare.js +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.d.ts +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.js +46 -8
- 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 +64 -21
- package/dist-lib/lib/office/engine/pptx/types.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/sheet.js +10 -4
- 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 +15 -0
- package/dist-lib/lib/plugins/registry.js +91 -22
- package/dist-lib/lib/plugins/require-bare.d.ts +1 -0
- package/dist-lib/lib/plugins/require-bare.js +13 -0
- package/dist-lib/lib/policy/index.d.ts +11 -0
- package/dist-lib/lib/policy/index.js +235 -0
- package/dist-lib/lib/prompt.d.ts +9 -4
- package/dist-lib/lib/prompt.js +95 -32
- package/dist-lib/lib/residency/completion-runtime.d.ts +15 -5
- package/dist-lib/lib/residency/completion-runtime.js +47 -36
- package/dist-lib/lib/residency/index.d.ts +56 -4
- package/dist-lib/lib/residency/index.js +442 -40
- package/dist-lib/lib/resolution-detector.js +3 -3
- package/dist-lib/lib/round-host.d.ts +12 -0
- package/dist-lib/lib/round-host.js +57 -0
- package/dist-lib/lib/round-port.d.ts +24 -0
- package/dist-lib/lib/round-port.js +81 -0
- package/dist-lib/lib/rpc-session.js +2 -1
- package/dist-lib/lib/run-log/request-codec.js +2 -2
- package/dist-lib/lib/sdk-loader.d.ts +1 -1
- package/dist-lib/lib/sdk-loader.js +47 -17
- package/dist-lib/lib/sdk-storage.d.ts +1 -0
- package/dist-lib/lib/sdk-storage.js +18 -2
- package/dist-lib/lib/serve.js +242 -50
- package/dist-lib/lib/sidecar/index.d.ts +39 -0
- package/dist-lib/lib/sidecar/index.js +205 -0
- package/dist-lib/lib/sidecar/user-plugins.d.ts +9 -0
- package/dist-lib/lib/sidecar/user-plugins.js +119 -0
- package/dist-lib/lib/skills-host/index.d.ts +3 -1
- package/dist-lib/lib/skills-host/index.js +27 -14
- package/dist-lib/lib/spawn.d.ts +6 -4
- package/dist-lib/lib/spawn.js +22 -20
- package/dist-lib/lib/spill.d.ts +1 -0
- package/dist-lib/lib/spill.js +12 -8
- package/dist-lib/lib/tools/ask-user.d.ts +2 -0
- package/dist-lib/lib/tools/ask-user.js +137 -0
- package/dist-lib/lib/tools/attachments/delivered.d.ts +5 -0
- package/dist-lib/lib/tools/attachments/delivered.js +16 -0
- package/dist-lib/lib/tools/attachments/fetched-file.d.ts +32 -0
- package/dist-lib/lib/tools/attachments/fetched-file.js +134 -0
- package/dist-lib/lib/tools/attachments/staging.d.ts +1 -0
- package/dist-lib/lib/tools/attachments/staging.js +19 -8
- package/dist-lib/lib/tools/exec/runner.d.ts +4 -0
- package/dist-lib/lib/tools/exec/runner.js +20 -2
- 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 +89 -27
- package/dist-lib/lib/tools/files/edit-file.d.ts +6 -0
- package/dist-lib/lib/tools/files/edit-file.js +266 -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 +212 -0
- package/dist-lib/lib/tools/files/index.d.ts +3 -0
- package/dist-lib/lib/tools/files/index.js +25 -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 +224 -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 +8 -0
- package/dist-lib/lib/tools/fs/document-text.js +22 -0
- package/dist-lib/lib/tools/fs/drive.d.ts +10 -14
- package/dist-lib/lib/tools/fs/drive.js +9 -1
- package/dist-lib/lib/tools/fs/edit-match.d.ts +33 -0
- package/dist-lib/lib/tools/fs/edit-match.js +445 -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 +45 -3
- package/dist-lib/lib/tools/fs/remote-protocol.js +1 -1
- package/dist-lib/lib/tools/fs/remote.d.ts +3 -11
- package/dist-lib/lib/tools/fs/remote.js +24 -14
- 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 +383 -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 +16 -3
- package/dist-lib/lib/tools/fs/walk.js +119 -24
- package/dist-lib/lib/tools/http-request/request.d.ts +4 -2
- package/dist-lib/lib/tools/http-request/request.js +2 -1
- package/dist-lib/lib/tools/http-request/truncate-response.d.ts +16 -1
- package/dist-lib/lib/tools/http-request/truncate-response.js +56 -11
- package/dist-lib/lib/tools/http-request.d.ts +1 -0
- package/dist-lib/lib/tools/http-request.js +101 -16
- package/dist-lib/lib/tools/index.d.ts +4 -1
- package/dist-lib/lib/tools/index.js +8 -12
- package/dist-lib/lib/tools/office/ops.d.ts +1 -0
- package/dist-lib/lib/tools/office/ops.js +5 -1
- package/dist-lib/lib/tools/office.d.ts +2 -1
- package/dist-lib/lib/tools/office.js +273 -56
- package/dist-lib/lib/tools/operations/builders.d.ts +4 -3
- package/dist-lib/lib/tools/operations/builders.js +41 -3
- package/dist-lib/lib/tools/operations/calendar-range.d.ts +16 -0
- package/dist-lib/lib/tools/operations/calendar-range.js +40 -0
- package/dist-lib/lib/tools/operations/compile.js +8 -6
- package/dist-lib/lib/tools/operations/manifest.d.ts +4 -0
- package/dist-lib/lib/tools/pdf/build.d.ts +15 -1
- package/dist-lib/lib/tools/pdf/build.js +77 -16
- package/dist-lib/lib/tools/pdf/pages.d.ts +12 -0
- package/dist-lib/lib/tools/pdf/pages.js +31 -0
- package/dist-lib/lib/tools/pdf/recognize.d.ts +13 -0
- package/dist-lib/lib/tools/pdf/recognize.js +59 -0
- package/dist-lib/lib/tools/pdf.js +56 -12
- package/dist-lib/lib/tools/skill.js +10 -7
- package/dist-lib/lib/tools/skills/bundled-dir.d.ts +5 -1
- package/dist-lib/lib/tools/skills/bundled-dir.js +27 -24
- package/dist-lib/lib/tools/skills/catalog.d.ts +3 -1
- package/dist-lib/lib/tools/skills/catalog.js +7 -3
- 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-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/credential-check.js +3 -0
- package/dist-lib/lib/tools/skills/credential-health.js +3 -3
- package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +3 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +5 -0
- package/dist-lib/lib/tools/skills/manifest-parse.d.ts +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +39 -3
- package/dist-lib/lib/tools/skills/manifest.d.ts +1 -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.d.ts +3 -3
- package/dist-lib/lib/tools/skills/overlay-crud.js +7 -6
- package/dist-lib/lib/tools/skills/overlay-watch.d.ts +2 -2
- package/dist-lib/lib/tools/skills/overlay-watch.js +4 -3
- package/dist-lib/lib/tools/skills/scope-key.d.ts +1 -0
- package/dist-lib/lib/tools/skills/scope-key.js +4 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +1 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.js +4 -0
- 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 +50 -133
- package/dist-lib/lib/wire.d.ts +13 -0
- package/dist-lib/lib/wire.js +78 -6
- package/dist-lib/plugins/coding/index.d.ts +1 -1
- package/dist-lib/plugins/coding/index.js +2 -4
- package/dist-lib/plugins/coding/read-only.d.ts +1 -0
- package/dist-lib/plugins/coding/read-only.js +264 -0
- package/dist-lib/plugins/coding/session.d.ts +6 -4
- package/dist-lib/plugins/coding/session.js +45 -16
- package/dist-lib/plugins/coding-guards/index.d.ts +25 -0
- package/dist-lib/plugins/coding-guards/index.js +126 -0
- 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 +184 -0
- package/dist-lib/plugins/image/edit-image.d.ts +3 -22
- package/dist-lib/plugins/image/edit-image.js +23 -46
- package/dist-lib/plugins/image/fit.d.ts +31 -0
- package/dist-lib/plugins/image/fit.js +28 -0
- package/dist-lib/plugins/image/generate-image.d.ts +27 -6
- package/dist-lib/plugins/image/generate-image.js +201 -74
- package/dist-lib/plugins/image/index.d.ts +2 -1
- package/dist-lib/plugins/image/index.js +29 -12
- package/dist-lib/plugins/knowledge/index.d.ts +3 -0
- package/dist-lib/plugins/knowledge/index.js +5 -0
- package/dist-lib/plugins/knowledge/manifest.d.ts +53 -0
- package/dist-lib/plugins/knowledge/manifest.js +86 -0
- package/dist-lib/plugins/knowledge/search-tool.js +8 -8
- package/dist-lib/plugins/knowledge/store.d.ts +45 -8
- package/dist-lib/plugins/knowledge/store.js +428 -166
- package/dist-lib/plugins/language-hint/index.d.ts +15 -0
- package/dist-lib/plugins/language-hint/index.js +54 -0
- package/dist-lib/plugins/lsp/tool.js +2 -2
- package/dist-lib/plugins/mcp/call.js +15 -4
- package/dist-lib/plugins/mcp/index.js +6 -3
- package/dist-lib/plugins/mcp/protocol.d.ts +10 -2
- package/dist-lib/plugins/mcp/protocol.js +13 -12
- package/dist-lib/plugins/mcp/server.js +1 -1
- package/dist-lib/plugins/mcp/tool-listing.d.ts +6 -0
- package/dist-lib/plugins/mcp/tool-listing.js +97 -0
- package/dist-lib/plugins/music/generate-music.d.ts +24 -5
- package/dist-lib/plugins/music/generate-music.js +170 -64
- package/dist-lib/plugins/music/index.d.ts +2 -1
- package/dist-lib/plugins/music/index.js +23 -11
- package/dist-lib/plugins/obsidian/command.js +2 -2
- package/dist-lib/plugins/obsidian/index.js +14 -4
- package/dist-lib/plugins/obsidian/note-name.js +2 -1
- package/dist-lib/plugins/obsidian/readiness.js +2 -2
- 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 +20 -18
- package/dist-lib/plugins/obsidian/vault-write.js +13 -12
- package/dist-lib/plugins/ocr/bmp.d.ts +2 -0
- package/dist-lib/plugins/ocr/bmp.js +27 -0
- package/dist-lib/plugins/ocr/index.d.ts +12 -0
- package/dist-lib/plugins/ocr/index.js +20 -0
- package/dist-lib/plugins/ocr/ocr-runtime.d.ts +23 -0
- package/dist-lib/plugins/ocr/ocr-runtime.js +82 -0
- package/dist-lib/plugins/ocr/reading-order.d.ts +5 -0
- package/dist-lib/plugins/ocr/reading-order.js +218 -0
- package/dist-lib/plugins/python/bare-floor.d.ts +1 -0
- package/dist-lib/plugins/python/bare-floor.js +2 -0
- 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/index.d.ts +4 -1
- package/dist-lib/plugins/python/index.js +6 -1
- package/dist-lib/plugins/python/interrupt-timer.js +2 -2
- package/dist-lib/plugins/python/language.js +11 -10
- package/dist-lib/plugins/python/loader.d.ts +1 -0
- package/dist-lib/plugins/python/loader.js +76 -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.d.ts +6 -1
- package/dist-lib/plugins/python/python-adapter.js +37 -2
- 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 +10 -9
- package/dist-lib/plugins/python/worker/entry.js +2 -8
- package/dist-lib/plugins/python/worker/preload.d.ts +1 -0
- package/dist-lib/plugins/python/worker/preload.js +2 -0
- 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 +3 -2
- package/dist-lib/plugins/quickjs/index.js +4 -0
- package/dist-lib/plugins/quickjs/runtime.js +8 -3
- 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 +32 -13
- package/dist-lib/plugins/run-report/layout.js +1 -1
- 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 +7 -4
- 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 +62 -0
- package/dist-lib/plugins/sandbox-linux/index.js +354 -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 +25 -11
- package/dist-lib/plugins/sandbox-macos/index.js +244 -49
- package/dist-lib/plugins/sandbox-vm/index.d.ts +2 -1
- package/dist-lib/plugins/sandbox-vm/index.js +5 -2
- package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +7 -3
- package/dist-lib/plugins/sandbox-vm/vm-shell.js +54 -20
- 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 +8 -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/index.d.ts +1 -0
- package/dist-lib/plugins/speech/index.js +8 -1
- package/dist-lib/plugins/speech/speech-engine.d.ts +1 -1
- package/dist-lib/plugins/speech/speech-engine.js +10 -5
- package/dist-lib/plugins/speech/speech-runtime.js +37 -37
- package/dist-lib/plugins/speech/speech-text.d.ts +1 -0
- package/dist-lib/plugins/speech/speech-text.js +9 -4
- package/dist-lib/plugins/speech/voice.d.ts +5 -1
- package/dist-lib/plugins/speech/voice.js +107 -33
- package/dist-lib/plugins/translation/index.d.ts +2 -1
- package/dist-lib/plugins/translation/index.js +21 -10
- package/dist-lib/plugins/translation/translate.d.ts +9 -5
- package/dist-lib/plugins/translation/translate.js +69 -64
- package/dist-lib/plugins/walkie-talkie/index.d.ts +4 -2
- package/dist-lib/plugins/walkie-talkie/index.js +19 -6
- package/dist-lib/plugins/walkie-talkie/wire.d.ts +5 -0
- package/dist-lib/plugins/walkie-talkie/wire.js +6 -5
- package/dist-lib/plugins/weather/geocode.js +2 -1
- package/dist-lib/plugins/weather/lookup.js +6 -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/generate.js +8 -1
- package/dist-lib/schema/harness.js +91 -12
- package/dist-lib/spec/bind.js +12 -0
- package/dist-lib/spec/calls.js +4 -0
- package/dist-lib/spec/hrpc/hrpc.json +55 -3
- package/dist-lib/spec/hrpc/index.js +58 -10
- package/dist-lib/spec/hrpc/messages.js +461 -209
- package/dist-lib/spec/hyperschema/index.js +461 -209
- package/dist-lib/spec/hyperschema/schema.json +285 -85
- package/dist-lib/spec/hyperschema/types.d.ts +41 -5
- package/package.json +264 -64
- package/patches/pyodide@314.0.2.patch +37 -8
- package/scripts/addon-externals.cjs +16 -5
- package/worker/harness-sidecar.mjs +23 -154
- package/dist-lib/lib/tools/create-documents.d.ts +0 -3
- package/dist-lib/lib/tools/create-documents.js +0 -95
- package/dist-lib/lib/tools/edit-documents.d.ts +0 -3
- package/dist-lib/lib/tools/edit-documents.js +0 -132
- package/dist-lib/lib/tools/exec/shell-argv.d.ts +0 -2
- package/dist-lib/lib/tools/exec/shell-argv.js +0 -61
- package/dist-lib/lib/tools/file-glob.js +0 -118
- package/dist-lib/lib/tools/grep.d.ts +0 -5
- package/dist-lib/lib/tools/grep.js +0 -184
- package/dist-lib/lib/tools/read-files.d.ts +0 -5
- package/dist-lib/lib/tools/read-files.js +0 -160
- package/dist-lib/plugins/coding/write-file.d.ts +0 -3
- package/dist-lib/plugins/coding/write-file.js +0 -52
- package/patches/@qvac%2Finference@0.21.0.patch +0 -67
- package/patches/bare-stow@0.1.5.patch +0 -68
- package/patches/hypercore-blob-server@1.15.0.patch +0 -15
- package/patches/localwatch@1.4.3.patch +0 -13
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { spliceFrom } from '../splice.js';
|
|
2
2
|
import { carriesRunOnlyText } from '../turns.js';
|
|
3
3
|
import { runRound } from './stream.js';
|
|
4
|
+
import { roundFold } from './streaming.js';
|
|
4
5
|
import { degenerateAnswer } from '../../../helpers/run-outcome.js';
|
|
5
6
|
import { stripToolCallMarkup } from '../../../helpers/tool-call-markup.js';
|
|
6
|
-
import { promptPrefixHash } from '../../prompt-prefix.js';
|
|
7
7
|
import { materializeCompletionHistory } from '../../tool-turns.js';
|
|
8
|
-
import {
|
|
8
|
+
import { requestPromptPrefix } from '../../prompt-prefix.js';
|
|
9
|
+
import { toolDialectFor } from '../../../models/model-catalog.js';
|
|
10
|
+
import { loadedSkills } from '../session.js';
|
|
11
|
+
import { CompletionMachine } from '../../../machine/index.js';
|
|
12
|
+
export const WRAP_UP_PREDICT = 4096;
|
|
9
13
|
export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session, operations }, context }) {
|
|
10
14
|
const { modelId, acquireRound, signal } = args;
|
|
11
|
-
const cacheKey =
|
|
12
|
-
|
|
15
|
+
const cacheKey = !args.replaysContext && carriesRunOnlyText(context.history)
|
|
16
|
+
? undefined
|
|
17
|
+
: (context.cacheKey ?? undefined);
|
|
18
|
+
const promptPrefix = session.reselectTools?.(loadedSkills(context, session), context.history) ?? context.promptPrefix;
|
|
13
19
|
const startedAt = Date.now();
|
|
14
20
|
const recovered = await runRound({
|
|
15
21
|
sdk,
|
|
22
|
+
modelRound: args.modelRound,
|
|
23
|
+
agent: args.agent,
|
|
24
|
+
kind: 'wrap-up',
|
|
25
|
+
session,
|
|
16
26
|
args: {
|
|
17
27
|
modelId,
|
|
18
28
|
acquireRound,
|
|
@@ -20,45 +30,74 @@ export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session,
|
|
|
20
30
|
failureResults: context.failureResults,
|
|
21
31
|
continuationNudge: context.policy.continuationNudge,
|
|
22
32
|
deliveredNudge: context.policy.deliveredNudge,
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
goalNudge: context.policy.goalNudge,
|
|
34
|
+
wrapUpNudge: context.policy.wrapUpNudge,
|
|
35
|
+
tools: session.sdkTools,
|
|
36
|
+
generationParams: wrapUpParams(session.generationParams, context.outcome === 'time-capped'),
|
|
37
|
+
toolDialect: args.model ? toolDialectFor(args.model) : undefined,
|
|
25
38
|
cacheKey,
|
|
26
39
|
signal,
|
|
27
40
|
round: context.roundsSent,
|
|
28
41
|
promptPrefix,
|
|
29
42
|
capture: args.captureInferenceCalls === true,
|
|
30
|
-
recordRequest: operations.recordRequest
|
|
43
|
+
recordRequest: operations.recordRequest,
|
|
44
|
+
fold: roundFold(args, session, context)
|
|
31
45
|
},
|
|
32
46
|
emit
|
|
33
47
|
});
|
|
34
48
|
const durationMs = Date.now() - startedAt;
|
|
35
|
-
const
|
|
36
|
-
const
|
|
49
|
+
const cutOff = CompletionMachine.atContextBoundary(recovered.final);
|
|
50
|
+
const replay = !cutOff && recovered.replay?.trim() ? stripToolCallMarkup(recovered.replay) : '';
|
|
51
|
+
const contentText = !cutOff && recovered.contentText.trim() ? recovered.contentText : '';
|
|
52
|
+
if (cutOff) {
|
|
53
|
+
emit({
|
|
54
|
+
type: 'round-reset',
|
|
55
|
+
runId: session.runId,
|
|
56
|
+
round: context.roundsSent,
|
|
57
|
+
replacedTypes: ['content', 'thinking']
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const fallbackResponse = degenerateAnswer(wrapOutcome(context), materializeCompletionHistory(context.history, context.failureResults), {
|
|
61
|
+
...previewFinishedRound(session.runOutcomes.snapshot()),
|
|
62
|
+
delivered: context.delivered,
|
|
63
|
+
repeated: CompletionMachine.repeatsBlocked(context)
|
|
64
|
+
});
|
|
37
65
|
return {
|
|
38
|
-
contentText
|
|
66
|
+
contentText,
|
|
39
67
|
thinkingText: '',
|
|
40
|
-
promptPrefix
|
|
68
|
+
promptPrefix: recovered.history
|
|
69
|
+
? requestPromptPrefix(recovered.history, session.sdkTools)
|
|
70
|
+
: promptPrefix,
|
|
41
71
|
toolCalls: [],
|
|
42
72
|
stats: recovered.final.stats,
|
|
43
73
|
stopReason: recovered.final.stopReason,
|
|
44
74
|
durationMs,
|
|
45
75
|
ctxSize: recovered.ctxSize,
|
|
76
|
+
overflows: recovered.overflows,
|
|
77
|
+
reasoningDeltas: recovered.reasoningDeltas,
|
|
46
78
|
replay,
|
|
47
79
|
history: recovered.history ? spliceFrom(context.history, recovered.history) : undefined,
|
|
48
80
|
cacheable: recovered.cacheable,
|
|
49
|
-
|
|
81
|
+
keyed: recovered.keyed,
|
|
82
|
+
response: replay || contentText || fallbackResponse
|
|
50
83
|
};
|
|
51
84
|
};
|
|
85
|
+
function wrapUpParams(params, timeUp) {
|
|
86
|
+
if (timeUp) {
|
|
87
|
+
return { ...params, reasoning_budget: 0, predict: WRAP_UP_PREDICT, tool_choice: 'none' };
|
|
88
|
+
}
|
|
89
|
+
if (!params) {
|
|
90
|
+
return { tool_choice: 'none' };
|
|
91
|
+
}
|
|
92
|
+
const reasoning = Math.max(params.reasoning_budget ?? 0, 0);
|
|
93
|
+
return { predict: reasoning + WRAP_UP_PREDICT, ...params, tool_choice: 'none' };
|
|
94
|
+
}
|
|
52
95
|
function previewFinishedRound(state) {
|
|
53
96
|
return {
|
|
54
97
|
latestFailure: state.hasRoundResult ? state.roundFailure : state.latestFailure,
|
|
55
98
|
confirmedWrites: state.confirmedWrites
|
|
56
99
|
};
|
|
57
100
|
}
|
|
58
|
-
function systemMessage(context) {
|
|
59
|
-
const first = context.history[0];
|
|
60
|
-
return first && !isFailureResultReference(first) && first.role === 'system' ? first.content : null;
|
|
61
|
-
}
|
|
62
101
|
function wrapOutcome(ctx) {
|
|
63
102
|
if (ctx.outcome === 'mute' ||
|
|
64
103
|
ctx.outcome === 'exhausted' ||
|
|
@@ -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_STALLED_NUDGE, GOAL_ROUNDS, MAX_TOOL_ROUNDS, TOOL_CONTEXT_BOUNDARY_MESSAGE, TOOL_CONTINUATION_NUDGE, WRAP_UP_NUDGE, TOOL_CUT_OFF_MESSAGE, TOOL_DENIED_MESSAGE, TOOL_REPEATED_FAILURE_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,9 +76,23 @@ 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
|
}
|
|
82
|
+
function* cutGoal(context, runId) {
|
|
83
|
+
const { goal } = context;
|
|
84
|
+
if (goal?.status !== 'open') {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
yield {
|
|
88
|
+
type: 'goal',
|
|
89
|
+
runId,
|
|
90
|
+
status: CompletionMachine.goalStatus(context),
|
|
91
|
+
turn: goal.turns,
|
|
92
|
+
round: context.round,
|
|
93
|
+
proof: goal.proof
|
|
94
|
+
};
|
|
95
|
+
}
|
|
83
96
|
function hookManifest(hooks) {
|
|
84
97
|
const ordinals = new Map();
|
|
85
98
|
return hooks.map((hook) => {
|
|
@@ -300,14 +313,27 @@ function isAgent(value) {
|
|
|
300
313
|
optionalNullableNumber('imageHeight') &&
|
|
301
314
|
optionalEnum('approvalMode', ['ask', 'skip-all']) &&
|
|
302
315
|
optionalStringArray('disabledToolsets') &&
|
|
303
|
-
(value.
|
|
316
|
+
(value.policy === undefined || value.policy === null || isRecord(value.policy)) &&
|
|
304
317
|
(value.plan === undefined || value.plan === null || typeof value.plan === 'boolean') &&
|
|
305
318
|
optionalNullableString('model'));
|
|
306
319
|
}
|
|
307
320
|
function isGenerationParams(value) {
|
|
308
321
|
return (isRecord(value) &&
|
|
309
|
-
(value.reasoning_budget ===
|
|
310
|
-
|
|
322
|
+
(value.reasoning_budget === undefined ||
|
|
323
|
+
(Number.isInteger(value.reasoning_budget) && Number(value.reasoning_budget) >= -1)) &&
|
|
324
|
+
(value.reasoning_rounds === undefined ||
|
|
325
|
+
value.reasoning_rounds === 'every' ||
|
|
326
|
+
value.reasoning_rounds === 'plan') &&
|
|
327
|
+
[
|
|
328
|
+
'temp',
|
|
329
|
+
'top_p',
|
|
330
|
+
'top_k',
|
|
331
|
+
'presence_penalty',
|
|
332
|
+
'repeat_penalty',
|
|
333
|
+
'frequency_penalty',
|
|
334
|
+
'predict',
|
|
335
|
+
'seed'
|
|
336
|
+
].every((key) => value[key] === undefined || typeof value[key] === 'number'));
|
|
311
337
|
}
|
|
312
338
|
function isResponseFormat(value) {
|
|
313
339
|
if (!isRecord(value)) {
|
|
@@ -338,14 +364,28 @@ function completionArgs(...parts) {
|
|
|
338
364
|
}
|
|
339
365
|
return { ...merged, model: own ?? merged.model, modelId, messages };
|
|
340
366
|
}
|
|
367
|
+
function worded(ports, guidelines) {
|
|
368
|
+
if (!guidelines) {
|
|
369
|
+
return ports;
|
|
370
|
+
}
|
|
371
|
+
return { ...ports, systemPrompt: (input) => ports.systemPrompt({ ...input, guidelines }) };
|
|
372
|
+
}
|
|
341
373
|
function runPolicy({ maxToolRounds, goal, wording }) {
|
|
342
374
|
return {
|
|
343
375
|
maxToolRounds: checkMaxToolRounds(goal?.rounds ?? maxToolRounds ?? (goal ? GOAL_ROUNDS : MAX_TOOL_ROUNDS)),
|
|
344
376
|
continuationNudge: wording?.toolContinuation ?? TOOL_CONTINUATION_NUDGE,
|
|
345
377
|
deliveredNudge: wording?.fileDelivered ?? FILE_DELIVERED_NUDGE,
|
|
378
|
+
wrapUpNudge: wording?.wrapUp ?? WRAP_UP_NUDGE,
|
|
346
379
|
deniedMessage: wording?.toolDenied ?? TOOL_DENIED_MESSAGE,
|
|
347
380
|
cutOffMessage: wording?.toolCutOff ?? TOOL_CUT_OFF_MESSAGE,
|
|
348
|
-
|
|
381
|
+
contextBoundaryMessage: wording?.toolContextBoundary ?? TOOL_CONTEXT_BOUNDARY_MESSAGE,
|
|
382
|
+
roundCutMessage: wording?.toolRoundCut ?? TOOL_ROUND_CUT_MESSAGE,
|
|
383
|
+
repeatedCallMessage: wording?.toolRepeated ?? TOOL_REPEATED_MESSAGE,
|
|
384
|
+
repeatedFailureMessage: wording?.toolRepeatedFailure ?? TOOL_REPEATED_FAILURE_MESSAGE,
|
|
385
|
+
unchangedMessage: wording?.toolUnchanged ?? TOOL_UNCHANGED_MESSAGE,
|
|
386
|
+
failingMessage: wording?.toolFailing,
|
|
387
|
+
goalNudge: wording?.goalContinuation ?? GOAL_CONTINUATION_NUDGE,
|
|
388
|
+
goalStalledNudge: wording?.goalStalled ?? GOAL_STALLED_NUDGE
|
|
349
389
|
};
|
|
350
390
|
}
|
|
351
391
|
function restoredContextMetrics(boot) {
|
|
@@ -463,6 +503,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
463
503
|
session: null,
|
|
464
504
|
final: null
|
|
465
505
|
};
|
|
506
|
+
args.roundCut?.((note) => completionState.session?.liveRound?.cut?.(note));
|
|
466
507
|
let full = detachedRequest(completionArgs(prepared.savedArgs, args));
|
|
467
508
|
let reachedPause = false;
|
|
468
509
|
const engine = runEngine({
|
|
@@ -472,7 +513,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
472
513
|
recovery: args.recovery,
|
|
473
514
|
request: options.redact ? options.redact(prepared.identity) : prepared.identity,
|
|
474
515
|
requestDigest: prepared.requestDigest,
|
|
475
|
-
budget: boot?.metadata?.budget ?? createRunBudget(now(), goal?.ms),
|
|
516
|
+
budget: boot?.metadata?.budget ?? createRunBudget(now(), goal?.ms ?? args.budgetMs),
|
|
476
517
|
signal: args.signal,
|
|
477
518
|
input: args.input && pipeline.hasPhase('promptSubmit')
|
|
478
519
|
? submittedInput(args.input, pipeline, { runId, agentId: full.agent?.id ?? null })
|
|
@@ -526,7 +567,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
526
567
|
runId,
|
|
527
568
|
pipeline,
|
|
528
569
|
outbound: options.outbound,
|
|
529
|
-
agentPorts: options.agentPorts
|
|
570
|
+
agentPorts: worded(options.agentPorts, full.wording?.guidelines)
|
|
530
571
|
});
|
|
531
572
|
session.startedAt = openedBoot.metadata?.startedAt ?? openedBoot.firstSavedAt ?? now();
|
|
532
573
|
if (openedBoot.metadata?.budget) {
|
|
@@ -579,11 +620,12 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
579
620
|
const snapshot = result.snapshot;
|
|
580
621
|
const facts = completionOutputFacts(snapshot.context.durable);
|
|
581
622
|
const landed = facts?.confirmedWrites ?? [];
|
|
582
|
-
const runMetrics = function* () {
|
|
623
|
+
const runMetrics = function* (cancelled = null) {
|
|
583
624
|
const usage = facts?.promptParts
|
|
584
625
|
? usageBreakdown(facts.promptParts, snapshot.context.metrics.cacheTokens, full.model)
|
|
585
626
|
: null;
|
|
586
|
-
const
|
|
627
|
+
const { outcome } = snapshot.context;
|
|
628
|
+
const metrics = metricsEvent({ ...snapshot.context.metrics, backends: facts?.backends }, Date.now() - wallStart, { usage, outcome: outcome === 'failed' ? null : outcome, cancelled });
|
|
587
629
|
if (metrics) {
|
|
588
630
|
yield { ...metrics, runId };
|
|
589
631
|
}
|
|
@@ -595,7 +637,8 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
595
637
|
'tag' in result.error &&
|
|
596
638
|
result.error.tag === 'aborted') {
|
|
597
639
|
reachedPause = true;
|
|
598
|
-
yield*
|
|
640
|
+
yield* cutGoal(snapshot.context, runId);
|
|
641
|
+
yield* runMetrics(cancelledRound(completionState.session?.liveRound));
|
|
599
642
|
throw new AbortedError();
|
|
600
643
|
}
|
|
601
644
|
throw rehydrateError(tagError(result.error));
|
|
@@ -631,7 +674,7 @@ export async function* driveCompletion(args, runtime, options) {
|
|
|
631
674
|
});
|
|
632
675
|
if (didDrainTimeOut(await raceDrain(runEnd))) {
|
|
633
676
|
options.onDetached?.(runEnd, runId);
|
|
634
|
-
|
|
677
|
+
HarnessLog.info('runEnd hook still running after completion closed', { runId });
|
|
635
678
|
}
|
|
636
679
|
}
|
|
637
680
|
}
|
|
@@ -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;
|
|
@@ -53,10 +54,11 @@ export interface DurableFacts extends Record<string, unknown> {
|
|
|
53
54
|
}
|
|
54
55
|
export interface ToolOperationFacts {
|
|
55
56
|
backends: RunBackendUse[];
|
|
56
|
-
runBudget: Pick<RunBudget, 'outputBytesUsed'>;
|
|
57
|
+
runBudget: Pick<RunBudget, 'outputBytesUsed' | 'delivered'>;
|
|
57
58
|
outcome: Pick<RunOutcomeState, 'confirmedWrites'>;
|
|
58
59
|
}
|
|
59
60
|
export declare function captureFacts(session: Session): DurableFacts;
|
|
60
61
|
export declare function captureToolOperationFacts(session: Session): ToolOperationFacts;
|
|
62
|
+
export declare function laterDelivered(current: RunBudget['delivered'], recorded: RunBudget['delivered']): RunBudget['delivered'];
|
|
61
63
|
export declare function restoreFacts(deps: CompletionDeps, facts: DurableFacts): void;
|
|
62
64
|
export {};
|
|
@@ -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) {
|
|
@@ -102,10 +106,16 @@ export function captureFacts(session) {
|
|
|
102
106
|
export function captureToolOperationFacts(session) {
|
|
103
107
|
return copy({
|
|
104
108
|
backends: [...session.backends],
|
|
105
|
-
runBudget: {
|
|
109
|
+
runBudget: {
|
|
110
|
+
outputBytesUsed: session.runBudget.outputBytesUsed,
|
|
111
|
+
delivered: session.runBudget.delivered
|
|
112
|
+
},
|
|
106
113
|
outcome: { confirmedWrites: session.runOutcomes.snapshot().confirmedWrites }
|
|
107
114
|
});
|
|
108
115
|
}
|
|
116
|
+
export function laterDelivered(current, recorded) {
|
|
117
|
+
return (recorded?.length ?? 0) > (current?.length ?? 0) ? recorded : current;
|
|
118
|
+
}
|
|
109
119
|
export function restoreFacts(deps, facts) {
|
|
110
120
|
facts = copy(facts);
|
|
111
121
|
const session = deps.session;
|
|
@@ -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;
|
|
@@ -3,6 +3,7 @@ import { type EngineBoot, type EngineStep } from '../../run-log/index.ts';
|
|
|
3
3
|
import type { CompletionSkillEntry } from '../skill-entry.ts';
|
|
4
4
|
import { type CompletionRun, type CompletionRuntime } from './driver.ts';
|
|
5
5
|
import type { CompletionArgs } from './loop.ts';
|
|
6
|
+
import { ModelRound } from './model-round.ts';
|
|
6
7
|
export interface CompletionEngineOptions {
|
|
7
8
|
hooks?: readonly HarnessHook[];
|
|
8
9
|
outbound?: OutboundGuard;
|
|
@@ -16,7 +17,8 @@ export interface CompletionEngineOptions {
|
|
|
16
17
|
bootRequest?: unknown;
|
|
17
18
|
}
|
|
18
19
|
export declare class CompletionEngine {
|
|
19
|
-
static
|
|
20
|
+
static WRAP_UP_PREDICT: number;
|
|
21
|
+
static serveModelRound: typeof ModelRound.serve;
|
|
20
22
|
runtime: CompletionRuntime;
|
|
21
23
|
hooks: readonly HarnessHook[];
|
|
22
24
|
outbound: OutboundGuard;
|
|
@@ -28,3 +30,5 @@ export declare class CompletionEngine {
|
|
|
28
30
|
}
|
|
29
31
|
export type { CompletionArgs } from './loop.ts';
|
|
30
32
|
export type { CompletionRun, CompletionRuntime } from './driver.ts';
|
|
33
|
+
export type { ModelRoundEvent, ModelRoundIo, ModelRoundPort, ModelRoundRequest, ModelRoundResult, ModelRoundServeOptions } from './model-round.ts';
|
|
34
|
+
export { ToolSets } from './tool-sets.ts';
|
|
@@ -4,9 +4,11 @@ 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
|
+
import { ModelRound } from './model-round.js';
|
|
8
9
|
export class CompletionEngine {
|
|
9
|
-
static
|
|
10
|
+
static WRAP_UP_PREDICT = WRAP_UP_PREDICT;
|
|
11
|
+
static serveModelRound = ModelRound.serve;
|
|
10
12
|
runtime;
|
|
11
13
|
hooks;
|
|
12
14
|
outbound;
|
|
@@ -42,3 +44,4 @@ export class CompletionEngine {
|
|
|
42
44
|
return new CompletionEngine(sdk, opts).run(args);
|
|
43
45
|
}
|
|
44
46
|
}
|
|
47
|
+
export { ToolSets } from './tool-sets.js';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
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
|
-
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';
|
|
4
|
+
import type { GuidelineWording, MediaRoundPort, ToolCallDisplay } from '../../contract/index.ts';
|
|
5
|
+
import type { AgentConfig, AccessPolicy, CompiledPolicy, CompletionEvent, ApproveFn, AskUserFn, AttachFn, DriveRoot, FetchAttachmentFn, LlmGenerationParams, Message, ProgressFn, ResponseFormat, RunBudget, RunGoal, RunInput, RoundModelLease, ShowImageFn, 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,39 +13,60 @@ export interface CompletionArgs {
|
|
|
12
13
|
lockOwner?: object;
|
|
13
14
|
modelId: string;
|
|
14
15
|
acquireRound?: (signal?: BareAbortSignal) => Promise<RoundModelLease>;
|
|
16
|
+
modelRound?: ModelRoundPort;
|
|
17
|
+
mediaRound?: MediaRoundPort;
|
|
15
18
|
model?: string;
|
|
16
19
|
agent?: AgentConfig;
|
|
17
20
|
ctxSize?: number;
|
|
18
21
|
cacheKey?: string;
|
|
22
|
+
replaysContext?: boolean;
|
|
23
|
+
session?: string;
|
|
19
24
|
thinkingDefault?: string;
|
|
20
25
|
generationParams?: LlmGenerationParams;
|
|
21
26
|
responseFormat?: ResponseFormat;
|
|
22
27
|
messages: Message[];
|
|
28
|
+
typedText?: string;
|
|
23
29
|
requestMessages?: Message[];
|
|
24
30
|
tools?: ToolDefinition[];
|
|
25
31
|
skillCatalog?: readonly CompletionSkillEntry[];
|
|
32
|
+
platform?: string | undefined;
|
|
26
33
|
approve?: ApproveFn;
|
|
27
34
|
attach?: AttachFn;
|
|
28
35
|
fetchAttachment?: FetchAttachmentFn;
|
|
36
|
+
showImage?: ShowImageFn;
|
|
29
37
|
progress?: ProgressFn;
|
|
30
38
|
askUser?: AskUserFn;
|
|
31
39
|
signal?: BareAbortSignal;
|
|
32
40
|
input?: AsyncIterable<RunInput>;
|
|
41
|
+
roundCut?: (cut: (note: string) => void) => void;
|
|
33
42
|
toolConfigs?: Record<string, Record<string, unknown>>;
|
|
34
43
|
fsRoots?: readonly DriveRoot[];
|
|
35
44
|
fsWriteRoots?: readonly DriveRoot[];
|
|
45
|
+
policy?: AccessPolicy;
|
|
46
|
+
access?: CompiledPolicy;
|
|
36
47
|
captureInferenceCalls?: boolean;
|
|
37
48
|
now?: () => number;
|
|
38
49
|
maxToolRounds?: number;
|
|
50
|
+
budgetMs?: number;
|
|
39
51
|
knowledge?: KnowledgeGrant;
|
|
40
52
|
planMode?: boolean;
|
|
53
|
+
deferTools?: boolean;
|
|
41
54
|
goal?: RunGoal;
|
|
42
55
|
wording?: {
|
|
43
56
|
toolContinuation?: string;
|
|
44
57
|
fileDelivered?: string;
|
|
58
|
+
wrapUp?: string;
|
|
45
59
|
toolDenied?: string;
|
|
46
60
|
toolCutOff?: string;
|
|
61
|
+
toolRoundCut?: string;
|
|
62
|
+
toolContextBoundary?: string;
|
|
63
|
+
toolRepeated?: string;
|
|
64
|
+
toolRepeatedFailure?: string;
|
|
65
|
+
toolUnchanged?: string;
|
|
66
|
+
toolFailing?: string;
|
|
47
67
|
goalContinuation?: string;
|
|
68
|
+
goalStalled?: string;
|
|
69
|
+
guidelines?: GuidelineWording;
|
|
48
70
|
};
|
|
49
71
|
}
|
|
50
72
|
export declare function labelOf(name: string, args: Record<string, unknown>, emoji: string | null): ToolCallDisplay;
|
|
@@ -55,4 +77,4 @@ export declare function createRunBudget(startedAt: number, ms?: number): RunBudg
|
|
|
55
77
|
export type ToolContextFactory = (turnImages?: {
|
|
56
78
|
path: string;
|
|
57
79
|
}[], ctxSize?: number, signal?: BareAbortSignal) => ToolExecuteContext;
|
|
58
|
-
export declare function runToolContext(args: Pick<CompletionArgs, 'agent' | 'attach' | 'fetchAttachment' | 'progress' | 'askUser' | 'signal' | 'fsRoots' | 'fsWriteRoots'>, runBudget: RunBudget): ToolContextFactory;
|
|
80
|
+
export declare function runToolContext(args: Pick<CompletionArgs, 'agent' | 'attach' | 'fetchAttachment' | 'progress' | 'askUser' | 'mediaRound' | 'signal' | 'fsRoots' | 'fsWriteRoots' | 'session' | 'cacheKey'>, runBudget: RunBudget): ToolContextFactory;
|
|
@@ -25,11 +25,13 @@ const RUN_WALL_CLOCK_BUDGET_MS = 30 * 60_000;
|
|
|
25
25
|
export function createRunBudget(startedAt, ms) {
|
|
26
26
|
const override = Number(process.env.QVAC_RUN_BUDGET_MS);
|
|
27
27
|
const fallback = Number.isFinite(override) && override > 0 ? override : RUN_WALL_CLOCK_BUDGET_MS;
|
|
28
|
-
|
|
28
|
+
const totalMs = ms ?? fallback;
|
|
29
|
+
return { deadlineMs: startedAt + totalMs, totalMs, outputBytesUsed: 0 };
|
|
29
30
|
}
|
|
30
31
|
export function runToolContext(args, runBudget) {
|
|
31
|
-
const { agent, attach, fetchAttachment, progress, askUser, signal } = args;
|
|
32
|
+
const { agent, attach, fetchAttachment, progress, askUser, mediaRound, signal } = args;
|
|
32
33
|
const image = imageSettingsFrom(agent);
|
|
34
|
+
const session = args.session ?? sessionOf(args.cacheKey);
|
|
33
35
|
return (turnImages = [], ctxSize, invocationSignal) => {
|
|
34
36
|
const context = {
|
|
35
37
|
agentId: agent?.id ?? null,
|
|
@@ -39,6 +41,9 @@ export function runToolContext(args, runBudget) {
|
|
|
39
41
|
runBudget,
|
|
40
42
|
signal: invocationSignal ?? signal
|
|
41
43
|
};
|
|
44
|
+
if (session) {
|
|
45
|
+
context.session = session;
|
|
46
|
+
}
|
|
42
47
|
if (image) {
|
|
43
48
|
context.image = image;
|
|
44
49
|
}
|
|
@@ -57,6 +62,12 @@ export function runToolContext(args, runBudget) {
|
|
|
57
62
|
if (askUser) {
|
|
58
63
|
context.askUser = askUser;
|
|
59
64
|
}
|
|
65
|
+
if (mediaRound) {
|
|
66
|
+
context.mediaRound = mediaRound;
|
|
67
|
+
}
|
|
60
68
|
return context;
|
|
61
69
|
};
|
|
62
70
|
}
|
|
71
|
+
function sessionOf(cacheKey) {
|
|
72
|
+
return cacheKey?.split('/')[0] || undefined;
|
|
73
|
+
}
|
|
@@ -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
|
}
|