@qvac/harness 1.0.0-rc.2 → 1.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/CHANGELOG.md +3073 -1485
- package/README.md +110 -46
- package/dist-lib/index.d.ts +63 -16
- package/dist-lib/index.js +232 -38
- package/dist-lib/lib/agent/delegate.d.ts +3 -2
- package/dist-lib/lib/agent/delegate.js +6 -4
- package/dist-lib/lib/agent/follow.d.ts +5 -0
- package/dist-lib/lib/agent/follow.js +11 -2
- package/dist-lib/lib/agent/resolve.js +30 -17
- package/dist-lib/lib/agent/tool-selection.d.ts +4 -2
- package/dist-lib/lib/agent/tool-selection.js +5 -6
- package/dist-lib/lib/agent/tools.d.ts +2 -0
- package/dist-lib/lib/agent/tools.js +2 -1
- package/dist-lib/lib/capabilities/agent-ports.d.ts +1 -1
- package/dist-lib/lib/capabilities/agent-ports.js +11 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/answering.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/batching.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/execute.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +132 -13
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +11 -5
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +54 -10
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +12 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +142 -50
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +78 -20
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +33 -16
- package/dist-lib/lib/capabilities/completion-engine/actors/run-prepare.js +38 -23
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +50 -12
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +80 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +5 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +101 -41
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +56 -17
- package/dist-lib/lib/capabilities/completion-engine/driver.js +58 -15
- package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +3 -1
- package/dist-lib/lib/capabilities/completion-engine/durable.js +12 -2
- package/dist-lib/lib/capabilities/completion-engine/engine.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/engine.js +14 -1
- package/dist-lib/lib/capabilities/completion-engine/index.d.ts +5 -1
- package/dist-lib/lib/capabilities/completion-engine/index.js +5 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +26 -3
- package/dist-lib/lib/capabilities/completion-engine/loop.js +14 -2
- package/dist-lib/lib/capabilities/completion-engine/metrics.d.ts +9 -2
- package/dist-lib/lib/capabilities/completion-engine/metrics.js +28 -7
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +63 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.js +99 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.js +30 -10
- package/dist-lib/lib/capabilities/completion-engine/ports.js +6 -9
- package/dist-lib/lib/capabilities/completion-engine/prepare-step.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +38 -6
- package/dist-lib/lib/capabilities/completion-engine/round.js +395 -118
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +12 -4
- package/dist-lib/lib/capabilities/completion-engine/session.js +31 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +5 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +8 -43
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +32 -141
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.d.ts +4 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.js +42 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-preflight.d.ts +43 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-preflight.js +91 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.d.ts +24 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.js +15 -0
- package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +17 -9
- package/dist-lib/lib/capabilities/completion-engine/turns.js +98 -86
- package/dist-lib/lib/capabilities/detect-language.d.ts +2 -1
- package/dist-lib/lib/capabilities/detect-language.js +14 -2
- package/dist-lib/lib/capabilities/download.d.ts +10 -8
- package/dist-lib/lib/capabilities/download.js +1 -1
- package/dist-lib/lib/capabilities/enhance.d.ts +1 -1
- package/dist-lib/lib/capabilities/enhance.js +23 -11
- package/dist-lib/lib/capabilities/kv-cache.d.ts +1 -1
- package/dist-lib/lib/capabilities/preview-model-source.d.ts +7 -0
- package/dist-lib/lib/capabilities/preview-model-source.js +83 -23
- package/dist-lib/lib/capabilities/prompt-prefix.d.ts +3 -1
- package/dist-lib/lib/capabilities/prompt-prefix.js +8 -0
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +13 -4
- package/dist-lib/lib/capabilities/sdk-tool.js +59 -7
- package/dist-lib/lib/capabilities/skill-entry.d.ts +13 -1
- package/dist-lib/lib/capabilities/skill-entry.js +33 -2
- package/dist-lib/lib/capabilities/tool-failed-note.d.ts +1 -0
- package/dist-lib/lib/capabilities/tool-failed-note.js +1 -0
- package/dist-lib/lib/capabilities/tool-plan.d.ts +5 -1
- package/dist-lib/lib/capabilities/tool-plan.js +20 -5
- package/dist-lib/lib/capabilities/tool-prompt-log.d.ts +1 -1
- package/dist-lib/lib/capabilities/tool-prompt-log.js +3 -3
- package/dist-lib/lib/capabilities/tool-turns/attachments.d.ts +7 -0
- package/dist-lib/lib/capabilities/tool-turns/attachments.js +39 -0
- package/dist-lib/lib/capabilities/tool-turns/copy.d.ts +13 -0
- package/dist-lib/lib/capabilities/tool-turns/copy.js +29 -0
- package/dist-lib/lib/capabilities/tool-turns/result-turn.d.ts +22 -0
- package/dist-lib/lib/capabilities/tool-turns/result-turn.js +120 -0
- package/dist-lib/lib/capabilities/tool-turns/run-limits.d.ts +6 -0
- package/dist-lib/lib/capabilities/tool-turns/run-limits.js +32 -0
- package/dist-lib/lib/capabilities/tool-turns/skill-loads.d.ts +9 -0
- package/dist-lib/lib/capabilities/tool-turns/skill-loads.js +71 -0
- package/dist-lib/lib/capabilities/tool-turns.d.ts +8 -43
- package/dist-lib/lib/capabilities/tool-turns.js +6 -253
- package/dist-lib/lib/capabilities/usage-breakdown.d.ts +1 -0
- package/dist-lib/lib/capabilities/usage-breakdown.js +4 -1
- package/dist-lib/lib/client/index.d.ts +19 -0
- package/dist-lib/lib/client/index.js +263 -0
- package/dist-lib/lib/connect/abort.d.ts +6 -0
- package/dist-lib/lib/connect/abort.js +52 -0
- package/dist-lib/lib/connect/bridges.d.ts +21 -0
- package/dist-lib/lib/connect/bridges.js +185 -0
- package/dist-lib/lib/connect/decode.d.ts +31 -0
- package/dist-lib/lib/connect/decode.js +114 -0
- package/dist-lib/lib/connect/host-run-log.d.ts +16 -0
- package/dist-lib/lib/connect/host-run-log.js +74 -0
- package/dist-lib/lib/connect/served.d.ts +7 -0
- package/dist-lib/lib/connect/served.js +45 -0
- package/dist-lib/lib/connect.d.ts +20 -11
- package/dist-lib/lib/connect.js +178 -415
- package/dist-lib/lib/context-window.d.ts +13 -5
- package/dist-lib/lib/context-window.js +19 -6
- package/dist-lib/lib/contract/agent.d.ts +25 -4
- package/dist-lib/lib/contract/completion.d.ts +82 -32
- package/dist-lib/lib/contract/drive.d.ts +130 -0
- package/dist-lib/lib/contract/drive.js +1 -0
- package/dist-lib/lib/contract/egress-proxy.d.ts +13 -0
- package/dist-lib/lib/contract/egress-proxy.js +1 -0
- package/dist-lib/lib/contract/exec.d.ts +4 -3
- package/dist-lib/lib/contract/hooks.d.ts +4 -1
- package/dist-lib/lib/contract/index.d.ts +4 -0
- package/dist-lib/lib/contract/knowledge.d.ts +10 -0
- package/dist-lib/lib/contract/managed-skills.d.ts +1 -0
- package/dist-lib/lib/contract/managed-skills.js +1 -0
- package/dist-lib/lib/contract/media.d.ts +58 -0
- package/dist-lib/lib/contract/media.js +1 -0
- package/dist-lib/lib/contract/models.d.ts +12 -6
- package/dist-lib/lib/contract/ocr.d.ts +17 -0
- package/dist-lib/lib/contract/ocr.js +1 -0
- package/dist-lib/lib/contract/policy.d.ts +75 -0
- package/dist-lib/lib/contract/policy.js +1 -0
- package/dist-lib/lib/contract/run.d.ts +28 -3
- package/dist-lib/lib/contract/sandbox.d.ts +3 -1
- package/dist-lib/lib/contract/speech.d.ts +1 -1
- package/dist-lib/lib/contract/translation.d.ts +20 -0
- package/dist-lib/lib/contract/translation.js +1 -0
- package/dist-lib/lib/contract-types.d.ts +48 -16
- package/dist-lib/lib/embeddings/index.d.ts +7 -1
- package/dist-lib/lib/embeddings/index.js +26 -5
- package/dist-lib/lib/errors.d.ts +278 -0
- package/dist-lib/lib/errors.js +212 -0
- package/dist-lib/lib/fold/index.d.ts +26 -1
- package/dist-lib/lib/fold/index.js +76 -9
- package/dist-lib/lib/guarded-fetch.js +11 -7
- package/dist-lib/lib/guards.d.ts +2 -0
- package/dist-lib/lib/guards.js +7 -0
- package/dist-lib/lib/hardware/capability-probe.js +10 -7
- package/dist-lib/lib/hardware/cpu-placement.d.ts +8 -0
- package/dist-lib/lib/hardware/cpu-placement.js +48 -0
- package/dist-lib/lib/hardware/gpu-probe-addon.js +26 -11
- package/dist-lib/lib/hardware/gpu-probe.js +10 -1
- package/dist-lib/lib/hardware/gpu-stats.native.cjs +17 -1
- package/dist-lib/lib/helpers/completion-params.d.ts +7 -2
- package/dist-lib/lib/helpers/completion-params.js +26 -2
- package/dist-lib/lib/helpers/control-tokens.d.ts +3 -0
- package/dist-lib/lib/helpers/control-tokens.js +25 -0
- package/dist-lib/lib/helpers/engine-error.d.ts +2 -1
- package/dist-lib/lib/helpers/engine-error.js +12 -12
- package/dist-lib/lib/helpers/goal-check/asks.d.ts +25 -0
- package/dist-lib/lib/helpers/goal-check/asks.js +52 -0
- package/dist-lib/lib/helpers/goal-check/checks.d.ts +8 -0
- package/dist-lib/lib/helpers/goal-check/checks.js +92 -0
- package/dist-lib/lib/helpers/goal-check/commands.d.ts +7 -0
- package/dist-lib/lib/helpers/goal-check/commands.js +130 -0
- package/dist-lib/lib/helpers/goal-check/paths.d.ts +5 -0
- package/dist-lib/lib/helpers/goal-check/paths.js +44 -0
- package/dist-lib/lib/helpers/goal-check/shell.d.ts +9 -0
- package/dist-lib/lib/helpers/goal-check/shell.js +96 -0
- package/dist-lib/lib/helpers/goal-check.d.ts +36 -0
- package/dist-lib/lib/helpers/goal-check.js +35 -0
- package/dist-lib/lib/helpers/head-tail.js +1 -1
- package/dist-lib/lib/helpers/html-helpers.js +9 -6
- package/dist-lib/lib/helpers/load-stall.d.ts +1 -1
- package/dist-lib/lib/helpers/load-stall.js +2 -2
- package/dist-lib/lib/helpers/markup-stream-filter.d.ts +4 -1
- package/dist-lib/lib/helpers/markup-stream-filter.js +20 -6
- package/dist-lib/lib/helpers/recent-map.d.ts +7 -0
- package/dist-lib/lib/helpers/recent-map.js +23 -0
- package/dist-lib/lib/helpers/repeated-reply.js +24 -16
- package/dist-lib/lib/helpers/require-peers.d.ts +3 -0
- package/dist-lib/lib/helpers/require-peers.js +23 -0
- package/dist-lib/lib/helpers/run-outcome.d.ts +2 -0
- package/dist-lib/lib/helpers/run-outcome.js +6 -2
- package/dist-lib/lib/helpers/spawn-path.d.ts +1 -0
- package/dist-lib/lib/helpers/spawn-path.js +2 -1
- package/dist-lib/lib/helpers/thinking.d.ts +3 -2
- package/dist-lib/lib/helpers/thinking.js +19 -0
- package/dist-lib/lib/helpers/tool-call-markup/emit.d.ts +6 -0
- package/dist-lib/lib/helpers/tool-call-markup/emit.js +15 -0
- package/dist-lib/lib/helpers/tool-call-markup/recover.d.ts +22 -0
- package/dist-lib/lib/helpers/tool-call-markup/recover.js +130 -0
- package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.d.ts +3 -0
- package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.js +56 -0
- package/dist-lib/lib/helpers/tool-call-markup/strip.d.ts +4 -0
- package/dist-lib/lib/helpers/tool-call-markup/strip.js +149 -0
- package/dist-lib/lib/helpers/tool-call-markup.d.ts +19 -24
- package/dist-lib/lib/helpers/tool-call-markup.js +17 -343
- package/dist-lib/lib/hooks/built-in/arg-repair.js +6 -2
- package/dist-lib/lib/hooks/built-in/policy-rules.d.ts +8 -0
- package/dist-lib/lib/hooks/built-in/policy-rules.js +192 -0
- package/dist-lib/lib/hooks/built-in/sandbox.js +23 -5
- package/dist-lib/lib/hooks/index.d.ts +4 -1
- package/dist-lib/lib/hooks/index.js +9 -4
- package/dist-lib/lib/hooks/run.js +3 -3
- package/dist-lib/lib/lifecycle/index.js +15 -14
- package/dist-lib/lib/lifecycle/machine.js +2 -2
- package/dist-lib/lib/log.d.ts +26 -5
- package/dist-lib/lib/log.js +86 -23
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +15 -16
- package/dist-lib/lib/machine/completion/actions/completion.js +164 -107
- package/dist-lib/lib/machine/completion/actions/goal.d.ts +10 -0
- package/dist-lib/lib/machine/completion/actions/goal.js +93 -0
- package/dist-lib/lib/machine/completion/actions/prepare.js +3 -2
- package/dist-lib/lib/machine/completion/actions/reject-tool.d.ts +16 -0
- package/dist-lib/lib/machine/completion/actions/reject-tool.js +147 -0
- package/dist-lib/lib/machine/completion/actions/retry-round.d.ts +6 -0
- package/dist-lib/lib/machine/completion/actions/retry-round.js +50 -0
- package/dist-lib/lib/machine/completion/actions/rounds.d.ts +5 -0
- package/dist-lib/lib/machine/completion/actions/rounds.js +31 -0
- package/dist-lib/lib/machine/completion/actions/tools.d.ts +1 -16
- package/dist-lib/lib/machine/completion/actions/tools.js +111 -140
- package/dist-lib/lib/machine/completion/context.js +11 -1
- package/dist-lib/lib/machine/completion/guards/retry.d.ts +3 -1
- package/dist-lib/lib/machine/completion/guards/retry.js +9 -2
- package/dist-lib/lib/machine/completion/implementations.d.ts +18 -9
- package/dist-lib/lib/machine/completion/implementations.js +64 -16
- package/dist-lib/lib/machine/completion/machine.d.ts +38 -9
- package/dist-lib/lib/machine/completion/machine.js +58 -9
- package/dist-lib/lib/machine/completion/metrics.d.ts +25 -0
- package/dist-lib/lib/machine/completion/metrics.js +68 -0
- package/dist-lib/lib/machine/completion/nudges.d.ts +5 -0
- package/dist-lib/lib/machine/completion/nudges.js +33 -0
- package/dist-lib/lib/machine/completion/rules.d.ts +19 -27
- package/dist-lib/lib/machine/completion/rules.js +48 -79
- package/dist-lib/lib/machine/completion/splice.d.ts +9 -0
- package/dist-lib/lib/machine/completion/splice.js +19 -0
- package/dist-lib/lib/machine/completion/types.d.ts +81 -14
- package/dist-lib/lib/machine/index.d.ts +50 -11
- package/dist-lib/lib/machine/index.js +12 -2
- package/dist-lib/lib/media-host.d.ts +12 -0
- package/dist-lib/lib/media-host.js +52 -0
- package/dist-lib/lib/media-port.d.ts +20 -0
- package/dist-lib/lib/media-port.js +77 -0
- package/dist-lib/lib/media-wire.d.ts +8 -0
- package/dist-lib/lib/media-wire.js +111 -0
- package/dist-lib/lib/models/context-choice.d.ts +15 -0
- package/dist-lib/lib/models/context-choice.js +62 -0
- package/dist-lib/lib/models/context.d.ts +1 -1
- package/dist-lib/lib/models/custom-model-cache.d.ts +1 -0
- package/dist-lib/lib/models/custom-model-cache.js +3 -0
- package/dist-lib/lib/models/download-gate.d.ts +20 -0
- package/dist-lib/lib/models/download-gate.js +73 -0
- package/dist-lib/lib/models/gguf-header.d.ts +11 -0
- package/dist-lib/lib/models/gguf-header.js +203 -15
- package/dist-lib/lib/models/gpu-selection.d.ts +6 -1
- package/dist-lib/lib/models/gpu-selection.js +29 -5
- package/dist-lib/lib/models/kv-cache.d.ts +2 -0
- package/dist-lib/lib/models/kv-cache.js +8 -0
- package/dist-lib/lib/models/llm-presets.d.ts +6 -1
- package/dist-lib/lib/models/llm-presets.js +33 -6
- package/dist-lib/lib/models/load-requests.d.ts +9 -0
- package/dist-lib/lib/models/load-requests.js +42 -0
- package/dist-lib/lib/models/memory-cap.d.ts +13 -0
- package/dist-lib/lib/models/memory-cap.js +21 -0
- package/dist-lib/lib/models/model-catalog-constants.d.ts +2 -2
- package/dist-lib/lib/models/model-catalog-constants.js +3 -4
- package/dist-lib/lib/models/model-catalog.d.ts +7 -3
- package/dist-lib/lib/models/model-catalog.js +44 -11
- package/dist-lib/lib/models/model-delete.d.ts +1 -1
- package/dist-lib/lib/models/model-fit.d.ts +2 -2
- package/dist-lib/lib/models/model-fit.js +5 -6
- package/dist-lib/lib/models/model-handle.d.ts +9 -2
- package/dist-lib/lib/models/model-handle.js +14 -3
- package/dist-lib/lib/models/model-list.d.ts +9 -2
- package/dist-lib/lib/models/model-list.js +23 -0
- package/dist-lib/lib/models/model-pool.d.ts +42 -7
- package/dist-lib/lib/models/model-pool.js +139 -49
- package/dist-lib/lib/models/model-source.d.ts +3 -2
- package/dist-lib/lib/models/model-source.js +23 -5
- package/dist-lib/lib/models/opencl-cache.js +2 -2
- package/dist-lib/lib/models/sdk-faults.d.ts +1 -0
- package/dist-lib/lib/models/sdk-faults.js +9 -0
- package/dist-lib/lib/models/tool-dialect.d.ts +1 -1
- package/dist-lib/lib/models/tts-model-default.d.ts +2 -1
- package/dist-lib/lib/models/tts-model-default.js +8 -6
- package/dist-lib/lib/no-redirect-fetch-bare.js +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.d.ts +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.js +46 -8
- package/dist-lib/lib/office/engine/pptx/picture-area.d.ts +23 -0
- package/dist-lib/lib/office/engine/pptx/picture-area.js +84 -0
- package/dist-lib/lib/office/engine/pptx/presentation.d.ts +2 -0
- package/dist-lib/lib/office/engine/pptx/presentation.js +64 -21
- package/dist-lib/lib/office/engine/pptx/types.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/sheet.js +10 -4
- package/dist-lib/lib/office/engine/xlsx/workbook.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/workbook.js +34 -3
- package/dist-lib/lib/office/extract.js +4 -3
- package/dist-lib/lib/office/index.js +2 -1
- package/dist-lib/lib/plugins/registry.d.ts +15 -0
- package/dist-lib/lib/plugins/registry.js +91 -22
- package/dist-lib/lib/plugins/require-bare.d.ts +1 -0
- package/dist-lib/lib/plugins/require-bare.js +13 -0
- package/dist-lib/lib/policy/index.d.ts +11 -0
- package/dist-lib/lib/policy/index.js +235 -0
- package/dist-lib/lib/prompt.d.ts +9 -4
- package/dist-lib/lib/prompt.js +95 -32
- package/dist-lib/lib/residency/completion-runtime.d.ts +17 -6
- package/dist-lib/lib/residency/completion-runtime.js +91 -37
- package/dist-lib/lib/residency/index.d.ts +59 -6
- package/dist-lib/lib/residency/index.js +444 -42
- package/dist-lib/lib/resolution-detector.js +3 -3
- package/dist-lib/lib/round-host.d.ts +12 -0
- package/dist-lib/lib/round-host.js +57 -0
- package/dist-lib/lib/round-port.d.ts +24 -0
- package/dist-lib/lib/round-port.js +81 -0
- package/dist-lib/lib/rpc-session.js +2 -1
- package/dist-lib/lib/run-log/redact.js +7 -7
- package/dist-lib/lib/run-log/request-codec.js +2 -2
- package/dist-lib/lib/sdk-loader.d.ts +1 -1
- package/dist-lib/lib/sdk-loader.js +47 -17
- package/dist-lib/lib/sdk-storage.d.ts +1 -0
- package/dist-lib/lib/sdk-storage.js +18 -2
- package/dist-lib/lib/serve/completion.d.ts +7 -0
- package/dist-lib/lib/serve/completion.js +553 -0
- package/dist-lib/lib/serve/downloads.d.ts +4 -0
- package/dist-lib/lib/serve/downloads.js +79 -0
- package/dist-lib/lib/serve/models.d.ts +5 -0
- package/dist-lib/lib/serve/models.js +120 -0
- package/dist-lib/lib/serve/noop.d.ts +1 -0
- package/dist-lib/lib/serve/noop.js +1 -0
- package/dist-lib/lib/serve/requests.d.ts +147 -0
- package/dist-lib/lib/serve/requests.js +1 -0
- package/dist-lib/lib/serve/rounds.d.ts +11 -0
- package/dist-lib/lib/serve/rounds.js +67 -0
- package/dist-lib/lib/serve/run-log-start.d.ts +38 -0
- package/dist-lib/lib/serve/run-log-start.js +254 -0
- package/dist-lib/lib/serve/skills.d.ts +32 -0
- package/dist-lib/lib/serve/skills.js +46 -0
- package/dist-lib/lib/serve.d.ts +5 -1
- package/dist-lib/lib/serve.js +51 -916
- package/dist-lib/lib/sidecar/index.d.ts +39 -0
- package/dist-lib/lib/sidecar/index.js +205 -0
- package/dist-lib/lib/sidecar/user-plugins.d.ts +9 -0
- package/dist-lib/lib/sidecar/user-plugins.js +119 -0
- package/dist-lib/lib/skills-host/index.d.ts +7 -3
- package/dist-lib/lib/skills-host/index.js +47 -22
- package/dist-lib/lib/spawn.d.ts +6 -4
- package/dist-lib/lib/spawn.js +22 -20
- package/dist-lib/lib/spill.d.ts +1 -0
- package/dist-lib/lib/spill.js +12 -8
- package/dist-lib/lib/tools/ask-user.d.ts +2 -0
- package/dist-lib/lib/tools/ask-user.js +137 -0
- package/dist-lib/lib/tools/attachments/delivered.d.ts +5 -0
- package/dist-lib/lib/tools/attachments/delivered.js +16 -0
- package/dist-lib/lib/tools/attachments/fetched-file.d.ts +32 -0
- package/dist-lib/lib/tools/attachments/fetched-file.js +134 -0
- package/dist-lib/lib/tools/attachments/staging.d.ts +1 -0
- package/dist-lib/lib/tools/attachments/staging.js +19 -8
- package/dist-lib/lib/tools/exec/runner.d.ts +4 -0
- package/dist-lib/lib/tools/exec/runner.js +20 -2
- package/dist-lib/lib/tools/exec/scope.d.ts +0 -1
- package/dist-lib/lib/tools/exec/scope.js +23 -114
- package/dist-lib/lib/tools/exec/shell-guidance.js +4 -4
- package/dist-lib/lib/tools/exec/shell-line.d.ts +26 -0
- package/dist-lib/lib/tools/exec/shell-line.js +334 -0
- package/dist-lib/lib/tools/exec.d.ts +4 -1
- package/dist-lib/lib/tools/exec.js +89 -27
- package/dist-lib/lib/tools/files/edit-file.d.ts +6 -0
- package/dist-lib/lib/tools/files/edit-file.js +266 -0
- package/dist-lib/lib/tools/files/glob.d.ts +3 -0
- package/dist-lib/lib/tools/files/glob.js +65 -0
- package/dist-lib/lib/tools/files/grep.d.ts +6 -0
- package/dist-lib/lib/tools/files/grep.js +212 -0
- package/dist-lib/lib/tools/files/index.d.ts +3 -0
- package/dist-lib/lib/tools/files/index.js +25 -0
- package/dist-lib/lib/tools/files/list-dir.d.ts +6 -0
- package/dist-lib/lib/tools/files/list-dir.js +136 -0
- package/dist-lib/lib/tools/files/make-dir.d.ts +3 -0
- package/dist-lib/lib/tools/files/make-dir.js +48 -0
- package/dist-lib/lib/tools/files/read-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/read-file.js +224 -0
- package/dist-lib/lib/tools/files/transfer.d.ts +4 -0
- package/dist-lib/lib/tools/files/transfer.js +83 -0
- package/dist-lib/lib/tools/files/trash-file.d.ts +4 -0
- package/dist-lib/lib/tools/files/trash-file.js +62 -0
- package/dist-lib/lib/tools/files/write-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/write-file.js +56 -0
- package/dist-lib/lib/tools/fs/document-text.d.ts +8 -0
- package/dist-lib/lib/tools/fs/document-text.js +22 -0
- package/dist-lib/lib/tools/fs/drive.d.ts +5 -25
- package/dist-lib/lib/tools/fs/drive.js +9 -1
- package/dist-lib/lib/tools/fs/edit-match.d.ts +33 -0
- package/dist-lib/lib/tools/fs/edit-match.js +445 -0
- package/dist-lib/lib/tools/fs/ignore.d.ts +13 -0
- package/dist-lib/lib/tools/fs/ignore.js +104 -0
- package/dist-lib/lib/tools/fs/local.js +28 -5
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +2 -40
- package/dist-lib/lib/tools/fs/remote-protocol.js +1 -1
- package/dist-lib/lib/tools/fs/remote.d.ts +3 -11
- package/dist-lib/lib/tools/fs/remote.js +24 -14
- package/dist-lib/lib/tools/fs/scope.d.ts +4 -15
- package/dist-lib/lib/tools/fs/scope.js +5 -2
- package/dist-lib/lib/tools/fs/search.d.ts +25 -0
- package/dist-lib/lib/tools/fs/search.js +383 -0
- package/dist-lib/lib/tools/{file-glob.d.ts → fs/targets.d.ts} +1 -5
- package/dist-lib/lib/tools/fs/targets.js +32 -0
- package/dist-lib/lib/tools/fs/tool-path.d.ts +27 -0
- package/dist-lib/lib/tools/fs/tool-path.js +70 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +14 -5
- package/dist-lib/lib/tools/fs/walk.js +119 -24
- package/dist-lib/lib/tools/http-request/request.d.ts +4 -2
- package/dist-lib/lib/tools/http-request/request.js +2 -1
- package/dist-lib/lib/tools/http-request/truncate-response.d.ts +16 -1
- package/dist-lib/lib/tools/http-request/truncate-response.js +56 -11
- package/dist-lib/lib/tools/http-request.d.ts +1 -0
- package/dist-lib/lib/tools/http-request.js +101 -16
- package/dist-lib/lib/tools/index.d.ts +4 -1
- package/dist-lib/lib/tools/index.js +8 -12
- package/dist-lib/lib/tools/office/ops.d.ts +1 -0
- package/dist-lib/lib/tools/office/ops.js +5 -1
- package/dist-lib/lib/tools/office.d.ts +2 -1
- package/dist-lib/lib/tools/office.js +273 -56
- package/dist-lib/lib/tools/operations/builders.d.ts +4 -3
- package/dist-lib/lib/tools/operations/builders.js +41 -3
- package/dist-lib/lib/tools/operations/calendar-range.d.ts +16 -0
- package/dist-lib/lib/tools/operations/calendar-range.js +40 -0
- package/dist-lib/lib/tools/operations/compile.js +8 -6
- package/dist-lib/lib/tools/operations/manifest.d.ts +4 -0
- package/dist-lib/lib/tools/pdf/build.d.ts +17 -3
- package/dist-lib/lib/tools/pdf/build.js +77 -16
- package/dist-lib/lib/tools/pdf/pages.d.ts +12 -0
- package/dist-lib/lib/tools/pdf/pages.js +31 -0
- package/dist-lib/lib/tools/pdf/recognize.d.ts +13 -0
- package/dist-lib/lib/tools/pdf/recognize.js +55 -0
- package/dist-lib/lib/tools/pdf/request.d.ts +3 -8
- package/dist-lib/lib/tools/pdf/request.js +4 -4
- package/dist-lib/lib/tools/pdf.d.ts +0 -1
- package/dist-lib/lib/tools/pdf.js +56 -13
- package/dist-lib/lib/tools/skill.js +23 -11
- package/dist-lib/lib/tools/skills/bundled-dir.d.ts +8 -1
- package/dist-lib/lib/tools/skills/bundled-dir.js +42 -36
- package/dist-lib/lib/tools/skills/bundled-hash.d.ts +1 -0
- package/dist-lib/lib/tools/skills/bundled-hash.js +4 -1
- package/dist-lib/lib/tools/skills/catalog-loader.d.ts +12 -0
- package/dist-lib/lib/tools/skills/catalog-loader.js +173 -0
- package/dist-lib/lib/tools/skills/catalog.d.ts +7 -8
- package/dist-lib/lib/tools/skills/catalog.js +1 -158
- package/dist-lib/lib/tools/skills/cli-argv.js +25 -5
- package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/cli-schema-check.js +3 -0
- package/dist-lib/lib/tools/skills/cli-schema-load.js +10 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +2 -0
- package/dist-lib/lib/tools/skills/cli-schema.js +6 -3
- package/dist-lib/lib/tools/skills/credential-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/credential-check.js +3 -0
- package/dist-lib/lib/tools/skills/credential-health.js +3 -3
- package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +3 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +5 -0
- package/dist-lib/lib/tools/skills/index.d.ts +1 -0
- package/dist-lib/lib/tools/skills/index.js +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.d.ts +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +39 -3
- package/dist-lib/lib/tools/skills/manifest.d.ts +1 -0
- package/dist-lib/lib/tools/skills/mention-name.d.ts +6 -0
- package/dist-lib/lib/tools/skills/mention-name.js +6 -0
- package/dist-lib/lib/tools/skills/mention.d.ts +2 -2
- package/dist-lib/lib/tools/skills/mention.js +11 -4
- package/dist-lib/lib/tools/skills/overlay-crud.d.ts +3 -3
- package/dist-lib/lib/tools/skills/overlay-crud.js +7 -6
- package/dist-lib/lib/tools/skills/overlay-watch.d.ts +2 -2
- package/dist-lib/lib/tools/skills/overlay-watch.js +4 -3
- package/dist-lib/lib/tools/skills/scope-key.d.ts +1 -0
- package/dist-lib/lib/tools/skills/scope-key.js +4 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +1 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.js +4 -0
- package/dist-lib/lib/tools/skills/skill-tree.d.ts +5 -0
- package/dist-lib/lib/tools/skills/skill-tree.js +54 -0
- package/dist-lib/lib/tools/url-guard.d.ts +6 -1
- package/dist-lib/lib/tools/url-guard.js +8 -2
- package/dist-lib/lib/tools/web-fetch.js +50 -133
- package/dist-lib/lib/wire/download.d.ts +10 -0
- package/dist-lib/lib/wire/download.js +35 -0
- package/dist-lib/lib/wire/event.d.ts +41 -0
- package/dist-lib/lib/wire/event.js +306 -0
- package/dist-lib/lib/wire/fields.d.ts +3 -0
- package/dist-lib/lib/wire/fields.js +12 -0
- package/dist-lib/lib/wire/knowledge.d.ts +9 -0
- package/dist-lib/lib/wire/knowledge.js +68 -0
- package/dist-lib/lib/wire/round.d.ts +14 -0
- package/dist-lib/lib/wire/round.js +45 -0
- package/dist-lib/lib/wire/vectors.d.ts +6 -0
- package/dist-lib/lib/wire/vectors.js +33 -0
- package/dist-lib/lib/wire.d.ts +28 -64
- package/dist-lib/lib/wire.js +24 -417
- package/dist-lib/plugins/coding/index.d.ts +1 -1
- package/dist-lib/plugins/coding/index.js +2 -4
- package/dist-lib/plugins/coding/read-only.d.ts +1 -0
- package/dist-lib/plugins/coding/read-only.js +264 -0
- package/dist-lib/plugins/coding/session.d.ts +6 -4
- package/dist-lib/plugins/coding/session.js +45 -16
- package/dist-lib/plugins/coding-guards/index.d.ts +25 -0
- package/dist-lib/plugins/coding-guards/index.js +126 -0
- package/dist-lib/plugins/command-hooks/index.js +5 -3
- package/dist-lib/plugins/egress-proxy/index.d.ts +53 -0
- package/dist-lib/plugins/egress-proxy/index.js +184 -0
- package/dist-lib/plugins/image/edit-image.d.ts +3 -22
- package/dist-lib/plugins/image/edit-image.js +23 -46
- package/dist-lib/plugins/image/fit.d.ts +31 -0
- package/dist-lib/plugins/image/fit.js +28 -0
- package/dist-lib/plugins/image/generate-image.d.ts +27 -6
- package/dist-lib/plugins/image/generate-image.js +201 -74
- package/dist-lib/plugins/image/index.d.ts +2 -1
- package/dist-lib/plugins/image/index.js +29 -12
- package/dist-lib/plugins/knowledge/index.d.ts +3 -0
- package/dist-lib/plugins/knowledge/index.js +5 -0
- package/dist-lib/plugins/knowledge/manifest.d.ts +53 -0
- package/dist-lib/plugins/knowledge/manifest.js +86 -0
- package/dist-lib/plugins/knowledge/search-tool.js +8 -8
- package/dist-lib/plugins/knowledge/store.d.ts +45 -8
- package/dist-lib/plugins/knowledge/store.js +428 -166
- package/dist-lib/plugins/language-hint/index.d.ts +15 -0
- package/dist-lib/plugins/language-hint/index.js +54 -0
- package/dist-lib/plugins/lsp/tool.js +2 -2
- package/dist-lib/plugins/mcp/call.js +15 -4
- package/dist-lib/plugins/mcp/index.js +6 -3
- package/dist-lib/plugins/mcp/protocol.d.ts +10 -2
- package/dist-lib/plugins/mcp/protocol.js +13 -12
- package/dist-lib/plugins/mcp/server.js +1 -1
- package/dist-lib/plugins/mcp/tool-listing.d.ts +6 -0
- package/dist-lib/plugins/mcp/tool-listing.js +97 -0
- package/dist-lib/plugins/music/generate-music.d.ts +24 -5
- package/dist-lib/plugins/music/generate-music.js +170 -64
- package/dist-lib/plugins/music/index.d.ts +2 -1
- package/dist-lib/plugins/music/index.js +23 -11
- package/dist-lib/plugins/obsidian/command.js +2 -2
- package/dist-lib/plugins/obsidian/index.js +14 -4
- package/dist-lib/plugins/obsidian/note-name.js +2 -1
- package/dist-lib/plugins/obsidian/readiness.js +2 -2
- package/dist-lib/plugins/obsidian/safe-path.js +5 -4
- package/dist-lib/plugins/obsidian/vault-create.js +3 -2
- package/dist-lib/plugins/obsidian/vault-fs.js +2 -2
- package/dist-lib/plugins/obsidian/vault-paths.js +3 -2
- package/dist-lib/plugins/obsidian/vault-read.js +20 -18
- package/dist-lib/plugins/obsidian/vault-write.js +13 -12
- package/dist-lib/plugins/ocr/bmp.d.ts +2 -0
- package/dist-lib/plugins/ocr/bmp.js +27 -0
- package/dist-lib/plugins/ocr/coverage.d.ts +3 -0
- package/dist-lib/plugins/ocr/coverage.js +67 -0
- package/dist-lib/plugins/ocr/index.d.ts +12 -0
- package/dist-lib/plugins/ocr/index.js +20 -0
- package/dist-lib/plugins/ocr/ocr-runtime.d.ts +25 -0
- package/dist-lib/plugins/ocr/ocr-runtime.js +103 -0
- package/dist-lib/plugins/ocr/reading-order.d.ts +5 -0
- package/dist-lib/plugins/ocr/reading-order.js +218 -0
- package/dist-lib/plugins/python/bare-floor.d.ts +1 -0
- package/dist-lib/plugins/python/bare-floor.js +2 -0
- package/dist-lib/plugins/python/guarded-fetch.d.ts +2 -1
- package/dist-lib/plugins/python/guarded-fetch.js +5 -1
- package/dist-lib/plugins/python/index.d.ts +4 -1
- package/dist-lib/plugins/python/index.js +6 -1
- package/dist-lib/plugins/python/interrupt-timer.js +2 -2
- package/dist-lib/plugins/python/language.js +11 -10
- package/dist-lib/plugins/python/loader.d.ts +1 -0
- package/dist-lib/plugins/python/loader.js +76 -3
- package/dist-lib/plugins/python/memfs.js +2 -2
- package/dist-lib/plugins/python/pyodide.d.ts +1 -0
- package/dist-lib/plugins/python/pyodide.js +9 -8
- package/dist-lib/plugins/python/python-adapter.d.ts +6 -1
- package/dist-lib/plugins/python/python-adapter.js +37 -2
- package/dist-lib/plugins/python/run-session.d.ts +1 -0
- package/dist-lib/plugins/python/run-session.js +19 -8
- package/dist-lib/plugins/python/wheels.js +8 -6
- package/dist-lib/plugins/python/worker/active.js +2 -2
- package/dist-lib/plugins/python/worker/client.js +10 -9
- package/dist-lib/plugins/python/worker/entry.js +2 -8
- package/dist-lib/plugins/python/worker/preload.d.ts +1 -0
- package/dist-lib/plugins/python/worker/preload.js +2 -0
- package/dist-lib/plugins/python/worker/protocol.d.ts +2 -0
- package/dist-lib/plugins/python/worker/serve.js +23 -4
- package/dist-lib/plugins/python/worker/spawn.d.ts +2 -1
- package/dist-lib/plugins/python/worker/spawn.js +3 -2
- package/dist-lib/plugins/quickjs/index.js +4 -0
- package/dist-lib/plugins/quickjs/runtime.js +8 -3
- package/dist-lib/plugins/run-report/chain.d.ts +2 -0
- package/dist-lib/plugins/run-report/chain.js +73 -0
- package/dist-lib/plugins/run-report/flow-view.js +2 -1
- package/dist-lib/plugins/run-report/flow.d.ts +1 -1
- package/dist-lib/plugins/run-report/flow.js +66 -14
- package/dist-lib/plugins/run-report/index.d.ts +23 -2
- package/dist-lib/plugins/run-report/index.js +32 -13
- package/dist-lib/plugins/run-report/layout.js +1 -1
- package/dist-lib/plugins/run-report/model.d.ts +10 -1
- package/dist-lib/plugins/run-report/model.js +12 -6
- package/dist-lib/plugins/run-report/page.d.ts +9 -0
- package/dist-lib/plugins/run-report/page.js +55 -15
- package/dist-lib/plugins/run-report/script.js +317 -43
- package/dist-lib/plugins/run-report/story.d.ts +2 -1
- package/dist-lib/plugins/run-report/story.js +7 -4
- package/dist-lib/plugins/run-report/style.d.ts +1 -1
- package/dist-lib/plugins/run-report/style.js +126 -0
- package/dist-lib/plugins/run-report/why.js +1 -1
- package/dist-lib/plugins/sandbox-linux/index.d.ts +62 -0
- package/dist-lib/plugins/sandbox-linux/index.js +354 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.d.ts +2 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.js +74 -0
- package/dist-lib/plugins/sandbox-macos/index.d.ts +25 -11
- package/dist-lib/plugins/sandbox-macos/index.js +244 -49
- package/dist-lib/plugins/sandbox-vm/index.d.ts +2 -1
- package/dist-lib/plugins/sandbox-vm/index.js +5 -2
- package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +7 -3
- package/dist-lib/plugins/sandbox-vm/vm-shell.js +54 -20
- package/dist-lib/plugins/sandbox-windows/helper/qvac-sandbox.c +554 -0
- package/dist-lib/plugins/sandbox-windows/index.d.ts +53 -0
- package/dist-lib/plugins/sandbox-windows/index.js +205 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/speech/audio-resample.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-resample.js +8 -8
- package/dist-lib/plugins/speech/audio-transcode-bare.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-bare.js +23 -26
- package/dist-lib/plugins/speech/audio-transcode-node.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-node.js +1 -3
- package/dist-lib/plugins/speech/index.d.ts +1 -0
- package/dist-lib/plugins/speech/index.js +8 -1
- package/dist-lib/plugins/speech/speech-engine.d.ts +1 -1
- package/dist-lib/plugins/speech/speech-engine.js +10 -5
- package/dist-lib/plugins/speech/speech-runtime.js +37 -37
- package/dist-lib/plugins/speech/speech-text.d.ts +1 -0
- package/dist-lib/plugins/speech/speech-text.js +9 -4
- package/dist-lib/plugins/speech/voice.d.ts +5 -1
- package/dist-lib/plugins/speech/voice.js +107 -33
- package/dist-lib/plugins/translation/index.d.ts +2 -1
- package/dist-lib/plugins/translation/index.js +21 -10
- package/dist-lib/plugins/translation/translate.d.ts +9 -5
- package/dist-lib/plugins/translation/translate.js +69 -64
- package/dist-lib/plugins/walkie-talkie/index.d.ts +4 -2
- package/dist-lib/plugins/walkie-talkie/index.js +19 -6
- package/dist-lib/plugins/walkie-talkie/wire.d.ts +5 -0
- package/dist-lib/plugins/walkie-talkie/wire.js +6 -5
- package/dist-lib/plugins/weather/geocode.js +2 -1
- package/dist-lib/plugins/weather/lookup.js +6 -4
- package/dist-lib/plugins/web-search/engines/bing.js +2 -1
- package/dist-lib/plugins/web-search/engines/google.js +2 -1
- package/dist-lib/plugins/web-search/fetch-html.d.ts +5 -5
- package/dist-lib/plugins/web-search/fetch-html.js +12 -15
- package/dist-lib/plugins/web-search/tool.js +1 -0
- package/dist-lib/schema/generate.js +8 -1
- package/dist-lib/schema/harness.js +94 -12
- package/dist-lib/spec/bind.js +12 -0
- package/dist-lib/spec/calls.js +4 -0
- package/dist-lib/spec/hrpc/hrpc.json +55 -3
- package/dist-lib/spec/hrpc/index.js +58 -10
- package/dist-lib/spec/hrpc/messages.js +485 -209
- package/dist-lib/spec/hyperschema/index.js +485 -209
- package/dist-lib/spec/hyperschema/schema.json +290 -85
- package/dist-lib/spec/hyperschema/types.d.ts +42 -5
- package/package.json +265 -65
- package/patches/pyodide@314.0.2.patch +37 -8
- package/scripts/addon-externals.cjs +16 -5
- package/worker/harness-sidecar.mjs +23 -154
- package/dist-lib/lib/tools/create-documents.d.ts +0 -3
- package/dist-lib/lib/tools/create-documents.js +0 -95
- package/dist-lib/lib/tools/edit-documents.d.ts +0 -3
- package/dist-lib/lib/tools/edit-documents.js +0 -132
- package/dist-lib/lib/tools/exec/shell-argv.d.ts +0 -2
- package/dist-lib/lib/tools/exec/shell-argv.js +0 -61
- package/dist-lib/lib/tools/file-glob.js +0 -118
- package/dist-lib/lib/tools/grep.d.ts +0 -5
- package/dist-lib/lib/tools/grep.js +0 -184
- package/dist-lib/lib/tools/read-files.d.ts +0 -5
- package/dist-lib/lib/tools/read-files.js +0 -160
- package/dist-lib/plugins/coding/write-file.d.ts +0 -3
- package/dist-lib/plugins/coding/write-file.js +0 -52
- package/patches/@qvac%2Finference@0.21.0.patch +0 -67
- package/patches/bare-stow@0.1.5.patch +0 -68
- package/patches/hypercore-blob-server@1.15.0.patch +0 -15
- package/patches/localwatch@1.4.3.patch +0 -13
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { errorMessage } from '../../guards.js';
|
|
2
|
+
import { searchTargets } from '../fs/targets.js';
|
|
3
|
+
import { compileGlob } from '../fs/glob.js';
|
|
4
|
+
import { callDenyRoots, defaultRealpath } from '../fs/scope.js';
|
|
5
|
+
import { DriveSearch } from '../fs/search.js';
|
|
6
|
+
import { anchorOf, shownPath, stringArg } from '../fs/tool-path.js';
|
|
7
|
+
import { MAX_WALK_ENTRIES, MAX_WALK_MS } from '../fs/walk.js';
|
|
8
|
+
import { folderArg, folderPaths } from './list-dir.js';
|
|
9
|
+
const GREP_MATCHES = 100;
|
|
10
|
+
const MAX_LIMIT = 500;
|
|
11
|
+
const MAX_LINE_CHARS = 300;
|
|
12
|
+
const TALLY_MATCHES = 5000;
|
|
13
|
+
const SPREAD_MATCHES = 1000;
|
|
14
|
+
const SPREAD_PER_FILE = 3;
|
|
15
|
+
const SPREAD_NAMED = 10;
|
|
16
|
+
const OUTPUTS = ['content', 'files', 'count'];
|
|
17
|
+
const isOutput = (value) => OUTPUTS.some((output) => output === value);
|
|
18
|
+
const ALTERNATIVE = /(?<![\\|])\|(?!\|)/;
|
|
19
|
+
const REGEX_LIKE = /\.\*|\\[a-z.(|]|^\^|\$$|\[[^\]]*\]|\(\?/i;
|
|
20
|
+
export function createGrepTool({ realpath = defaultRealpath, deniedRoots, maxWalkEntries = MAX_WALK_ENTRIES } = {}) {
|
|
21
|
+
return {
|
|
22
|
+
name: 'grep',
|
|
23
|
+
toolset: 'files',
|
|
24
|
+
description: 'Search inside the files of the shared folder. The pattern is plain text, case-insensitive; ' +
|
|
25
|
+
'"a|b" finds either; set regex for a regular expression. Returns "path:line: text"; output ' +
|
|
26
|
+
'"files" lists matching files with the first line and count, "count" counts per file. Narrow with include (e.g. "*.ts").',
|
|
27
|
+
parameters: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
pattern: { type: 'string', description: 'Text to find' },
|
|
31
|
+
dir: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Folder to search, relative to the shared folder (optional)'
|
|
34
|
+
},
|
|
35
|
+
include: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Only files whose name matches this pattern (optional)'
|
|
38
|
+
},
|
|
39
|
+
regex: { type: 'boolean', description: 'Treat pattern as a regular expression' },
|
|
40
|
+
output: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
enum: [...OUTPUTS],
|
|
43
|
+
description: 'content (default): matching lines; files: matching paths; count: per file'
|
|
44
|
+
},
|
|
45
|
+
limit: { type: 'number', description: `Most rows to return (default ${GREP_MATCHES})` },
|
|
46
|
+
offset: { type: 'number', description: 'Rows to skip, to page past a cut-off answer' }
|
|
47
|
+
},
|
|
48
|
+
required: ['pattern']
|
|
49
|
+
},
|
|
50
|
+
effect: () => 'read',
|
|
51
|
+
concurrent: true,
|
|
52
|
+
stableRead: true,
|
|
53
|
+
autoApprove: true,
|
|
54
|
+
rootsRequired: true,
|
|
55
|
+
validate(args) {
|
|
56
|
+
if (!stringArg(args, 'pattern'))
|
|
57
|
+
return 'pattern is required';
|
|
58
|
+
if (args.output !== undefined && !isOutput(args.output)) {
|
|
59
|
+
return `output is one of ${OUTPUTS.join(', ')}`;
|
|
60
|
+
}
|
|
61
|
+
for (const key of ['limit', 'offset']) {
|
|
62
|
+
if (args[key] !== undefined && !(Number.isInteger(args[key]) && Number(args[key]) >= 0)) {
|
|
63
|
+
return `${key} is a whole number`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (args.regex !== true) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
new RegExp(String(args.pattern), 'i');
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
return `invalid regex: ${errorMessage(err)}`;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
paths: (args, ctx) => folderPaths(args, ctx),
|
|
78
|
+
resource: (args) => ({ kind: 'file', label: `grep ${String(args.pattern ?? '')}` }),
|
|
79
|
+
async execute(args, ctx) {
|
|
80
|
+
const roots = ctx?.fsRoots ?? [];
|
|
81
|
+
const deny = await callDenyRoots(deniedRoots, ctx?.policy, realpath);
|
|
82
|
+
const scoped = await searchTargets(folderArg(args, ctx), roots, { realpath, deny });
|
|
83
|
+
if ('error' in scoped) {
|
|
84
|
+
return scoped;
|
|
85
|
+
}
|
|
86
|
+
const pattern = String(args.pattern);
|
|
87
|
+
const regex = args.regex === true;
|
|
88
|
+
const queries = regex ? [pattern] : alternatives(pattern);
|
|
89
|
+
const output = isOutput(args.output) ? args.output : 'content';
|
|
90
|
+
const limit = Math.min(Number(args.limit ?? GREP_MATCHES), MAX_LIMIT);
|
|
91
|
+
const offset = Number(args.offset ?? 0);
|
|
92
|
+
const spread = args.output === undefined && args.limit === undefined && offset === 0;
|
|
93
|
+
const wanted = spread ? SPREAD_MATCHES : reach(output, offset + limit);
|
|
94
|
+
const query = {
|
|
95
|
+
search: new DriveSearch(queries, { regex }),
|
|
96
|
+
queries,
|
|
97
|
+
regex,
|
|
98
|
+
include: stringArg(args, 'include') ? includes(String(args.include), anchorOf(ctx)) : null,
|
|
99
|
+
deny,
|
|
100
|
+
maxEntries: maxWalkEntries
|
|
101
|
+
};
|
|
102
|
+
const hits = [];
|
|
103
|
+
let truncated = false;
|
|
104
|
+
for (const target of scoped.targets) {
|
|
105
|
+
let found;
|
|
106
|
+
try {
|
|
107
|
+
found = await searchTarget(target, {
|
|
108
|
+
...query,
|
|
109
|
+
maxMatches: wanted + 1 - hits.length
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
return { error: errorMessage(err) };
|
|
114
|
+
}
|
|
115
|
+
hits.push(...found.hits);
|
|
116
|
+
truncated ||= found.truncated || found.cut;
|
|
117
|
+
if (found.capped) {
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const anchor = anchorOf(ctx);
|
|
122
|
+
if (spread && hits.length > limit) {
|
|
123
|
+
return {
|
|
124
|
+
matches: spreadRows(hits.slice(0, wanted), limit, (file) => shownPath(file, anchor)),
|
|
125
|
+
truncated: true
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const all = answerRows(hits.slice(0, wanted), output, (file) => shownPath(file, anchor));
|
|
129
|
+
const rows = all.slice(offset, offset + limit);
|
|
130
|
+
const more = all.length > offset + limit || hits.length > wanted;
|
|
131
|
+
return {
|
|
132
|
+
matches: rows.join('\n') || noMatches(pattern, { regex, offset, found: all.length }),
|
|
133
|
+
truncated: truncated || more || undefined
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function includes(pattern, anchor) {
|
|
139
|
+
const glob = compileGlob(pattern.replace(/^\.\//, ''));
|
|
140
|
+
return pattern.includes('/') ? (_name, full) => glob(shownPath(full, anchor)) : glob;
|
|
141
|
+
}
|
|
142
|
+
const reach = (output, lines) => output === 'content' ? lines : TALLY_MATCHES;
|
|
143
|
+
function spreadRows(hits, limit, shown) {
|
|
144
|
+
const files = new Map();
|
|
145
|
+
for (const hit of hits) {
|
|
146
|
+
files.set(hit.file, [...(files.get(hit.file) ?? []), hit]);
|
|
147
|
+
}
|
|
148
|
+
const take = new Map();
|
|
149
|
+
let room = limit;
|
|
150
|
+
for (const [file, list] of files) {
|
|
151
|
+
const n = Math.min(list.length, SPREAD_PER_FILE, room);
|
|
152
|
+
take.set(file, n);
|
|
153
|
+
room -= n;
|
|
154
|
+
}
|
|
155
|
+
const bySize = [...files].sort(([, a], [, b]) => a.length - b.length);
|
|
156
|
+
for (const [file, list] of bySize) {
|
|
157
|
+
const n = Math.min(list.length - (take.get(file) ?? 0), room);
|
|
158
|
+
take.set(file, (take.get(file) ?? 0) + n);
|
|
159
|
+
room -= n;
|
|
160
|
+
}
|
|
161
|
+
const rows = [...files].flatMap(([file, list]) => list
|
|
162
|
+
.slice(0, take.get(file))
|
|
163
|
+
.map((hit) => `${shown(file)}:${hit.line}: ${hit.text.slice(0, MAX_LINE_CHARS)}`));
|
|
164
|
+
const left = [...files]
|
|
165
|
+
.map(([file, list]) => ({ file, n: list.length - (take.get(file) ?? 0) }))
|
|
166
|
+
.filter(({ n }) => n > 0);
|
|
167
|
+
const named = left.slice(0, SPREAD_NAMED).map(({ file, n }) => `${shown(file)} (${n})`);
|
|
168
|
+
const rest = left.length > SPREAD_NAMED ? `, and ${left.length - SPREAD_NAMED} more files` : '';
|
|
169
|
+
const more = left.reduce((sum, { n }) => sum + n, 0);
|
|
170
|
+
return [...rows, `… ${more} more matching lines: ${named.join(', ')}${rest}`].join('\n');
|
|
171
|
+
}
|
|
172
|
+
function alternatives(pattern) {
|
|
173
|
+
const parts = pattern
|
|
174
|
+
.split(ALTERNATIVE)
|
|
175
|
+
.map((part) => part.trim().replaceAll('\\|', '|'))
|
|
176
|
+
.filter(Boolean);
|
|
177
|
+
return parts.length ? parts : [pattern];
|
|
178
|
+
}
|
|
179
|
+
function answerRows(hits, output, shown) {
|
|
180
|
+
if (output === 'content') {
|
|
181
|
+
return hits.map((hit) => `${shown(hit.file)}:${hit.line}: ${hit.text.slice(0, MAX_LINE_CHARS)}`);
|
|
182
|
+
}
|
|
183
|
+
const files = new Map();
|
|
184
|
+
for (const hit of hits) {
|
|
185
|
+
const seen = files.get(hit.file);
|
|
186
|
+
files.set(hit.file, seen ? { ...seen, n: seen.n + 1 } : { first: hit.line, n: 1 });
|
|
187
|
+
}
|
|
188
|
+
return [...files].map(([file, { first, n }]) => output === 'files' ? `${shown(file)}:${first} (${n})` : `${shown(file)}: ${n}`);
|
|
189
|
+
}
|
|
190
|
+
function noMatches(pattern, { regex, offset, found }) {
|
|
191
|
+
if (found > 0)
|
|
192
|
+
return `no matches past offset ${offset} (${found} in all)`;
|
|
193
|
+
if (!regex && REGEX_LIKE.test(pattern)) {
|
|
194
|
+
return 'no matches (the pattern was searched as plain text; set regex: true for a regular expression)';
|
|
195
|
+
}
|
|
196
|
+
return 'no matches';
|
|
197
|
+
}
|
|
198
|
+
function searchTarget({ root, folder }, { search, queries, regex, include, deny, maxEntries, maxMatches }) {
|
|
199
|
+
if (root.kind === 'hyper' && root.search && !include) {
|
|
200
|
+
return root.search({
|
|
201
|
+
folder,
|
|
202
|
+
queries: [...queries],
|
|
203
|
+
regex,
|
|
204
|
+
caseSensitive: false,
|
|
205
|
+
includeIgnored: false,
|
|
206
|
+
maxMatches,
|
|
207
|
+
maxEntries,
|
|
208
|
+
maxMs: MAX_WALK_MS
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return search.searchFolder(root, folder, { maxMatches, maxEntries, include, deny });
|
|
212
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createEditFileTool, createEditManyTool, createInsertTextTool } from './edit-file.js';
|
|
2
|
+
import { createGlobTool } from './glob.js';
|
|
3
|
+
import { createGrepTool } from './grep.js';
|
|
4
|
+
import { createListDirTool } from './list-dir.js';
|
|
5
|
+
import { createMakeDirTool } from './make-dir.js';
|
|
6
|
+
import { createReadFileTool } from './read-file.js';
|
|
7
|
+
import { createCopyFileTool, createMoveFileTool } from './transfer.js';
|
|
8
|
+
import { createTrashFileTool } from './trash-file.js';
|
|
9
|
+
import { createWriteFileTool } from './write-file.js';
|
|
10
|
+
export function createFileTools(options = {}) {
|
|
11
|
+
return [
|
|
12
|
+
createReadFileTool(options),
|
|
13
|
+
createListDirTool(options),
|
|
14
|
+
createGlobTool(options),
|
|
15
|
+
createGrepTool(options),
|
|
16
|
+
createWriteFileTool(options),
|
|
17
|
+
createEditFileTool(options),
|
|
18
|
+
createInsertTextTool(options),
|
|
19
|
+
createEditManyTool(options),
|
|
20
|
+
createMoveFileTool(options),
|
|
21
|
+
createCopyFileTool(options),
|
|
22
|
+
createMakeDirTool(options),
|
|
23
|
+
createTrashFileTool(options)
|
|
24
|
+
];
|
|
25
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../../contract/index.ts';
|
|
2
|
+
import { type FsToolOptions } from '../fs/scope.ts';
|
|
3
|
+
import { type Grants } from '../fs/tool-path.ts';
|
|
4
|
+
export declare function createListDirTool({ realpath, deniedRoots }?: FsToolOptions): ToolDefinition;
|
|
5
|
+
export declare function folderArg(args: Record<string, unknown>, grants: Grants | undefined): string | undefined;
|
|
6
|
+
export declare function folderPaths(args: Record<string, unknown>, grants: Grants | undefined): string[];
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { relativeKey, searchTargets } from '../fs/targets.js';
|
|
3
|
+
import { callDenyRoots, defaultRealpath, displayPath, hostPath, isDeniedPath } from '../fs/scope.js';
|
|
4
|
+
import { anchorOf, rootedPath, stringArg } from '../fs/tool-path.js';
|
|
5
|
+
import { WALK_SKIP_DIRS, walkFiles } from '../fs/walk.js';
|
|
6
|
+
const LIST_ENTRIES = 200;
|
|
7
|
+
export function createListDirTool({ realpath = defaultRealpath, deniedRoots } = {}) {
|
|
8
|
+
return {
|
|
9
|
+
name: 'list_dir',
|
|
10
|
+
toolset: 'files',
|
|
11
|
+
description: 'List a folder inside the shared folder: each entry with its type, size and last change. ' +
|
|
12
|
+
'Leave path empty for the shared folder itself. Use this, not exec, to look inside it.',
|
|
13
|
+
parameters: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
path: { type: 'string', description: 'Folder, relative to the shared folder (optional)' }
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
effect: () => 'read',
|
|
20
|
+
concurrent: true,
|
|
21
|
+
stableRead: true,
|
|
22
|
+
autoApprove: true,
|
|
23
|
+
rootsRequired: true,
|
|
24
|
+
paths: (args, ctx) => folderPaths(args, ctx),
|
|
25
|
+
resource: (args, ctx) => ({
|
|
26
|
+
kind: 'file',
|
|
27
|
+
label: `list ${folderArg(args, ctx) ?? 'shared folder'}`
|
|
28
|
+
}),
|
|
29
|
+
async execute(args, ctx) {
|
|
30
|
+
const roots = ctx?.fsRoots ?? [];
|
|
31
|
+
const deny = await callDenyRoots(deniedRoots, ctx?.policy, realpath);
|
|
32
|
+
const scoped = await searchTargets(folderArg(args, ctx), roots, { realpath, deny });
|
|
33
|
+
if ('error' in scoped) {
|
|
34
|
+
return scoped;
|
|
35
|
+
}
|
|
36
|
+
const { entries, truncated } = await collect(scoped.targets, { deny, anchor: anchorOf(ctx) });
|
|
37
|
+
const rows = await describe([...entries].slice(0, LIST_ENTRIES));
|
|
38
|
+
return {
|
|
39
|
+
entries: rows.join('\n') || '(empty)',
|
|
40
|
+
truncated: truncated || entries.size > LIST_ENTRIES || undefined
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function folderArg(args, grants) {
|
|
46
|
+
const folder = stringArg(args, 'dir') ?? stringArg(args, 'path');
|
|
47
|
+
return folder && folder !== '.' && folder !== '/'
|
|
48
|
+
? rootedPath(folder, anchorOf(grants))
|
|
49
|
+
: undefined;
|
|
50
|
+
}
|
|
51
|
+
export function folderPaths(args, grants) {
|
|
52
|
+
const folder = folderArg(args, grants);
|
|
53
|
+
return folder ? [folder] : (grants?.fsRoots ?? []).map((root) => displayPath(root, '/'));
|
|
54
|
+
}
|
|
55
|
+
async function collect(targets, { deny, anchor }) {
|
|
56
|
+
const entries = new Map();
|
|
57
|
+
let truncated = false;
|
|
58
|
+
for (const target of targets) {
|
|
59
|
+
const own = targets.length === 1 || target.root === anchor;
|
|
60
|
+
const level = target.root.kind === 'local'
|
|
61
|
+
? await localLevel(target.root, target.folder, deny)
|
|
62
|
+
: await walkedLevel(target, deny);
|
|
63
|
+
truncated ||= level.truncated;
|
|
64
|
+
for (const child of level.children) {
|
|
65
|
+
const name = own ? child.name : displayPath(target.root, child.key);
|
|
66
|
+
entries.set(name, { ...child, drive: target.root.drive });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { entries, truncated };
|
|
70
|
+
}
|
|
71
|
+
async function localLevel(root, folder, deny) {
|
|
72
|
+
const children = [];
|
|
73
|
+
for (const dirent of await readdir(hostPath(root, folder))) {
|
|
74
|
+
const key = childKey(folder, dirent.name);
|
|
75
|
+
if (dirent.isSymbolicLink() || isDeniedPath(hostPath(root, key), deny)) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (dirent.isDirectory() && !WALK_SKIP_DIRS.has(dirent.name)) {
|
|
79
|
+
const items = (await readdir(hostPath(root, key))).length;
|
|
80
|
+
children.push({ name: dirent.name, key, folder: true, items });
|
|
81
|
+
}
|
|
82
|
+
else if (dirent.isFile()) {
|
|
83
|
+
children.push({ name: dirent.name, key, folder: false, items: 0 });
|
|
84
|
+
}
|
|
85
|
+
if (children.length > LIST_ENTRIES) {
|
|
86
|
+
return { children, truncated: true };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { children, truncated: false };
|
|
90
|
+
}
|
|
91
|
+
async function walkedLevel(target, deny) {
|
|
92
|
+
const walk = await walkFiles(target.root, target.folder);
|
|
93
|
+
const children = [];
|
|
94
|
+
const folders = new Map();
|
|
95
|
+
for (const file of walk.files) {
|
|
96
|
+
if (isDeniedPath(file.path, deny))
|
|
97
|
+
continue;
|
|
98
|
+
const [name, below] = relativeKey(file.key, target.folder).split('/');
|
|
99
|
+
if (below === undefined) {
|
|
100
|
+
children.push({ name, key: file.key, folder: false, items: 0 });
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
folders.set(name, (folders.get(name) ?? new Set()).add(below));
|
|
104
|
+
}
|
|
105
|
+
for (const [name, items] of folders) {
|
|
106
|
+
children.push({ name, key: childKey(target.folder, name), folder: true, items: items.size });
|
|
107
|
+
}
|
|
108
|
+
return { children, truncated: walk.truncated };
|
|
109
|
+
}
|
|
110
|
+
async function readdir(dir) {
|
|
111
|
+
try {
|
|
112
|
+
return await fs.promises.readdir(dir, { withFileTypes: true });
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function childKey(folder, name) {
|
|
119
|
+
return folder === '/' ? `/${name}` : `${folder}/${name}`;
|
|
120
|
+
}
|
|
121
|
+
async function describe(entries) {
|
|
122
|
+
const rows = [];
|
|
123
|
+
for (const [name, entry] of entries) {
|
|
124
|
+
if (entry.folder) {
|
|
125
|
+
rows.push(`${name}/ (folder, ${entry.items} ${entry.items === 1 ? 'item' : 'items'})`);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const stat = await entry.drive.entry(entry.key);
|
|
129
|
+
const size = stat?.value.blob?.byteLength ?? 0;
|
|
130
|
+
const changed = stat?.mtime
|
|
131
|
+
? `, changed ${new Date(stat.mtime).toISOString().slice(0, 16)}`
|
|
132
|
+
: '';
|
|
133
|
+
rows.push(`${name} (${size} bytes${changed})`);
|
|
134
|
+
}
|
|
135
|
+
return rows;
|
|
136
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { errorMessage } from '../../guards.js';
|
|
3
|
+
import { defaultRealpath } from '../fs/scope.js';
|
|
4
|
+
import { localPathOf, resolveRooted, rootedArgs, rootedLabel, stringArg } from '../fs/tool-path.js';
|
|
5
|
+
export function createMakeDirTool({ realpath = defaultRealpath, deniedRoots } = {}) {
|
|
6
|
+
return {
|
|
7
|
+
name: 'make_dir',
|
|
8
|
+
toolset: 'files',
|
|
9
|
+
description: 'Create a folder (and any missing parents) inside the shared folder.',
|
|
10
|
+
parameters: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
path: { type: 'string', description: 'Folder path, relative to the shared folder' }
|
|
14
|
+
},
|
|
15
|
+
required: ['path']
|
|
16
|
+
},
|
|
17
|
+
effect: () => 'read',
|
|
18
|
+
writeRootsRequired: true,
|
|
19
|
+
validate: (args) => (stringArg(args, 'path') ? null : 'path is required'),
|
|
20
|
+
paths: (args, ctx) => rootedArgs(args, ctx, ['path']),
|
|
21
|
+
resource: (args, ctx) => ({
|
|
22
|
+
kind: 'file',
|
|
23
|
+
label: rootedLabel('mkdir', { grants: ctx, paths: [String(args.path)] })
|
|
24
|
+
}),
|
|
25
|
+
async execute(args, ctx) {
|
|
26
|
+
const resolved = await resolveRooted(String(args.path), {
|
|
27
|
+
grants: ctx,
|
|
28
|
+
write: true,
|
|
29
|
+
realpath,
|
|
30
|
+
deniedRoots
|
|
31
|
+
});
|
|
32
|
+
if ('error' in resolved) {
|
|
33
|
+
return resolved;
|
|
34
|
+
}
|
|
35
|
+
const target = localPathOf(resolved);
|
|
36
|
+
if (!target) {
|
|
37
|
+
return { error: 'folders can only be created in a folder on this device' };
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
await fs.promises.mkdir(target, { recursive: true });
|
|
41
|
+
return { created: String(args.path) };
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
return { error: errorMessage(err) };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
import { errorMessage } from '../../guards.js';
|
|
3
|
+
import { documentText, isDocument } from '../fs/document-text.js';
|
|
4
|
+
import { createLocalRoots } from '../fs/local.js';
|
|
5
|
+
import { defaultRealpath, resolveKey } from '../fs/scope.js';
|
|
6
|
+
import { anchorOf, positiveInt, resolveRooted, rootedArgs, rootedPath, stringArg } from '../fs/tool-path.js';
|
|
7
|
+
const MAX_DOCUMENT_BYTES = 8 * 1024 * 1024;
|
|
8
|
+
const READ_LINES = 400;
|
|
9
|
+
const READ_CHARS = 20_000;
|
|
10
|
+
const BINARY_PROBE = 1024;
|
|
11
|
+
const LINE_BYTES = 3 * READ_CHARS + 4;
|
|
12
|
+
export function createReadFileTool({ realpath = defaultRealpath, deniedRoots } = {}) {
|
|
13
|
+
return {
|
|
14
|
+
name: 'read_file',
|
|
15
|
+
toolset: 'files',
|
|
16
|
+
description: 'Read one file from the shared folder. Lines come back numbered ("12| text"). For a long file, ' +
|
|
17
|
+
'read a range with startLine/endLine; partial reads may show an unknown total. PDF, Word and PowerPoint files come back as their text. ' +
|
|
18
|
+
'Use this, not exec, for files in the shared folder.',
|
|
19
|
+
parameters: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
path: { type: 'string', description: 'File path, relative to the shared folder' },
|
|
23
|
+
startLine: { type: 'integer', description: 'First line to read (1-based, optional)' },
|
|
24
|
+
endLine: { type: 'integer', description: 'Last line to read (optional)' }
|
|
25
|
+
},
|
|
26
|
+
required: ['path']
|
|
27
|
+
},
|
|
28
|
+
effect: () => 'read',
|
|
29
|
+
concurrent: true,
|
|
30
|
+
stableRead: true,
|
|
31
|
+
autoApprove: true,
|
|
32
|
+
rootsRequired: true,
|
|
33
|
+
validate: (args) => (stringArg(args, 'path') ? null : 'path is required'),
|
|
34
|
+
paths: (args, ctx) => rootedArgs(args, ctx, ['path']),
|
|
35
|
+
resource(args, ctx) {
|
|
36
|
+
const requested = stringArg(args, 'path');
|
|
37
|
+
return requested ? { kind: 'file', label: rootedPath(requested, anchorOf(ctx)) } : null;
|
|
38
|
+
},
|
|
39
|
+
async execute(args, ctx) {
|
|
40
|
+
const requested = String(args.path);
|
|
41
|
+
const spill = ctx?.spill ? await createLocalRoots([ctx.spill.dir], realpath) : [];
|
|
42
|
+
const own = spill.length ? await resolveKey(requested, spill, { realpath }) : null;
|
|
43
|
+
const resolved = own && !('error' in own)
|
|
44
|
+
? own
|
|
45
|
+
: await resolveRooted(requested, { grants: ctx, write: false, realpath, deniedRoots });
|
|
46
|
+
if ('error' in resolved) {
|
|
47
|
+
return resolved;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const range = {
|
|
51
|
+
start: positiveInt(args.startLine),
|
|
52
|
+
end: positiveInt(args.endLine)
|
|
53
|
+
};
|
|
54
|
+
if (isDocument(resolved.key)) {
|
|
55
|
+
const text = await documentOf(resolved, requested, ctx);
|
|
56
|
+
return typeof text === 'string' ? numbered(text, range) : text;
|
|
57
|
+
}
|
|
58
|
+
return await textRange(resolved, requested, range);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
return { error: errorMessage(err) };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function documentOf(resolved, requested, ctx) {
|
|
67
|
+
const { drive } = resolved.root;
|
|
68
|
+
const entry = await drive.entry(resolved.key);
|
|
69
|
+
if (entry?.value.blob && entry.value.blob.byteLength > MAX_DOCUMENT_BYTES) {
|
|
70
|
+
return {
|
|
71
|
+
error: `${requested} is larger than the ${MAX_DOCUMENT_BYTES}-byte document extraction limit`
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const bytes = entry ? await drive.get(resolved.key) : null;
|
|
75
|
+
if (bytes === null) {
|
|
76
|
+
return { error: `no such file: ${requested}. Use list_dir or glob to find the right path.` };
|
|
77
|
+
}
|
|
78
|
+
if (bytes.byteLength > MAX_DOCUMENT_BYTES) {
|
|
79
|
+
return {
|
|
80
|
+
error: `${requested} is larger than the ${MAX_DOCUMENT_BYTES}-byte document extraction limit`
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return documentText(resolved.key, bytes, { ocr: ctx?.ocr, signal: ctx?.signal });
|
|
84
|
+
}
|
|
85
|
+
function numbered(text, { start, end }) {
|
|
86
|
+
const lines = text.split('\n');
|
|
87
|
+
if (lines.length > 1 && lines[lines.length - 1] === '') {
|
|
88
|
+
lines.pop();
|
|
89
|
+
}
|
|
90
|
+
const total = lines.length;
|
|
91
|
+
const first = Math.min(start ?? 1, Math.max(total, 1));
|
|
92
|
+
const out = [];
|
|
93
|
+
let chars = 0;
|
|
94
|
+
let cut = false;
|
|
95
|
+
for (let n = first; n <= Math.min(total, end ?? first + READ_LINES - 1); n++) {
|
|
96
|
+
const row = `${n}| ${lines[n - 1]}`;
|
|
97
|
+
if (chars + row.length > READ_CHARS) {
|
|
98
|
+
cut = out.length === 0;
|
|
99
|
+
if (cut) {
|
|
100
|
+
out.push(row.slice(0, READ_CHARS));
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
out.push(row);
|
|
105
|
+
chars += row.length + 1;
|
|
106
|
+
}
|
|
107
|
+
const last = first + out.length - 1;
|
|
108
|
+
const shown = cut
|
|
109
|
+
? `line ${first} of ${total}, cut at ${READ_CHARS} characters`
|
|
110
|
+
: `lines ${first}-${last} of ${total}`;
|
|
111
|
+
const header = last < total ? `${shown}; continue with startLine ${last + 1}` : shown;
|
|
112
|
+
return { content: `${header}\n${out.join('\n')}` };
|
|
113
|
+
}
|
|
114
|
+
async function textRange(resolved, requested, range) {
|
|
115
|
+
const { drive } = resolved.root;
|
|
116
|
+
if (!(await drive.entry(resolved.key))) {
|
|
117
|
+
return { error: `no such file: ${requested}. Use list_dir or glob to find the right path.` };
|
|
118
|
+
}
|
|
119
|
+
const reader = new TextRange(range);
|
|
120
|
+
let probed = 0;
|
|
121
|
+
for await (const chunk of drive.createReadStream(resolved.key)) {
|
|
122
|
+
if (chunk.subarray(0, Math.max(0, BINARY_PROBE - probed)).includes(0)) {
|
|
123
|
+
return { error: `${requested} is a binary file (not text, PDF, Word or PowerPoint)` };
|
|
124
|
+
}
|
|
125
|
+
probed += chunk.length;
|
|
126
|
+
reader.feed(chunk);
|
|
127
|
+
if (reader.stopped) {
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return { content: reader.finish() };
|
|
132
|
+
}
|
|
133
|
+
class TextRange {
|
|
134
|
+
stopped = false;
|
|
135
|
+
#first;
|
|
136
|
+
#last;
|
|
137
|
+
#out = [];
|
|
138
|
+
#shownFirst;
|
|
139
|
+
#chars = 0;
|
|
140
|
+
#cut = false;
|
|
141
|
+
#full = false;
|
|
142
|
+
#lines = 0;
|
|
143
|
+
#line = emptyLine();
|
|
144
|
+
#previous = emptyLine();
|
|
145
|
+
constructor({ start, end }) {
|
|
146
|
+
this.#first = start ?? 1;
|
|
147
|
+
this.#last = end ?? this.#first + READ_LINES - 1;
|
|
148
|
+
this.#shownFirst = this.#first;
|
|
149
|
+
}
|
|
150
|
+
feed(chunk) {
|
|
151
|
+
let at = 0;
|
|
152
|
+
while (!this.stopped) {
|
|
153
|
+
if (this.#full) {
|
|
154
|
+
this.stopped = at < chunk.length;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const newline = chunk.indexOf(0x0a, at);
|
|
158
|
+
this.#append(chunk.subarray(at, newline === -1 ? chunk.length : newline));
|
|
159
|
+
if (newline !== -1 || (this.#line.cut && this.#lines + 1 >= this.#first)) {
|
|
160
|
+
this.#close();
|
|
161
|
+
}
|
|
162
|
+
if (newline === -1) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
at = newline + 1;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
finish() {
|
|
169
|
+
const eof = !this.stopped;
|
|
170
|
+
if (eof && this.#line.bytes > 0) {
|
|
171
|
+
this.#close();
|
|
172
|
+
}
|
|
173
|
+
if (eof && this.#out.length === 0 && this.#last >= this.#first) {
|
|
174
|
+
this.#shownFirst = Math.max(this.#lines, 1);
|
|
175
|
+
const row = `${this.#shownFirst}| ${lineText(this.#previous)}`;
|
|
176
|
+
this.#out.push(row.slice(0, READ_CHARS));
|
|
177
|
+
this.#cut = this.#previous.cut || row.length > READ_CHARS;
|
|
178
|
+
}
|
|
179
|
+
const total = eof ? String(Math.max(this.#lines, 1)) : 'unknown';
|
|
180
|
+
const lastShown = this.#shownFirst + this.#out.length - 1;
|
|
181
|
+
const shown = this.#cut
|
|
182
|
+
? `line ${this.#shownFirst} of ${total}, cut at ${READ_CHARS} characters`
|
|
183
|
+
: `lines ${this.#shownFirst}-${lastShown} of ${total}`;
|
|
184
|
+
const header = !eof || lastShown < this.#lines ? `${shown}; continue with startLine ${lastShown + 1}` : shown;
|
|
185
|
+
return `${header}\n${this.#out.join('\n')}`;
|
|
186
|
+
}
|
|
187
|
+
#append(bytes) {
|
|
188
|
+
const kept = bytes.subarray(0, LINE_BYTES - this.#line.bytes);
|
|
189
|
+
if (kept.length) {
|
|
190
|
+
this.#line.parts.push(kept);
|
|
191
|
+
}
|
|
192
|
+
this.#line.bytes += kept.length;
|
|
193
|
+
this.#line.cut ||= kept.length < bytes.length;
|
|
194
|
+
}
|
|
195
|
+
#close() {
|
|
196
|
+
this.#lines++;
|
|
197
|
+
this.#previous = this.#line;
|
|
198
|
+
this.#line = emptyLine();
|
|
199
|
+
if (this.#lines < this.#first) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const row = `${this.#lines}| ${lineText(this.#previous)}`;
|
|
203
|
+
if (this.#out.length === 0) {
|
|
204
|
+
this.#shownFirst = this.#lines;
|
|
205
|
+
}
|
|
206
|
+
if (this.#chars + row.length > READ_CHARS) {
|
|
207
|
+
this.#cut = this.#out.length === 0;
|
|
208
|
+
if (this.#cut) {
|
|
209
|
+
this.#out.push(row.slice(0, READ_CHARS));
|
|
210
|
+
}
|
|
211
|
+
this.stopped = true;
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
this.#out.push(row);
|
|
215
|
+
this.#chars += row.length + 1;
|
|
216
|
+
this.#full = this.#lines === this.#last;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function emptyLine() {
|
|
220
|
+
return { parts: [], bytes: 0, cut: false };
|
|
221
|
+
}
|
|
222
|
+
function lineText(line) {
|
|
223
|
+
return b4a.toString(b4a.concat(line.parts), 'utf8');
|
|
224
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../../contract/index.ts';
|
|
2
|
+
import { type FsToolOptions } from '../fs/scope.ts';
|
|
3
|
+
export declare function createMoveFileTool(options?: FsToolOptions): ToolDefinition;
|
|
4
|
+
export declare function createCopyFileTool(options?: FsToolOptions): ToolDefinition;
|