@qvac/harness 1.0.0-rc.2 → 1.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/CHANGELOG.md +3073 -1485
- package/README.md +110 -46
- package/dist-lib/index.d.ts +63 -16
- package/dist-lib/index.js +232 -38
- package/dist-lib/lib/agent/delegate.d.ts +3 -2
- package/dist-lib/lib/agent/delegate.js +6 -4
- package/dist-lib/lib/agent/follow.d.ts +5 -0
- package/dist-lib/lib/agent/follow.js +11 -2
- package/dist-lib/lib/agent/resolve.js +30 -17
- package/dist-lib/lib/agent/tool-selection.d.ts +4 -2
- package/dist-lib/lib/agent/tool-selection.js +5 -6
- package/dist-lib/lib/agent/tools.d.ts +2 -0
- package/dist-lib/lib/agent/tools.js +2 -1
- package/dist-lib/lib/capabilities/agent-ports.d.ts +1 -1
- package/dist-lib/lib/capabilities/agent-ports.js +11 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/answering.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/batching.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/execute.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +132 -13
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +11 -5
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +54 -10
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +12 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +142 -50
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +78 -20
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +33 -16
- package/dist-lib/lib/capabilities/completion-engine/actors/run-prepare.js +38 -23
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +50 -12
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +80 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +5 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +101 -41
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +56 -17
- package/dist-lib/lib/capabilities/completion-engine/driver.js +58 -15
- package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +3 -1
- package/dist-lib/lib/capabilities/completion-engine/durable.js +12 -2
- package/dist-lib/lib/capabilities/completion-engine/engine.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/engine.js +14 -1
- package/dist-lib/lib/capabilities/completion-engine/index.d.ts +5 -1
- package/dist-lib/lib/capabilities/completion-engine/index.js +5 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +26 -3
- package/dist-lib/lib/capabilities/completion-engine/loop.js +14 -2
- package/dist-lib/lib/capabilities/completion-engine/metrics.d.ts +9 -2
- package/dist-lib/lib/capabilities/completion-engine/metrics.js +28 -7
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +63 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.js +99 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.js +30 -10
- package/dist-lib/lib/capabilities/completion-engine/ports.js +6 -9
- package/dist-lib/lib/capabilities/completion-engine/prepare-step.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +38 -6
- package/dist-lib/lib/capabilities/completion-engine/round.js +395 -118
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +12 -4
- package/dist-lib/lib/capabilities/completion-engine/session.js +31 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +5 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +8 -43
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +32 -141
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.d.ts +4 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.js +42 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-preflight.d.ts +43 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-preflight.js +91 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.d.ts +24 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.js +15 -0
- package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +17 -9
- package/dist-lib/lib/capabilities/completion-engine/turns.js +98 -86
- package/dist-lib/lib/capabilities/detect-language.d.ts +2 -1
- package/dist-lib/lib/capabilities/detect-language.js +14 -2
- package/dist-lib/lib/capabilities/download.d.ts +10 -8
- package/dist-lib/lib/capabilities/download.js +1 -1
- package/dist-lib/lib/capabilities/enhance.d.ts +1 -1
- package/dist-lib/lib/capabilities/enhance.js +23 -11
- package/dist-lib/lib/capabilities/kv-cache.d.ts +1 -1
- package/dist-lib/lib/capabilities/preview-model-source.d.ts +7 -0
- package/dist-lib/lib/capabilities/preview-model-source.js +83 -23
- package/dist-lib/lib/capabilities/prompt-prefix.d.ts +3 -1
- package/dist-lib/lib/capabilities/prompt-prefix.js +8 -0
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +13 -4
- package/dist-lib/lib/capabilities/sdk-tool.js +59 -7
- package/dist-lib/lib/capabilities/skill-entry.d.ts +13 -1
- package/dist-lib/lib/capabilities/skill-entry.js +33 -2
- package/dist-lib/lib/capabilities/tool-failed-note.d.ts +1 -0
- package/dist-lib/lib/capabilities/tool-failed-note.js +1 -0
- package/dist-lib/lib/capabilities/tool-plan.d.ts +5 -1
- package/dist-lib/lib/capabilities/tool-plan.js +20 -5
- package/dist-lib/lib/capabilities/tool-prompt-log.d.ts +1 -1
- package/dist-lib/lib/capabilities/tool-prompt-log.js +3 -3
- package/dist-lib/lib/capabilities/tool-turns/attachments.d.ts +7 -0
- package/dist-lib/lib/capabilities/tool-turns/attachments.js +39 -0
- package/dist-lib/lib/capabilities/tool-turns/copy.d.ts +13 -0
- package/dist-lib/lib/capabilities/tool-turns/copy.js +29 -0
- package/dist-lib/lib/capabilities/tool-turns/result-turn.d.ts +22 -0
- package/dist-lib/lib/capabilities/tool-turns/result-turn.js +120 -0
- package/dist-lib/lib/capabilities/tool-turns/run-limits.d.ts +6 -0
- package/dist-lib/lib/capabilities/tool-turns/run-limits.js +32 -0
- package/dist-lib/lib/capabilities/tool-turns/skill-loads.d.ts +9 -0
- package/dist-lib/lib/capabilities/tool-turns/skill-loads.js +71 -0
- package/dist-lib/lib/capabilities/tool-turns.d.ts +8 -43
- package/dist-lib/lib/capabilities/tool-turns.js +6 -253
- package/dist-lib/lib/capabilities/usage-breakdown.d.ts +1 -0
- package/dist-lib/lib/capabilities/usage-breakdown.js +4 -1
- package/dist-lib/lib/client/index.d.ts +19 -0
- package/dist-lib/lib/client/index.js +263 -0
- package/dist-lib/lib/connect/abort.d.ts +6 -0
- package/dist-lib/lib/connect/abort.js +52 -0
- package/dist-lib/lib/connect/bridges.d.ts +21 -0
- package/dist-lib/lib/connect/bridges.js +185 -0
- package/dist-lib/lib/connect/decode.d.ts +31 -0
- package/dist-lib/lib/connect/decode.js +114 -0
- package/dist-lib/lib/connect/host-run-log.d.ts +16 -0
- package/dist-lib/lib/connect/host-run-log.js +74 -0
- package/dist-lib/lib/connect/served.d.ts +7 -0
- package/dist-lib/lib/connect/served.js +45 -0
- package/dist-lib/lib/connect.d.ts +20 -11
- package/dist-lib/lib/connect.js +178 -415
- package/dist-lib/lib/context-window.d.ts +13 -5
- package/dist-lib/lib/context-window.js +19 -6
- package/dist-lib/lib/contract/agent.d.ts +25 -4
- package/dist-lib/lib/contract/completion.d.ts +82 -32
- package/dist-lib/lib/contract/drive.d.ts +130 -0
- package/dist-lib/lib/contract/drive.js +1 -0
- package/dist-lib/lib/contract/egress-proxy.d.ts +13 -0
- package/dist-lib/lib/contract/egress-proxy.js +1 -0
- package/dist-lib/lib/contract/exec.d.ts +4 -3
- package/dist-lib/lib/contract/hooks.d.ts +4 -1
- package/dist-lib/lib/contract/index.d.ts +4 -0
- package/dist-lib/lib/contract/knowledge.d.ts +10 -0
- package/dist-lib/lib/contract/managed-skills.d.ts +1 -0
- package/dist-lib/lib/contract/managed-skills.js +1 -0
- package/dist-lib/lib/contract/media.d.ts +58 -0
- package/dist-lib/lib/contract/media.js +1 -0
- package/dist-lib/lib/contract/models.d.ts +12 -6
- package/dist-lib/lib/contract/ocr.d.ts +17 -0
- package/dist-lib/lib/contract/ocr.js +1 -0
- package/dist-lib/lib/contract/policy.d.ts +75 -0
- package/dist-lib/lib/contract/policy.js +1 -0
- package/dist-lib/lib/contract/run.d.ts +28 -3
- package/dist-lib/lib/contract/sandbox.d.ts +3 -1
- package/dist-lib/lib/contract/speech.d.ts +1 -1
- package/dist-lib/lib/contract/translation.d.ts +20 -0
- package/dist-lib/lib/contract/translation.js +1 -0
- package/dist-lib/lib/contract-types.d.ts +48 -16
- package/dist-lib/lib/embeddings/index.d.ts +7 -1
- package/dist-lib/lib/embeddings/index.js +26 -5
- package/dist-lib/lib/errors.d.ts +278 -0
- package/dist-lib/lib/errors.js +212 -0
- package/dist-lib/lib/fold/index.d.ts +26 -1
- package/dist-lib/lib/fold/index.js +76 -9
- package/dist-lib/lib/guarded-fetch.js +11 -7
- package/dist-lib/lib/guards.d.ts +2 -0
- package/dist-lib/lib/guards.js +7 -0
- package/dist-lib/lib/hardware/capability-probe.js +10 -7
- package/dist-lib/lib/hardware/cpu-placement.d.ts +8 -0
- package/dist-lib/lib/hardware/cpu-placement.js +48 -0
- package/dist-lib/lib/hardware/gpu-probe-addon.js +26 -11
- package/dist-lib/lib/hardware/gpu-probe.js +10 -1
- package/dist-lib/lib/hardware/gpu-stats.native.cjs +17 -1
- package/dist-lib/lib/helpers/completion-params.d.ts +7 -2
- package/dist-lib/lib/helpers/completion-params.js +26 -2
- package/dist-lib/lib/helpers/control-tokens.d.ts +3 -0
- package/dist-lib/lib/helpers/control-tokens.js +25 -0
- package/dist-lib/lib/helpers/engine-error.d.ts +2 -1
- package/dist-lib/lib/helpers/engine-error.js +12 -12
- package/dist-lib/lib/helpers/goal-check/asks.d.ts +25 -0
- package/dist-lib/lib/helpers/goal-check/asks.js +52 -0
- package/dist-lib/lib/helpers/goal-check/checks.d.ts +8 -0
- package/dist-lib/lib/helpers/goal-check/checks.js +92 -0
- package/dist-lib/lib/helpers/goal-check/commands.d.ts +7 -0
- package/dist-lib/lib/helpers/goal-check/commands.js +130 -0
- package/dist-lib/lib/helpers/goal-check/paths.d.ts +5 -0
- package/dist-lib/lib/helpers/goal-check/paths.js +44 -0
- package/dist-lib/lib/helpers/goal-check/shell.d.ts +9 -0
- package/dist-lib/lib/helpers/goal-check/shell.js +96 -0
- package/dist-lib/lib/helpers/goal-check.d.ts +36 -0
- package/dist-lib/lib/helpers/goal-check.js +35 -0
- package/dist-lib/lib/helpers/head-tail.js +1 -1
- package/dist-lib/lib/helpers/html-helpers.js +9 -6
- package/dist-lib/lib/helpers/load-stall.d.ts +1 -1
- package/dist-lib/lib/helpers/load-stall.js +2 -2
- package/dist-lib/lib/helpers/markup-stream-filter.d.ts +4 -1
- package/dist-lib/lib/helpers/markup-stream-filter.js +20 -6
- package/dist-lib/lib/helpers/recent-map.d.ts +7 -0
- package/dist-lib/lib/helpers/recent-map.js +23 -0
- package/dist-lib/lib/helpers/repeated-reply.js +24 -16
- package/dist-lib/lib/helpers/require-peers.d.ts +3 -0
- package/dist-lib/lib/helpers/require-peers.js +23 -0
- package/dist-lib/lib/helpers/run-outcome.d.ts +2 -0
- package/dist-lib/lib/helpers/run-outcome.js +6 -2
- package/dist-lib/lib/helpers/spawn-path.d.ts +1 -0
- package/dist-lib/lib/helpers/spawn-path.js +2 -1
- package/dist-lib/lib/helpers/thinking.d.ts +3 -2
- package/dist-lib/lib/helpers/thinking.js +19 -0
- package/dist-lib/lib/helpers/tool-call-markup/emit.d.ts +6 -0
- package/dist-lib/lib/helpers/tool-call-markup/emit.js +15 -0
- package/dist-lib/lib/helpers/tool-call-markup/recover.d.ts +22 -0
- package/dist-lib/lib/helpers/tool-call-markup/recover.js +130 -0
- package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.d.ts +3 -0
- package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.js +56 -0
- package/dist-lib/lib/helpers/tool-call-markup/strip.d.ts +4 -0
- package/dist-lib/lib/helpers/tool-call-markup/strip.js +149 -0
- package/dist-lib/lib/helpers/tool-call-markup.d.ts +19 -24
- package/dist-lib/lib/helpers/tool-call-markup.js +17 -343
- package/dist-lib/lib/hooks/built-in/arg-repair.js +6 -2
- package/dist-lib/lib/hooks/built-in/policy-rules.d.ts +8 -0
- package/dist-lib/lib/hooks/built-in/policy-rules.js +192 -0
- package/dist-lib/lib/hooks/built-in/sandbox.js +23 -5
- package/dist-lib/lib/hooks/index.d.ts +4 -1
- package/dist-lib/lib/hooks/index.js +9 -4
- package/dist-lib/lib/hooks/run.js +3 -3
- package/dist-lib/lib/lifecycle/index.js +15 -14
- package/dist-lib/lib/lifecycle/machine.js +2 -2
- package/dist-lib/lib/log.d.ts +26 -5
- package/dist-lib/lib/log.js +86 -23
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +15 -16
- package/dist-lib/lib/machine/completion/actions/completion.js +164 -107
- package/dist-lib/lib/machine/completion/actions/goal.d.ts +10 -0
- package/dist-lib/lib/machine/completion/actions/goal.js +93 -0
- package/dist-lib/lib/machine/completion/actions/prepare.js +3 -2
- package/dist-lib/lib/machine/completion/actions/reject-tool.d.ts +16 -0
- package/dist-lib/lib/machine/completion/actions/reject-tool.js +147 -0
- package/dist-lib/lib/machine/completion/actions/retry-round.d.ts +6 -0
- package/dist-lib/lib/machine/completion/actions/retry-round.js +50 -0
- package/dist-lib/lib/machine/completion/actions/rounds.d.ts +5 -0
- package/dist-lib/lib/machine/completion/actions/rounds.js +31 -0
- package/dist-lib/lib/machine/completion/actions/tools.d.ts +1 -16
- package/dist-lib/lib/machine/completion/actions/tools.js +111 -140
- package/dist-lib/lib/machine/completion/context.js +11 -1
- package/dist-lib/lib/machine/completion/guards/retry.d.ts +3 -1
- package/dist-lib/lib/machine/completion/guards/retry.js +9 -2
- package/dist-lib/lib/machine/completion/implementations.d.ts +18 -9
- package/dist-lib/lib/machine/completion/implementations.js +64 -16
- package/dist-lib/lib/machine/completion/machine.d.ts +38 -9
- package/dist-lib/lib/machine/completion/machine.js +58 -9
- package/dist-lib/lib/machine/completion/metrics.d.ts +25 -0
- package/dist-lib/lib/machine/completion/metrics.js +68 -0
- package/dist-lib/lib/machine/completion/nudges.d.ts +5 -0
- package/dist-lib/lib/machine/completion/nudges.js +33 -0
- package/dist-lib/lib/machine/completion/rules.d.ts +19 -27
- package/dist-lib/lib/machine/completion/rules.js +48 -79
- package/dist-lib/lib/machine/completion/splice.d.ts +9 -0
- package/dist-lib/lib/machine/completion/splice.js +19 -0
- package/dist-lib/lib/machine/completion/types.d.ts +81 -14
- package/dist-lib/lib/machine/index.d.ts +50 -11
- package/dist-lib/lib/machine/index.js +12 -2
- package/dist-lib/lib/media-host.d.ts +12 -0
- package/dist-lib/lib/media-host.js +52 -0
- package/dist-lib/lib/media-port.d.ts +20 -0
- package/dist-lib/lib/media-port.js +77 -0
- package/dist-lib/lib/media-wire.d.ts +8 -0
- package/dist-lib/lib/media-wire.js +111 -0
- package/dist-lib/lib/models/context-choice.d.ts +15 -0
- package/dist-lib/lib/models/context-choice.js +62 -0
- package/dist-lib/lib/models/context.d.ts +1 -1
- package/dist-lib/lib/models/custom-model-cache.d.ts +1 -0
- package/dist-lib/lib/models/custom-model-cache.js +3 -0
- package/dist-lib/lib/models/download-gate.d.ts +20 -0
- package/dist-lib/lib/models/download-gate.js +73 -0
- package/dist-lib/lib/models/gguf-header.d.ts +11 -0
- package/dist-lib/lib/models/gguf-header.js +203 -15
- package/dist-lib/lib/models/gpu-selection.d.ts +6 -1
- package/dist-lib/lib/models/gpu-selection.js +29 -5
- package/dist-lib/lib/models/kv-cache.d.ts +2 -0
- package/dist-lib/lib/models/kv-cache.js +8 -0
- package/dist-lib/lib/models/llm-presets.d.ts +6 -1
- package/dist-lib/lib/models/llm-presets.js +33 -6
- package/dist-lib/lib/models/load-requests.d.ts +9 -0
- package/dist-lib/lib/models/load-requests.js +42 -0
- package/dist-lib/lib/models/memory-cap.d.ts +13 -0
- package/dist-lib/lib/models/memory-cap.js +21 -0
- package/dist-lib/lib/models/model-catalog-constants.d.ts +2 -2
- package/dist-lib/lib/models/model-catalog-constants.js +3 -4
- package/dist-lib/lib/models/model-catalog.d.ts +7 -3
- package/dist-lib/lib/models/model-catalog.js +44 -11
- package/dist-lib/lib/models/model-delete.d.ts +1 -1
- package/dist-lib/lib/models/model-fit.d.ts +2 -2
- package/dist-lib/lib/models/model-fit.js +5 -6
- package/dist-lib/lib/models/model-handle.d.ts +9 -2
- package/dist-lib/lib/models/model-handle.js +14 -3
- package/dist-lib/lib/models/model-list.d.ts +9 -2
- package/dist-lib/lib/models/model-list.js +23 -0
- package/dist-lib/lib/models/model-pool.d.ts +42 -7
- package/dist-lib/lib/models/model-pool.js +139 -49
- package/dist-lib/lib/models/model-source.d.ts +3 -2
- package/dist-lib/lib/models/model-source.js +23 -5
- package/dist-lib/lib/models/opencl-cache.js +2 -2
- package/dist-lib/lib/models/sdk-faults.d.ts +1 -0
- package/dist-lib/lib/models/sdk-faults.js +9 -0
- package/dist-lib/lib/models/tool-dialect.d.ts +1 -1
- package/dist-lib/lib/models/tts-model-default.d.ts +2 -1
- package/dist-lib/lib/models/tts-model-default.js +8 -6
- package/dist-lib/lib/no-redirect-fetch-bare.js +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.d.ts +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.js +46 -8
- package/dist-lib/lib/office/engine/pptx/picture-area.d.ts +23 -0
- package/dist-lib/lib/office/engine/pptx/picture-area.js +84 -0
- package/dist-lib/lib/office/engine/pptx/presentation.d.ts +2 -0
- package/dist-lib/lib/office/engine/pptx/presentation.js +64 -21
- package/dist-lib/lib/office/engine/pptx/types.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/sheet.js +10 -4
- package/dist-lib/lib/office/engine/xlsx/workbook.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/workbook.js +34 -3
- package/dist-lib/lib/office/extract.js +4 -3
- package/dist-lib/lib/office/index.js +2 -1
- package/dist-lib/lib/plugins/registry.d.ts +15 -0
- package/dist-lib/lib/plugins/registry.js +91 -22
- package/dist-lib/lib/plugins/require-bare.d.ts +1 -0
- package/dist-lib/lib/plugins/require-bare.js +13 -0
- package/dist-lib/lib/policy/index.d.ts +11 -0
- package/dist-lib/lib/policy/index.js +235 -0
- package/dist-lib/lib/prompt.d.ts +9 -4
- package/dist-lib/lib/prompt.js +95 -32
- package/dist-lib/lib/residency/completion-runtime.d.ts +17 -6
- package/dist-lib/lib/residency/completion-runtime.js +91 -37
- package/dist-lib/lib/residency/index.d.ts +59 -6
- package/dist-lib/lib/residency/index.js +444 -42
- package/dist-lib/lib/resolution-detector.js +3 -3
- package/dist-lib/lib/round-host.d.ts +12 -0
- package/dist-lib/lib/round-host.js +57 -0
- package/dist-lib/lib/round-port.d.ts +24 -0
- package/dist-lib/lib/round-port.js +81 -0
- package/dist-lib/lib/rpc-session.js +2 -1
- package/dist-lib/lib/run-log/redact.js +7 -7
- package/dist-lib/lib/run-log/request-codec.js +2 -2
- package/dist-lib/lib/sdk-loader.d.ts +1 -1
- package/dist-lib/lib/sdk-loader.js +47 -17
- package/dist-lib/lib/sdk-storage.d.ts +1 -0
- package/dist-lib/lib/sdk-storage.js +18 -2
- package/dist-lib/lib/serve/completion.d.ts +7 -0
- package/dist-lib/lib/serve/completion.js +553 -0
- package/dist-lib/lib/serve/downloads.d.ts +4 -0
- package/dist-lib/lib/serve/downloads.js +79 -0
- package/dist-lib/lib/serve/models.d.ts +5 -0
- package/dist-lib/lib/serve/models.js +120 -0
- package/dist-lib/lib/serve/noop.d.ts +1 -0
- package/dist-lib/lib/serve/noop.js +1 -0
- package/dist-lib/lib/serve/requests.d.ts +147 -0
- package/dist-lib/lib/serve/requests.js +1 -0
- package/dist-lib/lib/serve/rounds.d.ts +11 -0
- package/dist-lib/lib/serve/rounds.js +67 -0
- package/dist-lib/lib/serve/run-log-start.d.ts +38 -0
- package/dist-lib/lib/serve/run-log-start.js +254 -0
- package/dist-lib/lib/serve/skills.d.ts +32 -0
- package/dist-lib/lib/serve/skills.js +46 -0
- package/dist-lib/lib/serve.d.ts +5 -1
- package/dist-lib/lib/serve.js +51 -916
- package/dist-lib/lib/sidecar/index.d.ts +39 -0
- package/dist-lib/lib/sidecar/index.js +205 -0
- package/dist-lib/lib/sidecar/user-plugins.d.ts +9 -0
- package/dist-lib/lib/sidecar/user-plugins.js +119 -0
- package/dist-lib/lib/skills-host/index.d.ts +7 -3
- package/dist-lib/lib/skills-host/index.js +47 -22
- package/dist-lib/lib/spawn.d.ts +6 -4
- package/dist-lib/lib/spawn.js +22 -20
- package/dist-lib/lib/spill.d.ts +1 -0
- package/dist-lib/lib/spill.js +12 -8
- package/dist-lib/lib/tools/ask-user.d.ts +2 -0
- package/dist-lib/lib/tools/ask-user.js +137 -0
- package/dist-lib/lib/tools/attachments/delivered.d.ts +5 -0
- package/dist-lib/lib/tools/attachments/delivered.js +16 -0
- package/dist-lib/lib/tools/attachments/fetched-file.d.ts +32 -0
- package/dist-lib/lib/tools/attachments/fetched-file.js +134 -0
- package/dist-lib/lib/tools/attachments/staging.d.ts +1 -0
- package/dist-lib/lib/tools/attachments/staging.js +19 -8
- package/dist-lib/lib/tools/exec/runner.d.ts +4 -0
- package/dist-lib/lib/tools/exec/runner.js +20 -2
- package/dist-lib/lib/tools/exec/scope.d.ts +0 -1
- package/dist-lib/lib/tools/exec/scope.js +23 -114
- package/dist-lib/lib/tools/exec/shell-guidance.js +4 -4
- package/dist-lib/lib/tools/exec/shell-line.d.ts +26 -0
- package/dist-lib/lib/tools/exec/shell-line.js +334 -0
- package/dist-lib/lib/tools/exec.d.ts +4 -1
- package/dist-lib/lib/tools/exec.js +89 -27
- package/dist-lib/lib/tools/files/edit-file.d.ts +6 -0
- package/dist-lib/lib/tools/files/edit-file.js +266 -0
- package/dist-lib/lib/tools/files/glob.d.ts +3 -0
- package/dist-lib/lib/tools/files/glob.js +65 -0
- package/dist-lib/lib/tools/files/grep.d.ts +6 -0
- package/dist-lib/lib/tools/files/grep.js +212 -0
- package/dist-lib/lib/tools/files/index.d.ts +3 -0
- package/dist-lib/lib/tools/files/index.js +25 -0
- package/dist-lib/lib/tools/files/list-dir.d.ts +6 -0
- package/dist-lib/lib/tools/files/list-dir.js +136 -0
- package/dist-lib/lib/tools/files/make-dir.d.ts +3 -0
- package/dist-lib/lib/tools/files/make-dir.js +48 -0
- package/dist-lib/lib/tools/files/read-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/read-file.js +224 -0
- package/dist-lib/lib/tools/files/transfer.d.ts +4 -0
- package/dist-lib/lib/tools/files/transfer.js +83 -0
- package/dist-lib/lib/tools/files/trash-file.d.ts +4 -0
- package/dist-lib/lib/tools/files/trash-file.js +62 -0
- package/dist-lib/lib/tools/files/write-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/write-file.js +56 -0
- package/dist-lib/lib/tools/fs/document-text.d.ts +8 -0
- package/dist-lib/lib/tools/fs/document-text.js +22 -0
- package/dist-lib/lib/tools/fs/drive.d.ts +5 -25
- package/dist-lib/lib/tools/fs/drive.js +9 -1
- package/dist-lib/lib/tools/fs/edit-match.d.ts +33 -0
- package/dist-lib/lib/tools/fs/edit-match.js +445 -0
- package/dist-lib/lib/tools/fs/ignore.d.ts +13 -0
- package/dist-lib/lib/tools/fs/ignore.js +104 -0
- package/dist-lib/lib/tools/fs/local.js +28 -5
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +2 -40
- package/dist-lib/lib/tools/fs/remote-protocol.js +1 -1
- package/dist-lib/lib/tools/fs/remote.d.ts +3 -11
- package/dist-lib/lib/tools/fs/remote.js +24 -14
- package/dist-lib/lib/tools/fs/scope.d.ts +4 -15
- package/dist-lib/lib/tools/fs/scope.js +5 -2
- package/dist-lib/lib/tools/fs/search.d.ts +25 -0
- package/dist-lib/lib/tools/fs/search.js +383 -0
- package/dist-lib/lib/tools/{file-glob.d.ts → fs/targets.d.ts} +1 -5
- package/dist-lib/lib/tools/fs/targets.js +32 -0
- package/dist-lib/lib/tools/fs/tool-path.d.ts +27 -0
- package/dist-lib/lib/tools/fs/tool-path.js +70 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +14 -5
- package/dist-lib/lib/tools/fs/walk.js +119 -24
- package/dist-lib/lib/tools/http-request/request.d.ts +4 -2
- package/dist-lib/lib/tools/http-request/request.js +2 -1
- package/dist-lib/lib/tools/http-request/truncate-response.d.ts +16 -1
- package/dist-lib/lib/tools/http-request/truncate-response.js +56 -11
- package/dist-lib/lib/tools/http-request.d.ts +1 -0
- package/dist-lib/lib/tools/http-request.js +101 -16
- package/dist-lib/lib/tools/index.d.ts +4 -1
- package/dist-lib/lib/tools/index.js +8 -12
- package/dist-lib/lib/tools/office/ops.d.ts +1 -0
- package/dist-lib/lib/tools/office/ops.js +5 -1
- package/dist-lib/lib/tools/office.d.ts +2 -1
- package/dist-lib/lib/tools/office.js +273 -56
- package/dist-lib/lib/tools/operations/builders.d.ts +4 -3
- package/dist-lib/lib/tools/operations/builders.js +41 -3
- package/dist-lib/lib/tools/operations/calendar-range.d.ts +16 -0
- package/dist-lib/lib/tools/operations/calendar-range.js +40 -0
- package/dist-lib/lib/tools/operations/compile.js +8 -6
- package/dist-lib/lib/tools/operations/manifest.d.ts +4 -0
- package/dist-lib/lib/tools/pdf/build.d.ts +17 -3
- package/dist-lib/lib/tools/pdf/build.js +77 -16
- package/dist-lib/lib/tools/pdf/pages.d.ts +12 -0
- package/dist-lib/lib/tools/pdf/pages.js +31 -0
- package/dist-lib/lib/tools/pdf/recognize.d.ts +13 -0
- package/dist-lib/lib/tools/pdf/recognize.js +55 -0
- package/dist-lib/lib/tools/pdf/request.d.ts +3 -8
- package/dist-lib/lib/tools/pdf/request.js +4 -4
- package/dist-lib/lib/tools/pdf.d.ts +0 -1
- package/dist-lib/lib/tools/pdf.js +56 -13
- package/dist-lib/lib/tools/skill.js +23 -11
- package/dist-lib/lib/tools/skills/bundled-dir.d.ts +8 -1
- package/dist-lib/lib/tools/skills/bundled-dir.js +42 -36
- package/dist-lib/lib/tools/skills/bundled-hash.d.ts +1 -0
- package/dist-lib/lib/tools/skills/bundled-hash.js +4 -1
- package/dist-lib/lib/tools/skills/catalog-loader.d.ts +12 -0
- package/dist-lib/lib/tools/skills/catalog-loader.js +173 -0
- package/dist-lib/lib/tools/skills/catalog.d.ts +7 -8
- package/dist-lib/lib/tools/skills/catalog.js +1 -158
- package/dist-lib/lib/tools/skills/cli-argv.js +25 -5
- package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/cli-schema-check.js +3 -0
- package/dist-lib/lib/tools/skills/cli-schema-load.js +10 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +2 -0
- package/dist-lib/lib/tools/skills/cli-schema.js +6 -3
- package/dist-lib/lib/tools/skills/credential-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/credential-check.js +3 -0
- package/dist-lib/lib/tools/skills/credential-health.js +3 -3
- package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +3 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +5 -0
- package/dist-lib/lib/tools/skills/index.d.ts +1 -0
- package/dist-lib/lib/tools/skills/index.js +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.d.ts +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +39 -3
- package/dist-lib/lib/tools/skills/manifest.d.ts +1 -0
- package/dist-lib/lib/tools/skills/mention-name.d.ts +6 -0
- package/dist-lib/lib/tools/skills/mention-name.js +6 -0
- package/dist-lib/lib/tools/skills/mention.d.ts +2 -2
- package/dist-lib/lib/tools/skills/mention.js +11 -4
- package/dist-lib/lib/tools/skills/overlay-crud.d.ts +3 -3
- package/dist-lib/lib/tools/skills/overlay-crud.js +7 -6
- package/dist-lib/lib/tools/skills/overlay-watch.d.ts +2 -2
- package/dist-lib/lib/tools/skills/overlay-watch.js +4 -3
- package/dist-lib/lib/tools/skills/scope-key.d.ts +1 -0
- package/dist-lib/lib/tools/skills/scope-key.js +4 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +1 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.js +4 -0
- package/dist-lib/lib/tools/skills/skill-tree.d.ts +5 -0
- package/dist-lib/lib/tools/skills/skill-tree.js +54 -0
- package/dist-lib/lib/tools/url-guard.d.ts +6 -1
- package/dist-lib/lib/tools/url-guard.js +8 -2
- package/dist-lib/lib/tools/web-fetch.js +50 -133
- package/dist-lib/lib/wire/download.d.ts +10 -0
- package/dist-lib/lib/wire/download.js +35 -0
- package/dist-lib/lib/wire/event.d.ts +41 -0
- package/dist-lib/lib/wire/event.js +306 -0
- package/dist-lib/lib/wire/fields.d.ts +3 -0
- package/dist-lib/lib/wire/fields.js +12 -0
- package/dist-lib/lib/wire/knowledge.d.ts +9 -0
- package/dist-lib/lib/wire/knowledge.js +68 -0
- package/dist-lib/lib/wire/round.d.ts +14 -0
- package/dist-lib/lib/wire/round.js +45 -0
- package/dist-lib/lib/wire/vectors.d.ts +6 -0
- package/dist-lib/lib/wire/vectors.js +33 -0
- package/dist-lib/lib/wire.d.ts +28 -64
- package/dist-lib/lib/wire.js +24 -417
- package/dist-lib/plugins/coding/index.d.ts +1 -1
- package/dist-lib/plugins/coding/index.js +2 -4
- package/dist-lib/plugins/coding/read-only.d.ts +1 -0
- package/dist-lib/plugins/coding/read-only.js +264 -0
- package/dist-lib/plugins/coding/session.d.ts +6 -4
- package/dist-lib/plugins/coding/session.js +45 -16
- package/dist-lib/plugins/coding-guards/index.d.ts +25 -0
- package/dist-lib/plugins/coding-guards/index.js +126 -0
- package/dist-lib/plugins/command-hooks/index.js +5 -3
- package/dist-lib/plugins/egress-proxy/index.d.ts +53 -0
- package/dist-lib/plugins/egress-proxy/index.js +184 -0
- package/dist-lib/plugins/image/edit-image.d.ts +3 -22
- package/dist-lib/plugins/image/edit-image.js +23 -46
- package/dist-lib/plugins/image/fit.d.ts +31 -0
- package/dist-lib/plugins/image/fit.js +28 -0
- package/dist-lib/plugins/image/generate-image.d.ts +27 -6
- package/dist-lib/plugins/image/generate-image.js +201 -74
- package/dist-lib/plugins/image/index.d.ts +2 -1
- package/dist-lib/plugins/image/index.js +29 -12
- package/dist-lib/plugins/knowledge/index.d.ts +3 -0
- package/dist-lib/plugins/knowledge/index.js +5 -0
- package/dist-lib/plugins/knowledge/manifest.d.ts +53 -0
- package/dist-lib/plugins/knowledge/manifest.js +86 -0
- package/dist-lib/plugins/knowledge/search-tool.js +8 -8
- package/dist-lib/plugins/knowledge/store.d.ts +45 -8
- package/dist-lib/plugins/knowledge/store.js +428 -166
- package/dist-lib/plugins/language-hint/index.d.ts +15 -0
- package/dist-lib/plugins/language-hint/index.js +54 -0
- package/dist-lib/plugins/lsp/tool.js +2 -2
- package/dist-lib/plugins/mcp/call.js +15 -4
- package/dist-lib/plugins/mcp/index.js +6 -3
- package/dist-lib/plugins/mcp/protocol.d.ts +10 -2
- package/dist-lib/plugins/mcp/protocol.js +13 -12
- package/dist-lib/plugins/mcp/server.js +1 -1
- package/dist-lib/plugins/mcp/tool-listing.d.ts +6 -0
- package/dist-lib/plugins/mcp/tool-listing.js +97 -0
- package/dist-lib/plugins/music/generate-music.d.ts +24 -5
- package/dist-lib/plugins/music/generate-music.js +170 -64
- package/dist-lib/plugins/music/index.d.ts +2 -1
- package/dist-lib/plugins/music/index.js +23 -11
- package/dist-lib/plugins/obsidian/command.js +2 -2
- package/dist-lib/plugins/obsidian/index.js +14 -4
- package/dist-lib/plugins/obsidian/note-name.js +2 -1
- package/dist-lib/plugins/obsidian/readiness.js +2 -2
- package/dist-lib/plugins/obsidian/safe-path.js +5 -4
- package/dist-lib/plugins/obsidian/vault-create.js +3 -2
- package/dist-lib/plugins/obsidian/vault-fs.js +2 -2
- package/dist-lib/plugins/obsidian/vault-paths.js +3 -2
- package/dist-lib/plugins/obsidian/vault-read.js +20 -18
- package/dist-lib/plugins/obsidian/vault-write.js +13 -12
- package/dist-lib/plugins/ocr/bmp.d.ts +2 -0
- package/dist-lib/plugins/ocr/bmp.js +27 -0
- package/dist-lib/plugins/ocr/coverage.d.ts +3 -0
- package/dist-lib/plugins/ocr/coverage.js +67 -0
- package/dist-lib/plugins/ocr/index.d.ts +12 -0
- package/dist-lib/plugins/ocr/index.js +20 -0
- package/dist-lib/plugins/ocr/ocr-runtime.d.ts +25 -0
- package/dist-lib/plugins/ocr/ocr-runtime.js +103 -0
- package/dist-lib/plugins/ocr/reading-order.d.ts +5 -0
- package/dist-lib/plugins/ocr/reading-order.js +218 -0
- package/dist-lib/plugins/python/bare-floor.d.ts +1 -0
- package/dist-lib/plugins/python/bare-floor.js +2 -0
- package/dist-lib/plugins/python/guarded-fetch.d.ts +2 -1
- package/dist-lib/plugins/python/guarded-fetch.js +5 -1
- package/dist-lib/plugins/python/index.d.ts +4 -1
- package/dist-lib/plugins/python/index.js +6 -1
- package/dist-lib/plugins/python/interrupt-timer.js +2 -2
- package/dist-lib/plugins/python/language.js +11 -10
- package/dist-lib/plugins/python/loader.d.ts +1 -0
- package/dist-lib/plugins/python/loader.js +76 -3
- package/dist-lib/plugins/python/memfs.js +2 -2
- package/dist-lib/plugins/python/pyodide.d.ts +1 -0
- package/dist-lib/plugins/python/pyodide.js +9 -8
- package/dist-lib/plugins/python/python-adapter.d.ts +6 -1
- package/dist-lib/plugins/python/python-adapter.js +37 -2
- package/dist-lib/plugins/python/run-session.d.ts +1 -0
- package/dist-lib/plugins/python/run-session.js +19 -8
- package/dist-lib/plugins/python/wheels.js +8 -6
- package/dist-lib/plugins/python/worker/active.js +2 -2
- package/dist-lib/plugins/python/worker/client.js +10 -9
- package/dist-lib/plugins/python/worker/entry.js +2 -8
- package/dist-lib/plugins/python/worker/preload.d.ts +1 -0
- package/dist-lib/plugins/python/worker/preload.js +2 -0
- package/dist-lib/plugins/python/worker/protocol.d.ts +2 -0
- package/dist-lib/plugins/python/worker/serve.js +23 -4
- package/dist-lib/plugins/python/worker/spawn.d.ts +2 -1
- package/dist-lib/plugins/python/worker/spawn.js +3 -2
- package/dist-lib/plugins/quickjs/index.js +4 -0
- package/dist-lib/plugins/quickjs/runtime.js +8 -3
- package/dist-lib/plugins/run-report/chain.d.ts +2 -0
- package/dist-lib/plugins/run-report/chain.js +73 -0
- package/dist-lib/plugins/run-report/flow-view.js +2 -1
- package/dist-lib/plugins/run-report/flow.d.ts +1 -1
- package/dist-lib/plugins/run-report/flow.js +66 -14
- package/dist-lib/plugins/run-report/index.d.ts +23 -2
- package/dist-lib/plugins/run-report/index.js +32 -13
- package/dist-lib/plugins/run-report/layout.js +1 -1
- package/dist-lib/plugins/run-report/model.d.ts +10 -1
- package/dist-lib/plugins/run-report/model.js +12 -6
- package/dist-lib/plugins/run-report/page.d.ts +9 -0
- package/dist-lib/plugins/run-report/page.js +55 -15
- package/dist-lib/plugins/run-report/script.js +317 -43
- package/dist-lib/plugins/run-report/story.d.ts +2 -1
- package/dist-lib/plugins/run-report/story.js +7 -4
- package/dist-lib/plugins/run-report/style.d.ts +1 -1
- package/dist-lib/plugins/run-report/style.js +126 -0
- package/dist-lib/plugins/run-report/why.js +1 -1
- package/dist-lib/plugins/sandbox-linux/index.d.ts +62 -0
- package/dist-lib/plugins/sandbox-linux/index.js +354 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.d.ts +2 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.js +74 -0
- package/dist-lib/plugins/sandbox-macos/index.d.ts +25 -11
- package/dist-lib/plugins/sandbox-macos/index.js +244 -49
- package/dist-lib/plugins/sandbox-vm/index.d.ts +2 -1
- package/dist-lib/plugins/sandbox-vm/index.js +5 -2
- package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +7 -3
- package/dist-lib/plugins/sandbox-vm/vm-shell.js +54 -20
- package/dist-lib/plugins/sandbox-windows/helper/qvac-sandbox.c +554 -0
- package/dist-lib/plugins/sandbox-windows/index.d.ts +53 -0
- package/dist-lib/plugins/sandbox-windows/index.js +205 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/speech/audio-resample.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-resample.js +8 -8
- package/dist-lib/plugins/speech/audio-transcode-bare.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-bare.js +23 -26
- package/dist-lib/plugins/speech/audio-transcode-node.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-node.js +1 -3
- package/dist-lib/plugins/speech/index.d.ts +1 -0
- package/dist-lib/plugins/speech/index.js +8 -1
- package/dist-lib/plugins/speech/speech-engine.d.ts +1 -1
- package/dist-lib/plugins/speech/speech-engine.js +10 -5
- package/dist-lib/plugins/speech/speech-runtime.js +37 -37
- package/dist-lib/plugins/speech/speech-text.d.ts +1 -0
- package/dist-lib/plugins/speech/speech-text.js +9 -4
- package/dist-lib/plugins/speech/voice.d.ts +5 -1
- package/dist-lib/plugins/speech/voice.js +107 -33
- package/dist-lib/plugins/translation/index.d.ts +2 -1
- package/dist-lib/plugins/translation/index.js +21 -10
- package/dist-lib/plugins/translation/translate.d.ts +9 -5
- package/dist-lib/plugins/translation/translate.js +69 -64
- package/dist-lib/plugins/walkie-talkie/index.d.ts +4 -2
- package/dist-lib/plugins/walkie-talkie/index.js +19 -6
- package/dist-lib/plugins/walkie-talkie/wire.d.ts +5 -0
- package/dist-lib/plugins/walkie-talkie/wire.js +6 -5
- package/dist-lib/plugins/weather/geocode.js +2 -1
- package/dist-lib/plugins/weather/lookup.js +6 -4
- package/dist-lib/plugins/web-search/engines/bing.js +2 -1
- package/dist-lib/plugins/web-search/engines/google.js +2 -1
- package/dist-lib/plugins/web-search/fetch-html.d.ts +5 -5
- package/dist-lib/plugins/web-search/fetch-html.js +12 -15
- package/dist-lib/plugins/web-search/tool.js +1 -0
- package/dist-lib/schema/generate.js +8 -1
- package/dist-lib/schema/harness.js +94 -12
- package/dist-lib/spec/bind.js +12 -0
- package/dist-lib/spec/calls.js +4 -0
- package/dist-lib/spec/hrpc/hrpc.json +55 -3
- package/dist-lib/spec/hrpc/index.js +58 -10
- package/dist-lib/spec/hrpc/messages.js +485 -209
- package/dist-lib/spec/hyperschema/index.js +485 -209
- package/dist-lib/spec/hyperschema/schema.json +290 -85
- package/dist-lib/spec/hyperschema/types.d.ts +42 -5
- package/package.json +265 -65
- package/patches/pyodide@314.0.2.patch +37 -8
- package/scripts/addon-externals.cjs +16 -5
- package/worker/harness-sidecar.mjs +23 -154
- package/dist-lib/lib/tools/create-documents.d.ts +0 -3
- package/dist-lib/lib/tools/create-documents.js +0 -95
- package/dist-lib/lib/tools/edit-documents.d.ts +0 -3
- package/dist-lib/lib/tools/edit-documents.js +0 -132
- package/dist-lib/lib/tools/exec/shell-argv.d.ts +0 -2
- package/dist-lib/lib/tools/exec/shell-argv.js +0 -61
- package/dist-lib/lib/tools/file-glob.js +0 -118
- package/dist-lib/lib/tools/grep.d.ts +0 -5
- package/dist-lib/lib/tools/grep.js +0 -184
- package/dist-lib/lib/tools/read-files.d.ts +0 -5
- package/dist-lib/lib/tools/read-files.js +0 -160
- package/dist-lib/plugins/coding/write-file.d.ts +0 -3
- package/dist-lib/plugins/coding/write-file.js +0 -52
- package/patches/@qvac%2Finference@0.21.0.patch +0 -67
- package/patches/bare-stow@0.1.5.patch +0 -68
- package/patches/hypercore-blob-server@1.15.0.patch +0 -15
- package/patches/localwatch@1.4.3.patch +0 -13
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { Writable } from 'streamx';
|
|
4
|
+
import { HarnessError } from '../../errors.js';
|
|
5
|
+
import { DriveReadTruncatedError } from './drive.js';
|
|
6
|
+
import { MAX_DRIVE_BYTES } from './remote-protocol.js';
|
|
7
|
+
import { MAX_WALK_MS } from './walk.js';
|
|
4
8
|
import { STAGING_DIR } from '../../staging.js';
|
|
5
9
|
export const DRIVE_CALL_TIMEOUT_MS = 20_000;
|
|
6
|
-
export const
|
|
10
|
+
export const DRIVE_SEARCH_TIMEOUT_MS = MAX_WALK_MS + DRIVE_CALL_TIMEOUT_MS;
|
|
7
11
|
export const DRIVE_LIST_PAGE = 256;
|
|
8
12
|
const noop = () => { };
|
|
9
|
-
export class DriveReadTruncatedError extends Error {
|
|
10
|
-
constructor(key) {
|
|
11
|
-
super(`read stopped at ${MAX_DRIVE_BYTES} bytes: ${key}`);
|
|
12
|
-
this.name = 'DriveReadTruncatedError';
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export function isDriveReadTruncated(err) {
|
|
16
|
-
return err instanceof DriveReadTruncatedError;
|
|
17
|
-
}
|
|
18
13
|
function withTimeout(promise, ms, op) {
|
|
19
14
|
return new Promise((resolve, reject) => {
|
|
20
|
-
const timer = setTimeout(() => reject(new
|
|
15
|
+
const timer = setTimeout(() => reject(new HarnessError('DRIVE_TIMED_OUT', [op])), ms);
|
|
21
16
|
promise.then((value) => {
|
|
22
17
|
clearTimeout(timer);
|
|
23
18
|
resolve(value);
|
|
@@ -62,9 +57,10 @@ function remoteDrive(driveKey, driveOp, timeoutMs) {
|
|
|
62
57
|
},
|
|
63
58
|
async *list(folder = '/', opts) {
|
|
64
59
|
const skip = [...(opts?.skip ?? [])];
|
|
60
|
+
const recursive = opts?.recursive ?? true;
|
|
65
61
|
let cursor = null;
|
|
66
62
|
while (true) {
|
|
67
|
-
const response = await call(driveOp, { op: 'list', driveKey, folder, skip, limit: DRIVE_LIST_PAGE, cursor }, timeoutMs);
|
|
63
|
+
const response = await call(driveOp, { op: 'list', driveKey, folder, skip, recursive, limit: DRIVE_LIST_PAGE, cursor }, timeoutMs);
|
|
68
64
|
const entries = response.entries ?? [];
|
|
69
65
|
for (const entry of entries) {
|
|
70
66
|
yield entry;
|
|
@@ -87,7 +83,7 @@ function remoteDrive(driveKey, driveOp, timeoutMs) {
|
|
|
87
83
|
await fs.promises.unlink(response.path).catch(noop);
|
|
88
84
|
}
|
|
89
85
|
if (response.truncated) {
|
|
90
|
-
throw new DriveReadTruncatedError(readKey);
|
|
86
|
+
throw new DriveReadTruncatedError(readKey, MAX_DRIVE_BYTES);
|
|
91
87
|
}
|
|
92
88
|
},
|
|
93
89
|
createWriteStream(writeKey, writeOpts) {
|
|
@@ -125,13 +121,27 @@ function remoteDrive(driveKey, driveOp, timeoutMs) {
|
|
|
125
121
|
}
|
|
126
122
|
};
|
|
127
123
|
}
|
|
124
|
+
function remoteSearch(driveKey, driveOp, timeoutMs) {
|
|
125
|
+
return async (query) => {
|
|
126
|
+
const response = await call(driveOp, { op: 'search', driveKey, ...query }, timeoutMs);
|
|
127
|
+
return {
|
|
128
|
+
hits: response.hits ?? [],
|
|
129
|
+
capped: response.capped === true,
|
|
130
|
+
cut: response.cut === true,
|
|
131
|
+
truncated: response.truncated === true,
|
|
132
|
+
skippedLinks: response.skippedLinks ?? 0
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
}
|
|
128
136
|
export function createRemoteRoots(drives, driveOp, opts = {}) {
|
|
129
137
|
const timeoutMs = opts.timeoutMs ?? DRIVE_CALL_TIMEOUT_MS;
|
|
138
|
+
const searchTimeoutMs = opts.searchTimeoutMs ?? DRIVE_SEARCH_TIMEOUT_MS;
|
|
130
139
|
return drives.map((drive) => ({
|
|
131
140
|
kind: 'hyper',
|
|
132
141
|
key: drive.key,
|
|
133
142
|
writable: drive.writable,
|
|
134
143
|
prefix: '/',
|
|
135
|
-
drive: remoteDrive(drive.key, driveOp, timeoutMs)
|
|
144
|
+
drive: remoteDrive(drive.key, driveOp, timeoutMs),
|
|
145
|
+
search: drive.search ? remoteSearch(drive.key, driveOp, searchTimeoutMs) : undefined
|
|
136
146
|
}));
|
|
137
147
|
}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CompiledPolicy } from '../../contract/policy.ts';
|
|
2
|
+
import type { DriveRoot, LocalRoot } from '../../contract/drive.ts';
|
|
3
|
+
export type { DriveRoot, HyperRoot, LocalRoot } from '../../contract/drive.ts';
|
|
2
4
|
export type Realpath = (p: string) => Promise<string>;
|
|
3
5
|
export declare const defaultRealpath: Realpath;
|
|
4
|
-
export interface LocalRoot {
|
|
5
|
-
readonly kind: 'local';
|
|
6
|
-
readonly root: string;
|
|
7
|
-
readonly drive: Drive;
|
|
8
|
-
}
|
|
9
|
-
export interface HyperRoot {
|
|
10
|
-
readonly kind: 'hyper';
|
|
11
|
-
readonly key: string;
|
|
12
|
-
readonly writable: boolean;
|
|
13
|
-
readonly prefix: string;
|
|
14
|
-
readonly drive: Drive;
|
|
15
|
-
}
|
|
16
|
-
export type DriveRoot = LocalRoot | HyperRoot;
|
|
17
6
|
export interface FsToolOptions {
|
|
18
7
|
readonly realpath?: Realpath;
|
|
19
8
|
readonly deniedRoots?: readonly string[];
|
|
@@ -22,10 +11,10 @@ export declare const NO_DIRS_GRANTED = "no directories are granted";
|
|
|
22
11
|
export interface FsToolError {
|
|
23
12
|
error: string;
|
|
24
13
|
}
|
|
25
|
-
export declare const NO_STORAGE_ROOT = "cannot fence the app storage root: the SDK home is unknown";
|
|
26
14
|
export declare function deniedRootsFor(sdkHome: string | undefined): readonly string[];
|
|
27
15
|
export declare const PROTECTED_PATH_ERROR = "path is inside a protected app directory";
|
|
28
16
|
export declare function canonicalDenyRoots(deniedRoots: readonly string[] | undefined, realpath: Realpath): Promise<readonly string[]>;
|
|
17
|
+
export declare function callDenyRoots(deniedRoots: readonly string[] | undefined, policy: CompiledPolicy | undefined, realpath: Realpath): Promise<readonly string[]>;
|
|
29
18
|
export declare function isDeniedPath(hostPath: string, canonicalDenyRoots: readonly string[]): boolean;
|
|
30
19
|
export declare function overlaps(a: string, b: string): boolean;
|
|
31
20
|
export declare function hostPath(root: LocalRoot, key: string): string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import process from 'process';
|
|
4
|
+
import { HarnessError } from '../../errors.js';
|
|
4
5
|
import { SPILL_DIR } from '../../spill.js';
|
|
5
6
|
export const defaultRealpath = (p) => fs.promises.realpath(p);
|
|
6
7
|
export const NO_DIRS_GRANTED = 'no directories are granted';
|
|
@@ -11,10 +12,9 @@ function rootLabel(root) {
|
|
|
11
12
|
function outside(roots) {
|
|
12
13
|
return { error: `path must be inside one of: ${roots.map(rootLabel).join(', ')}` };
|
|
13
14
|
}
|
|
14
|
-
export const NO_STORAGE_ROOT = 'cannot fence the app storage root: the SDK home is unknown';
|
|
15
15
|
export function deniedRootsFor(sdkHome) {
|
|
16
16
|
if (!sdkHome)
|
|
17
|
-
throw new
|
|
17
|
+
throw new HarnessError('NO_STORAGE_ROOT');
|
|
18
18
|
return [path.dirname(sdkHome), SPILL_DIR];
|
|
19
19
|
}
|
|
20
20
|
export const PROTECTED_PATH_ERROR = 'path is inside a protected app directory';
|
|
@@ -34,6 +34,9 @@ export async function canonicalDenyRoots(deniedRoots, realpath) {
|
|
|
34
34
|
}
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
|
+
export function callDenyRoots(deniedRoots, policy, realpath) {
|
|
38
|
+
return canonicalDenyRoots([...(deniedRoots ?? []), ...(policy?.files.deny ?? [])], realpath);
|
|
39
|
+
}
|
|
37
40
|
export function isDeniedPath(hostPath, canonicalDenyRoots) {
|
|
38
41
|
return canonicalDenyRoots.some((root) => contained(hostPath, root, { ignoreCase: true }));
|
|
39
42
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Drive, FolderSearchResult, SearchFile, SearchResult } from '../../contract/drive.ts';
|
|
2
|
+
import type { DriveResponse, DriveSearchRequest } from './remote-protocol.ts';
|
|
3
|
+
import { type DriveRoot } from './scope.ts';
|
|
4
|
+
export type { FolderSearchResult, SearchFile, SearchHit, SearchResult } from '../../contract/drive.ts';
|
|
5
|
+
export declare const MAX_GREP_MATCHES = 1000;
|
|
6
|
+
export interface SearchOptions {
|
|
7
|
+
regex?: boolean;
|
|
8
|
+
caseSensitive?: boolean;
|
|
9
|
+
concurrency?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface FolderSearchOptions {
|
|
12
|
+
maxMatches: number;
|
|
13
|
+
includeIgnored?: boolean;
|
|
14
|
+
maxEntries?: number;
|
|
15
|
+
maxMs?: number;
|
|
16
|
+
deny?: readonly string[];
|
|
17
|
+
include?: ((name: string, path: string) => boolean) | null;
|
|
18
|
+
}
|
|
19
|
+
export declare class DriveSearch {
|
|
20
|
+
#private;
|
|
21
|
+
constructor(queries: readonly string[], { regex, caseSensitive, concurrency }?: SearchOptions);
|
|
22
|
+
static answer(drive: Drive, request: DriveSearchRequest): Promise<DriveResponse>;
|
|
23
|
+
searchFolder(root: DriveRoot, folder: string, { maxMatches, includeIgnored, maxEntries, maxMs, deny, include }: FolderSearchOptions): Promise<FolderSearchResult>;
|
|
24
|
+
search(drive: Drive, files: AsyncIterable<SearchFile>, maxMatches: number): Promise<SearchResult>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import { errorMessage } from '../../guards.js';
|
|
3
|
+
import { HarnessLog } from '../../log.js';
|
|
4
|
+
import { isDriveReadTruncated } from './drive.js';
|
|
5
|
+
import { isDeniedPath } from './scope.js';
|
|
6
|
+
import { MAX_WALK_ENTRIES, MAX_WALK_MS, streamFiles } from './walk.js';
|
|
7
|
+
export const MAX_GREP_MATCHES = 1000;
|
|
8
|
+
const NEWLINE = 0x0a;
|
|
9
|
+
const LINE_END = b4a.from([NEWLINE]);
|
|
10
|
+
const MAX_LINE_CHARS = 500;
|
|
11
|
+
const BINARY_PROBE_BYTES = 1024;
|
|
12
|
+
const DEFAULT_CONCURRENCY = 8;
|
|
13
|
+
const MAX_UNCOUNTED_BYTES = 1024 * 1024;
|
|
14
|
+
const MAX_LINE_BYTES = 1024 * 1024;
|
|
15
|
+
const UNSEARCHED = -2;
|
|
16
|
+
const LOOKAROUND = /\(\?<?[=!]/;
|
|
17
|
+
const BACKREFERENCE = /\\[1-9]|\\k</;
|
|
18
|
+
const CROSSES_LINES = /\[\^|\\(?:[sWDn0]|12|x0[aA]|u000[aA]|c[jJ])|\\(?:x[\da-fA-F]{2}|u[\da-fA-F]{4}|c[a-zA-Z]|[^dDsSwW])-|[\0-\n]|\(\?[a-zA-Z-]/;
|
|
19
|
+
function cursors(keys) {
|
|
20
|
+
return keys.map((key) => ({ key, at: UNSEARCHED }));
|
|
21
|
+
}
|
|
22
|
+
function nearest(all, from, find) {
|
|
23
|
+
let best = -1;
|
|
24
|
+
for (const cursor of all) {
|
|
25
|
+
if (cursor.at === UNSEARCHED || (cursor.at >= 0 && cursor.at < from)) {
|
|
26
|
+
cursor.at = find(cursor.key, from);
|
|
27
|
+
}
|
|
28
|
+
if (cursor.at >= 0 && (best === -1 || cursor.at < best)) {
|
|
29
|
+
best = cursor.at;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return best;
|
|
33
|
+
}
|
|
34
|
+
function countNewlines(bytes, start, end) {
|
|
35
|
+
let count = 0;
|
|
36
|
+
for (let i = start; i < end; i++) {
|
|
37
|
+
if (bytes[i] === NEWLINE) {
|
|
38
|
+
count++;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return count;
|
|
42
|
+
}
|
|
43
|
+
class ByteHaystack {
|
|
44
|
+
#bytes;
|
|
45
|
+
#needles;
|
|
46
|
+
constructor(bytes, needles) {
|
|
47
|
+
this.#bytes = bytes;
|
|
48
|
+
this.#needles = cursors(needles);
|
|
49
|
+
}
|
|
50
|
+
get length() {
|
|
51
|
+
return this.#bytes.length;
|
|
52
|
+
}
|
|
53
|
+
next(from) {
|
|
54
|
+
return nearest(this.#needles, from, (needle, at) => b4a.indexOf(this.#bytes, needle, at));
|
|
55
|
+
}
|
|
56
|
+
newlineAt(from) {
|
|
57
|
+
return b4a.indexOf(this.#bytes, NEWLINE, from);
|
|
58
|
+
}
|
|
59
|
+
newlineBefore(index) {
|
|
60
|
+
return b4a.lastIndexOf(this.#bytes, NEWLINE, index - 1);
|
|
61
|
+
}
|
|
62
|
+
slice(start, end) {
|
|
63
|
+
return b4a.toString(this.#bytes, 'utf8', start, end);
|
|
64
|
+
}
|
|
65
|
+
newlines(start, end) {
|
|
66
|
+
return countNewlines(this.#bytes, start, end);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
class TextHaystack {
|
|
70
|
+
#text;
|
|
71
|
+
#finders;
|
|
72
|
+
constructor(text, finders) {
|
|
73
|
+
this.#text = text;
|
|
74
|
+
this.#finders = finders === null ? null : cursors(finders);
|
|
75
|
+
}
|
|
76
|
+
get length() {
|
|
77
|
+
return this.#text.length;
|
|
78
|
+
}
|
|
79
|
+
next(from) {
|
|
80
|
+
const at = this.#finders === null
|
|
81
|
+
? from
|
|
82
|
+
: nearest(this.#finders, from, (finder, start) => {
|
|
83
|
+
finder.lastIndex = start;
|
|
84
|
+
return finder.exec(this.#text)?.index ?? -1;
|
|
85
|
+
});
|
|
86
|
+
return at < this.#text.length ? at : -1;
|
|
87
|
+
}
|
|
88
|
+
newlineAt(from) {
|
|
89
|
+
return this.#text.indexOf('\n', from);
|
|
90
|
+
}
|
|
91
|
+
newlineBefore(index) {
|
|
92
|
+
return this.#text.lastIndexOf('\n', index - 1);
|
|
93
|
+
}
|
|
94
|
+
slice(start, end) {
|
|
95
|
+
return this.#text.slice(start, end);
|
|
96
|
+
}
|
|
97
|
+
newlines(start, end) {
|
|
98
|
+
let count = 0;
|
|
99
|
+
let at = this.#text.indexOf('\n', start);
|
|
100
|
+
while (at !== -1 && at < end) {
|
|
101
|
+
count++;
|
|
102
|
+
at = this.#text.indexOf('\n', at + 1);
|
|
103
|
+
}
|
|
104
|
+
return count;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
class LineCounter {
|
|
108
|
+
line = 1;
|
|
109
|
+
#pending = [];
|
|
110
|
+
#pendingBytes = 0;
|
|
111
|
+
defer(block) {
|
|
112
|
+
this.#pending.push(block);
|
|
113
|
+
this.#pendingBytes += block.length;
|
|
114
|
+
if (this.#pendingBytes > MAX_UNCOUNTED_BYTES) {
|
|
115
|
+
this.flush();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
flush() {
|
|
119
|
+
for (const block of this.#pending) {
|
|
120
|
+
this.line += countNewlines(block, 0, block.length);
|
|
121
|
+
}
|
|
122
|
+
this.#pending.length = 0;
|
|
123
|
+
this.#pendingBytes = 0;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
class OrderedCommits {
|
|
127
|
+
hits = [];
|
|
128
|
+
cut = false;
|
|
129
|
+
#maxMatches;
|
|
130
|
+
#pending = [];
|
|
131
|
+
constructor(maxMatches) {
|
|
132
|
+
this.#maxMatches = maxMatches;
|
|
133
|
+
}
|
|
134
|
+
get room() {
|
|
135
|
+
return this.#maxMatches - this.hits.length;
|
|
136
|
+
}
|
|
137
|
+
add(file, read) {
|
|
138
|
+
const entry = { file, read, scan: null };
|
|
139
|
+
void read.then((scan) => {
|
|
140
|
+
entry.scan = scan;
|
|
141
|
+
});
|
|
142
|
+
this.#pending.push(entry);
|
|
143
|
+
}
|
|
144
|
+
async settle(keep) {
|
|
145
|
+
for (let head = this.#pending[0]; head !== undefined; head = this.#pending[0]) {
|
|
146
|
+
if (head.scan === null && this.#pending.length <= keep) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
const scan = head.scan ?? (await head.read);
|
|
150
|
+
this.#pending.shift();
|
|
151
|
+
if (this.#commit(head.file, scan)) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
result(capped) {
|
|
158
|
+
return { hits: this.hits, capped, cut: this.cut };
|
|
159
|
+
}
|
|
160
|
+
#commit(file, scan) {
|
|
161
|
+
const room = this.room;
|
|
162
|
+
if (scan.hits.length >= room) {
|
|
163
|
+
this.hits.push(...scan.hits.slice(0, room));
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
if (scan.end === 'unreadable') {
|
|
167
|
+
HarnessLog.info('warn: grep skipped a file', {
|
|
168
|
+
file: file.path,
|
|
169
|
+
err: errorMessage(scan.error)
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
else if (scan.end !== 'binary') {
|
|
173
|
+
this.cut ||= scan.end === 'cut';
|
|
174
|
+
this.hits.push(...scan.hits);
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function escapeLiteral(query) {
|
|
180
|
+
return query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
181
|
+
}
|
|
182
|
+
function finders(sources, flags) {
|
|
183
|
+
if (!sources.some((source) => BACKREFERENCE.test(source))) {
|
|
184
|
+
try {
|
|
185
|
+
return [new RegExp(sources.map((source) => `(?:${source})`).join('|'), flags)];
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return sources.map((source) => new RegExp(source, flags));
|
|
191
|
+
}
|
|
192
|
+
function hasNul(head) {
|
|
193
|
+
return b4a.indexOf(head.subarray(0, BINARY_PROBE_BYTES), 0) !== -1;
|
|
194
|
+
}
|
|
195
|
+
async function* gated(files, gate) {
|
|
196
|
+
for await (const file of files) {
|
|
197
|
+
if (Date.now() > gate.deadline) {
|
|
198
|
+
gate.late = true;
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const name = file.key.slice(file.key.lastIndexOf('/') + 1);
|
|
202
|
+
if (!isDeniedPath(file.path, gate.deny) &&
|
|
203
|
+
(gate.include === null || gate.include(name, file.path))) {
|
|
204
|
+
yield file;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
export class DriveSearch {
|
|
209
|
+
#concurrency;
|
|
210
|
+
#tests;
|
|
211
|
+
#needles;
|
|
212
|
+
#finders;
|
|
213
|
+
constructor(queries, { regex = false, caseSensitive = false, concurrency = DEFAULT_CONCURRENCY } = {}) {
|
|
214
|
+
this.#concurrency = concurrency;
|
|
215
|
+
const bytes = !regex && caseSensitive && !queries.some((query) => query === '' || query.includes('\uFFFD'));
|
|
216
|
+
const flags = caseSensitive ? '' : 'i';
|
|
217
|
+
const sources = regex ? queries : queries.map(escapeLiteral);
|
|
218
|
+
const lines = bytes ? [] : sources.map((source) => new RegExp(source, flags));
|
|
219
|
+
this.#tests = bytes
|
|
220
|
+
? queries.map((query) => (line) => line.includes(query))
|
|
221
|
+
: lines.map((rx) => (line) => rx.test(line));
|
|
222
|
+
this.#needles = bytes ? queries.map((query) => b4a.from(query)) : null;
|
|
223
|
+
this.#finders =
|
|
224
|
+
bytes ||
|
|
225
|
+
(regex && queries.some((query) => LOOKAROUND.test(query) || CROSSES_LINES.test(query)))
|
|
226
|
+
? null
|
|
227
|
+
: finders(sources, `${flags}g${regex ? 'm' : ''}`);
|
|
228
|
+
}
|
|
229
|
+
static async answer(drive, request) {
|
|
230
|
+
const search = new DriveSearch(request.queries, {
|
|
231
|
+
regex: request.regex,
|
|
232
|
+
caseSensitive: request.caseSensitive
|
|
233
|
+
});
|
|
234
|
+
const root = {
|
|
235
|
+
kind: 'hyper',
|
|
236
|
+
key: request.driveKey,
|
|
237
|
+
writable: false,
|
|
238
|
+
prefix: '/',
|
|
239
|
+
drive
|
|
240
|
+
};
|
|
241
|
+
return search.searchFolder(root, request.folder, {
|
|
242
|
+
includeIgnored: request.includeIgnored,
|
|
243
|
+
maxMatches: Math.min(request.maxMatches, MAX_GREP_MATCHES),
|
|
244
|
+
maxEntries: Math.min(request.maxEntries, MAX_WALK_ENTRIES),
|
|
245
|
+
maxMs: Math.min(request.maxMs, MAX_WALK_MS)
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
async searchFolder(root, folder, { maxMatches, includeIgnored, maxEntries, maxMs, deny = [], include = null }) {
|
|
249
|
+
const walk = streamFiles(root, folder, { includeIgnored, maxEntries, maxMs });
|
|
250
|
+
const gate = {
|
|
251
|
+
deny,
|
|
252
|
+
include,
|
|
253
|
+
deadline: maxMs === undefined ? Infinity : Date.now() + maxMs,
|
|
254
|
+
late: false
|
|
255
|
+
};
|
|
256
|
+
const found = await this.search(root.drive, gated(walk.files, gate), maxMatches);
|
|
257
|
+
const listed = await walk.result;
|
|
258
|
+
return {
|
|
259
|
+
...found,
|
|
260
|
+
truncated: listed.truncated || gate.late,
|
|
261
|
+
skippedLinks: listed.skippedLinks
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
async search(drive, files, maxMatches) {
|
|
265
|
+
const commits = new OrderedCommits(maxMatches);
|
|
266
|
+
const stop = { stopped: false };
|
|
267
|
+
try {
|
|
268
|
+
for await (const file of files) {
|
|
269
|
+
if (await commits.settle(this.#concurrency - 1)) {
|
|
270
|
+
return commits.result(true);
|
|
271
|
+
}
|
|
272
|
+
commits.add(file, this.#scan(drive, { file, room: commits.room, stop }));
|
|
273
|
+
}
|
|
274
|
+
return commits.result(await commits.settle(0));
|
|
275
|
+
}
|
|
276
|
+
finally {
|
|
277
|
+
stop.stopped = true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
async #scan(drive, { file, room, stop }) {
|
|
281
|
+
const state = {
|
|
282
|
+
file,
|
|
283
|
+
room,
|
|
284
|
+
hits: [],
|
|
285
|
+
lines: new LineCounter(),
|
|
286
|
+
probed: false,
|
|
287
|
+
carry: null,
|
|
288
|
+
skipping: false
|
|
289
|
+
};
|
|
290
|
+
try {
|
|
291
|
+
for await (const chunk of drive.createReadStream(file.key)) {
|
|
292
|
+
const end = stop.stopped ? 'complete' : this.#take(chunk, state);
|
|
293
|
+
if (end !== null) {
|
|
294
|
+
return { hits: state.hits, end };
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return { hits: state.hits, end: this.#last(state) };
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
if (!state.probed && state.carry !== null && !hasNul(state.carry)) {
|
|
301
|
+
this.#wholeLines(state.carry, state);
|
|
302
|
+
}
|
|
303
|
+
return { hits: state.hits, end: isDriveReadTruncated(error) ? 'cut' : 'unreadable', error };
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
#take(chunk, state) {
|
|
307
|
+
if (state.skipping) {
|
|
308
|
+
const newline = b4a.indexOf(chunk, NEWLINE);
|
|
309
|
+
if (newline === -1) {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
state.skipping = false;
|
|
313
|
+
chunk = chunk.subarray(newline + 1);
|
|
314
|
+
}
|
|
315
|
+
const buffer = state.carry === null ? chunk : b4a.concat([state.carry, chunk]);
|
|
316
|
+
if (!state.probed && buffer.length < BINARY_PROBE_BYTES) {
|
|
317
|
+
state.carry = buffer;
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
if (!state.probed && hasNul(buffer)) {
|
|
321
|
+
return 'binary';
|
|
322
|
+
}
|
|
323
|
+
state.probed = true;
|
|
324
|
+
return this.#wholeLines(buffer, state) || this.#longLine(state) ? 'complete' : null;
|
|
325
|
+
}
|
|
326
|
+
#longLine(state) {
|
|
327
|
+
const { carry } = state;
|
|
328
|
+
if (carry === null || carry.length <= MAX_LINE_BYTES) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
state.carry = null;
|
|
332
|
+
state.skipping = true;
|
|
333
|
+
return this.#block(b4a.concat([carry.subarray(0, MAX_LINE_BYTES), LINE_END]), state);
|
|
334
|
+
}
|
|
335
|
+
#last(state) {
|
|
336
|
+
const { carry } = state;
|
|
337
|
+
if (carry === null) {
|
|
338
|
+
return 'complete';
|
|
339
|
+
}
|
|
340
|
+
if (!state.probed && hasNul(carry)) {
|
|
341
|
+
return 'binary';
|
|
342
|
+
}
|
|
343
|
+
this.#block(carry[carry.length - 1] === NEWLINE ? carry : b4a.concat([carry, LINE_END]), state);
|
|
344
|
+
return 'complete';
|
|
345
|
+
}
|
|
346
|
+
#wholeLines(buffer, state) {
|
|
347
|
+
const last = b4a.lastIndexOf(buffer, NEWLINE);
|
|
348
|
+
state.carry = last + 1 === buffer.length ? null : buffer.subarray(last + 1);
|
|
349
|
+
return last !== -1 && this.#block(buffer.subarray(0, last + 1), state);
|
|
350
|
+
}
|
|
351
|
+
#block(block, { file, hits, lines, room }) {
|
|
352
|
+
const hay = this.#needles === null
|
|
353
|
+
? new TextHaystack(b4a.toString(block, 'utf8'), this.#finders)
|
|
354
|
+
: new ByteHaystack(block, this.#needles);
|
|
355
|
+
let counted = -1;
|
|
356
|
+
for (let at = hay.next(0); at !== -1; at = hay.next(counted)) {
|
|
357
|
+
const start = at === 0 ? 0 : hay.newlineBefore(at) + 1;
|
|
358
|
+
const newline = hay.newlineAt(at);
|
|
359
|
+
const end = newline === -1 ? hay.length : newline;
|
|
360
|
+
if (counted === -1) {
|
|
361
|
+
lines.flush();
|
|
362
|
+
counted = 0;
|
|
363
|
+
}
|
|
364
|
+
lines.line += hay.newlines(counted, start);
|
|
365
|
+
const text = hay.slice(start, end);
|
|
366
|
+
if (this.#tests.some((test) => test(text))) {
|
|
367
|
+
hits.push({ file: file.path, line: lines.line, text: text.slice(0, MAX_LINE_CHARS) });
|
|
368
|
+
}
|
|
369
|
+
if (hits.length >= room) {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
lines.line++;
|
|
373
|
+
counted = end + 1;
|
|
374
|
+
}
|
|
375
|
+
if (counted === -1) {
|
|
376
|
+
lines.defer(block);
|
|
377
|
+
}
|
|
378
|
+
else if (counted < hay.length) {
|
|
379
|
+
lines.line += hay.newlines(counted, hay.length);
|
|
380
|
+
}
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type DriveRoot, type FsToolError, type FsToolOptions, type ResolveKeyOptions } from './fs/scope.ts';
|
|
3
|
-
export declare const DEFAULT_GLOB_MATCHES = 100;
|
|
4
|
-
export declare const MAX_GLOB_MATCHES = 1000;
|
|
1
|
+
import { type DriveRoot, type FsToolError, type ResolveKeyOptions } from './scope.ts';
|
|
5
2
|
export interface SearchTarget {
|
|
6
3
|
root: DriveRoot;
|
|
7
4
|
folder: string;
|
|
@@ -11,4 +8,3 @@ export interface ResolvedTargets {
|
|
|
11
8
|
}
|
|
12
9
|
export declare function searchTargets(dir: unknown, roots: readonly DriveRoot[], { realpath, deny }: ResolveKeyOptions): Promise<ResolvedTargets | FsToolError>;
|
|
13
10
|
export declare function relativeKey(key: string, folder: string): string;
|
|
14
|
-
export declare function createFileGlobTool({ realpath, deniedRoots }?: FsToolOptions): ToolDefinition;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { NO_DIRS_GRANTED, resolveKey } from './scope.js';
|
|
2
|
+
export async function searchTargets(dir, roots, { realpath, deny }) {
|
|
3
|
+
if (typeof dir === 'string' && dir.trim()) {
|
|
4
|
+
const resolved = await resolveKey(dir, roots, { realpath, deny });
|
|
5
|
+
if ('error' in resolved) {
|
|
6
|
+
return resolved;
|
|
7
|
+
}
|
|
8
|
+
if (resolved.root.kind === 'local') {
|
|
9
|
+
if (!resolved.exists) {
|
|
10
|
+
return { error: `no such file: ${dir}` };
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
let hasEntry = false;
|
|
15
|
+
for await (const _entry of resolved.root.drive.list(resolved.key)) {
|
|
16
|
+
hasEntry = true;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
if (!hasEntry && (await resolved.root.drive.entry(resolved.key)) === null) {
|
|
20
|
+
return { error: `no such file: ${dir}` };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { targets: [{ root: resolved.root, folder: resolved.key }] };
|
|
24
|
+
}
|
|
25
|
+
if (roots.length === 0) {
|
|
26
|
+
return { error: NO_DIRS_GRANTED };
|
|
27
|
+
}
|
|
28
|
+
return { targets: roots.map((root) => ({ root, folder: '/' })) };
|
|
29
|
+
}
|
|
30
|
+
export function relativeKey(key, folder) {
|
|
31
|
+
return folder === '/' ? key.slice(1) : key.slice(folder.length + 1);
|
|
32
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CompiledPolicy } from '../../contract/policy.ts';
|
|
2
|
+
import { type DriveRoot, type FsToolError, type Realpath, type ResolvedKey } from './scope.ts';
|
|
3
|
+
export interface Grants {
|
|
4
|
+
readonly fsRoots?: readonly DriveRoot[] | undefined;
|
|
5
|
+
readonly fsWriteRoots?: readonly DriveRoot[] | undefined;
|
|
6
|
+
readonly policy?: CompiledPolicy | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare function anchorOf(grants: Grants | undefined): DriveRoot | undefined;
|
|
9
|
+
export declare function rootedPath(p: string, anchor: DriveRoot | undefined): string;
|
|
10
|
+
export declare function shownPath(full: string, anchor: DriveRoot | undefined): string;
|
|
11
|
+
export interface RootedScope {
|
|
12
|
+
readonly grants: Grants | undefined;
|
|
13
|
+
readonly write: boolean;
|
|
14
|
+
readonly realpath: Realpath;
|
|
15
|
+
readonly deniedRoots?: readonly string[] | undefined;
|
|
16
|
+
}
|
|
17
|
+
export declare function resolveRooted(p: string, { grants, write, realpath, deniedRoots }: RootedScope): Promise<ResolvedKey | FsToolError>;
|
|
18
|
+
export declare function rootedArgs(args: Record<string, unknown>, grants: Grants | undefined, keys: readonly string[]): string[] | null;
|
|
19
|
+
export declare function stringArg(args: Record<string, unknown>, key: string): string | null;
|
|
20
|
+
export declare function positiveInt(value: unknown): number | undefined;
|
|
21
|
+
export declare function existsNow(p: string | null, grants: Grants | undefined): boolean;
|
|
22
|
+
export interface LabelPaths {
|
|
23
|
+
readonly grants: Grants | undefined;
|
|
24
|
+
readonly paths: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
export declare function rootedLabel(verb: string, { grants, paths }: LabelPaths): string;
|
|
27
|
+
export declare function localPathOf(resolved: ResolvedKey): string | null;
|