@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,70 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { callDenyRoots, hostPath, resolveKey } from './scope.js';
|
|
4
|
+
const HYPER_PREFIX = 'hyper://';
|
|
5
|
+
export function anchorOf(grants) {
|
|
6
|
+
return grants?.fsRoots?.[0] ?? grants?.fsWriteRoots?.[0];
|
|
7
|
+
}
|
|
8
|
+
function baseOf(root) {
|
|
9
|
+
return root.kind === 'local' ? root.root : `${HYPER_PREFIX}${root.key}`;
|
|
10
|
+
}
|
|
11
|
+
export function rootedPath(p, anchor) {
|
|
12
|
+
if (!anchor || p.startsWith(HYPER_PREFIX) || path.isAbsolute(p) || p.startsWith('~')) {
|
|
13
|
+
return p;
|
|
14
|
+
}
|
|
15
|
+
if (anchor.kind === 'local') {
|
|
16
|
+
return path.join(anchor.root, p);
|
|
17
|
+
}
|
|
18
|
+
const prefix = anchor.prefix === '/' ? '' : anchor.prefix;
|
|
19
|
+
return `${HYPER_PREFIX}${anchor.key}${prefix}/${p.replace(/^\.?\//, '')}`;
|
|
20
|
+
}
|
|
21
|
+
export function shownPath(full, anchor) {
|
|
22
|
+
if (!anchor) {
|
|
23
|
+
return full;
|
|
24
|
+
}
|
|
25
|
+
const base = baseOf(anchor);
|
|
26
|
+
if (full === base) {
|
|
27
|
+
return '.';
|
|
28
|
+
}
|
|
29
|
+
return full.startsWith(base + '/') ? full.slice(base.length + 1) : full;
|
|
30
|
+
}
|
|
31
|
+
export async function resolveRooted(p, { grants, write, realpath, deniedRoots }) {
|
|
32
|
+
const roots = (write ? grants?.fsWriteRoots : grants?.fsRoots) ?? [];
|
|
33
|
+
const deny = await callDenyRoots(deniedRoots, grants?.policy, realpath);
|
|
34
|
+
return resolveKey(rootedPath(p, anchorOf(grants)), roots, { realpath, deny });
|
|
35
|
+
}
|
|
36
|
+
export function rootedArgs(args, grants, keys) {
|
|
37
|
+
const anchor = anchorOf(grants);
|
|
38
|
+
const paths = [];
|
|
39
|
+
for (const key of keys) {
|
|
40
|
+
const value = stringArg(args, key);
|
|
41
|
+
if (value === null) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
paths.push(rootedPath(value, anchor));
|
|
45
|
+
}
|
|
46
|
+
return paths;
|
|
47
|
+
}
|
|
48
|
+
export function stringArg(args, key) {
|
|
49
|
+
const value = args[key];
|
|
50
|
+
return typeof value === 'string' && value.trim() ? value : null;
|
|
51
|
+
}
|
|
52
|
+
export function positiveInt(value) {
|
|
53
|
+
const n = Number(value);
|
|
54
|
+
return value === undefined || value === null || !Number.isInteger(n) || n < 1 ? undefined : n;
|
|
55
|
+
}
|
|
56
|
+
export function existsNow(p, grants) {
|
|
57
|
+
const anchor = anchorOf(grants);
|
|
58
|
+
if (!p || !anchor || anchor.kind !== 'local') {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
const target = rootedPath(p, anchor);
|
|
62
|
+
return !path.isAbsolute(target) || fs.existsSync(target);
|
|
63
|
+
}
|
|
64
|
+
export function rootedLabel(verb, { grants, paths }) {
|
|
65
|
+
const anchor = anchorOf(grants);
|
|
66
|
+
return `${verb} ${paths.map((p) => rootedPath(p, anchor)).join(' → ')}`;
|
|
67
|
+
}
|
|
68
|
+
export function localPathOf(resolved) {
|
|
69
|
+
return resolved.root.kind === 'local' ? hostPath(resolved.root, resolved.key) : null;
|
|
70
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DriveRoot, WalkSummary } from '../../contract/drive.ts';
|
|
2
2
|
export declare const WALK_SKIP_DIRS: Set<string>;
|
|
3
3
|
export declare const MAX_WALK_ENTRIES = 10000;
|
|
4
4
|
export declare const MAX_WALK_MS = 30000;
|
|
@@ -6,10 +6,19 @@ export interface WalkedFile {
|
|
|
6
6
|
path: string;
|
|
7
7
|
key: string;
|
|
8
8
|
byteLength: number;
|
|
9
|
+
mtime?: number;
|
|
9
10
|
}
|
|
10
|
-
export interface WalkResult {
|
|
11
|
+
export interface WalkResult extends WalkSummary {
|
|
11
12
|
files: WalkedFile[];
|
|
12
|
-
truncated: boolean;
|
|
13
|
-
skippedLinks: number;
|
|
14
13
|
}
|
|
15
|
-
export
|
|
14
|
+
export interface WalkStream {
|
|
15
|
+
files: AsyncIterable<WalkedFile>;
|
|
16
|
+
result: Promise<WalkSummary>;
|
|
17
|
+
}
|
|
18
|
+
export interface WalkOptions {
|
|
19
|
+
includeIgnored?: boolean;
|
|
20
|
+
maxEntries?: number;
|
|
21
|
+
maxMs?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function walkFiles(root: DriveRoot, folder?: string, opts?: WalkOptions): Promise<WalkResult>;
|
|
24
|
+
export declare function streamFiles(root: DriveRoot, folder?: string, opts?: WalkOptions): WalkStream;
|
|
@@ -1,41 +1,136 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
1
2
|
import { errorMessage } from '../../guards.js';
|
|
2
|
-
import {
|
|
3
|
+
import { HarnessLog } from '../../log.js';
|
|
4
|
+
import { pushQueue } from '../../queue.js';
|
|
5
|
+
import { IgnoreRules } from './ignore.js';
|
|
3
6
|
import { displayPath } from './scope.js';
|
|
4
|
-
export const WALK_SKIP_DIRS = new Set(['.git', 'node_modules']);
|
|
7
|
+
export const WALK_SKIP_DIRS = new Set(['.git', 'node_modules', '.trash']);
|
|
8
|
+
const HIDDEN_DIRS = new Set(['.hg', '.svn', '.venv', '.cache', '.next']);
|
|
9
|
+
const IGNORE_FILES = ['.gitignore', '.ignore'];
|
|
5
10
|
export const MAX_WALK_ENTRIES = 10_000;
|
|
6
11
|
export const MAX_WALK_MS = 30_000;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
function childKey(dir, name) {
|
|
13
|
+
return dir === '/' ? `/${name}` : `${dir}/${name}`;
|
|
14
|
+
}
|
|
15
|
+
function isIgnoreFile(child, key) {
|
|
16
|
+
return !('dir' in child) && child.value.linkname === null && child.key === key;
|
|
17
|
+
}
|
|
18
|
+
class Walk {
|
|
19
|
+
skippedLinks = 0;
|
|
20
|
+
kept = 0;
|
|
21
|
+
#root;
|
|
22
|
+
#onFile;
|
|
23
|
+
#includeIgnored;
|
|
24
|
+
#maxEntries;
|
|
25
|
+
#deadline;
|
|
26
|
+
constructor(root, onFile, { includeIgnored = false, maxEntries = MAX_WALK_ENTRIES, maxMs = MAX_WALK_MS }) {
|
|
27
|
+
this.#root = root;
|
|
28
|
+
this.#onFile = onFile;
|
|
29
|
+
this.#includeIgnored = includeIgnored;
|
|
30
|
+
this.#maxEntries = maxEntries;
|
|
31
|
+
this.#deadline = Date.now() + maxMs;
|
|
32
|
+
}
|
|
33
|
+
async #withIgnoreFile(rules, key) {
|
|
34
|
+
const bytes = await this.#root.drive.get(key);
|
|
35
|
+
const dir = key.slice(0, key.lastIndexOf('/'));
|
|
36
|
+
return bytes === null ? rules : rules.add(dir.slice(1), b4a.toString(bytes, 'utf8'));
|
|
37
|
+
}
|
|
38
|
+
async rootRules(folder) {
|
|
39
|
+
let rules = new IgnoreRules();
|
|
40
|
+
if (this.#includeIgnored) {
|
|
41
|
+
return rules;
|
|
42
|
+
}
|
|
43
|
+
const parts = folder.split('/').filter(Boolean);
|
|
44
|
+
for (let depth = 0; depth < parts.length; depth++) {
|
|
45
|
+
const dir = '/' + parts.slice(0, depth).join('/');
|
|
46
|
+
for (const name of IGNORE_FILES) {
|
|
47
|
+
rules = await this.#withIgnoreFile(rules, childKey(dir, name));
|
|
16
48
|
}
|
|
17
|
-
|
|
18
|
-
|
|
49
|
+
}
|
|
50
|
+
return rules;
|
|
51
|
+
}
|
|
52
|
+
async #list(dir) {
|
|
53
|
+
const children = [];
|
|
54
|
+
const listing = this.#root.drive.list(dir, { skip: WALK_SKIP_DIRS, recursive: false });
|
|
55
|
+
for await (const child of listing) {
|
|
56
|
+
if (Date.now() > this.#deadline)
|
|
57
|
+
return null;
|
|
58
|
+
children.push(child);
|
|
59
|
+
}
|
|
60
|
+
return children;
|
|
61
|
+
}
|
|
62
|
+
#keeps(child, rules) {
|
|
63
|
+
if (this.#includeIgnored)
|
|
64
|
+
return true;
|
|
65
|
+
const isDir = 'dir' in child;
|
|
66
|
+
const name = child.key.slice(child.key.lastIndexOf('/') + 1);
|
|
67
|
+
return !(isDir && HIDDEN_DIRS.has(name)) && !rules.ignored(child.key.slice(1), isDir);
|
|
68
|
+
}
|
|
69
|
+
async #rulesFor(dir, children, inherited) {
|
|
70
|
+
let rules = inherited;
|
|
71
|
+
for (const name of IGNORE_FILES) {
|
|
72
|
+
const key = childKey(dir, name);
|
|
73
|
+
if (!this.#includeIgnored && children.some((child) => isIgnoreFile(child, key))) {
|
|
74
|
+
rules = await this.#withIgnoreFile(rules, key);
|
|
19
75
|
}
|
|
20
|
-
|
|
21
|
-
|
|
76
|
+
}
|
|
77
|
+
return rules;
|
|
78
|
+
}
|
|
79
|
+
async visit(dir, inherited) {
|
|
80
|
+
const children = await this.#list(dir);
|
|
81
|
+
if (children === null) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const rules = await this.#rulesFor(dir, children, inherited);
|
|
85
|
+
for (const child of children) {
|
|
86
|
+
if (!this.#keeps(child, rules))
|
|
22
87
|
continue;
|
|
88
|
+
if (++this.kept > this.#maxEntries || Date.now() > this.#deadline) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if ('dir' in child) {
|
|
92
|
+
if (!(await this.visit(child.key, rules))) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (child.value.linkname !== null) {
|
|
97
|
+
this.skippedLinks++;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
this.#onFile({
|
|
101
|
+
path: displayPath(this.#root, child.key),
|
|
102
|
+
key: child.key,
|
|
103
|
+
byteLength: child.value.blob?.byteLength ?? 0,
|
|
104
|
+
mtime: child.mtime
|
|
105
|
+
});
|
|
23
106
|
}
|
|
24
|
-
files.push({
|
|
25
|
-
path: displayPath(root, entry.key),
|
|
26
|
-
key: entry.key,
|
|
27
|
-
byteLength: entry.value.blob?.byteLength ?? 0
|
|
28
|
-
});
|
|
29
107
|
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async function run(walk, root, folder) {
|
|
112
|
+
try {
|
|
113
|
+
const complete = await walk.visit(folder, await walk.rootRules(folder));
|
|
114
|
+
return { truncated: !complete, skippedLinks: walk.skippedLinks };
|
|
30
115
|
}
|
|
31
116
|
catch (err) {
|
|
32
|
-
|
|
117
|
+
HarnessLog.warn('warn: walk aborted mid-listing', {
|
|
33
118
|
root: displayPath(root, '/'),
|
|
34
119
|
folder,
|
|
35
|
-
|
|
120
|
+
kept: walk.kept,
|
|
36
121
|
err: errorMessage(err)
|
|
37
122
|
});
|
|
38
|
-
return {
|
|
123
|
+
return { truncated: true, skippedLinks: walk.skippedLinks };
|
|
39
124
|
}
|
|
40
|
-
|
|
125
|
+
}
|
|
126
|
+
export async function walkFiles(root, folder = '/', opts = {}) {
|
|
127
|
+
const files = [];
|
|
128
|
+
const summary = await run(new Walk(root, (file) => files.push(file), opts), root, folder);
|
|
129
|
+
return { files, ...summary };
|
|
130
|
+
}
|
|
131
|
+
export function streamFiles(root, folder = '/', opts = {}) {
|
|
132
|
+
const queue = pushQueue();
|
|
133
|
+
const result = run(new Walk(root, (file) => void queue.push(file), opts), root, folder);
|
|
134
|
+
void result.then(() => queue.end());
|
|
135
|
+
return { files: queue, result };
|
|
41
136
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
2
2
|
export declare const MAX_RESPONSE_CHARS = 8192;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const IDLE_TIMEOUT_MS = 10000;
|
|
4
|
+
export declare const TIMEOUT_MS = 120000;
|
|
4
5
|
export interface FetchInit {
|
|
5
6
|
method: string;
|
|
6
7
|
headers: Record<string, string>;
|
|
@@ -8,8 +9,9 @@ export interface FetchInit {
|
|
|
8
9
|
signal: BareAbortSignal;
|
|
9
10
|
redirect?: 'manual';
|
|
10
11
|
validatedAddresses?: readonly string[] | undefined;
|
|
11
|
-
maxBytes?: number;
|
|
12
|
+
maxBytes?: number | ((contentType: string) => number);
|
|
12
13
|
truncate?: boolean;
|
|
14
|
+
idleTimeoutMs?: number;
|
|
13
15
|
}
|
|
14
16
|
export declare function isRedirectStatus(status: number): boolean;
|
|
15
17
|
export type ParseResult<T> = {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isRecord } from '../../guards.js';
|
|
2
2
|
const BLOCKED_HEADERS = new Set(['authorization', 'cookie', 'proxy-authorization']);
|
|
3
3
|
export const MAX_RESPONSE_CHARS = 8192;
|
|
4
|
-
export const
|
|
4
|
+
export const IDLE_TIMEOUT_MS = 10_000;
|
|
5
|
+
export const TIMEOUT_MS = 120_000;
|
|
5
6
|
export function isRedirectStatus(status) {
|
|
6
7
|
return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
|
|
7
8
|
}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ToolExecuteContext } from '../../contract/index.ts';
|
|
2
|
+
type BudgetContext = Pick<ToolExecuteContext, 'ctxSize' | 'runBudget'> | undefined;
|
|
3
|
+
export declare function responseBudgetChars(ctx: BudgetContext): number;
|
|
4
|
+
export declare function capResponseBody(body: string, ctx: BudgetContext): CappedBody;
|
|
5
|
+
export interface ResponseCoverage {
|
|
6
|
+
readonly keptChars: number;
|
|
7
|
+
readonly totalChars: number;
|
|
8
|
+
readonly percent: number;
|
|
9
|
+
readonly note: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CappedBody {
|
|
12
|
+
readonly body: string;
|
|
13
|
+
readonly truncated?: ResponseCoverage;
|
|
14
|
+
}
|
|
15
|
+
export declare function truncateResponseBody(body: string, budget: number): CappedBody;
|
|
2
16
|
export declare const ELISION = "\u2026 [truncated]";
|
|
17
|
+
export {};
|
|
@@ -1,19 +1,55 @@
|
|
|
1
1
|
import { MAX_RESPONSE_CHARS } from './request.js';
|
|
2
2
|
import { isRecord } from '../../guards.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const RESPONSE_FLOOR_CHARS = 2048;
|
|
4
|
+
export function responseBudgetChars(ctx) {
|
|
5
|
+
const room = ctx?.runBudget?.responseRoomChars;
|
|
6
|
+
if (room !== undefined) {
|
|
7
|
+
return Math.max(RESPONSE_FLOOR_CHARS, room);
|
|
8
|
+
}
|
|
9
|
+
const ctxSize = ctx?.ctxSize;
|
|
10
|
+
return ctxSize ? Math.max(MAX_RESPONSE_CHARS, Math.floor(ctxSize / 4)) : MAX_RESPONSE_CHARS;
|
|
11
|
+
}
|
|
12
|
+
export function capResponseBody(body, ctx) {
|
|
13
|
+
const capped = truncateResponseBody(body, responseBudgetChars(ctx));
|
|
14
|
+
const budget = ctx?.runBudget;
|
|
15
|
+
if (budget?.responseRoomChars !== undefined) {
|
|
16
|
+
budget.responseRoomChars = Math.max(0, budget.responseRoomChars - capped.body.length);
|
|
17
|
+
}
|
|
18
|
+
return capped;
|
|
19
|
+
}
|
|
20
|
+
const NOT_JSON = Symbol('not-json');
|
|
21
|
+
export function truncateResponseBody(body, budget) {
|
|
22
|
+
if (body.length <= budget) {
|
|
23
|
+
return { body };
|
|
24
|
+
}
|
|
25
|
+
const parsed = parseJson(body);
|
|
26
|
+
if (parsed !== NOT_JSON) {
|
|
27
|
+
const compact = JSON.stringify(parsed);
|
|
28
|
+
if (compact.length <= budget) {
|
|
29
|
+
return { body: compact };
|
|
30
|
+
}
|
|
31
|
+
const kept = JSON.stringify(fit(parsed, budget));
|
|
32
|
+
return { body: kept, truncated: coverageOf(Math.min(kept.length, budget), compact.length) };
|
|
33
|
+
}
|
|
34
|
+
const kept = `${body.slice(0, budget)}${ELISION}`;
|
|
35
|
+
return { body: kept, truncated: coverageOf(budget, body.length) };
|
|
36
|
+
}
|
|
37
|
+
function coverageOf(keptChars, totalChars) {
|
|
38
|
+
const percent = Math.max(1, Math.floor((keptChars / totalChars) * 100));
|
|
39
|
+
return {
|
|
40
|
+
keptChars,
|
|
41
|
+
totalChars,
|
|
42
|
+
percent,
|
|
43
|
+
note: `Only the first ${percent}% of this response was read, to fit the context window. Tell the user that your answer covers that part only.`
|
|
44
|
+
};
|
|
7
45
|
}
|
|
8
|
-
function
|
|
9
|
-
let parsed;
|
|
46
|
+
function parseJson(body) {
|
|
10
47
|
try {
|
|
11
|
-
|
|
48
|
+
return JSON.parse(body);
|
|
12
49
|
}
|
|
13
50
|
catch {
|
|
14
|
-
return
|
|
51
|
+
return NOT_JSON;
|
|
15
52
|
}
|
|
16
|
-
return JSON.stringify(fit(parsed, MAX_RESPONSE_CHARS));
|
|
17
53
|
}
|
|
18
54
|
const MARKER_CHARS = 64;
|
|
19
55
|
function shrinkable(value) {
|
|
@@ -27,7 +63,16 @@ function fitString(value, budget) {
|
|
|
27
63
|
if (room <= 0) {
|
|
28
64
|
return ELISION;
|
|
29
65
|
}
|
|
30
|
-
|
|
66
|
+
let cut = Math.min(value.length, room);
|
|
67
|
+
let size = serializedLength(value.slice(0, cut));
|
|
68
|
+
while (size > room) {
|
|
69
|
+
cut = Math.min(cut - 1, Math.floor((cut * room) / size));
|
|
70
|
+
size = serializedLength(value.slice(0, cut));
|
|
71
|
+
}
|
|
72
|
+
return `${value.slice(0, cut)}${ELISION}`;
|
|
73
|
+
}
|
|
74
|
+
function serializedLength(value) {
|
|
75
|
+
return JSON.stringify(value).length - 2;
|
|
31
76
|
}
|
|
32
77
|
function fitArray(value, room) {
|
|
33
78
|
const kept = [];
|
|
@@ -88,7 +133,7 @@ function fit(value, budget) {
|
|
|
88
133
|
return fitObject(value, room);
|
|
89
134
|
}
|
|
90
135
|
if (typeof value === 'string' && JSON.stringify(value).length > budget) {
|
|
91
|
-
return fitString(value,
|
|
136
|
+
return fitString(value, room);
|
|
92
137
|
}
|
|
93
138
|
return value;
|
|
94
139
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { noRedirectFetch } from '#no-redirect-fetch';
|
|
2
2
|
import { AbortController } from 'bare-abort-controller';
|
|
3
|
+
import { URL } from 'url';
|
|
3
4
|
import { lookupHost } from '../dns-lookup.js';
|
|
4
5
|
import { READ_METHODS } from './http-methods.js';
|
|
5
6
|
import { encodeDeclaredFields } from './http-request/encode-fields.js';
|
|
6
|
-
import {
|
|
7
|
+
import { capResponseBody } from './http-request/truncate-response.js';
|
|
7
8
|
import { AbortedError } from '../helpers/race-abort.js';
|
|
8
|
-
import { applyQuery, buildHeaders, contentTypeOf, encodeBody, isRedirectStatus, parseJsonBody, parseObjectArg, TIMEOUT_MS } from './http-request/request.js';
|
|
9
|
+
import { applyQuery, buildHeaders, contentTypeOf, encodeBody, isRedirectStatus, parseJsonBody, IDLE_TIMEOUT_MS, parseObjectArg, TIMEOUT_MS } from './http-request/request.js';
|
|
9
10
|
import { parseAuth, resolveBearerHeader, resolveRedirectBearerHeader } from './skills/auth-resolver.js';
|
|
10
11
|
import { recordCredentialHealth } from './skills/credential-health.js';
|
|
12
|
+
import { Policy } from '../policy/index.js';
|
|
13
|
+
import { attachFetchedFile, attachTextFile, bareMime, dispositionFileName, isFileMime, MAX_FILE_BYTES } from './attachments/fetched-file.js';
|
|
11
14
|
import { resolveOutboundUrl } from './url-guard.js';
|
|
12
15
|
const MAX_REDIRECTS = 5;
|
|
13
16
|
export function createHttpRequestTool({ policyVersion, fetch: fetchImpl, credentialStore, credentialAllowList, resolveHost = lookupHost } = {}) {
|
|
@@ -15,7 +18,8 @@ export function createHttpRequestTool({ policyVersion, fetch: fetchImpl, credent
|
|
|
15
18
|
name: 'http_request',
|
|
16
19
|
policyVersion,
|
|
17
20
|
toolset: 'http-request',
|
|
18
|
-
|
|
21
|
+
defer: true,
|
|
22
|
+
description: 'Make an outbound HTTP or HTTPS request and return the response status and body as text. A body too large for the context window is cut, and `truncated` then says what share of it was read. Authorization/Cookie headers are stripped before sending. Stored skill credentials are attached automatically for their allow-listed hosts; `auth` is only needed to force a specific credential key. A response that is a file — PDF, .docx, .xlsx, an image, audio, video, any binary — is attached to the chat instead of returned as text: the result carries its attachmentId, and `fileName` names it.',
|
|
19
23
|
parameters: {
|
|
20
24
|
type: 'object',
|
|
21
25
|
properties: {
|
|
@@ -41,6 +45,10 @@ export function createHttpRequestTool({ policyVersion, fetch: fetchImpl, credent
|
|
|
41
45
|
auth: {
|
|
42
46
|
type: 'object',
|
|
43
47
|
description: 'Optional bearer auth: {"type": "bearer", "tokenCredentialKey": "<key>"}. Pass ONLY the credential key name — NEVER a token value. The tool resolves the actual secret itself; the model never sees it.'
|
|
48
|
+
},
|
|
49
|
+
fileName: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
description: 'Optional. The name to attach a file response under, e.g. "report.pdf"'
|
|
44
52
|
}
|
|
45
53
|
},
|
|
46
54
|
required: ['url']
|
|
@@ -64,6 +72,9 @@ export function createHttpRequestTool({ policyVersion, fetch: fetchImpl, credent
|
|
|
64
72
|
},
|
|
65
73
|
async execute(rawArgs, ctx) {
|
|
66
74
|
const args = rawArgs;
|
|
75
|
+
if (ctx?.signal?.aborted) {
|
|
76
|
+
return { error: 'request cancelled', code: 'cancelled' };
|
|
77
|
+
}
|
|
67
78
|
let url;
|
|
68
79
|
try {
|
|
69
80
|
url = new URL(args.url);
|
|
@@ -98,15 +109,33 @@ export function createHttpRequestTool({ policyVersion, fetch: fetchImpl, credent
|
|
|
98
109
|
if (!auth.ok) {
|
|
99
110
|
return { error: auth.error };
|
|
100
111
|
}
|
|
101
|
-
|
|
112
|
+
if (args.fileName !== undefined && typeof args.fileName !== 'string') {
|
|
113
|
+
return { error: 'fileName must be a string' };
|
|
114
|
+
}
|
|
115
|
+
const hosts = Policy.hostsOf(ctx?.policy);
|
|
102
116
|
const controller = new AbortController();
|
|
103
|
-
|
|
117
|
+
let timedOut = false;
|
|
118
|
+
const timeout = setTimeout(() => {
|
|
119
|
+
timedOut = true;
|
|
120
|
+
controller.abort(undefined);
|
|
121
|
+
}, TIMEOUT_MS);
|
|
122
|
+
const onCallerAbort = () => controller.abort(undefined);
|
|
123
|
+
ctx?.signal?.addEventListener('abort', onCallerAbort);
|
|
124
|
+
const requestCtx = ctx ? { ...ctx, signal: controller.signal } : undefined;
|
|
104
125
|
try {
|
|
105
|
-
const
|
|
126
|
+
const allowList = credentialAllowList?.(requestCtx);
|
|
127
|
+
if (controller.signal.aborted) {
|
|
128
|
+
throw new AbortedError();
|
|
129
|
+
}
|
|
130
|
+
const initialCheck = await resolveOutboundUrl(url, {
|
|
131
|
+
resolveHost,
|
|
132
|
+
signal: controller.signal,
|
|
133
|
+
hosts
|
|
134
|
+
});
|
|
106
135
|
if (initialCheck.blocked) {
|
|
107
136
|
return { error: initialCheck.blocked };
|
|
108
137
|
}
|
|
109
|
-
const bearer = await resolveBearerHeader(auth.value, url, credentialStore, allowList,
|
|
138
|
+
const bearer = await resolveBearerHeader(auth.value, url, credentialStore, allowList, requestCtx, controller.signal);
|
|
110
139
|
if ('error' in bearer) {
|
|
111
140
|
return { error: bearer.error };
|
|
112
141
|
}
|
|
@@ -124,6 +153,9 @@ export function createHttpRequestTool({ policyVersion, fetch: fetchImpl, credent
|
|
|
124
153
|
let validatedAddresses = initialCheck.addresses;
|
|
125
154
|
let response;
|
|
126
155
|
for (let redirects = 0;; redirects++) {
|
|
156
|
+
if (controller.signal.aborted) {
|
|
157
|
+
throw new AbortedError();
|
|
158
|
+
}
|
|
127
159
|
const hopHeaders = { ...headers };
|
|
128
160
|
delete hopHeaders['Authorization'];
|
|
129
161
|
if (header) {
|
|
@@ -135,7 +167,10 @@ export function createHttpRequestTool({ policyVersion, fetch: fetchImpl, credent
|
|
|
135
167
|
body,
|
|
136
168
|
signal: controller.signal,
|
|
137
169
|
redirect: 'manual',
|
|
138
|
-
validatedAddresses
|
|
170
|
+
validatedAddresses,
|
|
171
|
+
idleTimeoutMs: IDLE_TIMEOUT_MS,
|
|
172
|
+
maxBytes: MAX_FILE_BYTES,
|
|
173
|
+
truncate: true
|
|
139
174
|
});
|
|
140
175
|
if (credentialKey) {
|
|
141
176
|
recordCredentialHealth(credentialKey, response.status, ctx?.agentId);
|
|
@@ -160,7 +195,11 @@ export function createHttpRequestTool({ policyVersion, fetch: fetchImpl, credent
|
|
|
160
195
|
if (redirects >= MAX_REDIRECTS) {
|
|
161
196
|
return { error: 'too many redirects' };
|
|
162
197
|
}
|
|
163
|
-
const hopCheck = await resolveOutboundUrl(nextUrl,
|
|
198
|
+
const hopCheck = await resolveOutboundUrl(nextUrl, {
|
|
199
|
+
resolveHost,
|
|
200
|
+
signal: controller.signal,
|
|
201
|
+
hosts
|
|
202
|
+
});
|
|
164
203
|
if (hopCheck.blocked) {
|
|
165
204
|
return { error: hopCheck.blocked };
|
|
166
205
|
}
|
|
@@ -171,27 +210,73 @@ export function createHttpRequestTool({ policyVersion, fetch: fetchImpl, credent
|
|
|
171
210
|
}
|
|
172
211
|
currentUrl = nextUrl;
|
|
173
212
|
validatedAddresses = hopCheck.addresses;
|
|
174
|
-
const next = await resolveRedirectBearerHeader(redirectAuth, currentUrl, credentialStore, allowList,
|
|
213
|
+
const next = await resolveRedirectBearerHeader(redirectAuth, currentUrl, credentialStore, allowList, requestCtx, controller.signal);
|
|
175
214
|
header = next.header;
|
|
176
215
|
credentialKey = next.credentialKey;
|
|
177
216
|
}
|
|
217
|
+
const mimeType = bareMime(response.headers?.get('content-type'));
|
|
218
|
+
if (ctx?.attach && isSuccess(response.status) && isFileMime(mimeType)) {
|
|
219
|
+
const attached = await attachFetchedFile(await response.bytes?.(), {
|
|
220
|
+
url: currentUrl,
|
|
221
|
+
mimeType,
|
|
222
|
+
attach: ctx.attach,
|
|
223
|
+
maxBytes: MAX_FILE_BYTES,
|
|
224
|
+
fileName: args.fileName ?? dispositionFileName(response.headers?.get('content-disposition'))
|
|
225
|
+
});
|
|
226
|
+
if ('error' in attached) {
|
|
227
|
+
return attached;
|
|
228
|
+
}
|
|
229
|
+
const { content, ...file } = attached;
|
|
230
|
+
return { status: response.status, ...file, body: content };
|
|
231
|
+
}
|
|
178
232
|
const text = await response.text();
|
|
233
|
+
if (ctx?.uncappedResponse) {
|
|
234
|
+
return { status: response.status, body: text };
|
|
235
|
+
}
|
|
236
|
+
const capped = capResponseBody(text, ctx);
|
|
237
|
+
const whole = capped.truncated && isSuccess(response.status) && isTextFile(mimeType, args.fileName)
|
|
238
|
+
? await attachTextFile(await response.bytes?.(), {
|
|
239
|
+
url: currentUrl,
|
|
240
|
+
mimeType,
|
|
241
|
+
attach: ctx?.attach,
|
|
242
|
+
maxBytes: MAX_FILE_BYTES,
|
|
243
|
+
fileName: args.fileName ?? dispositionFileName(response.headers?.get('content-disposition'))
|
|
244
|
+
})
|
|
245
|
+
: null;
|
|
246
|
+
if (!whole || !capped.truncated) {
|
|
247
|
+
return { status: response.status, ...capped };
|
|
248
|
+
}
|
|
179
249
|
return {
|
|
180
250
|
status: response.status,
|
|
181
|
-
body:
|
|
251
|
+
body: capped.body,
|
|
252
|
+
attachmentId: whole.id,
|
|
253
|
+
fileName: whole.fileName,
|
|
254
|
+
truncated: {
|
|
255
|
+
...capped.truncated,
|
|
256
|
+
note: `${capped.truncated.note} The whole file is attached as "${whole.fileName}": stage it with exec as inputs [{ "attachmentId": "${whole.id}", "path": "${whole.fileName}" }] to read or search past the cut.`
|
|
257
|
+
}
|
|
182
258
|
};
|
|
183
259
|
}
|
|
184
260
|
catch (err) {
|
|
185
261
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
262
|
+
if (ctx?.signal?.aborted) {
|
|
263
|
+
return { error: 'request cancelled', code: 'cancelled' };
|
|
264
|
+
}
|
|
265
|
+
if (timedOut || error.name === 'TimeoutError') {
|
|
266
|
+
return { error: 'request timed out', code: 'timeout' };
|
|
267
|
+
}
|
|
268
|
+
return { error: `request failed: ${error.message}`, code: 'transport' };
|
|
191
269
|
}
|
|
192
270
|
finally {
|
|
193
271
|
clearTimeout(timeout);
|
|
272
|
+
ctx?.signal?.removeEventListener('abort', onCallerAbort);
|
|
194
273
|
}
|
|
195
274
|
}
|
|
196
275
|
};
|
|
197
276
|
}
|
|
277
|
+
function isTextFile(mimeType, fileName) {
|
|
278
|
+
return fileName !== undefined || (mimeType.startsWith('text/') && mimeType !== 'text/html');
|
|
279
|
+
}
|
|
280
|
+
function isSuccess(status) {
|
|
281
|
+
return status >= 200 && status < 300;
|
|
282
|
+
}
|
|
@@ -6,16 +6,19 @@ import type { CredentialStoreFn } from './skills/auth-resolver.ts';
|
|
|
6
6
|
import { ensureBundledSkillsDir } from './skills/bundled-dir.ts';
|
|
7
7
|
import type { SkillCatalogEntry } from './skills/catalog.ts';
|
|
8
8
|
export type { ExecInput } from './attachments/staging.ts';
|
|
9
|
+
export type { SkillsBundle } from './skills/bundled-dir.ts';
|
|
9
10
|
export interface ProductToolsOptions {
|
|
10
11
|
readonly sdkHome: string;
|
|
11
12
|
readonly skillsDir?: string | undefined;
|
|
12
13
|
readonly skillCatalog?: readonly SkillCatalogEntry[] | undefined;
|
|
13
14
|
readonly credentialStore?: CredentialStoreFn | undefined;
|
|
15
|
+
readonly files?: boolean | undefined;
|
|
16
|
+
readonly ask?: boolean | undefined;
|
|
14
17
|
}
|
|
15
18
|
export declare class Tools {
|
|
16
19
|
static deniedRoots: typeof deniedRootsFor;
|
|
17
20
|
static bundledSkillsDir: typeof ensureBundledSkillsDir;
|
|
18
21
|
static stageInputs: typeof stageInputs;
|
|
19
22
|
static operations: typeof compileOperationTools;
|
|
20
|
-
static product({ sdkHome, skillsDir, skillCatalog, credentialStore }: ProductToolsOptions): ToolDefinition[];
|
|
23
|
+
static product({ sdkHome, skillsDir, skillCatalog, credentialStore, files, ask }: ProductToolsOptions): ToolDefinition[];
|
|
21
24
|
}
|