@qvac/harness 1.0.0-rc.2 → 1.0.0-rc.21
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 +3073 -1485
- package/README.md +110 -46
- package/dist-lib/index.d.ts +63 -16
- package/dist-lib/index.js +232 -38
- 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 +30 -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/answering.js +2 -2
- 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/execute.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +132 -13
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +11 -5
- 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 +12 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +142 -50
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +78 -20
- 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 +38 -23
- 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 +101 -41
- 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 +56 -17
- 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 +26 -3
- package/dist-lib/lib/capabilities/completion-engine/loop.js +14 -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 +395 -118
- 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 +5 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +8 -43
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +32 -141
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.d.ts +4 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.js +42 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-preflight.d.ts +43 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-preflight.js +91 -0
- 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 +98 -86
- 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/attachments.d.ts +7 -0
- package/dist-lib/lib/capabilities/tool-turns/attachments.js +39 -0
- package/dist-lib/lib/capabilities/tool-turns/copy.d.ts +13 -0
- package/dist-lib/lib/capabilities/tool-turns/copy.js +29 -0
- package/dist-lib/lib/capabilities/tool-turns/result-turn.d.ts +22 -0
- package/dist-lib/lib/capabilities/tool-turns/result-turn.js +120 -0
- package/dist-lib/lib/capabilities/tool-turns/run-limits.d.ts +6 -0
- package/dist-lib/lib/capabilities/tool-turns/run-limits.js +32 -0
- package/dist-lib/lib/capabilities/tool-turns/skill-loads.d.ts +9 -0
- package/dist-lib/lib/capabilities/tool-turns/skill-loads.js +71 -0
- package/dist-lib/lib/capabilities/tool-turns.d.ts +8 -43
- package/dist-lib/lib/capabilities/tool-turns.js +6 -253
- 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/abort.d.ts +6 -0
- package/dist-lib/lib/connect/abort.js +52 -0
- package/dist-lib/lib/connect/bridges.d.ts +21 -0
- package/dist-lib/lib/connect/bridges.js +185 -0
- package/dist-lib/lib/connect/decode.d.ts +31 -0
- package/dist-lib/lib/connect/decode.js +114 -0
- package/dist-lib/lib/connect/host-run-log.d.ts +16 -0
- package/dist-lib/lib/connect/host-run-log.js +74 -0
- package/dist-lib/lib/connect/served.d.ts +7 -0
- package/dist-lib/lib/connect/served.js +45 -0
- package/dist-lib/lib/connect.d.ts +20 -11
- package/dist-lib/lib/connect.js +178 -415
- package/dist-lib/lib/context-window.d.ts +13 -5
- package/dist-lib/lib/context-window.js +19 -6
- package/dist-lib/lib/contract/agent.d.ts +25 -4
- package/dist-lib/lib/contract/completion.d.ts +82 -32
- package/dist-lib/lib/contract/drive.d.ts +130 -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 +17 -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 +48 -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/asks.d.ts +25 -0
- package/dist-lib/lib/helpers/goal-check/asks.js +52 -0
- package/dist-lib/lib/helpers/goal-check/checks.d.ts +8 -0
- package/dist-lib/lib/helpers/goal-check/checks.js +92 -0
- package/dist-lib/lib/helpers/goal-check/commands.d.ts +7 -0
- package/dist-lib/lib/helpers/goal-check/commands.js +130 -0
- package/dist-lib/lib/helpers/goal-check/paths.d.ts +5 -0
- package/dist-lib/lib/helpers/goal-check/paths.js +44 -0
- package/dist-lib/lib/helpers/goal-check/shell.d.ts +9 -0
- package/dist-lib/lib/helpers/goal-check/shell.js +96 -0
- package/dist-lib/lib/helpers/goal-check.d.ts +36 -0
- package/dist-lib/lib/helpers/goal-check.js +35 -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/recent-map.d.ts +7 -0
- package/dist-lib/lib/helpers/recent-map.js +23 -0
- 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/helpers/tool-call-markup/emit.d.ts +6 -0
- package/dist-lib/lib/helpers/tool-call-markup/emit.js +15 -0
- package/dist-lib/lib/helpers/tool-call-markup/recover.d.ts +22 -0
- package/dist-lib/lib/helpers/tool-call-markup/recover.js +130 -0
- package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.d.ts +3 -0
- package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.js +56 -0
- package/dist-lib/lib/helpers/tool-call-markup/strip.d.ts +4 -0
- package/dist-lib/lib/helpers/tool-call-markup/strip.js +149 -0
- package/dist-lib/lib/helpers/tool-call-markup.d.ts +19 -24
- package/dist-lib/lib/helpers/tool-call-markup.js +17 -343
- 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 +15 -16
- package/dist-lib/lib/machine/completion/actions/completion.js +164 -107
- package/dist-lib/lib/machine/completion/actions/goal.d.ts +10 -0
- package/dist-lib/lib/machine/completion/actions/goal.js +93 -0
- package/dist-lib/lib/machine/completion/actions/prepare.js +3 -2
- package/dist-lib/lib/machine/completion/actions/reject-tool.d.ts +16 -0
- package/dist-lib/lib/machine/completion/actions/reject-tool.js +147 -0
- package/dist-lib/lib/machine/completion/actions/retry-round.d.ts +6 -0
- package/dist-lib/lib/machine/completion/actions/retry-round.js +50 -0
- package/dist-lib/lib/machine/completion/actions/rounds.d.ts +5 -0
- package/dist-lib/lib/machine/completion/actions/rounds.js +31 -0
- package/dist-lib/lib/machine/completion/actions/tools.d.ts +1 -16
- package/dist-lib/lib/machine/completion/actions/tools.js +111 -140
- 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 +18 -9
- package/dist-lib/lib/machine/completion/implementations.js +64 -16
- package/dist-lib/lib/machine/completion/machine.d.ts +38 -9
- package/dist-lib/lib/machine/completion/machine.js +58 -9
- package/dist-lib/lib/machine/completion/metrics.d.ts +25 -0
- package/dist-lib/lib/machine/completion/metrics.js +68 -0
- package/dist-lib/lib/machine/completion/nudges.d.ts +5 -0
- package/dist-lib/lib/machine/completion/nudges.js +33 -0
- package/dist-lib/lib/machine/completion/rules.d.ts +19 -27
- package/dist-lib/lib/machine/completion/rules.js +48 -79
- package/dist-lib/lib/machine/completion/splice.d.ts +9 -0
- package/dist-lib/lib/machine/completion/splice.js +19 -0
- package/dist-lib/lib/machine/completion/types.d.ts +81 -14
- package/dist-lib/lib/machine/index.d.ts +50 -11
- package/dist-lib/lib/machine/index.js +12 -2
- 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 +17 -6
- package/dist-lib/lib/residency/completion-runtime.js +91 -37
- package/dist-lib/lib/residency/index.d.ts +59 -6
- package/dist-lib/lib/residency/index.js +444 -42
- 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/redact.js +7 -7
- 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/completion.d.ts +7 -0
- package/dist-lib/lib/serve/completion.js +553 -0
- package/dist-lib/lib/serve/downloads.d.ts +4 -0
- package/dist-lib/lib/serve/downloads.js +79 -0
- package/dist-lib/lib/serve/models.d.ts +5 -0
- package/dist-lib/lib/serve/models.js +120 -0
- package/dist-lib/lib/serve/noop.d.ts +1 -0
- package/dist-lib/lib/serve/noop.js +1 -0
- package/dist-lib/lib/serve/requests.d.ts +147 -0
- package/dist-lib/lib/serve/requests.js +1 -0
- package/dist-lib/lib/serve/rounds.d.ts +11 -0
- package/dist-lib/lib/serve/rounds.js +67 -0
- package/dist-lib/lib/serve/run-log-start.d.ts +38 -0
- package/dist-lib/lib/serve/run-log-start.js +254 -0
- package/dist-lib/lib/serve/skills.d.ts +32 -0
- package/dist-lib/lib/serve/skills.js +46 -0
- package/dist-lib/lib/serve.d.ts +5 -1
- package/dist-lib/lib/serve.js +51 -916
- 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 +7 -3
- package/dist-lib/lib/skills-host/index.js +47 -22
- 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 +5 -25
- 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 +2 -40
- 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 +4 -15
- package/dist-lib/lib/tools/fs/scope.js +5 -2
- package/dist-lib/lib/tools/fs/search.d.ts +25 -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 +14 -5
- 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 +17 -3
- 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 +55 -0
- package/dist-lib/lib/tools/pdf/request.d.ts +3 -8
- package/dist-lib/lib/tools/pdf/request.js +4 -4
- package/dist-lib/lib/tools/pdf.d.ts +0 -1
- package/dist-lib/lib/tools/pdf.js +56 -13
- package/dist-lib/lib/tools/skill.js +23 -11
- package/dist-lib/lib/tools/skills/bundled-dir.d.ts +8 -1
- package/dist-lib/lib/tools/skills/bundled-dir.js +42 -36
- package/dist-lib/lib/tools/skills/bundled-hash.d.ts +1 -0
- package/dist-lib/lib/tools/skills/bundled-hash.js +4 -1
- package/dist-lib/lib/tools/skills/catalog-loader.d.ts +12 -0
- package/dist-lib/lib/tools/skills/catalog-loader.js +173 -0
- package/dist-lib/lib/tools/skills/catalog.d.ts +7 -8
- package/dist-lib/lib/tools/skills/catalog.js +1 -158
- 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/index.d.ts +1 -0
- package/dist-lib/lib/tools/skills/index.js +1 -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/skills/skill-tree.d.ts +5 -0
- package/dist-lib/lib/tools/skills/skill-tree.js +54 -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/download.d.ts +10 -0
- package/dist-lib/lib/wire/download.js +35 -0
- package/dist-lib/lib/wire/event.d.ts +41 -0
- package/dist-lib/lib/wire/event.js +306 -0
- package/dist-lib/lib/wire/fields.d.ts +3 -0
- package/dist-lib/lib/wire/fields.js +12 -0
- package/dist-lib/lib/wire/knowledge.d.ts +9 -0
- package/dist-lib/lib/wire/knowledge.js +68 -0
- package/dist-lib/lib/wire/round.d.ts +14 -0
- package/dist-lib/lib/wire/round.js +45 -0
- package/dist-lib/lib/wire/vectors.d.ts +6 -0
- package/dist-lib/lib/wire/vectors.js +33 -0
- package/dist-lib/lib/wire.d.ts +28 -64
- package/dist-lib/lib/wire.js +24 -417
- 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/coverage.d.ts +3 -0
- package/dist-lib/plugins/ocr/coverage.js +67 -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 +25 -0
- package/dist-lib/plugins/ocr/ocr-runtime.js +103 -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 +94 -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 +485 -209
- package/dist-lib/spec/hyperschema/index.js +485 -209
- package/dist-lib/spec/hyperschema/schema.json +290 -85
- package/dist-lib/spec/hyperschema/types.d.ts +42 -5
- package/package.json +265 -65
- 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,24 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContextWindow } from '../../context-window.js';
|
|
2
|
+
import { Agent } from '../../agent/index.js';
|
|
3
|
+
import { HarnessError } from '../../errors.js';
|
|
2
4
|
import { bufferBurst } from '../../helpers/buffer-burst.js';
|
|
3
5
|
import { endsTurn, stopAtControlToken } from '../../helpers/control-tokens.js';
|
|
4
6
|
import { createMarkupStreamFilter } from '../../helpers/markup-stream-filter.js';
|
|
5
7
|
import { AbortedError, raceAbort } from '../../helpers/race-abort.js';
|
|
6
8
|
import { raceTimeout } from '../../helpers/race-timeout.js';
|
|
7
9
|
import { withoutRepeatedReply } from '../../helpers/repeated-reply.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { ToolCallMarkup } from '../../helpers/tool-call-markup.js';
|
|
11
|
+
import { splitThinking, tapThinking } from '../../helpers/thinking.js';
|
|
12
|
+
import { errorMessage } from '../../guards.js';
|
|
13
|
+
import { HarnessLog } from '../../log.js';
|
|
14
|
+
import { isContextOverflowError, isForcedCallFault, isKvCacheSaveFault, isSdkModelWedgedError, isToolGrammarFault } from '../../models/sdk-faults.js';
|
|
12
15
|
import { copy } from '../../helpers/copy.js';
|
|
13
16
|
import { stableStringify } from '../../helpers/stable-stringify.js';
|
|
14
17
|
import { detachJson } from '../../helpers/detach-json.js';
|
|
15
|
-
import { materializeCompletionHistory } from '../tool-turns.js';
|
|
18
|
+
import { isSkillMentionNudge, materializeCompletionHistory } from '../tool-turns.js';
|
|
16
19
|
import { completionParams } from '../../helpers/completion-params.js';
|
|
20
|
+
import { requestPromptPrefix } from '../prompt-prefix.js';
|
|
21
|
+
import { renderedTools } from '../sdk-tool.js';
|
|
17
22
|
import { isFailureResultReference } from '../../helpers/failure-result.js';
|
|
23
|
+
import { GoalCheck } from '../../helpers/goal-check.js';
|
|
18
24
|
import { Fold } from '../../fold/index.js';
|
|
25
|
+
import { CompletionMachine } from '../../machine/index.js';
|
|
19
26
|
import { modelTurns } from './turns.js';
|
|
20
27
|
const BURST_WINDOW_MS = 100;
|
|
21
|
-
export const CONTEXT_OVERFLOW_MESSAGE = 'This message is too large for the model context window.';
|
|
22
28
|
const noop = () => { };
|
|
23
29
|
function unprovenReplay(state, final) {
|
|
24
30
|
if (!state.unproven)
|
|
@@ -26,7 +32,10 @@ function unprovenReplay(state, final) {
|
|
|
26
32
|
if (state.stopToken) {
|
|
27
33
|
return endsTurn(state.stopToken) ? state.unproven : null;
|
|
28
34
|
}
|
|
29
|
-
if (
|
|
35
|
+
if (state.runaway ||
|
|
36
|
+
state.cut !== null ||
|
|
37
|
+
final.stopReason === 'length' ||
|
|
38
|
+
final.stopReason === 'cancelled') {
|
|
30
39
|
return null;
|
|
31
40
|
}
|
|
32
41
|
return state.unproven;
|
|
@@ -42,15 +51,39 @@ function cancelOnce(sdk, requestId) {
|
|
|
42
51
|
};
|
|
43
52
|
return Object.assign(cancel, { flush: () => pending });
|
|
44
53
|
}
|
|
45
|
-
async function*
|
|
54
|
+
async function* contentDeltas(events) {
|
|
55
|
+
for await (const event of events) {
|
|
56
|
+
if (event.type === 'contentDelta') {
|
|
57
|
+
yield event.text;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function* countGenerated(tokens, state) {
|
|
62
|
+
for await (const token of tokens) {
|
|
63
|
+
state.live.rawChars += token.length;
|
|
64
|
+
yield token;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function* runRoundTokens({ result, state, cancelThisRound, unsettled, signal, startInThink, knownTools }) {
|
|
46
68
|
signal?.addEventListener('abort', cancelThisRound, { once: true });
|
|
47
|
-
|
|
69
|
+
armCut(state, cancelThisRound);
|
|
70
|
+
const closeCalls = watchToolCalls(result.toolCallStream, state, cancelThisRound);
|
|
71
|
+
const tokens = stopAtControlToken(contentDeltas(result.events), (token) => {
|
|
48
72
|
state.stopToken = token;
|
|
49
73
|
});
|
|
74
|
+
const counted = tapThinking(tokens, { startInThink }, () => {
|
|
75
|
+
state.live.reasoningDeltas = ++state.reasoningDeltas;
|
|
76
|
+
});
|
|
50
77
|
let tokenEvents = 0;
|
|
51
|
-
const events = splitThinking(bufferBurst(
|
|
52
|
-
|
|
53
|
-
|
|
78
|
+
const events = splitThinking(bufferBurst(countGenerated(counted, state), BURST_WINDOW_MS), {
|
|
79
|
+
startInThink
|
|
80
|
+
});
|
|
81
|
+
const thinkingFilter = createMarkupStreamFilter({
|
|
82
|
+
onToolCall: watchMarkupCalls(state, knownTools, cancelThisRound)
|
|
83
|
+
});
|
|
84
|
+
const contentFilter = createMarkupStreamFilter({
|
|
85
|
+
onToolCall: watchMarkupCalls(state, knownTools, cancelThisRound)
|
|
86
|
+
});
|
|
54
87
|
try {
|
|
55
88
|
tokenEvents = yield* processRoundTokenEvents({
|
|
56
89
|
events,
|
|
@@ -60,7 +93,7 @@ async function* runRoundTokens({ result, state, cancelThisRound, signal, startIn
|
|
|
60
93
|
thinkingFilter,
|
|
61
94
|
contentFilter
|
|
62
95
|
});
|
|
63
|
-
|
|
96
|
+
HarnessLog.info('stream ended', { events: tokenEvents, stopToken: state.stopToken });
|
|
64
97
|
if (state.stopToken) {
|
|
65
98
|
cancelThisRound();
|
|
66
99
|
}
|
|
@@ -70,22 +103,97 @@ async function* runRoundTokens({ result, state, cancelThisRound, signal, startIn
|
|
|
70
103
|
cancelThisRound();
|
|
71
104
|
}
|
|
72
105
|
signal?.removeEventListener('abort', cancelThisRound);
|
|
73
|
-
|
|
106
|
+
state.live.cut = undefined;
|
|
107
|
+
closeCalls();
|
|
108
|
+
const closed = events.return(null);
|
|
109
|
+
if (signal?.aborted) {
|
|
110
|
+
unsettled.push(closed.catch(noop));
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
await closed;
|
|
114
|
+
}
|
|
74
115
|
}
|
|
75
116
|
}
|
|
117
|
+
function armCut(state, cancelThisRound) {
|
|
118
|
+
if (state.live.kind !== 'streaming')
|
|
119
|
+
return;
|
|
120
|
+
state.live.cut = (note) => {
|
|
121
|
+
if (state.cut !== null)
|
|
122
|
+
return;
|
|
123
|
+
state.cut = note;
|
|
124
|
+
HarnessLog.info('round cut by the host', { round: state.live.round });
|
|
125
|
+
cancelThisRound();
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function tripsCap(state, seen, call) {
|
|
129
|
+
state.calls.push(call);
|
|
130
|
+
return tripsCount(seen, stableStringify([call.name, call.arguments]), state.calls.length);
|
|
131
|
+
}
|
|
132
|
+
function tripsCount(seen, key, total) {
|
|
133
|
+
const count = (seen.get(key) ?? 0) + 1;
|
|
134
|
+
seen.set(key, count);
|
|
135
|
+
return count >= CompletionMachine.MAX_ROUND_REPEATS || total >= CompletionMachine.MAX_ROUND_CALLS;
|
|
136
|
+
}
|
|
137
|
+
function watchMarkupCalls(state, knownTools, cancelThisRound) {
|
|
138
|
+
const seen = new Map();
|
|
139
|
+
let blocks = 0;
|
|
140
|
+
return (body) => {
|
|
141
|
+
if (state.runaway)
|
|
142
|
+
return;
|
|
143
|
+
blocks++;
|
|
144
|
+
const parsed = ToolCallMarkup.recoverMarkupToolCalls(body, knownTools).map((call) => [
|
|
145
|
+
call.name,
|
|
146
|
+
call.arguments
|
|
147
|
+
]);
|
|
148
|
+
const key = parsed.length ? stableStringify(parsed) : body.trim();
|
|
149
|
+
if (tripsCount(seen, key, blocks)) {
|
|
150
|
+
state.runaway = true;
|
|
151
|
+
HarnessLog.info('round stopped on its tool markup', { blocks });
|
|
152
|
+
cancelThisRound();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function watchToolCalls(stream, state, cancelThisRound) {
|
|
157
|
+
if (!stream)
|
|
158
|
+
return noop;
|
|
159
|
+
const calls = stream[Symbol.asyncIterator]();
|
|
160
|
+
const seen = new Map();
|
|
161
|
+
let closed = false;
|
|
162
|
+
const close = () => {
|
|
163
|
+
if (closed)
|
|
164
|
+
return;
|
|
165
|
+
closed = true;
|
|
166
|
+
Promise.resolve(calls.return?.()).catch(noop);
|
|
167
|
+
};
|
|
168
|
+
const drain = async () => {
|
|
169
|
+
let next = await calls.next();
|
|
170
|
+
while (!next.done && !closed) {
|
|
171
|
+
if (tripsCap(state, seen, next.value.call)) {
|
|
172
|
+
state.runaway = true;
|
|
173
|
+
HarnessLog.info('round stopped on its tool calls', { calls: state.calls.length });
|
|
174
|
+
cancelThisRound();
|
|
175
|
+
close();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
next = await calls.next();
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
drain().catch(noop);
|
|
182
|
+
return close;
|
|
183
|
+
}
|
|
76
184
|
async function* processRoundTokenEvents({ events, state, cancelThisRound, signal, thinkingFilter, contentFilter }) {
|
|
77
185
|
let tokenEvents = 0;
|
|
78
186
|
while (true) {
|
|
79
|
-
|
|
187
|
+
if (signal?.aborted) {
|
|
188
|
+
cancelThisRound();
|
|
189
|
+
throw new AbortedError();
|
|
190
|
+
}
|
|
191
|
+
const next = await raceAbort(events.next(), signal);
|
|
80
192
|
if (next.done) {
|
|
81
193
|
state.unproven = next.value;
|
|
82
194
|
yield* flushFilterTails(thinkingFilter, contentFilter);
|
|
83
195
|
break;
|
|
84
196
|
}
|
|
85
|
-
if (signal?.aborted) {
|
|
86
|
-
cancelThisRound();
|
|
87
|
-
throw new AbortedError();
|
|
88
|
-
}
|
|
89
197
|
tokenEvents++;
|
|
90
198
|
if (next.value.type === 'content') {
|
|
91
199
|
state.rawContentText += next.value.text;
|
|
@@ -108,16 +216,36 @@ async function* flushFilterTails(thinkingFilter, contentFilter) {
|
|
|
108
216
|
yield { type: 'content', text: contentTail };
|
|
109
217
|
}
|
|
110
218
|
}
|
|
111
|
-
function
|
|
112
|
-
if (
|
|
219
|
+
export function foldTokens(stats, cacheable) {
|
|
220
|
+
if (cacheable !== false)
|
|
221
|
+
return stats?.cacheTokens;
|
|
222
|
+
if (stats?.promptTokens === undefined)
|
|
113
223
|
return undefined;
|
|
114
|
-
|
|
115
|
-
|
|
224
|
+
return stats.promptTokens + (stats.generatedTokens ?? 0);
|
|
225
|
+
}
|
|
226
|
+
function slotStats(stats, previous) {
|
|
227
|
+
if (!stats)
|
|
116
228
|
return undefined;
|
|
117
|
-
|
|
229
|
+
const { cacheTokens: _summed, promptTokensPerSecond: _scheduler, ...own } = stats;
|
|
230
|
+
const { promptTokens, timeToFirstToken } = stats;
|
|
231
|
+
const rest = promptTokens !== undefined &&
|
|
232
|
+
promptTokens > 0 &&
|
|
233
|
+
timeToFirstToken !== undefined &&
|
|
234
|
+
timeToFirstToken > 0
|
|
235
|
+
? { ...own, promptTokensPerSecond: (promptTokens / timeToFirstToken) * 1000 }
|
|
236
|
+
: own;
|
|
237
|
+
if (previous === undefined || promptTokens === undefined) {
|
|
238
|
+
return rest;
|
|
239
|
+
}
|
|
240
|
+
return { ...rest, cacheTokens: previous + promptTokens + (stats.generatedTokens ?? 0) };
|
|
118
241
|
}
|
|
119
|
-
function
|
|
120
|
-
|
|
242
|
+
function boundaryStats(final, predict) {
|
|
243
|
+
const stats = copy(final.stats);
|
|
244
|
+
if (final.stopReason !== 'length' || stats?.contextBoundary !== undefined) {
|
|
245
|
+
return stats;
|
|
246
|
+
}
|
|
247
|
+
const capped = predict !== undefined && predict > 0 && (stats?.generatedTokens ?? 0) >= predict;
|
|
248
|
+
return { ...stats, contextBoundary: !capped };
|
|
121
249
|
}
|
|
122
250
|
function roundTokens(stats) {
|
|
123
251
|
if (!stats)
|
|
@@ -143,67 +271,106 @@ function truncatedFinal(final, contentText) {
|
|
|
143
271
|
}
|
|
144
272
|
export async function* runRecoveredRound(sdk, args) {
|
|
145
273
|
const lease = args.acquireRound ? await args.acquireRound(args.signal) : null;
|
|
274
|
+
const unsettled = [];
|
|
146
275
|
try {
|
|
147
276
|
const roundSdk = lease?.sdk ?? sdk;
|
|
148
277
|
if (!roundSdk) {
|
|
149
278
|
throw new Error('A completion round requires an SDK');
|
|
150
279
|
}
|
|
151
280
|
const ctxSize = lease?.ctxSize ?? args.fold?.ctxSize;
|
|
281
|
+
const slotted = (lease?.slots ?? 1) > 1;
|
|
282
|
+
const attempts = { sent: 0, uncached: false, overflows: 0, unsettled };
|
|
152
283
|
const round = yield* runRecoveredRoundWith({
|
|
153
284
|
sdk: roundSdk,
|
|
154
|
-
args,
|
|
285
|
+
args: lease?.canThink === undefined ? args : { ...args, canThink: lease.canThink },
|
|
155
286
|
modelId: lease?.modelId ?? args.modelId,
|
|
156
287
|
ctxSize,
|
|
157
|
-
attempts
|
|
288
|
+
attempts
|
|
158
289
|
});
|
|
159
|
-
|
|
160
|
-
|
|
290
|
+
const final = slotted
|
|
291
|
+
? {
|
|
292
|
+
...round.final,
|
|
293
|
+
stats: slotStats(round.final.stats, round.cacheable !== false && args.cacheKey
|
|
294
|
+
? (Fold.reading(args.cacheKey)?.cacheTokens ?? 0)
|
|
295
|
+
: undefined)
|
|
296
|
+
}
|
|
297
|
+
: round.final;
|
|
298
|
+
if (args.fold?.cacheKey) {
|
|
299
|
+
Fold.observe(args.fold.cacheKey, {
|
|
300
|
+
cacheTokens: foldTokens(final.stats, round.cacheable),
|
|
301
|
+
ctxSize
|
|
302
|
+
});
|
|
161
303
|
}
|
|
162
|
-
|
|
304
|
+
const overflows = attempts.overflows ? { overflows: attempts.overflows } : {};
|
|
305
|
+
return { ...round, final, ctxSize: lease?.ctxSize, ...overflows };
|
|
163
306
|
}
|
|
164
307
|
finally {
|
|
165
|
-
|
|
166
|
-
|
|
308
|
+
if (lease && unsettled.length) {
|
|
309
|
+
void Promise.all(unsettled).then(() => releaseLease(lease));
|
|
167
310
|
}
|
|
168
|
-
|
|
169
|
-
|
|
311
|
+
else if (lease) {
|
|
312
|
+
releaseLease(lease);
|
|
170
313
|
}
|
|
171
314
|
}
|
|
172
315
|
}
|
|
316
|
+
function releaseLease(lease) {
|
|
317
|
+
try {
|
|
318
|
+
lease.release();
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
HarnessLog.info('completion round lease release failed', { error: errorMessage(error) });
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
export async function recordWholeRound(args) {
|
|
325
|
+
const history = materializeCompletionHistory(args.history, args.failureResults);
|
|
326
|
+
const origins = historyOrigins(args.history, history);
|
|
327
|
+
const params = inferenceParams({ args, modelId: args.modelId, history });
|
|
328
|
+
await args.recordRequest?.({ round: args.round, attempt: 0, droppedTurns: 0, params }, failureTurns(args, origins, history));
|
|
329
|
+
if (args.signal?.aborted) {
|
|
330
|
+
throw new AbortedError();
|
|
331
|
+
}
|
|
332
|
+
return params;
|
|
333
|
+
}
|
|
173
334
|
async function* runRecoveredRoundWith(send) {
|
|
174
335
|
const { args } = send;
|
|
175
336
|
let history = materializeCompletionHistory(args.history, args.failureResults);
|
|
176
337
|
const origins = historyOrigins(args.history, history);
|
|
177
|
-
const reading = args.
|
|
178
|
-
|
|
179
|
-
|
|
338
|
+
const reading = args.fold?.reading ??
|
|
339
|
+
(args.round === 0 && args.fold?.cacheKey ? Fold.reading(args.fold.cacheKey) : undefined);
|
|
340
|
+
const fold = { chat: false, rounds: false };
|
|
341
|
+
if (reading && Fold.due({ ...reading, ctxSize: reading.ctxSize ?? send.ctxSize })) {
|
|
342
|
+
history = (yield* foldHistory(send, history, fold)) ?? history;
|
|
180
343
|
}
|
|
181
|
-
const fold = { tried: false };
|
|
182
344
|
while (true) {
|
|
183
345
|
const outcome = yield* runLadder({ send, history, origins, fold });
|
|
184
346
|
if ('round' in outcome) {
|
|
185
347
|
return outcome.round;
|
|
186
348
|
}
|
|
187
349
|
if (!('folded' in outcome)) {
|
|
188
|
-
throw
|
|
350
|
+
throw new HarnessError('CONTEXT_WINDOW_EXCEEDED', [], { cause: outcome.overflow });
|
|
189
351
|
}
|
|
190
352
|
history = outcome.folded;
|
|
191
353
|
}
|
|
192
354
|
}
|
|
193
355
|
async function* runLadder({ send, history, origins, fold }) {
|
|
194
356
|
let lastOverflow = null;
|
|
195
|
-
|
|
357
|
+
const candidates = ContextWindow.contextCandidates(history, ...harnessTurns(send.args, history));
|
|
358
|
+
for (const candidate of candidates) {
|
|
196
359
|
const outcome = yield* runCandidateAttempts({ ...send, candidate, history, origins });
|
|
197
360
|
if ('round' in outcome) {
|
|
198
|
-
|
|
361
|
+
const cacheable = !send.attempts.uncached;
|
|
362
|
+
return { round: recoveredRound({ candidate, attempt: outcome.round, origins, cacheable }) };
|
|
199
363
|
}
|
|
200
364
|
lastOverflow = outcome.overflow;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const folded = yield* foldHistory(send, history);
|
|
365
|
+
send.attempts.overflows++;
|
|
366
|
+
if (candidate.history === history) {
|
|
367
|
+
const folded = yield* foldHistory(send, history, fold);
|
|
204
368
|
if (folded) {
|
|
205
369
|
return { folded };
|
|
206
370
|
}
|
|
371
|
+
if (candidates.length > 1) {
|
|
372
|
+
await dropShrunkKey(send);
|
|
373
|
+
}
|
|
207
374
|
}
|
|
208
375
|
}
|
|
209
376
|
if (!lastOverflow) {
|
|
@@ -211,7 +378,64 @@ async function* runLadder({ send, history, origins, fold }) {
|
|
|
211
378
|
}
|
|
212
379
|
return { overflow: lastOverflow };
|
|
213
380
|
}
|
|
214
|
-
async function* foldHistory(send, history) {
|
|
381
|
+
async function* foldHistory(send, history, tries) {
|
|
382
|
+
if (!tries.chat) {
|
|
383
|
+
tries.chat = true;
|
|
384
|
+
const folded = yield* foldChat(send, history);
|
|
385
|
+
if (folded) {
|
|
386
|
+
return folded;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
if (tries.rounds) {
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
tries.rounds = true;
|
|
393
|
+
return foldRounds(send, history);
|
|
394
|
+
}
|
|
395
|
+
function harnessTurns(args, history) {
|
|
396
|
+
const mentions = history.flatMap((message) => message.role === 'user' && isSkillMentionNudge(message.content) ? [message.content] : []);
|
|
397
|
+
const wrapUp = args.wrapUpNudge === undefined ? [] : [args.wrapUpNudge];
|
|
398
|
+
return [args.continuationNudge, args.deliveredNudge, ...wrapUp, ...goalTurns(args), ...mentions];
|
|
399
|
+
}
|
|
400
|
+
function goalTurns(args) {
|
|
401
|
+
const goal = args.goalNudge === undefined ? [] : [args.goalNudge];
|
|
402
|
+
return [...goal, GoalCheck.GOAL_CHECKS_ASK, GoalCheck.GOAL_PROOF_ASK, GoalCheck.GOAL_REVIEW_ASK];
|
|
403
|
+
}
|
|
404
|
+
async function foldRounds(send, history) {
|
|
405
|
+
const { sdk, args, ctxSize } = send;
|
|
406
|
+
const spec = args.fold;
|
|
407
|
+
const nudges = harnessTurns(args, history);
|
|
408
|
+
const goals = goalTurns(args);
|
|
409
|
+
if (!spec || !Fold.roundBoundary(history, { nudges, goals, keeps: keepsLoad })?.foldedRounds) {
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
const instructions = await spec.instructions?.(history);
|
|
413
|
+
const result = await new Fold(summarizer(send)).rounds(history, {
|
|
414
|
+
ctxSize,
|
|
415
|
+
instructions,
|
|
416
|
+
nudges,
|
|
417
|
+
goals,
|
|
418
|
+
keeps: keepsLoad
|
|
419
|
+
});
|
|
420
|
+
if (args.signal?.aborted) {
|
|
421
|
+
throw new AbortedError();
|
|
422
|
+
}
|
|
423
|
+
if (!result.folded) {
|
|
424
|
+
HarnessLog.info('rounds fold refused', { round: args.round, reason: result.reason });
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
if (args.cacheKey) {
|
|
428
|
+
await dropFoldedKey(sdk, args.cacheKey);
|
|
429
|
+
}
|
|
430
|
+
HarnessLog.info('folded rounds', { round: args.round, foldedRounds: result.foldedRounds });
|
|
431
|
+
return result.history;
|
|
432
|
+
}
|
|
433
|
+
function keepsLoad(message) {
|
|
434
|
+
return (message.role === 'tool' &&
|
|
435
|
+
(message.content.startsWith(ContextWindow.TOOL_SEARCH_RESULT) ||
|
|
436
|
+
message.content.startsWith(`[Tool: ${Agent.SKILL_TOOL_NAME} (`)));
|
|
437
|
+
}
|
|
438
|
+
async function* foldChat(send, history) {
|
|
215
439
|
const { sdk, args, ctxSize } = send;
|
|
216
440
|
const spec = args.fold;
|
|
217
441
|
const widest = spec && Fold.boundary(spec.messages);
|
|
@@ -231,7 +455,7 @@ async function* foldHistory(send, history) {
|
|
|
231
455
|
}
|
|
232
456
|
const result = step.value;
|
|
233
457
|
if (!result.folded) {
|
|
234
|
-
|
|
458
|
+
HarnessLog.info('fold refused', { round: args.round, reason: result.reason });
|
|
235
459
|
return null;
|
|
236
460
|
}
|
|
237
461
|
const replaced = modelTurns(spec.messages.slice(0, result.end), spec.nudge).length;
|
|
@@ -243,7 +467,7 @@ async function* foldHistory(send, history) {
|
|
|
243
467
|
if (args.cacheKey) {
|
|
244
468
|
await dropFoldedKey(sdk, args.cacheKey);
|
|
245
469
|
}
|
|
246
|
-
|
|
470
|
+
HarnessLog.info('folded', { round: args.round, foldedTurns: result.foldedTurns });
|
|
247
471
|
yield {
|
|
248
472
|
type: 'fold',
|
|
249
473
|
phase: 'done',
|
|
@@ -253,16 +477,21 @@ async function* foldHistory(send, history) {
|
|
|
253
477
|
};
|
|
254
478
|
return folded;
|
|
255
479
|
}
|
|
480
|
+
async function dropShrunkKey({ sdk, args, attempts }) {
|
|
481
|
+
if (args.cacheKey && !attempts.uncached) {
|
|
482
|
+
await dropFoldedKey(sdk, args.cacheKey);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
256
485
|
async function dropFoldedKey(sdk, cacheKey) {
|
|
257
486
|
Fold.forget(cacheKey);
|
|
258
487
|
try {
|
|
259
488
|
const deleted = await sdk.deleteCache?.({ kvCacheKey: cacheKey });
|
|
260
489
|
if (deleted && !deleted.success) {
|
|
261
|
-
|
|
490
|
+
HarnessLog.info('fold key delete did not succeed');
|
|
262
491
|
}
|
|
263
492
|
}
|
|
264
493
|
catch (error) {
|
|
265
|
-
|
|
494
|
+
HarnessLog.info('fold key delete failed', { error: errorMessage(error) });
|
|
266
495
|
}
|
|
267
496
|
}
|
|
268
497
|
function renderedAt(history, spec, end) {
|
|
@@ -270,51 +499,71 @@ function renderedAt(history, spec, end) {
|
|
|
270
499
|
const matches = (at) => rendered.every((turn, index) => history[at + index]?.role === turn.role && history[at + index]?.content === turn.content);
|
|
271
500
|
return [0, 1].find(matches) ?? null;
|
|
272
501
|
}
|
|
273
|
-
function summarizer(
|
|
502
|
+
function summarizer(send) {
|
|
274
503
|
return async (prompt) => {
|
|
275
|
-
const params = completionParams({
|
|
276
|
-
modelId,
|
|
277
|
-
history: [{ role: 'user', content: prompt }],
|
|
278
|
-
generationParams: { reasoning_budget: 0 }
|
|
279
|
-
});
|
|
280
|
-
await args.recordRequest?.({ round: args.round, attempt: attempts.sent++, droppedTurns: 0, params }, []);
|
|
281
|
-
if (args.signal?.aborted) {
|
|
282
|
-
return { text: null, overflowed: false };
|
|
283
|
-
}
|
|
284
|
-
const result = withoutRepeatedReply(sdk.completion(params));
|
|
285
|
-
result.final.catch(noop);
|
|
286
|
-
const cancel = cancelOnce(sdk, result.requestId);
|
|
287
|
-
args.signal?.addEventListener('abort', cancel, { once: true });
|
|
288
|
-
let text = '';
|
|
289
504
|
try {
|
|
290
|
-
|
|
291
|
-
if (event.type === 'content') {
|
|
292
|
-
text += event.text;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
await raceAbort(result.final, args.signal);
|
|
296
|
-
return { text: args.signal?.aborted ? null : text, overflowed: false };
|
|
505
|
+
return await summarizeOnce(send, prompt);
|
|
297
506
|
}
|
|
298
507
|
catch (error) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
508
|
+
if (!isKvCacheSaveFault(error)) {
|
|
509
|
+
return refusedSummary(error);
|
|
510
|
+
}
|
|
511
|
+
HarnessLog.info('kv cache save failed, retrying the fold summary', {
|
|
512
|
+
round: send.args.round,
|
|
513
|
+
error: errorMessage(error)
|
|
514
|
+
});
|
|
515
|
+
return summarizeOnce(send, prompt).catch(refusedSummary);
|
|
305
516
|
}
|
|
306
517
|
};
|
|
307
518
|
}
|
|
519
|
+
async function summarizeOnce(send, prompt) {
|
|
520
|
+
const { sdk, args, modelId, attempts } = send;
|
|
521
|
+
const params = completionParams({
|
|
522
|
+
modelId,
|
|
523
|
+
history: [{ role: 'user', content: prompt }],
|
|
524
|
+
generationParams: { reasoning_budget: 0 }
|
|
525
|
+
});
|
|
526
|
+
await args.recordRequest?.({ round: args.round, attempt: attempts.sent++, droppedTurns: 0, params }, []);
|
|
527
|
+
if (args.signal?.aborted) {
|
|
528
|
+
return { text: null, overflowed: false };
|
|
529
|
+
}
|
|
530
|
+
const result = withoutRepeatedReply(sdk.completion(params));
|
|
531
|
+
result.final.catch(noop);
|
|
532
|
+
const cancel = cancelOnce(sdk, result.requestId);
|
|
533
|
+
args.signal?.addEventListener('abort', cancel, { once: true });
|
|
534
|
+
let text = '';
|
|
535
|
+
try {
|
|
536
|
+
for await (const event of splitThinking(stopAtControlToken(contentDeltas(result.events), cancel))) {
|
|
537
|
+
if (event.type === 'content') {
|
|
538
|
+
text += event.text;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
await raceAbort(result.final, args.signal);
|
|
542
|
+
return { text: args.signal?.aborted ? null : text, overflowed: false };
|
|
543
|
+
}
|
|
544
|
+
catch (error) {
|
|
545
|
+
cancel();
|
|
546
|
+
throw error;
|
|
547
|
+
}
|
|
548
|
+
finally {
|
|
549
|
+
args.signal?.removeEventListener('abort', cancel);
|
|
550
|
+
await raceTimeout(cancel.flush(), { ms: TRUNCATED_FINAL_MS, fallback: undefined });
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function refusedSummary(error) {
|
|
554
|
+
return { text: null, overflowed: isContextOverflowError(error) };
|
|
555
|
+
}
|
|
308
556
|
async function* runCandidateAttempts(input) {
|
|
309
557
|
const { sdk, args, modelId, candidate, history, origins, attempts } = input;
|
|
310
|
-
let attemptArgs = args;
|
|
558
|
+
let attemptArgs = attempts.uncached ? { ...args, cacheKey: undefined } : args;
|
|
311
559
|
while (true) {
|
|
312
560
|
if (args.signal?.aborted)
|
|
313
561
|
throw new AbortedError();
|
|
314
562
|
const progress = {
|
|
315
563
|
cancel: cancelOnce(sdk, undefined),
|
|
316
564
|
emitted: false,
|
|
317
|
-
attempt: attempts.sent
|
|
565
|
+
attempt: attempts.sent++,
|
|
566
|
+
unsettled: attempts.unsettled
|
|
318
567
|
};
|
|
319
568
|
try {
|
|
320
569
|
const round = yield* runCandidate({
|
|
@@ -323,7 +572,6 @@ async function* runCandidateAttempts(input) {
|
|
|
323
572
|
modelId,
|
|
324
573
|
candidate,
|
|
325
574
|
progress,
|
|
326
|
-
baseHistory: history,
|
|
327
575
|
origins
|
|
328
576
|
});
|
|
329
577
|
return { round };
|
|
@@ -337,24 +585,36 @@ async function* runCandidateAttempts(input) {
|
|
|
337
585
|
}
|
|
338
586
|
const grammarOff = withoutToolGrammar(attemptArgs, err);
|
|
339
587
|
if (grammarOff) {
|
|
340
|
-
|
|
588
|
+
HarnessLog.info('tool grammar fault, retrying the round without it', { round: args.round });
|
|
341
589
|
yield* resetShownRound(args, progress);
|
|
342
590
|
attemptArgs = grammarOff;
|
|
343
591
|
continue;
|
|
344
592
|
}
|
|
345
593
|
const unforced = withoutForcedCall(attemptArgs, err);
|
|
346
594
|
if (unforced) {
|
|
347
|
-
|
|
595
|
+
HarnessLog.info('forced tool call refused, retrying the round without it', {
|
|
596
|
+
round: args.round
|
|
597
|
+
});
|
|
348
598
|
yield* resetShownRound(args, progress);
|
|
349
599
|
attemptArgs = unforced;
|
|
350
600
|
continue;
|
|
351
601
|
}
|
|
602
|
+
if (!attempts.uncached && isKvCacheSaveFault(err)) {
|
|
603
|
+
HarnessLog.info('kv cache save failed, retrying the round uncached', {
|
|
604
|
+
round: args.round,
|
|
605
|
+
error: errorMessage(err)
|
|
606
|
+
});
|
|
607
|
+
yield* resetShownRound(args, progress);
|
|
608
|
+
attempts.uncached = true;
|
|
609
|
+
attemptArgs = { ...attemptArgs, cacheKey: undefined };
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
352
612
|
if (!isContextOverflowError(err)) {
|
|
353
613
|
throw err;
|
|
354
614
|
}
|
|
355
615
|
if (progress.emitted) {
|
|
356
|
-
yield*
|
|
357
|
-
throw
|
|
616
|
+
yield* foldChat(input, history);
|
|
617
|
+
throw new HarnessError('CONTEXT_WINDOW_EXCEEDED', [], { cause: err });
|
|
358
618
|
}
|
|
359
619
|
return { overflow: err };
|
|
360
620
|
}
|
|
@@ -396,16 +656,19 @@ async function flushCandidate(args, progress) {
|
|
|
396
656
|
}
|
|
397
657
|
await raceTimeout(progress.cancel.flush(), { ms: TRUNCATED_FINAL_MS, fallback: undefined });
|
|
398
658
|
}
|
|
399
|
-
function recoveredRound({ candidate, attempt, origins }) {
|
|
659
|
+
function recoveredRound({ candidate, attempt, origins, cacheable }) {
|
|
400
660
|
const replay = unprovenReplay(attempt.state, attempt.final);
|
|
401
661
|
logCandidateFinal(attempt, replay);
|
|
402
662
|
return {
|
|
403
663
|
contentText: attempt.contentText,
|
|
404
664
|
final: attempt.final,
|
|
405
665
|
history: restoreHistory(candidate.history, origins),
|
|
406
|
-
cacheable
|
|
666
|
+
cacheable,
|
|
667
|
+
keyed: attempt.keyed,
|
|
407
668
|
unproven: attempt.state.unproven,
|
|
408
|
-
replay
|
|
669
|
+
replay,
|
|
670
|
+
reasoningDeltas: attempt.state.reasoningDeltas || undefined,
|
|
671
|
+
cut: attempt.state.cut ?? undefined
|
|
409
672
|
};
|
|
410
673
|
}
|
|
411
674
|
function historyOrigins(entries, messages) {
|
|
@@ -421,16 +684,15 @@ function historyOrigins(entries, messages) {
|
|
|
421
684
|
});
|
|
422
685
|
return origins;
|
|
423
686
|
}
|
|
424
|
-
async function* runCandidate({ sdk, args, modelId, candidate, progress,
|
|
425
|
-
const
|
|
426
|
-
const params = inferenceParams({ args, modelId, history: candidate.history, cacheable });
|
|
687
|
+
async function* runCandidate({ sdk, args, modelId, candidate, progress, origins }) {
|
|
688
|
+
const params = inferenceParams({ args, modelId, history: candidate.history });
|
|
427
689
|
if (args.capture) {
|
|
428
690
|
yield inferenceCall({
|
|
429
691
|
args,
|
|
430
|
-
candidate,
|
|
692
|
+
droppedTurns: candidate.droppedTurns,
|
|
431
693
|
modelId,
|
|
432
694
|
params,
|
|
433
|
-
cacheKey:
|
|
695
|
+
cacheKey: args.cacheKey
|
|
434
696
|
});
|
|
435
697
|
}
|
|
436
698
|
await args.recordRequest?.({
|
|
@@ -445,47 +707,65 @@ async function* runCandidate({ sdk, args, modelId, candidate, progress, baseHist
|
|
|
445
707
|
const result = withoutRepeatedReply(sdk.completion(params));
|
|
446
708
|
result.final.catch(noop);
|
|
447
709
|
progress.cancel = cancelOnce(sdk, result.requestId);
|
|
448
|
-
|
|
710
|
+
args.live.rawChars = 0;
|
|
711
|
+
args.live.reasoningDeltas = 0;
|
|
712
|
+
const state = {
|
|
713
|
+
live: args.live,
|
|
714
|
+
stopToken: null,
|
|
715
|
+
calls: [],
|
|
716
|
+
runaway: false,
|
|
717
|
+
cut: null,
|
|
718
|
+
unproven: null,
|
|
719
|
+
rawContentText: '',
|
|
720
|
+
reasoningDeltas: 0
|
|
721
|
+
};
|
|
449
722
|
const contentText = yield* streamCandidateTokens({ result, state, args, progress });
|
|
450
|
-
const final = state.stopToken
|
|
723
|
+
const final = state.stopToken || state.runaway || state.cut !== null
|
|
451
724
|
? await truncatedFinal(result.final, state.rawContentText)
|
|
452
725
|
: await raceAbort(result.final, args.signal);
|
|
453
726
|
const detachedFinal = {
|
|
454
727
|
...final,
|
|
455
|
-
toolCalls: copy(final.toolCalls ?? []),
|
|
728
|
+
toolCalls: copy(state.runaway || state.cut !== null ? state.calls : (final.toolCalls ?? [])),
|
|
456
729
|
toolErrors: copy(final.toolErrors ?? []),
|
|
457
|
-
stats:
|
|
730
|
+
stats: boundaryStats(final, params.generationParams?.predict)
|
|
458
731
|
};
|
|
459
732
|
if (args.capture) {
|
|
460
733
|
yield inferenceSent({ args, candidate, final: detachedFinal });
|
|
461
734
|
}
|
|
462
|
-
return { contentText, final: detachedFinal, state,
|
|
735
|
+
return { contentText, final: detachedFinal, state, keyed: args.cacheKey !== undefined };
|
|
463
736
|
}
|
|
464
|
-
function inferenceParams({ args, modelId, history
|
|
737
|
+
function inferenceParams({ args, modelId, history }) {
|
|
465
738
|
return completionParams({
|
|
466
739
|
modelId,
|
|
467
740
|
history: detachJson(history),
|
|
468
741
|
tools: args.tools ? detachJson(args.tools) : undefined,
|
|
469
|
-
generationParams:
|
|
742
|
+
generationParams: generationParams(args),
|
|
470
743
|
responseFormat: args.responseFormat ? detachJson(args.responseFormat) : undefined,
|
|
471
744
|
toolDialect: args.toolDialect,
|
|
472
|
-
kvCache:
|
|
745
|
+
kvCache: args.cacheKey
|
|
473
746
|
});
|
|
474
747
|
}
|
|
475
|
-
function
|
|
748
|
+
function generationParams(args) {
|
|
749
|
+
const { reasoning_rounds: _rounds, ...host } = args.generationParams
|
|
750
|
+
? detachJson(args.generationParams)
|
|
751
|
+
: {};
|
|
752
|
+
const sent = args.generationParams ? host : undefined;
|
|
753
|
+
return args.tools?.length ? { parallel_tool_calls: true, ...sent } : sent;
|
|
754
|
+
}
|
|
755
|
+
export function inferenceCall({ args, droppedTurns, modelId, params, cacheKey }) {
|
|
476
756
|
return {
|
|
477
757
|
type: 'inference-call',
|
|
478
758
|
call: {
|
|
479
759
|
round: args.round,
|
|
480
|
-
droppedTurns
|
|
760
|
+
droppedTurns,
|
|
481
761
|
modelId,
|
|
482
762
|
messages: params.history,
|
|
483
|
-
tools: params.tools,
|
|
763
|
+
tools: renderedTools(params.tools, params.history),
|
|
484
764
|
generationParams: params.generationParams,
|
|
485
765
|
responseFormat: params.responseFormat,
|
|
486
766
|
toolDialect: params.toolDialect,
|
|
487
767
|
cacheKey,
|
|
488
|
-
promptPrefix:
|
|
768
|
+
promptPrefix: requestPromptPrefix(params.history, params.tools)
|
|
489
769
|
}
|
|
490
770
|
};
|
|
491
771
|
}
|
|
@@ -494,7 +774,6 @@ function inferenceSent({ args, candidate, final }) {
|
|
|
494
774
|
type: 'inference-sent',
|
|
495
775
|
round: args.round,
|
|
496
776
|
droppedTurns: candidate.droppedTurns,
|
|
497
|
-
messages: sentMessages(final.stats),
|
|
498
777
|
tokens: roundTokens(final.stats),
|
|
499
778
|
outcome: 'completed',
|
|
500
779
|
reason: undefined
|
|
@@ -502,13 +781,15 @@ function inferenceSent({ args, candidate, final }) {
|
|
|
502
781
|
}
|
|
503
782
|
async function* streamCandidateTokens({ result, state, args, progress }) {
|
|
504
783
|
let contentText = '';
|
|
505
|
-
const startInThink = args.generationParams?.reasoning_budget
|
|
784
|
+
const startInThink = (args.generationParams?.reasoning_budget ?? 0) !== 0 && args.canThink !== false;
|
|
506
785
|
for await (const event of runRoundTokens({
|
|
507
786
|
result,
|
|
508
787
|
state,
|
|
509
788
|
cancelThisRound: progress.cancel,
|
|
789
|
+
unsettled: progress.unsettled,
|
|
510
790
|
signal: args.signal,
|
|
511
|
-
startInThink
|
|
791
|
+
startInThink,
|
|
792
|
+
knownTools: args.knownTools ?? []
|
|
512
793
|
})) {
|
|
513
794
|
if (event.type === 'content') {
|
|
514
795
|
contentText += event.text;
|
|
@@ -523,25 +804,26 @@ function candidateFailureEvent({ args, candidate, error }) {
|
|
|
523
804
|
type: 'inference-sent',
|
|
524
805
|
round: args.round,
|
|
525
806
|
droppedTurns: candidate.droppedTurns,
|
|
526
|
-
messages: undefined,
|
|
527
807
|
tokens: undefined,
|
|
528
808
|
outcome: isContextOverflowError(error) ? 'overflowed' : 'failed',
|
|
529
809
|
reason: errorMessage(error)
|
|
530
810
|
};
|
|
531
811
|
}
|
|
532
812
|
function logCandidateFinal({ state, final, contentText }, replay) {
|
|
533
|
-
|
|
813
|
+
HarnessLog.debug('final', {
|
|
534
814
|
stopReason: final.stopReason,
|
|
535
815
|
toolCalls: final.toolCalls.length,
|
|
536
816
|
toolErrors: final.toolErrors?.length ?? 0,
|
|
537
817
|
contentChars: contentText.length,
|
|
538
818
|
stopToken: state.stopToken,
|
|
819
|
+
runaway: state.runaway,
|
|
820
|
+
cut: state.cut !== null,
|
|
539
821
|
replay: replay !== null
|
|
540
822
|
});
|
|
541
823
|
}
|
|
542
824
|
function failureTurns(args, origins, sent) {
|
|
543
825
|
return sent.flatMap((message, at) => {
|
|
544
|
-
const source = compactedFrom(message);
|
|
826
|
+
const source = ContextWindow.compactedFrom(message);
|
|
545
827
|
const entry = origins.get(source ?? message)?.entry;
|
|
546
828
|
if (!entry || !isFailureResultReference(entry)) {
|
|
547
829
|
return [];
|
|
@@ -553,7 +835,7 @@ function failureTurns(args, origins, sent) {
|
|
|
553
835
|
}
|
|
554
836
|
function restoreHistory(messages, origins) {
|
|
555
837
|
return messages.map((message) => {
|
|
556
|
-
const source = compactedFrom(message);
|
|
838
|
+
const source = ContextWindow.compactedFrom(message);
|
|
557
839
|
const origin = origins.get(source ?? message);
|
|
558
840
|
if (!origin || stableStringify(source ?? message) !== origin.fingerprint) {
|
|
559
841
|
return message;
|
|
@@ -561,8 +843,3 @@ function restoreHistory(messages, origins) {
|
|
|
561
843
|
return source ? { ...origin.entry, compactedTo: message.content.length } : origin.entry;
|
|
562
844
|
});
|
|
563
845
|
}
|
|
564
|
-
function errorWithCause(message, cause) {
|
|
565
|
-
const error = new Error(message);
|
|
566
|
-
Object.defineProperty(error, 'cause', { value: cause, configurable: true });
|
|
567
|
-
return error;
|
|
568
|
-
}
|