@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
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
const SHELL_OPERATOR = /(&&|\|\||;|\||\n)/;
|
|
2
|
+
const RUNNER = /^(python[\d.]*|bash|sh|node|bun|pytest)$/;
|
|
3
|
+
const CHECKS_HEADING = /^[\s*#_]*checks:?[\s*_]*$/i;
|
|
4
|
+
const CHECK_LINE = /^\s*(?:[-*]|\d+[.)])?\s*`([^`]+)`\s*$/;
|
|
5
|
+
const SPAN = /`([^`\n]+)`/g;
|
|
6
|
+
const FILE_TEST = /^-[sfed]$/;
|
|
7
|
+
const NOT_A_PATH = /^(-\w+|!|!?=+|<|>|\]\]?)$/;
|
|
8
|
+
const COMPARISON = /^(!?=+|-(eq|ne|lt|le|gt|ge))$/;
|
|
9
|
+
const TEST_SCRIPT = /^(tests?|checks?|verify|validate)(?=[_.-]|$)/;
|
|
10
|
+
const PACKAGE_TEST = /^tests?(?=[:_.-]|$)/;
|
|
11
|
+
const PACKAGE_MANAGER = /^(npm|yarn|pnpm|bun)$/;
|
|
12
|
+
const PYTHON = /^python[\d.]*$/;
|
|
13
|
+
const COMPARE = /^(diff|cmp)$/;
|
|
14
|
+
const QUIET = /^(-[a-zA-Z]*q[a-zA-Z]*|--quiet)$/;
|
|
15
|
+
const NEVER_RUNS = /^(cat|ls|head|tail|stat|file|wc|echo|printf|touch|chmod|chown|cp|mv|mkdir|rm|ln|unlink|rmdir|true|\w*sum)$/;
|
|
16
|
+
const INTERPRETER = /^(python[\d.]*|bash|sh|zsh|node|bun|deno|go|ruby|perl|php|lua|Rscript|julia|tsx|ts-node|java)$/;
|
|
17
|
+
const SYNTAX_ONLY = /^((ba|z)?sh -n|node (-c|--check)|(perl|ruby) -c|php -l)$/;
|
|
18
|
+
const SOURCE = /\.(py|js|mjs|cjs|ts|mts|cts|jsx|tsx|sh|bash|zsh|rb|pl|php|lua|r|jl|go|rs|c|h|cc|cpp|cxx|hpp|java)$/i;
|
|
19
|
+
const COMPILER = /^(gcc|g\+\+|cc|c\+\+|clang|clang\+\+|rustc)$/;
|
|
20
|
+
const SYSTEM_BIN = /^\/(usr\/)?s?bin\//;
|
|
21
|
+
const MAKE_DRY_RUN = /^(-n|-q|--dry-run|--just-print|--question)$/;
|
|
22
|
+
const CLEAN = /^(clean|distclean)$/;
|
|
23
|
+
const PATH_BREAK = /[\s'"`(),;:=<>|&[\]{}]+/;
|
|
24
|
+
const WRITE = /(?<![>&\d])>\|?\s*(['"]?)([^\s'";|&<>()]+)\1/g;
|
|
25
|
+
const HEREDOC = /(<<-?\s*(['"]?)(\w+)\2[^\n]*)\n([\s\S]*?\n)?\t*\3(?=\n|$)/g;
|
|
26
|
+
const WRAPPERS = new Map([
|
|
27
|
+
['timeout', /^(-s|-k|--signal|--kill-after)$/],
|
|
28
|
+
['env', /^(-u|-C|--unset|--chdir)$/],
|
|
29
|
+
['nice', /^(-n|--adjustment)$/],
|
|
30
|
+
['stdbuf', /^(-i|-o|-e|--input|--output|--error)$/],
|
|
31
|
+
['npx', /^(-p|--package)$/],
|
|
32
|
+
['bunx', /^(-p|--package)$/]
|
|
33
|
+
]);
|
|
34
|
+
const BRACKETS = new Map([
|
|
35
|
+
['[', ']'],
|
|
36
|
+
['[[', ']]']
|
|
37
|
+
]);
|
|
38
|
+
export const MAX_GOAL_CHECKS = 8;
|
|
39
|
+
export const MAX_PROVING = MAX_GOAL_CHECKS * 2;
|
|
40
|
+
export const GOAL_CHECKS_ASK = '[This goal has no checks yet. Name the commands that will prove the task is done: write a ' +
|
|
41
|
+
'line `Checks:`, then one command per line in backticks, such as `test -s /app/result.json` ' +
|
|
42
|
+
'or `python3 check.py`. Each must exit 0 only once the task is done, with no pipe, ; or && ' +
|
|
43
|
+
'in it. The goal is met only once each of them ran on its own and exited 0.]';
|
|
44
|
+
export const GOAL_PROOF_ASK = '[The checks this goal has so far may only show that the output exists, not that it is right. Name the ' +
|
|
45
|
+
'commands that will prove the result is correct, such as running the program on an input ' +
|
|
46
|
+
"and comparing with what the task asks, or the task's own tests: write a line `Checks:`, " +
|
|
47
|
+
'then one command per line in backticks, with no pipe, ; or && in it. A command that repeats ' +
|
|
48
|
+
'one of those checks does not count. The goal is met only once each check ran on its own and exited 0.]';
|
|
49
|
+
export const GOAL_REVIEW_ASK = '[Before the goal is met, read the task again and list each requirement it states, one line ' +
|
|
50
|
+
'each, with the command that proves it in backticks and the output it gave. Then write a ' +
|
|
51
|
+
'line `Checks:` and, one per line in backticks, a command for each requirement nothing proved ' +
|
|
52
|
+
'yet, that exits 0 only when it holds, with no pipe, ; or && in it. If every requirement is ' +
|
|
53
|
+
'proved, name no command.]';
|
|
54
|
+
export const GOAL_CASES_ASK = '[The checks pass with most of the budget left. Read the task again and quote each case it ' +
|
|
55
|
+
'names, such as an input, an edge case or an output format, one line each. For each one, ' +
|
|
56
|
+
'run a command that feeds it to your result and show the output it gave. Fix what does not ' +
|
|
57
|
+
'hold, then answer.]';
|
|
58
|
+
export const GOAL_DELIVERABLE_ASK = '[The checks pass, but none of them runs or reads {paths}, what the task asks for. A check ' +
|
|
59
|
+
'counts only when its command, or a script it runs that you wrote, names one of those paths. ' +
|
|
60
|
+
'Write a line `Checks:`, then one command per line in backticks that runs or reads it on an ' +
|
|
61
|
+
'input and exits 0 only when the result is right, with no pipe, ; or && in it. The checks so ' +
|
|
62
|
+
'far stay.]';
|
|
63
|
+
export const GOAL_RUN_ASK = '[No command ran `{path}` after your last edit. Run a test that exercises it. It counts only ' +
|
|
64
|
+
'when it exits 0 on its own, with no pipe, `|| true` or ; after it.]';
|
|
65
|
+
export const MAX_PROOF_ASKS = 2;
|
|
66
|
+
export function deliverableAsk(paths) {
|
|
67
|
+
return GOAL_DELIVERABLE_ASK.replaceAll('{paths}', paths.join(', '));
|
|
68
|
+
}
|
|
69
|
+
export function deliverableChecked(goal) {
|
|
70
|
+
const { deliverable, proving = [] } = goal;
|
|
71
|
+
return (!deliverable || goal.checks.some((check) => runsDeliverable(check.name, deliverable, proving)));
|
|
72
|
+
}
|
|
73
|
+
export function asksDeliverable(goal) {
|
|
74
|
+
return (!asksChecks(goal) && goal.checks.every((check) => check.passed) && !deliverableChecked(goal));
|
|
75
|
+
}
|
|
76
|
+
export function runAsk(path) {
|
|
77
|
+
return GOAL_RUN_ASK.replaceAll('{path}', path);
|
|
78
|
+
}
|
|
79
|
+
export function codeUnrun(goal) {
|
|
80
|
+
return !!goal.checkable && !!goal.edited?.length && !goal.proof;
|
|
81
|
+
}
|
|
82
|
+
export function asksRun(goal) {
|
|
83
|
+
return (codeUnrun(goal) &&
|
|
84
|
+
!asksChecks(goal) &&
|
|
85
|
+
goal.checks.every((check) => check.passed) &&
|
|
86
|
+
deliverableChecked(goal));
|
|
87
|
+
}
|
|
88
|
+
export function asksChecks(goal) {
|
|
89
|
+
return !!goal.checkable && !goal.named && goal.turns < MAX_PROOF_ASKS;
|
|
90
|
+
}
|
|
91
|
+
export function existenceOnly(checks) {
|
|
92
|
+
return (checks.length > 0 &&
|
|
93
|
+
checks.every((check) => check
|
|
94
|
+
.split(SHELL_OPERATOR)
|
|
95
|
+
.filter((part, at) => at % 2 === 0 && part.trim())
|
|
96
|
+
.every((part) => testsExistence(commandOf(part)))));
|
|
97
|
+
}
|
|
98
|
+
function testsExistence(tokens) {
|
|
99
|
+
const close = BRACKETS.get(tokens[0]);
|
|
100
|
+
if ((tokens[0] !== 'test' && !close) || (close && tokens.at(-1) !== close)) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
const path = tokens.slice(2, close ? -1 : undefined);
|
|
104
|
+
return (FILE_TEST.test(tokens[1] ?? '') &&
|
|
105
|
+
path.length > 0 &&
|
|
106
|
+
!path.some((token) => NOT_A_PATH.test(token)));
|
|
107
|
+
}
|
|
108
|
+
export function pathsOf(checks) {
|
|
109
|
+
const paths = checks.flatMap((check) => check
|
|
110
|
+
.split(SHELL_OPERATOR)
|
|
111
|
+
.filter((part, at) => at % 2 === 0)
|
|
112
|
+
.map(commandOf)
|
|
113
|
+
.filter(testsExistence)
|
|
114
|
+
.flatMap((tokens) => tokens.slice(2, BRACKETS.has(tokens[0]) ? -1 : undefined)));
|
|
115
|
+
return [...new Set(paths)];
|
|
116
|
+
}
|
|
117
|
+
export function runsDeliverable(check, deliverable, proving) {
|
|
118
|
+
return (!existenceOnly([check]) &&
|
|
119
|
+
exitSegments(check).some((segment) => {
|
|
120
|
+
const tokens = commandOf(segment);
|
|
121
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
122
|
+
const tests = program === 'test' || BRACKETS.has(program);
|
|
123
|
+
if ((tests && !tokens.some((token) => COMPARISON.test(token))) || NEVER_RUNS.test(program)) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const script = scriptOf(tokens);
|
|
127
|
+
return (namesPath(tokens.join(' '), deliverable) ||
|
|
128
|
+
(script !== undefined && proving.some((path) => samePath(script, path))) ||
|
|
129
|
+
runsTests(tokens));
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
export function sourceFile(path) {
|
|
133
|
+
return SOURCE.test(path);
|
|
134
|
+
}
|
|
135
|
+
export function runsCode(command, edited) {
|
|
136
|
+
const segments = exitSegments(command.replace(HEREDOC, '$1'));
|
|
137
|
+
return segments.find((segment, at) => {
|
|
138
|
+
const tokens = commandOf(segment);
|
|
139
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
140
|
+
if (program === 'test' || BRACKETS.has(program)) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
const script = INTERPRETER.test(program) ? interpreted(tokens) : tokens[0];
|
|
144
|
+
return (runsSuite(tokens) ||
|
|
145
|
+
runsProject(tokens) ||
|
|
146
|
+
(!!tokens[0]?.includes('/') &&
|
|
147
|
+
!SYSTEM_BIN.test(tokens[0]) &&
|
|
148
|
+
segments.slice(0, at).some((part) => builds(commandOf(part)))) ||
|
|
149
|
+
(script !== undefined &&
|
|
150
|
+
(edited.some((path) => samePath(script, path)) ||
|
|
151
|
+
TEST_SCRIPT.test(script.split('/').at(-1) ?? ''))));
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
export function runsCodeCheck(command, checks) {
|
|
155
|
+
return checks.find((check) => runsCheck(command, check) &&
|
|
156
|
+
exitSegments(check).some((segment) => {
|
|
157
|
+
const tokens = commandOf(segment);
|
|
158
|
+
return runsSuite(tokens) || sourceFile(scriptOf(tokens) ?? '');
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
function interpreted(tokens) {
|
|
162
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
163
|
+
let at = 1;
|
|
164
|
+
for (; tokens[at]?.startsWith('-'); at++) {
|
|
165
|
+
if (tokens[at] === '-m' || SYNTAX_ONLY.test(`${program} ${tokens[at]}`)) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return (program === 'bun' || program === 'deno' || program === 'go') && tokens[at] === 'run'
|
|
170
|
+
? tokens[at + 1]
|
|
171
|
+
: tokens[at];
|
|
172
|
+
}
|
|
173
|
+
function runsProject(tokens) {
|
|
174
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
175
|
+
const [, next, target = ''] = tokens;
|
|
176
|
+
return ((program === 'cargo' && next === 'run') ||
|
|
177
|
+
(program === 'go' && next === 'run' && !target.endsWith('.go')));
|
|
178
|
+
}
|
|
179
|
+
function builds(tokens) {
|
|
180
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
181
|
+
const next = tokens[1];
|
|
182
|
+
return ((COMPILER.test(program) && !tokens.includes('-c')) ||
|
|
183
|
+
((program === 'go' || program === 'cargo') && next === 'build') ||
|
|
184
|
+
(program === 'make' &&
|
|
185
|
+
!tokens.some((token) => MAKE_DRY_RUN.test(token)) &&
|
|
186
|
+
!cleansOnly(tokens.slice(1).filter((token) => !token.startsWith('-')))) ||
|
|
187
|
+
(program === 'cmake' &&
|
|
188
|
+
tokens.includes('--build') &&
|
|
189
|
+
!cleansOnly(tokens.slice(tokens.indexOf('--target') + 1))));
|
|
190
|
+
}
|
|
191
|
+
function cleansOnly(tokens) {
|
|
192
|
+
const end = tokens.findIndex((token) => token.startsWith('-'));
|
|
193
|
+
const targets = end === -1 ? tokens : tokens.slice(0, end);
|
|
194
|
+
return targets.length > 0 && targets.every((target) => CLEAN.test(target));
|
|
195
|
+
}
|
|
196
|
+
export function runsScript(check, paths) {
|
|
197
|
+
return exitSegments(check).some((segment) => {
|
|
198
|
+
const script = scriptOf(commandOf(segment));
|
|
199
|
+
return script !== undefined && paths.some((path) => samePath(script, path));
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function runsTests(tokens) {
|
|
203
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
204
|
+
if (program === 'pytest' || PYTHON.test(program)) {
|
|
205
|
+
return (program === 'pytest' || testRunner(tokens)) && scriptOf(tokens) === undefined;
|
|
206
|
+
}
|
|
207
|
+
return testRunner(tokens);
|
|
208
|
+
}
|
|
209
|
+
function runsSuite(tokens) {
|
|
210
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
211
|
+
return (program === 'pytest' ||
|
|
212
|
+
program === 'ctest' ||
|
|
213
|
+
(program === 'node' && tokens.includes('--test')) ||
|
|
214
|
+
testRunner(tokens));
|
|
215
|
+
}
|
|
216
|
+
function testRunner(tokens) {
|
|
217
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
218
|
+
const [, next = '', third = ''] = tokens;
|
|
219
|
+
const module = tokens.indexOf('-m');
|
|
220
|
+
return ((PACKAGE_MANAGER.test(program) && PACKAGE_TEST.test(next === 'run' ? third : next)) ||
|
|
221
|
+
((program === 'cargo' || program === 'go') && next === 'test') ||
|
|
222
|
+
(program === 'make' && (next === 'test' || next === 'check')) ||
|
|
223
|
+
(PYTHON.test(program) && module > 0 && /^(pytest|unittest)$/.test(tokens[module + 1] ?? '')));
|
|
224
|
+
}
|
|
225
|
+
export function namesPath(text, paths) {
|
|
226
|
+
return text
|
|
227
|
+
.split(PATH_BREAK)
|
|
228
|
+
.some((token) => token && paths.some((path) => samePath(token, path)));
|
|
229
|
+
}
|
|
230
|
+
export function writtenTexts(args) {
|
|
231
|
+
const text = args.content ?? args.new;
|
|
232
|
+
if (typeof args.path === 'string' && typeof text === 'string') {
|
|
233
|
+
return [[args.path, text]];
|
|
234
|
+
}
|
|
235
|
+
const { command } = args;
|
|
236
|
+
if (typeof command !== 'string') {
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
const heredocs = [...command.matchAll(HEREDOC)].map((match) => ({
|
|
240
|
+
opened: match.index + match[1].length,
|
|
241
|
+
end: match.index + match[0].length,
|
|
242
|
+
body: match[4] ?? ''
|
|
243
|
+
}));
|
|
244
|
+
const written = [];
|
|
245
|
+
for (const match of command.matchAll(WRITE)) {
|
|
246
|
+
const [, , target] = match;
|
|
247
|
+
const inBody = heredocs.some(({ opened, end }) => match.index > opened && match.index < end);
|
|
248
|
+
if (inBody || target.startsWith('/dev/')) {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
const close = command.indexOf('\n', match.index);
|
|
252
|
+
const line = command.slice(command.lastIndexOf('\n', match.index) + 1, close < 0 ? undefined : close);
|
|
253
|
+
written.push([target, heredocs.find(({ opened }) => opened === close)?.body ?? line]);
|
|
254
|
+
}
|
|
255
|
+
return written;
|
|
256
|
+
}
|
|
257
|
+
export function provesResult(command) {
|
|
258
|
+
return exitSegments(command).find(proves);
|
|
259
|
+
}
|
|
260
|
+
function proves(segment) {
|
|
261
|
+
if (segment.split('"').length % 2 === 0 || segment.split("'").length % 2 === 0) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
const tokens = commandOf(segment);
|
|
265
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
266
|
+
const python = PYTHON.test(program);
|
|
267
|
+
if (program === 'test' || program === '[' || program === '[[') {
|
|
268
|
+
return tokens.some((token) => COMPARISON.test(token));
|
|
269
|
+
}
|
|
270
|
+
if ((python && tokens.includes('-c')) || (program === 'node' && tokens.includes('-e'))) {
|
|
271
|
+
return /\bassert\b/.test(segment);
|
|
272
|
+
}
|
|
273
|
+
return (COMPARE.test(program) ||
|
|
274
|
+
(program === 'grep' && tokens.some((token) => QUIET.test(token))) ||
|
|
275
|
+
runsSuite(tokens) ||
|
|
276
|
+
TEST_SCRIPT.test(scriptOf(tokens)?.split('/').at(-1) ?? ''));
|
|
277
|
+
}
|
|
278
|
+
function scriptOf(tokens) {
|
|
279
|
+
let at = 0;
|
|
280
|
+
if (RUNNER.test(tokens[0]?.split('/').at(-1) ?? '')) {
|
|
281
|
+
at++;
|
|
282
|
+
while (tokens[at]?.startsWith('-')) {
|
|
283
|
+
at += tokens[at] === '-m' ? 2 : 1;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return tokens[at];
|
|
287
|
+
}
|
|
288
|
+
export function citesPassed(text, passed) {
|
|
289
|
+
const lines = text.split('\n');
|
|
290
|
+
const heading = lines.findIndex((line) => CHECKS_HEADING.test(line));
|
|
291
|
+
const cited = lines.slice(0, heading < 0 ? undefined : heading).join('\n');
|
|
292
|
+
return [...cited.matchAll(SPAN)].some(([, span]) => passed.some((command) => runsCheck(span, command)));
|
|
293
|
+
}
|
|
294
|
+
export function namedChecks(text) {
|
|
295
|
+
const lines = text.split('\n');
|
|
296
|
+
const heading = lines.findIndex((line) => CHECKS_HEADING.test(line));
|
|
297
|
+
if (heading < 0) {
|
|
298
|
+
return [];
|
|
299
|
+
}
|
|
300
|
+
const named = [];
|
|
301
|
+
for (const line of lines.slice(heading + 1)) {
|
|
302
|
+
const command = CHECK_LINE.exec(line)?.[1].trim();
|
|
303
|
+
if (!command) {
|
|
304
|
+
if (line.trim() || named.length) {
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (runsCheck(command, command) && !named.includes(command)) {
|
|
310
|
+
named.push(command);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return named.slice(0, MAX_GOAL_CHECKS);
|
|
314
|
+
}
|
|
315
|
+
export function mergeChecks(host, named) {
|
|
316
|
+
const known = new Set(host.map(normalize));
|
|
317
|
+
const fresh = named
|
|
318
|
+
.filter((name) => !known.has(normalize(name)))
|
|
319
|
+
.slice(0, host.length ? MAX_GOAL_CHECKS - 1 : MAX_GOAL_CHECKS);
|
|
320
|
+
if (!fresh.length) {
|
|
321
|
+
return [];
|
|
322
|
+
}
|
|
323
|
+
return [...host.slice(0, MAX_GOAL_CHECKS - fresh.length), ...fresh];
|
|
324
|
+
}
|
|
325
|
+
function normalize(command) {
|
|
326
|
+
return command.trim().replace(/\s+/g, ' ');
|
|
327
|
+
}
|
|
328
|
+
export function runsCheck(command, check) {
|
|
329
|
+
const named = words(check);
|
|
330
|
+
const wanted = named.slice(Math.max(commandStart(named), 0));
|
|
331
|
+
return exitSegments(command).some((segment) => invokes(words(segment), wanted));
|
|
332
|
+
}
|
|
333
|
+
function exitSegments(command) {
|
|
334
|
+
const parts = command.split(SHELL_OPERATOR);
|
|
335
|
+
for (let at = parts.length - 1; at >= 0; at -= 2) {
|
|
336
|
+
if (!parts[at].trim()) {
|
|
337
|
+
parts.splice(at === parts.length - 1 ? Math.max(at - 1, 0) : at, 2);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const segments = [];
|
|
341
|
+
for (let at = 0; at < parts.length; at += 2) {
|
|
342
|
+
const after = parts.slice(at + 1).filter((_, n) => n % 2 === 0);
|
|
343
|
+
if (parts[at - 1] !== '||' && after.every((operator) => operator === '&&')) {
|
|
344
|
+
segments.push(parts[at].trim());
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return segments;
|
|
348
|
+
}
|
|
349
|
+
function commandOf(segment) {
|
|
350
|
+
const all = words(segment);
|
|
351
|
+
return all.slice(Math.max(commandStart(all), 0));
|
|
352
|
+
}
|
|
353
|
+
function words(text) {
|
|
354
|
+
return text
|
|
355
|
+
.trim()
|
|
356
|
+
.split(/\s+/)
|
|
357
|
+
.filter(Boolean)
|
|
358
|
+
.map((word) => word.replace(/^['"]|['"]$/g, ''));
|
|
359
|
+
}
|
|
360
|
+
function invokes(tokens, wanted) {
|
|
361
|
+
let start = commandStart(tokens);
|
|
362
|
+
if (start < 0) {
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
if (leads(tokens.slice(start), wanted)) {
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
if (!RUNNER.test(tokens[start].split('/').at(-1) ?? '')) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
start++;
|
|
372
|
+
while (tokens[start]?.startsWith('-')) {
|
|
373
|
+
start++;
|
|
374
|
+
}
|
|
375
|
+
return leads(tokens.slice(start), wanted);
|
|
376
|
+
}
|
|
377
|
+
function commandStart(tokens) {
|
|
378
|
+
let at = 0;
|
|
379
|
+
while (at < tokens.length) {
|
|
380
|
+
if (/^\w+=/.test(tokens[at])) {
|
|
381
|
+
at++;
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
const wrapper = tokens[at].split('/').at(-1) ?? '';
|
|
385
|
+
const takesValue = WRAPPERS.get(wrapper);
|
|
386
|
+
if (!takesValue) {
|
|
387
|
+
return at;
|
|
388
|
+
}
|
|
389
|
+
at++;
|
|
390
|
+
while (tokens[at]?.startsWith('-')) {
|
|
391
|
+
at += takesValue.test(tokens[at]) ? 2 : 1;
|
|
392
|
+
}
|
|
393
|
+
if (wrapper === 'timeout') {
|
|
394
|
+
at++;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return -1;
|
|
398
|
+
}
|
|
399
|
+
function leads(tokens, wanted) {
|
|
400
|
+
return (wanted.length > 0 &&
|
|
401
|
+
wanted.every((word, at) => tokens[at] !== undefined && samePath(tokens[at], word)));
|
|
402
|
+
}
|
|
403
|
+
export function samePath(a, b) {
|
|
404
|
+
const left = a.replace(/^\.\//, '');
|
|
405
|
+
const right = b.replace(/^\.\//, '');
|
|
406
|
+
return left === right || left.endsWith(`/${right}`) || right.endsWith(`/${left}`);
|
|
407
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function omitted(count, locator, startLine) {
|
|
2
|
-
const where = locator ? `;
|
|
2
|
+
const where = locator ? `; read_file path=${locator} startLine=${startLine}` : '';
|
|
3
3
|
return `\n…[${count} chars omitted${where}]…\n`;
|
|
4
4
|
}
|
|
5
5
|
export function headTail(text, limit) {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export function stripHtmlTags(text) {
|
|
2
|
-
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const lastClose = text.lastIndexOf('>');
|
|
3
|
+
let out = '';
|
|
4
|
+
let at = 0;
|
|
5
|
+
let open = text.indexOf('<');
|
|
6
|
+
while (open !== -1 && open < lastClose) {
|
|
7
|
+
out += text.slice(at, open);
|
|
8
|
+
at = text.indexOf('>', open) + 1;
|
|
9
|
+
open = text.indexOf('<', at);
|
|
7
10
|
}
|
|
8
|
-
return out;
|
|
11
|
+
return out + text.slice(at);
|
|
9
12
|
}
|
|
10
13
|
const NAMED_ENTITIES = {
|
|
11
14
|
'<': '<',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function createLoadStall(ms,
|
|
1
|
+
export function createLoadStall(ms, stalled) {
|
|
2
2
|
let timer = null;
|
|
3
3
|
let rejectStall = null;
|
|
4
4
|
const promise = new Promise((_, reject) => {
|
|
@@ -9,7 +9,7 @@ export function createLoadStall(ms, message) {
|
|
|
9
9
|
clearTimeout(timer);
|
|
10
10
|
}
|
|
11
11
|
timer = setTimeout(() => {
|
|
12
|
-
rejectStall?.(
|
|
12
|
+
rejectStall?.(stalled());
|
|
13
13
|
}, ms);
|
|
14
14
|
};
|
|
15
15
|
arm();
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
export interface MarkupStreamFilterOptions {
|
|
2
|
+
readonly onToolCall?: (body: string) => void;
|
|
3
|
+
}
|
|
1
4
|
export interface MarkupStreamFilter {
|
|
2
5
|
readonly push: (token: string) => string;
|
|
3
6
|
readonly flush: () => string;
|
|
4
7
|
}
|
|
5
|
-
export declare function createMarkupStreamFilter(): MarkupStreamFilter;
|
|
8
|
+
export declare function createMarkupStreamFilter(options?: MarkupStreamFilterOptions): MarkupStreamFilter;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { holdback } from 'asenion/scan';
|
|
2
2
|
import { createJoinGuard } from './join-guard.js';
|
|
3
3
|
import { scanNamedMarkup } from './markup-scanner.js';
|
|
4
|
-
const
|
|
4
|
+
const TOOL_CALL_OPEN = '<tool_call>';
|
|
5
|
+
const MARKUP_OPENERS = [TOOL_CALL_OPEN, '<tool_response>'];
|
|
5
6
|
const MARKUP_CLOSERS = {
|
|
6
7
|
'<tool_call>': '</tool_call>',
|
|
7
8
|
'<tool_response>': '</tool_response>'
|
|
@@ -9,13 +10,15 @@ const MARKUP_CLOSERS = {
|
|
|
9
10
|
const MARKUP_MARKERS = [...MARKUP_OPENERS, ...Object.values(MARKUP_CLOSERS)];
|
|
10
11
|
const FUNCTION_CLOSE = '</function>';
|
|
11
12
|
const JOIN_MARKERS = [...MARKUP_MARKERS, '<function', '</function>', '<FUNCTION', '</FUNCTION>'];
|
|
12
|
-
function initialState() {
|
|
13
|
+
function initialState({ onToolCall = noop }) {
|
|
13
14
|
return {
|
|
14
15
|
buffer: '',
|
|
15
16
|
lower: '',
|
|
16
17
|
markerAt: MARKUP_MARKERS.map(() => -1),
|
|
17
18
|
namedFrom: 0,
|
|
18
19
|
closer: null,
|
|
20
|
+
held: null,
|
|
21
|
+
onToolCall,
|
|
19
22
|
candidate: null,
|
|
20
23
|
candidateTail: '',
|
|
21
24
|
stripNewline: false,
|
|
@@ -67,8 +70,8 @@ function nextStep(state) {
|
|
|
67
70
|
}
|
|
68
71
|
return state.closer ? consumeSuppressed(state) : emitUntilOpener(state);
|
|
69
72
|
}
|
|
70
|
-
export function createMarkupStreamFilter() {
|
|
71
|
-
const state = initialState();
|
|
73
|
+
export function createMarkupStreamFilter(options = {}) {
|
|
74
|
+
const state = initialState(options);
|
|
72
75
|
return {
|
|
73
76
|
push(token) {
|
|
74
77
|
appendBuffer(state, token);
|
|
@@ -87,6 +90,7 @@ export function createMarkupStreamFilter() {
|
|
|
87
90
|
function resetPending(state) {
|
|
88
91
|
setBuffer(state, '');
|
|
89
92
|
state.closer = null;
|
|
93
|
+
state.held = null;
|
|
90
94
|
state.candidate = null;
|
|
91
95
|
state.candidateTail = '';
|
|
92
96
|
state.stripNewline = false;
|
|
@@ -112,10 +116,18 @@ function consumeSuppressed(state) {
|
|
|
112
116
|
const closer = state.closer ?? '';
|
|
113
117
|
const end = state.buffer.indexOf(closer);
|
|
114
118
|
if (end === -1) {
|
|
115
|
-
const
|
|
116
|
-
|
|
119
|
+
const kept = state.buffer.length - holdback(state.buffer, [closer]);
|
|
120
|
+
if (state.held !== null) {
|
|
121
|
+
state.held += state.buffer.slice(0, kept);
|
|
122
|
+
}
|
|
123
|
+
setBuffer(state, state.buffer.slice(kept));
|
|
117
124
|
return { out: '', done: true };
|
|
118
125
|
}
|
|
126
|
+
if (state.held !== null) {
|
|
127
|
+
const body = state.held + state.buffer.slice(0, end);
|
|
128
|
+
state.held = null;
|
|
129
|
+
state.onToolCall(body);
|
|
130
|
+
}
|
|
119
131
|
setBuffer(state, state.buffer.slice(end + closer.length));
|
|
120
132
|
state.stripNewline = true;
|
|
121
133
|
state.closer = null;
|
|
@@ -143,6 +155,7 @@ function consumeFixedMarker(state, index, marker) {
|
|
|
143
155
|
const closer = MARKUP_CLOSERS[marker];
|
|
144
156
|
state.stripNewline = closer === undefined;
|
|
145
157
|
state.closer = closer ?? null;
|
|
158
|
+
state.held = marker === TOOL_CALL_OPEN ? '' : null;
|
|
146
159
|
return { out, done: false };
|
|
147
160
|
}
|
|
148
161
|
function scanNamedOpen(buffer, haystack, start) {
|
|
@@ -179,3 +192,4 @@ function emitUntilOpener(state) {
|
|
|
179
192
|
setBuffer(state, state.buffer.slice(state.buffer.length - hold));
|
|
180
193
|
return { out, done: true };
|
|
181
194
|
}
|
|
195
|
+
function noop() { }
|
|
@@ -17,28 +17,36 @@ function firstHalf(items, key) {
|
|
|
17
17
|
const repeats = items.slice(half).every((item, at) => key(item) === key(items[at]));
|
|
18
18
|
return repeats ? items.slice(0, half) : items;
|
|
19
19
|
}
|
|
20
|
-
async function* withoutRepeatedTail(
|
|
20
|
+
async function* withoutRepeatedTail(events) {
|
|
21
21
|
let streamed = '';
|
|
22
|
-
let held =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
let held = [];
|
|
23
|
+
let heldText = '';
|
|
24
|
+
for await (const event of events) {
|
|
25
|
+
if (event.type !== 'contentDelta') {
|
|
26
|
+
yield event;
|
|
26
27
|
continue;
|
|
27
28
|
}
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
if (heldText && streamed.startsWith(heldText + event.text)) {
|
|
30
|
+
held.push(event);
|
|
31
|
+
heldText += event.text;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (heldText) {
|
|
35
|
+
yield* held;
|
|
36
|
+
streamed += heldText;
|
|
37
|
+
held = [];
|
|
38
|
+
heldText = '';
|
|
32
39
|
}
|
|
33
|
-
if (streamed.length >= MIN_REPEAT_CHARS &&
|
|
34
|
-
held =
|
|
40
|
+
if (streamed.length >= MIN_REPEAT_CHARS && event.text && streamed.startsWith(event.text)) {
|
|
41
|
+
held = [event];
|
|
42
|
+
heldText = event.text;
|
|
35
43
|
continue;
|
|
36
44
|
}
|
|
37
|
-
streamed +=
|
|
38
|
-
yield
|
|
45
|
+
streamed += event.text;
|
|
46
|
+
yield event;
|
|
39
47
|
}
|
|
40
|
-
if (
|
|
41
|
-
yield held;
|
|
48
|
+
if (heldText && heldText !== streamed) {
|
|
49
|
+
yield* held;
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
function once(reply) {
|
|
@@ -58,6 +66,6 @@ function once(reply) {
|
|
|
58
66
|
export function withoutRepeatedReply(result) {
|
|
59
67
|
const final = result.final.then(once);
|
|
60
68
|
final.catch(noop);
|
|
61
|
-
return { ...result,
|
|
69
|
+
return { ...result, events: withoutRepeatedTail(result.events), final };
|
|
62
70
|
}
|
|
63
71
|
function noop() { }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function missingPeers(peers) {
|
|
2
|
+
return Object.keys(peers).filter((name) => !resolves(peers[name]));
|
|
3
|
+
}
|
|
4
|
+
export function requirePeers(subject, peers) {
|
|
5
|
+
const missing = missingPeers(peers);
|
|
6
|
+
if (missing.length === 0) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
throw new Error(`${subject} needs ${missing.join(', ')}, not installed (optional peers of @qvac/harness): npm install ${missing.join(' ')}`);
|
|
10
|
+
}
|
|
11
|
+
function resolves(resolve) {
|
|
12
|
+
try {
|
|
13
|
+
resolve?.();
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
const code = Reflect.get(Object(error), 'code');
|
|
18
|
+
if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { RunOutcome, ToolExecutionOutcome } from '../contract/index.ts';
|
|
|
2
2
|
export type { RunOutcome };
|
|
3
3
|
export declare const DEGENERATE_ANSWER_FALLBACK = "I couldn't complete that step and don't have a useful result to share.";
|
|
4
4
|
export declare const ROUND_CAP_ANSWER = "I ran out of steps before I could finish that. Ask me to continue and I'll pick up where I left off.";
|
|
5
|
+
export declare const REPEATED_CALL_ANSWER = "I stopped because I kept repeating the same step without getting anywhere. Tell me more about what you want, or put it another way, and I'll try something else.";
|
|
5
6
|
export declare const SEARCH_CAPPED_ANSWER = "I searched the web but couldn't find the answer in the results I got.";
|
|
6
7
|
export declare const DELIVERED_ANSWER = "Your file is attached to the chat.";
|
|
7
8
|
export declare const WRITE_RESULT_LEAD = "Here's what came back:";
|
|
@@ -10,6 +11,7 @@ export interface RunOutcomeFacts {
|
|
|
10
11
|
readonly latestFailure: string | null;
|
|
11
12
|
readonly confirmedWrites: ReadonlyArray<string>;
|
|
12
13
|
readonly delivered?: boolean;
|
|
14
|
+
readonly repeated?: boolean;
|
|
13
15
|
}
|
|
14
16
|
export interface HistoryTurn {
|
|
15
17
|
readonly role: string;
|