@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,26 @@
|
|
|
1
|
+
export type ShellConstructKind = 'chain' | 'ampersand' | 'pipe' | 'redirect-output' | 'redirect-input' | 'newline' | 'expansion' | 'backtick' | 'continuation' | 'process-substitution' | 'subshell' | 'group' | 'negation' | 'keyword' | 'function' | 'eval' | 'comment' | 'unterminated';
|
|
2
|
+
export interface ShellConstruct {
|
|
3
|
+
readonly kind: ShellConstructKind;
|
|
4
|
+
readonly at: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ShellRedirect {
|
|
7
|
+
readonly fd: string;
|
|
8
|
+
readonly op: string;
|
|
9
|
+
readonly target: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ShellCommand {
|
|
12
|
+
readonly argv: string[];
|
|
13
|
+
readonly expands: boolean[];
|
|
14
|
+
readonly assignments: string[];
|
|
15
|
+
readonly redirects: ShellRedirect[];
|
|
16
|
+
}
|
|
17
|
+
export declare class ShellLine {
|
|
18
|
+
#private;
|
|
19
|
+
readonly commands: ShellCommand[];
|
|
20
|
+
readonly ops: string[];
|
|
21
|
+
readonly constructs: ShellConstruct[];
|
|
22
|
+
readonly unjudgeable: string | null;
|
|
23
|
+
constructor(line: string);
|
|
24
|
+
static parse(line: string): ShellLine;
|
|
25
|
+
static escape(value: string): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
const UNJUDGEABLE = {
|
|
2
|
+
expansion: '$ expansion',
|
|
3
|
+
backtick: 'backtick substitution',
|
|
4
|
+
'process-substitution': 'process substitution',
|
|
5
|
+
subshell: 'subshell',
|
|
6
|
+
group: '{ } group',
|
|
7
|
+
negation: '! negation',
|
|
8
|
+
keyword: 'shell keyword',
|
|
9
|
+
function: 'function definition',
|
|
10
|
+
eval: 'eval, ., source, trap or a builtin given $ or `',
|
|
11
|
+
comment: 'comment',
|
|
12
|
+
unterminated: 'unterminated quote'
|
|
13
|
+
};
|
|
14
|
+
const KEYWORDS = [
|
|
15
|
+
'if',
|
|
16
|
+
'then',
|
|
17
|
+
'else',
|
|
18
|
+
'elif',
|
|
19
|
+
'fi',
|
|
20
|
+
'for',
|
|
21
|
+
'while',
|
|
22
|
+
'until',
|
|
23
|
+
'do',
|
|
24
|
+
'done',
|
|
25
|
+
'case',
|
|
26
|
+
'esac',
|
|
27
|
+
'in',
|
|
28
|
+
'select',
|
|
29
|
+
'function',
|
|
30
|
+
'[['
|
|
31
|
+
];
|
|
32
|
+
const RESERVED = new Map([
|
|
33
|
+
['{', 'group'],
|
|
34
|
+
['}', 'group'],
|
|
35
|
+
['!', 'negation'],
|
|
36
|
+
...KEYWORDS.map((word) => [word, 'keyword'])
|
|
37
|
+
]);
|
|
38
|
+
const REINTERPRETS = new Set(['eval', '.', 'source', 'trap']);
|
|
39
|
+
const SUBSCRIPTS = new Set([
|
|
40
|
+
'let',
|
|
41
|
+
'declare',
|
|
42
|
+
'typeset',
|
|
43
|
+
'local',
|
|
44
|
+
'export',
|
|
45
|
+
'readonly',
|
|
46
|
+
'read',
|
|
47
|
+
'unset'
|
|
48
|
+
]);
|
|
49
|
+
const SEPARATORS = [
|
|
50
|
+
['&&', 'ampersand'],
|
|
51
|
+
['||', 'pipe'],
|
|
52
|
+
['|&', 'pipe'],
|
|
53
|
+
[';', 'chain'],
|
|
54
|
+
['&', 'ampersand'],
|
|
55
|
+
['|', 'pipe']
|
|
56
|
+
];
|
|
57
|
+
const REDIRECTS = [
|
|
58
|
+
['&>>', 'ampersand'],
|
|
59
|
+
['&>', 'ampersand'],
|
|
60
|
+
['<<<', 'redirect-input'],
|
|
61
|
+
['<<-', 'redirect-input'],
|
|
62
|
+
['<<', 'redirect-input'],
|
|
63
|
+
['<>', 'redirect-input'],
|
|
64
|
+
['<&', 'redirect-input'],
|
|
65
|
+
['>>', 'redirect-output'],
|
|
66
|
+
['>|', 'redirect-output'],
|
|
67
|
+
['>&', 'redirect-output'],
|
|
68
|
+
['<', 'redirect-input'],
|
|
69
|
+
['>', 'redirect-output']
|
|
70
|
+
];
|
|
71
|
+
const ASSIGNMENT = /^[A-Za-z_]\w*(\[[^\]]*\])?\+?=/;
|
|
72
|
+
const BLANK = /^[ \t\n]*$/;
|
|
73
|
+
const FD = /^\d+$/;
|
|
74
|
+
const GLOB = /[*?]|\[[^\]]*\]/;
|
|
75
|
+
const BRACE_LIST = /\{[^{}]*(,|\.\.)[^{}]*\}/;
|
|
76
|
+
const QUOTED = '\0';
|
|
77
|
+
function emptyCommand() {
|
|
78
|
+
return { argv: [], expands: [], assignments: [], redirects: [] };
|
|
79
|
+
}
|
|
80
|
+
function expands(unquoted) {
|
|
81
|
+
return GLOB.test(unquoted) || unquoted.startsWith('~') || BRACE_LIST.test(unquoted);
|
|
82
|
+
}
|
|
83
|
+
function evaluates(argv) {
|
|
84
|
+
const [program = '', ...rest] = argv;
|
|
85
|
+
const named = SUBSCRIPTS.has(program) || (program === 'printf' && rest.includes('-v'));
|
|
86
|
+
return named && rest.some((word) => /[$`]/.test(word));
|
|
87
|
+
}
|
|
88
|
+
export class ShellLine {
|
|
89
|
+
commands = [];
|
|
90
|
+
ops = [];
|
|
91
|
+
constructs = [];
|
|
92
|
+
unjudgeable;
|
|
93
|
+
#line;
|
|
94
|
+
#i = 0;
|
|
95
|
+
#start = 0;
|
|
96
|
+
#word = null;
|
|
97
|
+
#command = emptyCommand();
|
|
98
|
+
#redirect = null;
|
|
99
|
+
#reason = null;
|
|
100
|
+
constructor(line) {
|
|
101
|
+
this.#line = line;
|
|
102
|
+
while (this.#i < line.length) {
|
|
103
|
+
this.#step();
|
|
104
|
+
}
|
|
105
|
+
this.#endWord();
|
|
106
|
+
this.#endCommand();
|
|
107
|
+
this.constructs.sort((a, b) => a.at - b.at);
|
|
108
|
+
this.unjudgeable = this.#reason;
|
|
109
|
+
}
|
|
110
|
+
static parse(line) {
|
|
111
|
+
return new ShellLine(line);
|
|
112
|
+
}
|
|
113
|
+
static escape(value) {
|
|
114
|
+
return value.replace(/[ \t\\'"`$;&|<>(){}#!*?[\]~]/g, '\\$&').replaceAll('\n', "'\n'");
|
|
115
|
+
}
|
|
116
|
+
#step() {
|
|
117
|
+
const c = this.#line.charAt(this.#i);
|
|
118
|
+
if (this.#word === null) {
|
|
119
|
+
this.#start = this.#i;
|
|
120
|
+
}
|
|
121
|
+
if (c === ' ' || c === '\t') {
|
|
122
|
+
this.#endWord();
|
|
123
|
+
this.#i++;
|
|
124
|
+
}
|
|
125
|
+
else if (c === '\n') {
|
|
126
|
+
this.#newline();
|
|
127
|
+
}
|
|
128
|
+
else if (c === '#' && this.#word === null) {
|
|
129
|
+
this.#comment();
|
|
130
|
+
}
|
|
131
|
+
else if (c === '\\') {
|
|
132
|
+
this.#escaped();
|
|
133
|
+
}
|
|
134
|
+
else if (c === "'") {
|
|
135
|
+
this.#singleQuoted();
|
|
136
|
+
}
|
|
137
|
+
else if (c === '"') {
|
|
138
|
+
this.#doubleQuoted();
|
|
139
|
+
}
|
|
140
|
+
else if (c === '$' || c === '`') {
|
|
141
|
+
this.#mark(c === '$' ? 'expansion' : 'backtick', this.#i);
|
|
142
|
+
this.#bare(c);
|
|
143
|
+
}
|
|
144
|
+
else if (!this.#operator(c)) {
|
|
145
|
+
this.#bare(c);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
#operator(c) {
|
|
149
|
+
const rest = this.#line.slice(this.#i);
|
|
150
|
+
if (/^[<>]\(/.test(rest)) {
|
|
151
|
+
this.#endWord();
|
|
152
|
+
this.#mark('process-substitution', this.#i);
|
|
153
|
+
this.#i += 2;
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
const redirect = REDIRECTS.find(([op]) => rest.startsWith(op));
|
|
157
|
+
if (redirect) {
|
|
158
|
+
this.#redirectOp(redirect);
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
const separator = SEPARATORS.find(([op]) => rest.startsWith(op));
|
|
162
|
+
if (separator) {
|
|
163
|
+
this.#endWord();
|
|
164
|
+
this.#mark(separator[1], this.#i);
|
|
165
|
+
this.#separate(separator[0]);
|
|
166
|
+
this.#i += separator[0].length;
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
if (c === '(' || c === ')') {
|
|
170
|
+
this.#paren(c);
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
#redirectOp([op, kind]) {
|
|
176
|
+
const word = this.#word;
|
|
177
|
+
const fd = word !== null && FD.test(word.raw) ? word.text : '';
|
|
178
|
+
if (fd) {
|
|
179
|
+
this.#word = null;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
this.#endWord();
|
|
183
|
+
}
|
|
184
|
+
this.#mark(kind, this.#i);
|
|
185
|
+
if (op === '<<' || op === '<<-') {
|
|
186
|
+
this.#reason ??= 'heredoc';
|
|
187
|
+
}
|
|
188
|
+
this.#redirect = { fd, op };
|
|
189
|
+
this.#i += op.length;
|
|
190
|
+
}
|
|
191
|
+
#paren(c) {
|
|
192
|
+
const words = this.#command.argv.length + (this.#word === null ? 0 : 1);
|
|
193
|
+
this.#endWord();
|
|
194
|
+
const defines = c === '(' && words === 1 && /^\(\s*\)/.test(this.#line.slice(this.#i));
|
|
195
|
+
this.#mark(defines ? 'function' : 'subshell', this.#i);
|
|
196
|
+
this.#endCommand();
|
|
197
|
+
this.#i++;
|
|
198
|
+
}
|
|
199
|
+
#newline() {
|
|
200
|
+
this.#endWord();
|
|
201
|
+
if (BLANK.test(this.#line.slice(this.#i))) {
|
|
202
|
+
this.#i = this.#line.length;
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
this.#mark('newline', this.#i);
|
|
206
|
+
this.#separate('\n');
|
|
207
|
+
this.#i++;
|
|
208
|
+
}
|
|
209
|
+
#comment() {
|
|
210
|
+
this.#mark('comment', this.#i);
|
|
211
|
+
const end = this.#line.indexOf('\n', this.#i);
|
|
212
|
+
this.#i = end === -1 ? this.#line.length : end;
|
|
213
|
+
}
|
|
214
|
+
#escaped() {
|
|
215
|
+
const next = this.#line[this.#i + 1];
|
|
216
|
+
if (next === '\n') {
|
|
217
|
+
this.#mark('continuation', this.#i);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
this.#literal(next ?? '\\', this.#line.slice(this.#i, this.#i + 2));
|
|
221
|
+
}
|
|
222
|
+
this.#i += 2;
|
|
223
|
+
}
|
|
224
|
+
#singleQuoted() {
|
|
225
|
+
const end = this.#line.indexOf("'", this.#i + 1);
|
|
226
|
+
if (end === -1) {
|
|
227
|
+
this.#mark('unterminated', this.#i);
|
|
228
|
+
}
|
|
229
|
+
const stop = end === -1 ? this.#line.length : end;
|
|
230
|
+
this.#literal(this.#line.slice(this.#i + 1, stop), this.#line.slice(this.#i, stop + 1));
|
|
231
|
+
this.#i = stop + 1;
|
|
232
|
+
}
|
|
233
|
+
#doubleQuoted() {
|
|
234
|
+
const open = this.#i;
|
|
235
|
+
let text = '';
|
|
236
|
+
this.#i++;
|
|
237
|
+
while (this.#i < this.#line.length && this.#line[this.#i] !== '"') {
|
|
238
|
+
text += this.#quotedChar();
|
|
239
|
+
}
|
|
240
|
+
if (this.#i >= this.#line.length) {
|
|
241
|
+
this.#mark('unterminated', open);
|
|
242
|
+
}
|
|
243
|
+
this.#i++;
|
|
244
|
+
this.#literal(text, this.#line.slice(open, this.#i));
|
|
245
|
+
}
|
|
246
|
+
#quotedChar() {
|
|
247
|
+
const c = this.#line.charAt(this.#i);
|
|
248
|
+
if (c === '\\') {
|
|
249
|
+
const next = this.#line[this.#i + 1];
|
|
250
|
+
if (next === '\n') {
|
|
251
|
+
this.#mark('continuation', this.#i);
|
|
252
|
+
}
|
|
253
|
+
this.#i += 2;
|
|
254
|
+
if (next === undefined || next === '\n') {
|
|
255
|
+
return next === undefined ? c : '';
|
|
256
|
+
}
|
|
257
|
+
return '$`"\\'.includes(next) ? next : c + next;
|
|
258
|
+
}
|
|
259
|
+
if (c === '$' || c === '`') {
|
|
260
|
+
this.#mark(c === '$' ? 'expansion' : 'backtick', this.#i);
|
|
261
|
+
}
|
|
262
|
+
this.#i++;
|
|
263
|
+
return c;
|
|
264
|
+
}
|
|
265
|
+
#literal(text, raw) {
|
|
266
|
+
const word = this.#open();
|
|
267
|
+
word.text += text;
|
|
268
|
+
word.raw += raw;
|
|
269
|
+
word.unquoted += QUOTED.repeat(text.length);
|
|
270
|
+
word.plain = false;
|
|
271
|
+
}
|
|
272
|
+
#bare(c) {
|
|
273
|
+
const word = this.#open();
|
|
274
|
+
word.text += c;
|
|
275
|
+
word.raw += c;
|
|
276
|
+
word.unquoted += c;
|
|
277
|
+
this.#i++;
|
|
278
|
+
}
|
|
279
|
+
#open() {
|
|
280
|
+
this.#word ??= { text: '', raw: '', unquoted: '', plain: true };
|
|
281
|
+
return this.#word;
|
|
282
|
+
}
|
|
283
|
+
#endWord() {
|
|
284
|
+
const word = this.#word;
|
|
285
|
+
this.#word = null;
|
|
286
|
+
if (word === null) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (this.#redirect) {
|
|
290
|
+
this.#command.redirects.push({ ...this.#redirect, target: word.text });
|
|
291
|
+
this.#redirect = null;
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (this.#command.argv.length === 0 && this.#prefix(word)) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (this.#command.argv.length === 0 && REINTERPRETS.has(word.text)) {
|
|
298
|
+
this.#mark('eval', this.#start);
|
|
299
|
+
}
|
|
300
|
+
this.#command.argv.push(word.text);
|
|
301
|
+
this.#command.expands.push(expands(word.unquoted));
|
|
302
|
+
}
|
|
303
|
+
#prefix(word) {
|
|
304
|
+
if (ASSIGNMENT.test(word.raw)) {
|
|
305
|
+
this.#command.assignments.push(word.text);
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
const kind = word.plain ? RESERVED.get(word.text) : undefined;
|
|
309
|
+
if (kind) {
|
|
310
|
+
this.#mark(kind, this.#start);
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
#separate(op) {
|
|
316
|
+
this.#endCommand();
|
|
317
|
+
this.ops.push(op);
|
|
318
|
+
}
|
|
319
|
+
#endCommand() {
|
|
320
|
+
const { argv, assignments, redirects } = this.#command;
|
|
321
|
+
if (evaluates(argv)) {
|
|
322
|
+
this.#mark('eval', this.#start);
|
|
323
|
+
}
|
|
324
|
+
if (argv.length > 0 || assignments.length > 0 || redirects.length > 0) {
|
|
325
|
+
this.commands.push(this.#command);
|
|
326
|
+
}
|
|
327
|
+
this.#command = emptyCommand();
|
|
328
|
+
this.#redirect = null;
|
|
329
|
+
}
|
|
330
|
+
#mark(kind, at) {
|
|
331
|
+
this.constructs.push({ kind, at });
|
|
332
|
+
this.#reason ??= UNJUDGEABLE[kind] ?? null;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
@@ -13,8 +13,11 @@ export interface ExecToolOptions {
|
|
|
13
13
|
readonly languages?: readonly ExecLanguage[];
|
|
14
14
|
readonly routes?: readonly ExecRoute[];
|
|
15
15
|
readonly skillSettings?: SkillSettingsFn;
|
|
16
|
+
readonly skillEnv?: SkillEnvFn;
|
|
16
17
|
readonly realpath?: Realpath;
|
|
17
18
|
readonly deniedRoots?: readonly string[];
|
|
18
19
|
readonly skillsDir?: string;
|
|
19
20
|
}
|
|
20
|
-
export
|
|
21
|
+
export type SkillEnvFn = (skill: string) => Readonly<Record<string, string>> | undefined;
|
|
22
|
+
export declare function declaredEnv(declared: Readonly<Record<string, string>> | undefined, session: string | undefined): Record<string, string>;
|
|
23
|
+
export declare function createExecTool({ policyVersion, spawn, killProcess, shell: composedShell, languages, routes, skillSettings, skillEnv, realpath, deniedRoots, skillsDir }?: ExecToolOptions): ToolDefinition;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createHash } from 'crypto';
|
|
2
|
+
import { Policy } from '../policy/index.js';
|
|
2
3
|
import { AbortedError } from '../helpers/race-abort.js';
|
|
3
4
|
import { createShellAdapter } from './exec/adapters/shell/shell-adapter.js';
|
|
4
5
|
import { isPythonLanguage } from './exec/python-source.js';
|
|
5
|
-
import { MAX_OUTPUT_CHARS_LIMIT } from './exec/runner.js';
|
|
6
|
-
import { bareBin,
|
|
6
|
+
import { MAX_OUTPUT_CHARS, MAX_OUTPUT_CHARS_LIMIT } from './exec/runner.js';
|
|
7
|
+
import { bareBin, sanitizeCommand } from './exec/scope.js';
|
|
7
8
|
import { LANGUAGE_UNAVAILABLE_ERROR, PYTHON_UNAVAILABLE_ERROR, SHELL_DOWNLOAD_NOTE, shellOnlyError, videoToolError } from './exec/shell-guidance.js';
|
|
8
|
-
import {
|
|
9
|
+
import { ShellLine } from './exec/shell-line.js';
|
|
9
10
|
import { bareRuntime } from './exec/bare-runtime.js';
|
|
10
11
|
import { canonicalDenyRoots, defaultRealpath, hostPath, resolveKey } from './fs/scope.js';
|
|
11
12
|
import { settingsEnv } from './skills/skill-settings.js';
|
|
@@ -19,29 +20,61 @@ function parsePositiveInt(value, name, max) {
|
|
|
19
20
|
}
|
|
20
21
|
return n;
|
|
21
22
|
}
|
|
22
|
-
function resolveShellOps(
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
function resolveShellOps(line, toolOps) {
|
|
24
|
+
const [program = '', ...argv] = line.commands[0]?.argv ?? [];
|
|
25
|
+
const bin = bareBin(program);
|
|
26
|
+
return { ops: (bin ? toolOps?.get(bin) : undefined) ?? [], argv };
|
|
25
27
|
}
|
|
26
28
|
function checkShellScope(command, toolOps) {
|
|
27
29
|
const unsafe = sanitizeCommand(command);
|
|
28
30
|
if (unsafe) {
|
|
29
31
|
return unsafe;
|
|
30
32
|
}
|
|
31
|
-
const { ops, argv } = resolveShellOps(command, toolOps);
|
|
33
|
+
const { ops, argv } = resolveShellOps(ShellLine.parse(command), toolOps);
|
|
32
34
|
if (ops.length === 0) {
|
|
33
35
|
return null;
|
|
34
36
|
}
|
|
35
37
|
return checkCliOps(argv, ops);
|
|
36
38
|
}
|
|
37
39
|
function shellEffect(command, toolOps) {
|
|
38
|
-
const
|
|
40
|
+
const line = ShellLine.parse(command);
|
|
41
|
+
const [first] = line.commands;
|
|
42
|
+
if (line.unjudgeable ||
|
|
43
|
+
line.ops.length > 0 ||
|
|
44
|
+
first?.redirects.length ||
|
|
45
|
+
first?.assignments.length) {
|
|
46
|
+
return 'write';
|
|
47
|
+
}
|
|
48
|
+
const { ops, argv } = resolveShellOps(line, toolOps);
|
|
39
49
|
const matched = ops.filter((op) => op.check(argv) === null);
|
|
40
50
|
if (matched.length === 0) {
|
|
41
51
|
return 'write';
|
|
42
52
|
}
|
|
43
53
|
return matched.every((op) => op.annotation(argv) === 'read') ? 'read' : 'write';
|
|
44
54
|
}
|
|
55
|
+
function shellOutputCap(command, toolOps) {
|
|
56
|
+
const { ops, argv } = resolveShellOps(ShellLine.parse(command), toolOps);
|
|
57
|
+
const caps = ops.map((op) => op.outputCap(argv)).filter((cap) => cap !== undefined);
|
|
58
|
+
return caps.length > 0 ? Math.min(...caps) : undefined;
|
|
59
|
+
}
|
|
60
|
+
const CUT_MARKER = /(…\[\d+ chars omitted[^\]]*)\]…/;
|
|
61
|
+
function noteCeiling(result, ceiling) {
|
|
62
|
+
if (!result || typeof result !== 'object')
|
|
63
|
+
return result;
|
|
64
|
+
const out = { ...result };
|
|
65
|
+
for (const stream of ['stdout', 'stderr']) {
|
|
66
|
+
const text = out[stream];
|
|
67
|
+
if (typeof text === 'string') {
|
|
68
|
+
out[stream] = text.replace(CUT_MARKER, `$1; this skill limits this command to ${ceiling} characters, a larger maxOutputChars does not apply]…`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
function cappedOutput(requested, ceiling) {
|
|
74
|
+
if (ceiling === undefined)
|
|
75
|
+
return requested;
|
|
76
|
+
return Math.min(requested ?? MAX_OUTPUT_CHARS, ceiling);
|
|
77
|
+
}
|
|
45
78
|
function stringList(value) {
|
|
46
79
|
if (!Array.isArray(value))
|
|
47
80
|
return undefined;
|
|
@@ -104,17 +137,32 @@ function checkExecutionScope(args, language, { toolOps, sandbox, languages }) {
|
|
|
104
137
|
shellOnlyError(command) ??
|
|
105
138
|
checkShellScope(command, toolOps));
|
|
106
139
|
}
|
|
107
|
-
async function skillsEnv(skillSettings, ctx) {
|
|
140
|
+
async function skillsEnv(skillSettings, skillEnv, ctx) {
|
|
108
141
|
const skills = ctx?.skills ?? [];
|
|
109
142
|
if (skills.length === 0) {
|
|
110
143
|
return undefined;
|
|
111
144
|
}
|
|
112
145
|
const env = {};
|
|
113
146
|
for (const skill of skills) {
|
|
114
|
-
|
|
147
|
+
if (skillSettings) {
|
|
148
|
+
Object.assign(env, settingsEnv(skill, await skillSettings(skill, ctx?.agentId)));
|
|
149
|
+
}
|
|
150
|
+
Object.assign(env, declaredEnv(skillEnv?.(skill), ctx?.session));
|
|
115
151
|
}
|
|
116
152
|
return Object.keys(env).length > 0 ? env : undefined;
|
|
117
153
|
}
|
|
154
|
+
export function declaredEnv(declared, session) {
|
|
155
|
+
const env = {};
|
|
156
|
+
for (const [name, value] of Object.entries(declared ?? {})) {
|
|
157
|
+
if (!value.includes('${session}')) {
|
|
158
|
+
env[name] = value;
|
|
159
|
+
}
|
|
160
|
+
else if (session) {
|
|
161
|
+
env[name] = value.replaceAll('${session}', session);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return env;
|
|
165
|
+
}
|
|
118
166
|
function execSchema(languages) {
|
|
119
167
|
const text = languages.map((language) => language.text);
|
|
120
168
|
const runs = (each) => text.map((t) => `, or ${each(t)}`).join('');
|
|
@@ -160,7 +208,7 @@ function execSchema(languages) {
|
|
|
160
208
|
},
|
|
161
209
|
maxOutputChars: {
|
|
162
210
|
type: 'number',
|
|
163
|
-
description: 'Optional stdout/stderr cap in characters (default 8192, max 65536); longer output keeps its start and end. Raise when reading long content, e.g. a full note.'
|
|
211
|
+
description: 'Optional stdout/stderr cap in characters (default 8192, max 65536); longer output keeps its start and end. Raise when reading long content, e.g. a full note. A skill may cap one of its commands lower; the truncation note says so, and raising this does not lift that cap.'
|
|
164
212
|
}
|
|
165
213
|
},
|
|
166
214
|
required: []
|
|
@@ -190,7 +238,7 @@ function execSchema(languages) {
|
|
|
190
238
|
}
|
|
191
239
|
};
|
|
192
240
|
}
|
|
193
|
-
export function createExecTool({ policyVersion, spawn, killProcess, shell: composedShell, languages = [], routes = [], skillSettings, realpath = defaultRealpath, deniedRoots, skillsDir } = {}) {
|
|
241
|
+
export function createExecTool({ policyVersion, spawn, killProcess, shell: composedShell, languages = [], routes = [], skillSettings, skillEnv, realpath = defaultRealpath, deniedRoots, skillsDir } = {}) {
|
|
194
242
|
const shell = composedShell ??
|
|
195
243
|
createShellAdapter({
|
|
196
244
|
spawn,
|
|
@@ -233,6 +281,12 @@ export function createExecTool({ policyVersion, spawn, killProcess, shell: compo
|
|
|
233
281
|
}
|
|
234
282
|
return shellEffect(String(call.args.command ?? '').trim(), ctx?.toolOps);
|
|
235
283
|
},
|
|
284
|
+
command(rawArgs) {
|
|
285
|
+
const call = resolveCall(rawArgs, languages);
|
|
286
|
+
return 'error' in call || call.language || call.bundled
|
|
287
|
+
? null
|
|
288
|
+
: String(call.args.command ?? '');
|
|
289
|
+
},
|
|
236
290
|
validate(args, ctx) {
|
|
237
291
|
const call = resolveCall(args, languages);
|
|
238
292
|
if ('error' in call) {
|
|
@@ -244,7 +298,7 @@ export function createExecTool({ policyVersion, spawn, killProcess, shell: compo
|
|
|
244
298
|
}
|
|
245
299
|
const { language } = call;
|
|
246
300
|
const rawArgs = run.args;
|
|
247
|
-
const sandbox = ctx?.
|
|
301
|
+
const sandbox = ctx?.policy?.network.mode === 'off';
|
|
248
302
|
const command = String(rawArgs.command ?? '').trim();
|
|
249
303
|
if (!command) {
|
|
250
304
|
return commandRequired(rawArgs, { sandbox }, language);
|
|
@@ -265,7 +319,8 @@ export function createExecTool({ policyVersion, spawn, killProcess, shell: compo
|
|
|
265
319
|
return language.validate(rawArgs, {
|
|
266
320
|
sandbox,
|
|
267
321
|
trusted: run.trusted,
|
|
268
|
-
toolNames: ctx?.toolNames
|
|
322
|
+
toolNames: ctx?.toolNames,
|
|
323
|
+
offeredTools: ctx?.offeredTools
|
|
269
324
|
});
|
|
270
325
|
}
|
|
271
326
|
return firstAnswer(languages, (each) => each.strays(rawArgs)) ?? shellStray(rawArgs);
|
|
@@ -285,7 +340,7 @@ export function createExecTool({ policyVersion, spawn, killProcess, shell: compo
|
|
|
285
340
|
}
|
|
286
341
|
const workdir = typeof args.workdir === 'string' && args.workdir.trim() ? args.workdir.trim() : null;
|
|
287
342
|
const body = call.language
|
|
288
|
-
? call.language.label(args, { sandbox: ctx?.
|
|
343
|
+
? call.language.label(args, { sandbox: ctx?.policy?.network.mode === 'off' })
|
|
289
344
|
: command;
|
|
290
345
|
return {
|
|
291
346
|
kind: 'command',
|
|
@@ -303,7 +358,7 @@ export function createExecTool({ policyVersion, spawn, killProcess, shell: compo
|
|
|
303
358
|
}
|
|
304
359
|
const { language } = call;
|
|
305
360
|
const rawArgs = run.args;
|
|
306
|
-
const sandbox = ctx?.
|
|
361
|
+
const sandbox = ctx?.policy?.network.mode === 'off';
|
|
307
362
|
const command = String(rawArgs.command ?? '').trim();
|
|
308
363
|
if (!command) {
|
|
309
364
|
return { error: commandRequired(rawArgs, { sandbox }, language) };
|
|
@@ -319,7 +374,8 @@ export function createExecTool({ policyVersion, spawn, killProcess, shell: compo
|
|
|
319
374
|
const workdir = rawArgs.workdir === undefined || rawArgs.workdir === null
|
|
320
375
|
? undefined
|
|
321
376
|
: String(rawArgs.workdir);
|
|
322
|
-
const
|
|
377
|
+
const policy = ctx?.policy ?? Policy.compile(undefined, { write: localRoots(ctx?.fsWriteRoots) });
|
|
378
|
+
const deny = await canonicalDenyRoots([...(deniedRoots ?? []), ...policy.files.deny], realpath);
|
|
323
379
|
let cwd = workdir;
|
|
324
380
|
if (workdir !== undefined && !language) {
|
|
325
381
|
const roots = ctx?.fsRoots ?? [];
|
|
@@ -354,10 +410,12 @@ export function createExecTool({ policyVersion, spawn, killProcess, shell: compo
|
|
|
354
410
|
timeout = Math.min(timeout, remaining);
|
|
355
411
|
}
|
|
356
412
|
}
|
|
357
|
-
const
|
|
358
|
-
if (
|
|
359
|
-
return
|
|
413
|
+
const requestedCap = parsePositiveInt(rawArgs.maxOutputChars, 'maxOutputChars', MAX_OUTPUT_CHARS_LIMIT);
|
|
414
|
+
if (requestedCap && typeof requestedCap === 'object') {
|
|
415
|
+
return requestedCap;
|
|
360
416
|
}
|
|
417
|
+
const ceiling = language ? undefined : shellOutputCap(command, ctx?.toolOps);
|
|
418
|
+
const maxOutputChars = cappedOutput(requestedCap, ceiling);
|
|
361
419
|
const route = language ? undefined : routes.find((each) => each.claims(command));
|
|
362
420
|
if (route) {
|
|
363
421
|
return route.run(command, ctx, {
|
|
@@ -367,29 +425,30 @@ export function createExecTool({ policyVersion, spawn, killProcess, shell: compo
|
|
|
367
425
|
runtime: spawn ? async () => ({ spawn, killProcess }) : bareRuntime
|
|
368
426
|
});
|
|
369
427
|
}
|
|
370
|
-
const
|
|
428
|
+
const childEnv = await skillsEnv(skillSettings, skillEnv, ctx);
|
|
371
429
|
try {
|
|
372
430
|
const context = {
|
|
373
431
|
attach: ctx?.attach,
|
|
374
432
|
fetchAttachment: ctx?.fetchAttachment,
|
|
375
433
|
turnImages: ctx?.turnImages,
|
|
376
434
|
runBudget: ctx?.runBudget,
|
|
377
|
-
|
|
435
|
+
policy: { ...policy, files: { ...policy.files, deny: [...new Set(deny)] } },
|
|
378
436
|
toolNames: ctx?.toolNames,
|
|
379
437
|
approval: ctx?.approval,
|
|
380
|
-
askUser: ctx?.askUser
|
|
381
|
-
writeRoots: (ctx?.fsWriteRoots ?? []).flatMap((each) => each.kind === 'local' ? [each.root] : []),
|
|
382
|
-
deniedRoots: deny
|
|
438
|
+
askUser: ctx?.askUser
|
|
383
439
|
};
|
|
384
440
|
const execution = language?.resolve(rawArgs, context) ?? shell.resolve(rawArgs, context);
|
|
385
|
-
|
|
441
|
+
const result = await execution.run({
|
|
386
442
|
cwd,
|
|
387
443
|
timeoutMs: timeout,
|
|
388
444
|
maxOutputChars,
|
|
389
445
|
signal: ctx?.signal,
|
|
390
|
-
env:
|
|
446
|
+
env: childEnv,
|
|
391
447
|
spill: ctx?.spill
|
|
392
448
|
});
|
|
449
|
+
return ceiling !== undefined && maxOutputChars === ceiling
|
|
450
|
+
? noteCeiling(result, ceiling)
|
|
451
|
+
: result;
|
|
393
452
|
}
|
|
394
453
|
catch (err) {
|
|
395
454
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
@@ -402,3 +461,6 @@ export function createExecTool({ policyVersion, spawn, killProcess, shell: compo
|
|
|
402
461
|
}
|
|
403
462
|
};
|
|
404
463
|
}
|
|
464
|
+
function localRoots(roots) {
|
|
465
|
+
return (roots ?? []).flatMap((each) => (each.kind === 'local' ? [each.root] : []));
|
|
466
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../../contract/index.ts';
|
|
2
|
+
import { type FsToolOptions } from '../fs/scope.ts';
|
|
3
|
+
export declare const EMPTY_OLD_GUIDANCE = "To add lines use insert_text; to change text put the exact current text in `old`.";
|
|
4
|
+
export declare function createEditFileTool(options?: FsToolOptions): ToolDefinition;
|
|
5
|
+
export declare function createInsertTextTool(options?: FsToolOptions): ToolDefinition;
|
|
6
|
+
export declare function createEditManyTool(options?: FsToolOptions): ToolDefinition;
|