@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
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { ShellLine } from '../../lib/tools/exec/shell-line.js';
|
|
4
|
+
const GREP = {
|
|
5
|
+
short: 'rniIlLcvwxhHoqsEFz',
|
|
6
|
+
valued: 'eABCm',
|
|
7
|
+
long: [
|
|
8
|
+
'--recursive',
|
|
9
|
+
'--line-number',
|
|
10
|
+
'--ignore-case',
|
|
11
|
+
'--files-with-matches',
|
|
12
|
+
'--files-without-match',
|
|
13
|
+
'--count',
|
|
14
|
+
'--invert-match',
|
|
15
|
+
'--word-regexp',
|
|
16
|
+
'--line-regexp',
|
|
17
|
+
'--only-matching',
|
|
18
|
+
'--no-filename',
|
|
19
|
+
'--with-filename',
|
|
20
|
+
'--extended-regexp',
|
|
21
|
+
'--fixed-strings'
|
|
22
|
+
],
|
|
23
|
+
longValued: [
|
|
24
|
+
'--regexp',
|
|
25
|
+
'--include',
|
|
26
|
+
'--exclude',
|
|
27
|
+
'--exclude-dir',
|
|
28
|
+
'--max-count',
|
|
29
|
+
'--context',
|
|
30
|
+
'--after-context',
|
|
31
|
+
'--before-context',
|
|
32
|
+
'--color',
|
|
33
|
+
'--colour'
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
const LINES = {
|
|
37
|
+
short: 'qv',
|
|
38
|
+
valued: 'nc',
|
|
39
|
+
long: ['--quiet', '--silent', '--verbose'],
|
|
40
|
+
longValued: ['--lines', '--bytes'],
|
|
41
|
+
count: true
|
|
42
|
+
};
|
|
43
|
+
const READERS = {
|
|
44
|
+
cat: { short: 'nbsAEetTuv' },
|
|
45
|
+
head: LINES,
|
|
46
|
+
tail: LINES,
|
|
47
|
+
wc: { short: 'clmwL', long: ['--bytes', '--chars', '--lines', '--words'] },
|
|
48
|
+
ls: { short: 'aAlhRrtS1dFpiogGnuUcCxsQ' },
|
|
49
|
+
pwd: { short: 'LP' },
|
|
50
|
+
echo: { short: 'neE', text: true },
|
|
51
|
+
nl: { valued: 'bvisnw' },
|
|
52
|
+
cut: {
|
|
53
|
+
short: 's',
|
|
54
|
+
valued: 'bcdf',
|
|
55
|
+
longValued: ['--bytes', '--characters', '--delimiter', '--fields']
|
|
56
|
+
},
|
|
57
|
+
tr: { short: 'cdsC', text: true },
|
|
58
|
+
file: { short: 'bLhiz', long: ['--brief', '--mime', '--mime-type'] },
|
|
59
|
+
stat: { short: 'L', valued: 'cf' },
|
|
60
|
+
du: { short: 'shacmkx', valued: 'd', longValued: ['--max-depth'] },
|
|
61
|
+
tree: { short: 'adfisDhpugFnC', valued: 'LIP' },
|
|
62
|
+
diff: { short: 'uqwbBiaty', valued: 'U' },
|
|
63
|
+
grep: GREP,
|
|
64
|
+
egrep: GREP,
|
|
65
|
+
fgrep: GREP,
|
|
66
|
+
rg: {
|
|
67
|
+
short: 'nilcvwoFSsuHNq',
|
|
68
|
+
valued: 'egtTABCmM',
|
|
69
|
+
long: [
|
|
70
|
+
'--hidden',
|
|
71
|
+
'--files',
|
|
72
|
+
'--count',
|
|
73
|
+
'--files-with-matches',
|
|
74
|
+
'--line-number',
|
|
75
|
+
'--ignore-case',
|
|
76
|
+
'--smart-case',
|
|
77
|
+
'--fixed-strings',
|
|
78
|
+
'--word-regexp',
|
|
79
|
+
'--no-ignore',
|
|
80
|
+
'--no-heading',
|
|
81
|
+
'--heading'
|
|
82
|
+
],
|
|
83
|
+
longValued: [
|
|
84
|
+
'--glob',
|
|
85
|
+
'--type',
|
|
86
|
+
'--type-not',
|
|
87
|
+
'--max-count',
|
|
88
|
+
'--context',
|
|
89
|
+
'--after-context',
|
|
90
|
+
'--before-context',
|
|
91
|
+
'--max-depth',
|
|
92
|
+
'--regexp',
|
|
93
|
+
'--color'
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
uniq: { short: 'cdui', valued: 'fs', most: 1 },
|
|
97
|
+
sort: {
|
|
98
|
+
short: 'nrufbdhgiMVsc',
|
|
99
|
+
valued: 'tk',
|
|
100
|
+
long: [
|
|
101
|
+
'--numeric-sort',
|
|
102
|
+
'--reverse',
|
|
103
|
+
'--unique',
|
|
104
|
+
'--ignore-case',
|
|
105
|
+
'--human-numeric-sort',
|
|
106
|
+
'--version-sort',
|
|
107
|
+
'--stable',
|
|
108
|
+
'--check'
|
|
109
|
+
],
|
|
110
|
+
longValued: ['--key', '--field-separator']
|
|
111
|
+
},
|
|
112
|
+
sed: { words: sedRange },
|
|
113
|
+
find: { words: findExpression }
|
|
114
|
+
};
|
|
115
|
+
const PRINT_RANGE = /^(\d+|\$)(,(\d+|\$))?p$/;
|
|
116
|
+
function sedRange(words, file) {
|
|
117
|
+
const [flag, range, ...files] = words;
|
|
118
|
+
return (flag === '-n' &&
|
|
119
|
+
PRINT_RANGE.test(range ?? '') &&
|
|
120
|
+
files.every((word) => !word.startsWith('-') && file(word)));
|
|
121
|
+
}
|
|
122
|
+
const FIND_TESTS = new Set([
|
|
123
|
+
'-name',
|
|
124
|
+
'-iname',
|
|
125
|
+
'-path',
|
|
126
|
+
'-ipath',
|
|
127
|
+
'-wholename',
|
|
128
|
+
'-regex',
|
|
129
|
+
'-iregex',
|
|
130
|
+
'-type',
|
|
131
|
+
'-maxdepth',
|
|
132
|
+
'-mindepth',
|
|
133
|
+
'-size',
|
|
134
|
+
'-mtime',
|
|
135
|
+
'-mmin',
|
|
136
|
+
'-newer'
|
|
137
|
+
]);
|
|
138
|
+
const FIND_FLAGS = new Set([
|
|
139
|
+
'-empty',
|
|
140
|
+
'-print',
|
|
141
|
+
'-print0',
|
|
142
|
+
'-prune',
|
|
143
|
+
'-not',
|
|
144
|
+
'!',
|
|
145
|
+
'(',
|
|
146
|
+
')',
|
|
147
|
+
'-o',
|
|
148
|
+
'-or',
|
|
149
|
+
'-a',
|
|
150
|
+
'-and'
|
|
151
|
+
]);
|
|
152
|
+
function findExpression(words, file) {
|
|
153
|
+
const rest = words[0] === '-P' ? words.slice(1) : words;
|
|
154
|
+
const begins = rest.findIndex((word) => word.startsWith('-') || FIND_FLAGS.has(word));
|
|
155
|
+
const starts = begins === -1 ? rest : rest.slice(0, begins);
|
|
156
|
+
let test = null;
|
|
157
|
+
for (const word of begins === -1 ? [] : rest.slice(begins)) {
|
|
158
|
+
if (test !== null) {
|
|
159
|
+
if (test === '-newer' && !file(word)) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
test = null;
|
|
163
|
+
}
|
|
164
|
+
else if (FIND_TESTS.has(word)) {
|
|
165
|
+
test = word;
|
|
166
|
+
}
|
|
167
|
+
else if (!FIND_FLAGS.has(word)) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return test === null && starts.every(file);
|
|
172
|
+
}
|
|
173
|
+
export function readsOnly(line, root) {
|
|
174
|
+
const parsed = ShellLine.parse(line);
|
|
175
|
+
const stays = root ? resolvesInside(root) : () => true;
|
|
176
|
+
return (parsed.unjudgeable === null &&
|
|
177
|
+
parsed.commands.length > 0 &&
|
|
178
|
+
parsed.commands.every((command) => reader(command, stays)));
|
|
179
|
+
}
|
|
180
|
+
function reader({ argv, expands, assignments, redirects }, stays) {
|
|
181
|
+
const name = argv[0] ?? '';
|
|
182
|
+
const known = Object.hasOwn(READERS, name) ? READERS[name] : undefined;
|
|
183
|
+
if (!known || assignments.length || !redirects.every((r) => harmless(r, stays))) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
if (expands.some(Boolean)) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
const file = (word) => inside(word) && stays(word);
|
|
190
|
+
const words = argv.slice(1);
|
|
191
|
+
if (known.words) {
|
|
192
|
+
return known.words(words, file);
|
|
193
|
+
}
|
|
194
|
+
const operands = operandsOf(known, words);
|
|
195
|
+
return (operands !== null &&
|
|
196
|
+
operands.length <= (known.most ?? Infinity) &&
|
|
197
|
+
(known.text === true || operands.every(file)));
|
|
198
|
+
}
|
|
199
|
+
function operandsOf(known, words) {
|
|
200
|
+
const operands = [];
|
|
201
|
+
let value = false;
|
|
202
|
+
for (const [i, word] of words.entries()) {
|
|
203
|
+
if (value) {
|
|
204
|
+
value = false;
|
|
205
|
+
}
|
|
206
|
+
else if (word === '--') {
|
|
207
|
+
return [...operands, ...words.slice(i + 1)];
|
|
208
|
+
}
|
|
209
|
+
else if (word === '-' || !word.startsWith('-')) {
|
|
210
|
+
operands.push(word);
|
|
211
|
+
}
|
|
212
|
+
else if (!(known.count && /^-\d+$/.test(word))) {
|
|
213
|
+
const taken = word.startsWith('--') ? longFlag(known, word) : shortFlags(known, word);
|
|
214
|
+
if (taken === null) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
value = taken === 1;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return operands;
|
|
221
|
+
}
|
|
222
|
+
function longFlag(known, word) {
|
|
223
|
+
const at = word.indexOf('=');
|
|
224
|
+
const name = at === -1 ? word : word.slice(0, at);
|
|
225
|
+
if (known.longValued?.includes(name)) {
|
|
226
|
+
return at === -1 ? 1 : 0;
|
|
227
|
+
}
|
|
228
|
+
return at === -1 && known.long?.includes(name) ? 0 : null;
|
|
229
|
+
}
|
|
230
|
+
function shortFlags(known, word) {
|
|
231
|
+
const letters = [...word.slice(1)];
|
|
232
|
+
for (const [i, letter] of letters.entries()) {
|
|
233
|
+
if (known.valued?.includes(letter)) {
|
|
234
|
+
return i === letters.length - 1 ? 1 : 0;
|
|
235
|
+
}
|
|
236
|
+
if (!known.short?.includes(letter)) {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return 0;
|
|
241
|
+
}
|
|
242
|
+
function resolvesInside(root) {
|
|
243
|
+
const real = realpath(root) ?? root;
|
|
244
|
+
return (word) => {
|
|
245
|
+
const target = realpath(path.resolve(root, word));
|
|
246
|
+
return target === null || target === real || target.startsWith(real + path.sep);
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function realpath(file) {
|
|
250
|
+
try {
|
|
251
|
+
return fs.realpathSync(file);
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function inside(word) {
|
|
258
|
+
return !word.startsWith('/') && !word.startsWith('~') && !word.split('/').includes('..');
|
|
259
|
+
}
|
|
260
|
+
function harmless({ op, target }, stays) {
|
|
261
|
+
return ((op === '<' && inside(target) && stays(target)) ||
|
|
262
|
+
target === '/dev/null' ||
|
|
263
|
+
((op === '>&' || op === '<&') && /^\d$/.test(target)));
|
|
264
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
2
|
-
import type { ToolDefinition, ToolExecuteContext } from '../../lib/contract/index.ts';
|
|
2
|
+
import type { CompiledPolicy, ToolDefinition, ToolExecuteContext } from '../../lib/contract/index.ts';
|
|
3
3
|
import type { SandboxExecResult, SandboxJob, SandboxService, SandboxWorkspace } from '../../lib/contract/sandbox.ts';
|
|
4
4
|
import { type LocalRoot } from '../../lib/tools/fs/scope.ts';
|
|
5
5
|
export interface ToolError {
|
|
@@ -10,7 +10,6 @@ export declare function guidance(error: string): ToolError;
|
|
|
10
10
|
export declare function isError(value: unknown): value is ToolError;
|
|
11
11
|
export declare function shellQuote(text: string): string;
|
|
12
12
|
export declare function errorText(error: unknown): string;
|
|
13
|
-
export declare function workspaceKey(root: LocalRoot, input: string): Promise<string | ToolError>;
|
|
14
13
|
export declare function capped(text: string, stream: 'stdout' | 'stderr', ctx: ToolExecuteContext | undefined): Promise<string>;
|
|
15
14
|
interface ExecCall {
|
|
16
15
|
timeoutMs?: number;
|
|
@@ -27,16 +26,19 @@ export declare class CodingSession {
|
|
|
27
26
|
private readonly _bind;
|
|
28
27
|
private readonly _workspaces;
|
|
29
28
|
private readonly _runs;
|
|
29
|
+
private readonly _keys;
|
|
30
|
+
private readonly _moved;
|
|
30
31
|
constructor(sandbox: SandboxService, deniedRoots?: readonly string[]);
|
|
31
|
-
effect(ctx: ToolExecuteContext | undefined): 'read' | 'write';
|
|
32
|
+
effect(ctx: ToolExecuteContext | undefined, args?: Record<string, unknown>): 'read' | 'write';
|
|
32
33
|
refusal(ctx: ToolExecuteContext | undefined): ToolError | null;
|
|
33
34
|
workspace(ctx: ToolExecuteContext | undefined): Promise<LocalRoot | ToolError>;
|
|
34
35
|
policyVersion(): string;
|
|
35
36
|
statePath(runId: string): string;
|
|
36
|
-
open(root: LocalRoot, runId: string): Promise<SandboxWorkspace>;
|
|
37
|
+
open(root: LocalRoot, runId: string, policy: CompiledPolicy): Promise<SandboxWorkspace>;
|
|
37
38
|
workspaceOf(runId: string): Promise<SandboxWorkspace> | null;
|
|
38
39
|
private _prelude;
|
|
39
40
|
exec({ workspace, runId, line }: SessionLine, { timeoutMs, signal }?: ExecCall): Promise<SandboxExecResult>;
|
|
41
|
+
private _moves;
|
|
40
42
|
jobLog(id: string): string;
|
|
41
43
|
start({ workspace, runId, line }: SessionLine, id: string): Promise<SandboxJob>;
|
|
42
44
|
execState(workspace: SandboxWorkspace, line: string): Promise<SandboxExecResult>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { randomBytes } from 'crypto';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import { Policy } from '../../lib/policy/index.js';
|
|
5
|
+
import { readsOnly } from './read-only.js';
|
|
6
|
+
import { HarnessError } from '../../lib/errors.js';
|
|
4
7
|
import { isRecord } from '../../lib/guards.js';
|
|
5
8
|
import { appendOutput, createCapturedOutput, formatOutput, MAX_OUTPUT_CHARS } from '../../lib/tools/exec/runner.js';
|
|
6
|
-
import {
|
|
9
|
+
import { callDenyRoots, defaultRealpath, overlaps, resolveKey } from '../../lib/tools/fs/scope.js';
|
|
7
10
|
const STATE_DIR = '"$__qvac_dir"';
|
|
8
11
|
const SHELL_TIMEOUT_MS = 300_000;
|
|
9
12
|
const MAX_TIMEOUT_MS = 1_800_000;
|
|
@@ -11,7 +14,7 @@ const NO_WORKSPACE = 'the coding tools need one writable directory granted to th
|
|
|
11
14
|
const DRIVE_WORKSPACE = 'the coding tools work in a local project folder, not a drive or a filesystem root';
|
|
12
15
|
const DENIED_WORKSPACE = 'the coding tools need a project folder that neither holds nor sits in a protected app folder';
|
|
13
16
|
const DRIVE_PATH = 'the coding tools take a local path inside the project, not a drive path';
|
|
14
|
-
const NOT_ISOLATED = '
|
|
17
|
+
const NOT_ISOLATED = 'the network is off and this sandbox is not isolated, so the coding tools are off';
|
|
15
18
|
const BUDGET_SPENT = 'run wall-clock budget exhausted; no time remains for this call';
|
|
16
19
|
export function guidance(error) {
|
|
17
20
|
return { error, guidance: true };
|
|
@@ -24,7 +27,7 @@ export function shellQuote(text) {
|
|
|
24
27
|
}
|
|
25
28
|
export function errorText(error) {
|
|
26
29
|
if (error instanceof Error) {
|
|
27
|
-
return error.name === 'AbortError' || error
|
|
30
|
+
return error.name === 'AbortError' || HarnessError.is(error, 'ABORTED')
|
|
28
31
|
? 'command aborted'
|
|
29
32
|
: error.message;
|
|
30
33
|
}
|
|
@@ -44,7 +47,7 @@ function workspaceRoot(ctx) {
|
|
|
44
47
|
}
|
|
45
48
|
return root;
|
|
46
49
|
}
|
|
47
|
-
|
|
50
|
+
async function workspaceKey(root, input) {
|
|
48
51
|
if (input.includes('://')) {
|
|
49
52
|
return { error: DRIVE_PATH };
|
|
50
53
|
}
|
|
@@ -89,25 +92,37 @@ export class CodingSession {
|
|
|
89
92
|
_bind;
|
|
90
93
|
_workspaces;
|
|
91
94
|
_runs;
|
|
95
|
+
_keys;
|
|
96
|
+
_moved;
|
|
92
97
|
constructor(sandbox, deniedRoots = []) {
|
|
93
98
|
this.sandbox = sandbox;
|
|
94
99
|
this.deniedRoots = deniedRoots;
|
|
95
100
|
this._bind = `__qvac_dir="\${TMPDIR:-/tmp}"/qvac-coding-${b4a.toHex(randomBytes(8))}`;
|
|
96
101
|
this._workspaces = new Map();
|
|
97
102
|
this._runs = new Map();
|
|
103
|
+
this._keys = new Map();
|
|
104
|
+
this._moved = new Set();
|
|
98
105
|
}
|
|
99
|
-
effect(ctx) {
|
|
106
|
+
effect(ctx, args) {
|
|
107
|
+
const root = ctx?.fsWriteRoots?.[0];
|
|
108
|
+
const line = args?.command;
|
|
109
|
+
const fresh = !args?.cwd && !this._moved.has(ctx?.runId ?? '');
|
|
110
|
+
if (typeof line === 'string' && fresh && root?.kind === 'local' && readsOnly(line, root.root)) {
|
|
111
|
+
return 'read';
|
|
112
|
+
}
|
|
100
113
|
return ctx?.planMode || !this.sandbox.isolated ? 'write' : 'read';
|
|
101
114
|
}
|
|
102
115
|
refusal(ctx) {
|
|
103
|
-
return ctx?.
|
|
116
|
+
return ctx?.policy?.network.mode === 'off' && !this.sandbox.isolated
|
|
117
|
+
? guidance(NOT_ISOLATED)
|
|
118
|
+
: null;
|
|
104
119
|
}
|
|
105
120
|
async workspace(ctx) {
|
|
106
121
|
const root = this.refusal(ctx) ?? workspaceRoot(ctx);
|
|
107
122
|
if (isError(root)) {
|
|
108
123
|
return root;
|
|
109
124
|
}
|
|
110
|
-
const deny = await
|
|
125
|
+
const deny = await callDenyRoots(this.deniedRoots, ctx?.policy, defaultRealpath);
|
|
111
126
|
return deny.some((each) => overlaps(root.root, each)) ? guidance(DENIED_WORKSPACE) : root;
|
|
112
127
|
}
|
|
113
128
|
policyVersion() {
|
|
@@ -120,19 +135,21 @@ export class CodingSession {
|
|
|
120
135
|
statePath(runId) {
|
|
121
136
|
return `${STATE_DIR}/${b4a.toHex(b4a.from(runId))}`;
|
|
122
137
|
}
|
|
123
|
-
open(root, runId) {
|
|
138
|
+
open(root, runId, policy) {
|
|
139
|
+
const key = `${root.root}\0${JSON.stringify(policy)}`;
|
|
124
140
|
this._runs.set(runId, root.root);
|
|
125
|
-
|
|
141
|
+
this._keys.set(runId, key);
|
|
142
|
+
let workspace = this._workspaces.get(key);
|
|
126
143
|
if (!workspace) {
|
|
127
|
-
workspace = this.sandbox.open(root.root);
|
|
128
|
-
workspace.catch(() => this._workspaces.delete(
|
|
129
|
-
this._workspaces.set(
|
|
144
|
+
workspace = this.sandbox.open(root.root, policy);
|
|
145
|
+
workspace.catch(() => this._workspaces.delete(key));
|
|
146
|
+
this._workspaces.set(key, workspace);
|
|
130
147
|
}
|
|
131
148
|
return workspace;
|
|
132
149
|
}
|
|
133
150
|
workspaceOf(runId) {
|
|
134
|
-
const
|
|
135
|
-
return
|
|
151
|
+
const key = this._keys.get(runId);
|
|
152
|
+
return key === undefined ? null : (this._workspaces.get(key) ?? null);
|
|
136
153
|
}
|
|
137
154
|
_prelude(runId) {
|
|
138
155
|
return [
|
|
@@ -144,6 +161,7 @@ export class CodingSession {
|
|
|
144
161
|
];
|
|
145
162
|
}
|
|
146
163
|
exec({ workspace, runId, line }, { timeoutMs, signal } = {}) {
|
|
164
|
+
this._moves(runId, line);
|
|
147
165
|
const script = [
|
|
148
166
|
...this._prelude(runId),
|
|
149
167
|
'__qvac_save() {',
|
|
@@ -157,10 +175,16 @@ export class CodingSession {
|
|
|
157
175
|
].join('\n');
|
|
158
176
|
return workspace.exec(script, { cwd: this._runs.get(runId), timeoutMs, signal });
|
|
159
177
|
}
|
|
178
|
+
_moves(runId, line) {
|
|
179
|
+
if (!readsOnly(line)) {
|
|
180
|
+
this._moved.add(runId);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
160
183
|
jobLog(id) {
|
|
161
184
|
return `${STATE_DIR}/jobs/${id}.log`;
|
|
162
185
|
}
|
|
163
186
|
start({ workspace, runId, line }, id) {
|
|
187
|
+
this._moves(runId, line);
|
|
164
188
|
const job = shellQuote(`trap wait EXIT\n${line}`);
|
|
165
189
|
const script = [...this._prelude(runId), `exec sh -c ${job} > ${this.jobLog(id)} 2>&1`];
|
|
166
190
|
return workspace.start(script.join('\n'), { cwd: this._runs.get(runId) });
|
|
@@ -171,6 +195,8 @@ export class CodingSession {
|
|
|
171
195
|
async endRun(runId) {
|
|
172
196
|
const workspace = this.workspaceOf(runId);
|
|
173
197
|
this._runs.delete(runId);
|
|
198
|
+
this._keys.delete(runId);
|
|
199
|
+
this._moved.delete(runId);
|
|
174
200
|
if (workspace) {
|
|
175
201
|
const state = this.statePath(runId);
|
|
176
202
|
await this.execState(await workspace, `rm -f ${state}.env ${state}.cwd ${state}.tmp`);
|
|
@@ -180,6 +206,7 @@ export class CodingSession {
|
|
|
180
206
|
const workspaces = await Promise.allSettled(this._workspaces.values());
|
|
181
207
|
this._workspaces.clear();
|
|
182
208
|
this._runs.clear();
|
|
209
|
+
this._keys.clear();
|
|
183
210
|
await Promise.allSettled(workspaces.map(async (each) => {
|
|
184
211
|
if (each.status !== 'fulfilled')
|
|
185
212
|
return;
|
|
@@ -233,7 +260,8 @@ async function runShell({ session, start }, args, ctx) {
|
|
|
233
260
|
}
|
|
234
261
|
const runId = ctx?.runId ?? '';
|
|
235
262
|
try {
|
|
236
|
-
const
|
|
263
|
+
const policy = ctx?.policy ?? Policy.compile(undefined, { write: [root.root] });
|
|
264
|
+
const call = { workspace: await session.open(root, runId, policy), runId, line };
|
|
237
265
|
if (args.background === true) {
|
|
238
266
|
return await start(call);
|
|
239
267
|
}
|
|
@@ -251,8 +279,9 @@ export function shellTool(options) {
|
|
|
251
279
|
policyVersion: session.policyVersion(),
|
|
252
280
|
description: SHELL_DESCRIPTION,
|
|
253
281
|
parameters: SHELL_PARAMETERS,
|
|
254
|
-
effect: (
|
|
282
|
+
effect: (args, ctx) => session.effect(ctx, args),
|
|
255
283
|
quote: (args) => (typeof args.command === 'string' ? args.command : null),
|
|
284
|
+
command: (args) => (typeof args.command === 'string' ? args.command : null),
|
|
256
285
|
validate(args) {
|
|
257
286
|
return typeof args.command === 'string' && args.command.trim()
|
|
258
287
|
? null
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HarnessPlugin, PluginSetup } from '../../lib/plugins/index.ts';
|
|
2
|
+
export interface CodingGuardsOptions {
|
|
3
|
+
sameWrite?: boolean | string;
|
|
4
|
+
promptNote?: boolean | string;
|
|
5
|
+
noRunner?: boolean | string;
|
|
6
|
+
}
|
|
7
|
+
export declare const SAME_WRITE: string;
|
|
8
|
+
export declare const PROMPT_NOTE: string;
|
|
9
|
+
export declare const NO_RUNNER: string;
|
|
10
|
+
export declare class CodingGuards implements HarnessPlugin {
|
|
11
|
+
readonly name = "coding-guards";
|
|
12
|
+
readonly api = 1;
|
|
13
|
+
private readonly _sameWrite;
|
|
14
|
+
private readonly _promptNote;
|
|
15
|
+
private readonly _noRunner;
|
|
16
|
+
private readonly _written;
|
|
17
|
+
constructor(options?: CodingGuardsOptions);
|
|
18
|
+
setup(): PluginSetup;
|
|
19
|
+
private readonly _prompt;
|
|
20
|
+
private _run;
|
|
21
|
+
private _pre;
|
|
22
|
+
private readonly _post;
|
|
23
|
+
private readonly _failure;
|
|
24
|
+
private readonly _end;
|
|
25
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { isRecord } from '../../lib/guards.js';
|
|
3
|
+
import { PluginRegistry } from '../../lib/plugins/index.js';
|
|
4
|
+
export const SAME_WRITE = 'This run already wrote exactly this content to {path}, so this call would repeat that write. ' +
|
|
5
|
+
'Work out what is still wrong from the task or the errors, then change that.';
|
|
6
|
+
export const PROMPT_NOTE = 'If this message reports failing tests or errors, first write one line per failure: the ' +
|
|
7
|
+
'test, what it expected, what the code did, and why. Then fix the causes, not each symptom.';
|
|
8
|
+
export const NO_RUNNER = 'Nothing can be built, compiled, run or tested in this session. Check your work by reasoning ' +
|
|
9
|
+
'from the code and the task.';
|
|
10
|
+
const CHANGES = new Set([
|
|
11
|
+
'edit_file',
|
|
12
|
+
'insert_text',
|
|
13
|
+
'edit_many',
|
|
14
|
+
'move_file',
|
|
15
|
+
'trash_file',
|
|
16
|
+
'copy_file',
|
|
17
|
+
'shell',
|
|
18
|
+
'exec'
|
|
19
|
+
]);
|
|
20
|
+
export class CodingGuards {
|
|
21
|
+
name = 'coding-guards';
|
|
22
|
+
api = PluginRegistry.API_VERSION;
|
|
23
|
+
_sameWrite;
|
|
24
|
+
_promptNote;
|
|
25
|
+
_noRunner;
|
|
26
|
+
_written = new Map();
|
|
27
|
+
constructor(options = {}) {
|
|
28
|
+
this._sameWrite = wording(options.sameWrite, SAME_WRITE);
|
|
29
|
+
this._promptNote = wording(options.promptNote, PROMPT_NOTE);
|
|
30
|
+
this._noRunner = wording(options.noRunner, NO_RUNNER);
|
|
31
|
+
}
|
|
32
|
+
setup() {
|
|
33
|
+
const hooks = [];
|
|
34
|
+
if (this._sameWrite) {
|
|
35
|
+
const refusal = this._sameWrite;
|
|
36
|
+
hooks.push({
|
|
37
|
+
name: 'coding-guards',
|
|
38
|
+
phase: 'preToolCall',
|
|
39
|
+
matcher: 'write_file',
|
|
40
|
+
run: (ctx) => this._pre(ctx, refusal)
|
|
41
|
+
}, { name: 'coding-guards', phase: 'postToolCall', run: this._post }, { name: 'coding-guards', phase: 'toolFailure', run: this._failure }, { name: 'coding-guards', phase: 'runEnd', run: this._end });
|
|
42
|
+
}
|
|
43
|
+
if (this._promptNote || this._noRunner) {
|
|
44
|
+
hooks.push({ name: 'coding-guards', phase: 'promptSubmit', run: this._prompt });
|
|
45
|
+
}
|
|
46
|
+
return { hooks };
|
|
47
|
+
}
|
|
48
|
+
_prompt = (ctx) => {
|
|
49
|
+
if (ctx.phase !== 'promptSubmit' || ctx.mode !== 'prompt')
|
|
50
|
+
return;
|
|
51
|
+
const notes = [this._noRunner, this._promptNote].filter((note) => note !== null);
|
|
52
|
+
return { context: notes.join('\n\n') };
|
|
53
|
+
};
|
|
54
|
+
_run(runId) {
|
|
55
|
+
let written = this._written.get(runId);
|
|
56
|
+
if (!written) {
|
|
57
|
+
written = new Map();
|
|
58
|
+
this._written.set(runId, written);
|
|
59
|
+
}
|
|
60
|
+
return written;
|
|
61
|
+
}
|
|
62
|
+
_pre(ctx, refusal) {
|
|
63
|
+
if (ctx.phase !== 'preToolCall')
|
|
64
|
+
return;
|
|
65
|
+
const { path, content } = writeArgs(ctx);
|
|
66
|
+
if (path !== null && this._run(ctx.runId).get(clean(path)) === content) {
|
|
67
|
+
return refuse(refusal, path);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
_post = (ctx) => {
|
|
71
|
+
if (ctx.phase !== 'postToolCall')
|
|
72
|
+
return;
|
|
73
|
+
const written = this._run(ctx.runId);
|
|
74
|
+
if (!succeeded(ctx)) {
|
|
75
|
+
if (ctx.toolName === 'write_file' || CHANGES.has(ctx.toolName)) {
|
|
76
|
+
written.clear();
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (ctx.toolName === 'write_file') {
|
|
81
|
+
const { path, content } = writeArgs(ctx);
|
|
82
|
+
if (path !== null) {
|
|
83
|
+
written.set(clean(path), content);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else if (CHANGES.has(ctx.toolName)) {
|
|
87
|
+
written.clear();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
_failure = (ctx) => {
|
|
91
|
+
if (ctx.phase !== 'toolFailure' || !ctx.executed)
|
|
92
|
+
return;
|
|
93
|
+
if (ctx.toolName === 'write_file' || CHANGES.has(ctx.toolName)) {
|
|
94
|
+
this._run(ctx.runId).clear();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
_end = (ctx) => {
|
|
98
|
+
this._written.delete(ctx.runId);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function clean(requested) {
|
|
102
|
+
if (requested.startsWith('hyper://')) {
|
|
103
|
+
return `hyper:${requested}`;
|
|
104
|
+
}
|
|
105
|
+
const normalized = path.normalize(requested);
|
|
106
|
+
return `${path.isAbsolute(requested) ? 'absolute' : 'relative'}:${normalized}`;
|
|
107
|
+
}
|
|
108
|
+
function wording(option, text) {
|
|
109
|
+
if (!option)
|
|
110
|
+
return null;
|
|
111
|
+
return option === true ? text : option;
|
|
112
|
+
}
|
|
113
|
+
function refuse(text, path) {
|
|
114
|
+
return { kind: 'hook-rejection', error: text.replaceAll('{path}', path), guidance: true };
|
|
115
|
+
}
|
|
116
|
+
function writeArgs(ctx) {
|
|
117
|
+
const { path, content } = ctx.args;
|
|
118
|
+
return typeof path === 'string' && typeof content === 'string'
|
|
119
|
+
? { path, content }
|
|
120
|
+
: { path: null, content: '' };
|
|
121
|
+
}
|
|
122
|
+
function succeeded(ctx) {
|
|
123
|
+
return (ctx.executed &&
|
|
124
|
+
ctx.outcome?.kind === 'success' &&
|
|
125
|
+
!(isRecord(ctx.result) && 'error' in ctx.result));
|
|
126
|
+
}
|
|
@@ -3,7 +3,7 @@ import { spawn } from 'child_process';
|
|
|
3
3
|
import process from 'process';
|
|
4
4
|
import { errorMessage, isRecord } from '../../lib/guards.js';
|
|
5
5
|
import { execEnv } from '../../lib/helpers/spawn-path.js';
|
|
6
|
-
import {
|
|
6
|
+
import { HarnessLog } from '../../lib/log.js';
|
|
7
7
|
import { PluginRegistry } from '../../lib/plugins/index.js';
|
|
8
8
|
const DEFAULT_TIMEOUT_S = 60;
|
|
9
9
|
const STDERR_TAIL = 2_000;
|
|
@@ -120,7 +120,7 @@ function blocked(event, reason) {
|
|
|
120
120
|
case 'Stop':
|
|
121
121
|
return { continue: said };
|
|
122
122
|
case 'PreCompact':
|
|
123
|
-
|
|
123
|
+
HarnessLog.info('PreCompact hook exited 2; a fold cannot be blocked', { reason: said });
|
|
124
124
|
return undefined;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -291,7 +291,9 @@ export class CommandHooks {
|
|
|
291
291
|
const config = this._hooks;
|
|
292
292
|
const skipped = Object.keys(config).filter(isSkipped);
|
|
293
293
|
if (skipped.length) {
|
|
294
|
-
|
|
294
|
+
HarnessLog.info('command-hooks: these events have no harness phase and never run', {
|
|
295
|
+
events: skipped
|
|
296
|
+
});
|
|
295
297
|
}
|
|
296
298
|
const commands = Object.entries(config).flatMap(([event, entries = []]) => isEvent(event) ? commandsOf(event, entries) : []);
|
|
297
299
|
const hooks = commands.map((spec) => ({
|