@qvac/harness 1.0.0-rc.2 → 1.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/CHANGELOG.md +3073 -1485
- package/README.md +110 -46
- package/dist-lib/index.d.ts +63 -16
- package/dist-lib/index.js +232 -38
- package/dist-lib/lib/agent/delegate.d.ts +3 -2
- package/dist-lib/lib/agent/delegate.js +6 -4
- package/dist-lib/lib/agent/follow.d.ts +5 -0
- package/dist-lib/lib/agent/follow.js +11 -2
- package/dist-lib/lib/agent/resolve.js +30 -17
- package/dist-lib/lib/agent/tool-selection.d.ts +4 -2
- package/dist-lib/lib/agent/tool-selection.js +5 -6
- package/dist-lib/lib/agent/tools.d.ts +2 -0
- package/dist-lib/lib/agent/tools.js +2 -1
- package/dist-lib/lib/capabilities/agent-ports.d.ts +1 -1
- package/dist-lib/lib/capabilities/agent-ports.js +11 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/answering.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/batching.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/execute.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +132 -13
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +11 -5
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +54 -10
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +12 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +142 -50
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +78 -20
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +33 -16
- package/dist-lib/lib/capabilities/completion-engine/actors/run-prepare.js +38 -23
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +50 -12
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +80 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +5 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +101 -41
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +56 -17
- package/dist-lib/lib/capabilities/completion-engine/driver.js +58 -15
- package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +3 -1
- package/dist-lib/lib/capabilities/completion-engine/durable.js +12 -2
- package/dist-lib/lib/capabilities/completion-engine/engine.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/engine.js +14 -1
- package/dist-lib/lib/capabilities/completion-engine/index.d.ts +5 -1
- package/dist-lib/lib/capabilities/completion-engine/index.js +5 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +26 -3
- package/dist-lib/lib/capabilities/completion-engine/loop.js +14 -2
- package/dist-lib/lib/capabilities/completion-engine/metrics.d.ts +9 -2
- package/dist-lib/lib/capabilities/completion-engine/metrics.js +28 -7
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +63 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.js +99 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.js +30 -10
- package/dist-lib/lib/capabilities/completion-engine/ports.js +6 -9
- package/dist-lib/lib/capabilities/completion-engine/prepare-step.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +38 -6
- package/dist-lib/lib/capabilities/completion-engine/round.js +395 -118
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +12 -4
- package/dist-lib/lib/capabilities/completion-engine/session.js +31 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +5 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +8 -43
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +32 -141
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.d.ts +4 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.js +42 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-preflight.d.ts +43 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-preflight.js +91 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.d.ts +24 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.js +15 -0
- package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +17 -9
- package/dist-lib/lib/capabilities/completion-engine/turns.js +98 -86
- package/dist-lib/lib/capabilities/detect-language.d.ts +2 -1
- package/dist-lib/lib/capabilities/detect-language.js +14 -2
- package/dist-lib/lib/capabilities/download.d.ts +10 -8
- package/dist-lib/lib/capabilities/download.js +1 -1
- package/dist-lib/lib/capabilities/enhance.d.ts +1 -1
- package/dist-lib/lib/capabilities/enhance.js +23 -11
- package/dist-lib/lib/capabilities/kv-cache.d.ts +1 -1
- package/dist-lib/lib/capabilities/preview-model-source.d.ts +7 -0
- package/dist-lib/lib/capabilities/preview-model-source.js +83 -23
- package/dist-lib/lib/capabilities/prompt-prefix.d.ts +3 -1
- package/dist-lib/lib/capabilities/prompt-prefix.js +8 -0
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +13 -4
- package/dist-lib/lib/capabilities/sdk-tool.js +59 -7
- package/dist-lib/lib/capabilities/skill-entry.d.ts +13 -1
- package/dist-lib/lib/capabilities/skill-entry.js +33 -2
- package/dist-lib/lib/capabilities/tool-failed-note.d.ts +1 -0
- package/dist-lib/lib/capabilities/tool-failed-note.js +1 -0
- package/dist-lib/lib/capabilities/tool-plan.d.ts +5 -1
- package/dist-lib/lib/capabilities/tool-plan.js +20 -5
- package/dist-lib/lib/capabilities/tool-prompt-log.d.ts +1 -1
- package/dist-lib/lib/capabilities/tool-prompt-log.js +3 -3
- package/dist-lib/lib/capabilities/tool-turns/attachments.d.ts +7 -0
- package/dist-lib/lib/capabilities/tool-turns/attachments.js +39 -0
- package/dist-lib/lib/capabilities/tool-turns/copy.d.ts +13 -0
- package/dist-lib/lib/capabilities/tool-turns/copy.js +29 -0
- package/dist-lib/lib/capabilities/tool-turns/result-turn.d.ts +22 -0
- package/dist-lib/lib/capabilities/tool-turns/result-turn.js +120 -0
- package/dist-lib/lib/capabilities/tool-turns/run-limits.d.ts +6 -0
- package/dist-lib/lib/capabilities/tool-turns/run-limits.js +32 -0
- package/dist-lib/lib/capabilities/tool-turns/skill-loads.d.ts +9 -0
- package/dist-lib/lib/capabilities/tool-turns/skill-loads.js +71 -0
- package/dist-lib/lib/capabilities/tool-turns.d.ts +8 -43
- package/dist-lib/lib/capabilities/tool-turns.js +6 -253
- package/dist-lib/lib/capabilities/usage-breakdown.d.ts +1 -0
- package/dist-lib/lib/capabilities/usage-breakdown.js +4 -1
- package/dist-lib/lib/client/index.d.ts +19 -0
- package/dist-lib/lib/client/index.js +263 -0
- package/dist-lib/lib/connect/abort.d.ts +6 -0
- package/dist-lib/lib/connect/abort.js +52 -0
- package/dist-lib/lib/connect/bridges.d.ts +21 -0
- package/dist-lib/lib/connect/bridges.js +185 -0
- package/dist-lib/lib/connect/decode.d.ts +31 -0
- package/dist-lib/lib/connect/decode.js +114 -0
- package/dist-lib/lib/connect/host-run-log.d.ts +16 -0
- package/dist-lib/lib/connect/host-run-log.js +74 -0
- package/dist-lib/lib/connect/served.d.ts +7 -0
- package/dist-lib/lib/connect/served.js +45 -0
- package/dist-lib/lib/connect.d.ts +20 -11
- package/dist-lib/lib/connect.js +178 -415
- package/dist-lib/lib/context-window.d.ts +13 -5
- package/dist-lib/lib/context-window.js +19 -6
- package/dist-lib/lib/contract/agent.d.ts +25 -4
- package/dist-lib/lib/contract/completion.d.ts +82 -32
- package/dist-lib/lib/contract/drive.d.ts +130 -0
- package/dist-lib/lib/contract/drive.js +1 -0
- package/dist-lib/lib/contract/egress-proxy.d.ts +13 -0
- package/dist-lib/lib/contract/egress-proxy.js +1 -0
- package/dist-lib/lib/contract/exec.d.ts +4 -3
- package/dist-lib/lib/contract/hooks.d.ts +4 -1
- package/dist-lib/lib/contract/index.d.ts +4 -0
- package/dist-lib/lib/contract/knowledge.d.ts +10 -0
- package/dist-lib/lib/contract/managed-skills.d.ts +1 -0
- package/dist-lib/lib/contract/managed-skills.js +1 -0
- package/dist-lib/lib/contract/media.d.ts +58 -0
- package/dist-lib/lib/contract/media.js +1 -0
- package/dist-lib/lib/contract/models.d.ts +12 -6
- package/dist-lib/lib/contract/ocr.d.ts +17 -0
- package/dist-lib/lib/contract/ocr.js +1 -0
- package/dist-lib/lib/contract/policy.d.ts +75 -0
- package/dist-lib/lib/contract/policy.js +1 -0
- package/dist-lib/lib/contract/run.d.ts +28 -3
- package/dist-lib/lib/contract/sandbox.d.ts +3 -1
- package/dist-lib/lib/contract/speech.d.ts +1 -1
- package/dist-lib/lib/contract/translation.d.ts +20 -0
- package/dist-lib/lib/contract/translation.js +1 -0
- package/dist-lib/lib/contract-types.d.ts +48 -16
- package/dist-lib/lib/embeddings/index.d.ts +7 -1
- package/dist-lib/lib/embeddings/index.js +26 -5
- package/dist-lib/lib/errors.d.ts +278 -0
- package/dist-lib/lib/errors.js +212 -0
- package/dist-lib/lib/fold/index.d.ts +26 -1
- package/dist-lib/lib/fold/index.js +76 -9
- package/dist-lib/lib/guarded-fetch.js +11 -7
- package/dist-lib/lib/guards.d.ts +2 -0
- package/dist-lib/lib/guards.js +7 -0
- package/dist-lib/lib/hardware/capability-probe.js +10 -7
- package/dist-lib/lib/hardware/cpu-placement.d.ts +8 -0
- package/dist-lib/lib/hardware/cpu-placement.js +48 -0
- package/dist-lib/lib/hardware/gpu-probe-addon.js +26 -11
- package/dist-lib/lib/hardware/gpu-probe.js +10 -1
- package/dist-lib/lib/hardware/gpu-stats.native.cjs +17 -1
- package/dist-lib/lib/helpers/completion-params.d.ts +7 -2
- package/dist-lib/lib/helpers/completion-params.js +26 -2
- package/dist-lib/lib/helpers/control-tokens.d.ts +3 -0
- package/dist-lib/lib/helpers/control-tokens.js +25 -0
- package/dist-lib/lib/helpers/engine-error.d.ts +2 -1
- package/dist-lib/lib/helpers/engine-error.js +12 -12
- package/dist-lib/lib/helpers/goal-check/asks.d.ts +25 -0
- package/dist-lib/lib/helpers/goal-check/asks.js +52 -0
- package/dist-lib/lib/helpers/goal-check/checks.d.ts +8 -0
- package/dist-lib/lib/helpers/goal-check/checks.js +92 -0
- package/dist-lib/lib/helpers/goal-check/commands.d.ts +7 -0
- package/dist-lib/lib/helpers/goal-check/commands.js +130 -0
- package/dist-lib/lib/helpers/goal-check/paths.d.ts +5 -0
- package/dist-lib/lib/helpers/goal-check/paths.js +44 -0
- package/dist-lib/lib/helpers/goal-check/shell.d.ts +9 -0
- package/dist-lib/lib/helpers/goal-check/shell.js +96 -0
- package/dist-lib/lib/helpers/goal-check.d.ts +36 -0
- package/dist-lib/lib/helpers/goal-check.js +35 -0
- package/dist-lib/lib/helpers/head-tail.js +1 -1
- package/dist-lib/lib/helpers/html-helpers.js +9 -6
- package/dist-lib/lib/helpers/load-stall.d.ts +1 -1
- package/dist-lib/lib/helpers/load-stall.js +2 -2
- package/dist-lib/lib/helpers/markup-stream-filter.d.ts +4 -1
- package/dist-lib/lib/helpers/markup-stream-filter.js +20 -6
- package/dist-lib/lib/helpers/recent-map.d.ts +7 -0
- package/dist-lib/lib/helpers/recent-map.js +23 -0
- package/dist-lib/lib/helpers/repeated-reply.js +24 -16
- package/dist-lib/lib/helpers/require-peers.d.ts +3 -0
- package/dist-lib/lib/helpers/require-peers.js +23 -0
- package/dist-lib/lib/helpers/run-outcome.d.ts +2 -0
- package/dist-lib/lib/helpers/run-outcome.js +6 -2
- package/dist-lib/lib/helpers/spawn-path.d.ts +1 -0
- package/dist-lib/lib/helpers/spawn-path.js +2 -1
- package/dist-lib/lib/helpers/thinking.d.ts +3 -2
- package/dist-lib/lib/helpers/thinking.js +19 -0
- package/dist-lib/lib/helpers/tool-call-markup/emit.d.ts +6 -0
- package/dist-lib/lib/helpers/tool-call-markup/emit.js +15 -0
- package/dist-lib/lib/helpers/tool-call-markup/recover.d.ts +22 -0
- package/dist-lib/lib/helpers/tool-call-markup/recover.js +130 -0
- package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.d.ts +3 -0
- package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.js +56 -0
- package/dist-lib/lib/helpers/tool-call-markup/strip.d.ts +4 -0
- package/dist-lib/lib/helpers/tool-call-markup/strip.js +149 -0
- package/dist-lib/lib/helpers/tool-call-markup.d.ts +19 -24
- package/dist-lib/lib/helpers/tool-call-markup.js +17 -343
- package/dist-lib/lib/hooks/built-in/arg-repair.js +6 -2
- package/dist-lib/lib/hooks/built-in/policy-rules.d.ts +8 -0
- package/dist-lib/lib/hooks/built-in/policy-rules.js +192 -0
- package/dist-lib/lib/hooks/built-in/sandbox.js +23 -5
- package/dist-lib/lib/hooks/index.d.ts +4 -1
- package/dist-lib/lib/hooks/index.js +9 -4
- package/dist-lib/lib/hooks/run.js +3 -3
- package/dist-lib/lib/lifecycle/index.js +15 -14
- package/dist-lib/lib/lifecycle/machine.js +2 -2
- package/dist-lib/lib/log.d.ts +26 -5
- package/dist-lib/lib/log.js +86 -23
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +15 -16
- package/dist-lib/lib/machine/completion/actions/completion.js +164 -107
- package/dist-lib/lib/machine/completion/actions/goal.d.ts +10 -0
- package/dist-lib/lib/machine/completion/actions/goal.js +93 -0
- package/dist-lib/lib/machine/completion/actions/prepare.js +3 -2
- package/dist-lib/lib/machine/completion/actions/reject-tool.d.ts +16 -0
- package/dist-lib/lib/machine/completion/actions/reject-tool.js +147 -0
- package/dist-lib/lib/machine/completion/actions/retry-round.d.ts +6 -0
- package/dist-lib/lib/machine/completion/actions/retry-round.js +50 -0
- package/dist-lib/lib/machine/completion/actions/rounds.d.ts +5 -0
- package/dist-lib/lib/machine/completion/actions/rounds.js +31 -0
- package/dist-lib/lib/machine/completion/actions/tools.d.ts +1 -16
- package/dist-lib/lib/machine/completion/actions/tools.js +111 -140
- package/dist-lib/lib/machine/completion/context.js +11 -1
- package/dist-lib/lib/machine/completion/guards/retry.d.ts +3 -1
- package/dist-lib/lib/machine/completion/guards/retry.js +9 -2
- package/dist-lib/lib/machine/completion/implementations.d.ts +18 -9
- package/dist-lib/lib/machine/completion/implementations.js +64 -16
- package/dist-lib/lib/machine/completion/machine.d.ts +38 -9
- package/dist-lib/lib/machine/completion/machine.js +58 -9
- package/dist-lib/lib/machine/completion/metrics.d.ts +25 -0
- package/dist-lib/lib/machine/completion/metrics.js +68 -0
- package/dist-lib/lib/machine/completion/nudges.d.ts +5 -0
- package/dist-lib/lib/machine/completion/nudges.js +33 -0
- package/dist-lib/lib/machine/completion/rules.d.ts +19 -27
- package/dist-lib/lib/machine/completion/rules.js +48 -79
- package/dist-lib/lib/machine/completion/splice.d.ts +9 -0
- package/dist-lib/lib/machine/completion/splice.js +19 -0
- package/dist-lib/lib/machine/completion/types.d.ts +81 -14
- package/dist-lib/lib/machine/index.d.ts +50 -11
- package/dist-lib/lib/machine/index.js +12 -2
- package/dist-lib/lib/media-host.d.ts +12 -0
- package/dist-lib/lib/media-host.js +52 -0
- package/dist-lib/lib/media-port.d.ts +20 -0
- package/dist-lib/lib/media-port.js +77 -0
- package/dist-lib/lib/media-wire.d.ts +8 -0
- package/dist-lib/lib/media-wire.js +111 -0
- package/dist-lib/lib/models/context-choice.d.ts +15 -0
- package/dist-lib/lib/models/context-choice.js +62 -0
- package/dist-lib/lib/models/context.d.ts +1 -1
- package/dist-lib/lib/models/custom-model-cache.d.ts +1 -0
- package/dist-lib/lib/models/custom-model-cache.js +3 -0
- package/dist-lib/lib/models/download-gate.d.ts +20 -0
- package/dist-lib/lib/models/download-gate.js +73 -0
- package/dist-lib/lib/models/gguf-header.d.ts +11 -0
- package/dist-lib/lib/models/gguf-header.js +203 -15
- package/dist-lib/lib/models/gpu-selection.d.ts +6 -1
- package/dist-lib/lib/models/gpu-selection.js +29 -5
- package/dist-lib/lib/models/kv-cache.d.ts +2 -0
- package/dist-lib/lib/models/kv-cache.js +8 -0
- package/dist-lib/lib/models/llm-presets.d.ts +6 -1
- package/dist-lib/lib/models/llm-presets.js +33 -6
- package/dist-lib/lib/models/load-requests.d.ts +9 -0
- package/dist-lib/lib/models/load-requests.js +42 -0
- package/dist-lib/lib/models/memory-cap.d.ts +13 -0
- package/dist-lib/lib/models/memory-cap.js +21 -0
- package/dist-lib/lib/models/model-catalog-constants.d.ts +2 -2
- package/dist-lib/lib/models/model-catalog-constants.js +3 -4
- package/dist-lib/lib/models/model-catalog.d.ts +7 -3
- package/dist-lib/lib/models/model-catalog.js +44 -11
- package/dist-lib/lib/models/model-delete.d.ts +1 -1
- package/dist-lib/lib/models/model-fit.d.ts +2 -2
- package/dist-lib/lib/models/model-fit.js +5 -6
- package/dist-lib/lib/models/model-handle.d.ts +9 -2
- package/dist-lib/lib/models/model-handle.js +14 -3
- package/dist-lib/lib/models/model-list.d.ts +9 -2
- package/dist-lib/lib/models/model-list.js +23 -0
- package/dist-lib/lib/models/model-pool.d.ts +42 -7
- package/dist-lib/lib/models/model-pool.js +139 -49
- package/dist-lib/lib/models/model-source.d.ts +3 -2
- package/dist-lib/lib/models/model-source.js +23 -5
- package/dist-lib/lib/models/opencl-cache.js +2 -2
- package/dist-lib/lib/models/sdk-faults.d.ts +1 -0
- package/dist-lib/lib/models/sdk-faults.js +9 -0
- package/dist-lib/lib/models/tool-dialect.d.ts +1 -1
- package/dist-lib/lib/models/tts-model-default.d.ts +2 -1
- package/dist-lib/lib/models/tts-model-default.js +8 -6
- package/dist-lib/lib/no-redirect-fetch-bare.js +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.d.ts +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.js +46 -8
- package/dist-lib/lib/office/engine/pptx/picture-area.d.ts +23 -0
- package/dist-lib/lib/office/engine/pptx/picture-area.js +84 -0
- package/dist-lib/lib/office/engine/pptx/presentation.d.ts +2 -0
- package/dist-lib/lib/office/engine/pptx/presentation.js +64 -21
- package/dist-lib/lib/office/engine/pptx/types.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/sheet.js +10 -4
- package/dist-lib/lib/office/engine/xlsx/workbook.d.ts +1 -0
- package/dist-lib/lib/office/engine/xlsx/workbook.js +34 -3
- package/dist-lib/lib/office/extract.js +4 -3
- package/dist-lib/lib/office/index.js +2 -1
- package/dist-lib/lib/plugins/registry.d.ts +15 -0
- package/dist-lib/lib/plugins/registry.js +91 -22
- package/dist-lib/lib/plugins/require-bare.d.ts +1 -0
- package/dist-lib/lib/plugins/require-bare.js +13 -0
- package/dist-lib/lib/policy/index.d.ts +11 -0
- package/dist-lib/lib/policy/index.js +235 -0
- package/dist-lib/lib/prompt.d.ts +9 -4
- package/dist-lib/lib/prompt.js +95 -32
- package/dist-lib/lib/residency/completion-runtime.d.ts +17 -6
- package/dist-lib/lib/residency/completion-runtime.js +91 -37
- package/dist-lib/lib/residency/index.d.ts +59 -6
- package/dist-lib/lib/residency/index.js +444 -42
- package/dist-lib/lib/resolution-detector.js +3 -3
- package/dist-lib/lib/round-host.d.ts +12 -0
- package/dist-lib/lib/round-host.js +57 -0
- package/dist-lib/lib/round-port.d.ts +24 -0
- package/dist-lib/lib/round-port.js +81 -0
- package/dist-lib/lib/rpc-session.js +2 -1
- package/dist-lib/lib/run-log/redact.js +7 -7
- package/dist-lib/lib/run-log/request-codec.js +2 -2
- package/dist-lib/lib/sdk-loader.d.ts +1 -1
- package/dist-lib/lib/sdk-loader.js +47 -17
- package/dist-lib/lib/sdk-storage.d.ts +1 -0
- package/dist-lib/lib/sdk-storage.js +18 -2
- package/dist-lib/lib/serve/completion.d.ts +7 -0
- package/dist-lib/lib/serve/completion.js +553 -0
- package/dist-lib/lib/serve/downloads.d.ts +4 -0
- package/dist-lib/lib/serve/downloads.js +79 -0
- package/dist-lib/lib/serve/models.d.ts +5 -0
- package/dist-lib/lib/serve/models.js +120 -0
- package/dist-lib/lib/serve/noop.d.ts +1 -0
- package/dist-lib/lib/serve/noop.js +1 -0
- package/dist-lib/lib/serve/requests.d.ts +147 -0
- package/dist-lib/lib/serve/requests.js +1 -0
- package/dist-lib/lib/serve/rounds.d.ts +11 -0
- package/dist-lib/lib/serve/rounds.js +67 -0
- package/dist-lib/lib/serve/run-log-start.d.ts +38 -0
- package/dist-lib/lib/serve/run-log-start.js +254 -0
- package/dist-lib/lib/serve/skills.d.ts +32 -0
- package/dist-lib/lib/serve/skills.js +46 -0
- package/dist-lib/lib/serve.d.ts +5 -1
- package/dist-lib/lib/serve.js +51 -916
- package/dist-lib/lib/sidecar/index.d.ts +39 -0
- package/dist-lib/lib/sidecar/index.js +205 -0
- package/dist-lib/lib/sidecar/user-plugins.d.ts +9 -0
- package/dist-lib/lib/sidecar/user-plugins.js +119 -0
- package/dist-lib/lib/skills-host/index.d.ts +7 -3
- package/dist-lib/lib/skills-host/index.js +47 -22
- package/dist-lib/lib/spawn.d.ts +6 -4
- package/dist-lib/lib/spawn.js +22 -20
- package/dist-lib/lib/spill.d.ts +1 -0
- package/dist-lib/lib/spill.js +12 -8
- package/dist-lib/lib/tools/ask-user.d.ts +2 -0
- package/dist-lib/lib/tools/ask-user.js +137 -0
- package/dist-lib/lib/tools/attachments/delivered.d.ts +5 -0
- package/dist-lib/lib/tools/attachments/delivered.js +16 -0
- package/dist-lib/lib/tools/attachments/fetched-file.d.ts +32 -0
- package/dist-lib/lib/tools/attachments/fetched-file.js +134 -0
- package/dist-lib/lib/tools/attachments/staging.d.ts +1 -0
- package/dist-lib/lib/tools/attachments/staging.js +19 -8
- package/dist-lib/lib/tools/exec/runner.d.ts +4 -0
- package/dist-lib/lib/tools/exec/runner.js +20 -2
- package/dist-lib/lib/tools/exec/scope.d.ts +0 -1
- package/dist-lib/lib/tools/exec/scope.js +23 -114
- package/dist-lib/lib/tools/exec/shell-guidance.js +4 -4
- package/dist-lib/lib/tools/exec/shell-line.d.ts +26 -0
- package/dist-lib/lib/tools/exec/shell-line.js +334 -0
- package/dist-lib/lib/tools/exec.d.ts +4 -1
- package/dist-lib/lib/tools/exec.js +89 -27
- package/dist-lib/lib/tools/files/edit-file.d.ts +6 -0
- package/dist-lib/lib/tools/files/edit-file.js +266 -0
- package/dist-lib/lib/tools/files/glob.d.ts +3 -0
- package/dist-lib/lib/tools/files/glob.js +65 -0
- package/dist-lib/lib/tools/files/grep.d.ts +6 -0
- package/dist-lib/lib/tools/files/grep.js +212 -0
- package/dist-lib/lib/tools/files/index.d.ts +3 -0
- package/dist-lib/lib/tools/files/index.js +25 -0
- package/dist-lib/lib/tools/files/list-dir.d.ts +6 -0
- package/dist-lib/lib/tools/files/list-dir.js +136 -0
- package/dist-lib/lib/tools/files/make-dir.d.ts +3 -0
- package/dist-lib/lib/tools/files/make-dir.js +48 -0
- package/dist-lib/lib/tools/files/read-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/read-file.js +224 -0
- package/dist-lib/lib/tools/files/transfer.d.ts +4 -0
- package/dist-lib/lib/tools/files/transfer.js +83 -0
- package/dist-lib/lib/tools/files/trash-file.d.ts +4 -0
- package/dist-lib/lib/tools/files/trash-file.js +62 -0
- package/dist-lib/lib/tools/files/write-file.d.ts +3 -0
- package/dist-lib/lib/tools/files/write-file.js +56 -0
- package/dist-lib/lib/tools/fs/document-text.d.ts +8 -0
- package/dist-lib/lib/tools/fs/document-text.js +22 -0
- package/dist-lib/lib/tools/fs/drive.d.ts +5 -25
- package/dist-lib/lib/tools/fs/drive.js +9 -1
- package/dist-lib/lib/tools/fs/edit-match.d.ts +33 -0
- package/dist-lib/lib/tools/fs/edit-match.js +445 -0
- package/dist-lib/lib/tools/fs/ignore.d.ts +13 -0
- package/dist-lib/lib/tools/fs/ignore.js +104 -0
- package/dist-lib/lib/tools/fs/local.js +28 -5
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +2 -40
- package/dist-lib/lib/tools/fs/remote-protocol.js +1 -1
- package/dist-lib/lib/tools/fs/remote.d.ts +3 -11
- package/dist-lib/lib/tools/fs/remote.js +24 -14
- package/dist-lib/lib/tools/fs/scope.d.ts +4 -15
- package/dist-lib/lib/tools/fs/scope.js +5 -2
- package/dist-lib/lib/tools/fs/search.d.ts +25 -0
- package/dist-lib/lib/tools/fs/search.js +383 -0
- package/dist-lib/lib/tools/{file-glob.d.ts → fs/targets.d.ts} +1 -5
- package/dist-lib/lib/tools/fs/targets.js +32 -0
- package/dist-lib/lib/tools/fs/tool-path.d.ts +27 -0
- package/dist-lib/lib/tools/fs/tool-path.js +70 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +14 -5
- package/dist-lib/lib/tools/fs/walk.js +119 -24
- package/dist-lib/lib/tools/http-request/request.d.ts +4 -2
- package/dist-lib/lib/tools/http-request/request.js +2 -1
- package/dist-lib/lib/tools/http-request/truncate-response.d.ts +16 -1
- package/dist-lib/lib/tools/http-request/truncate-response.js +56 -11
- package/dist-lib/lib/tools/http-request.d.ts +1 -0
- package/dist-lib/lib/tools/http-request.js +101 -16
- package/dist-lib/lib/tools/index.d.ts +4 -1
- package/dist-lib/lib/tools/index.js +8 -12
- package/dist-lib/lib/tools/office/ops.d.ts +1 -0
- package/dist-lib/lib/tools/office/ops.js +5 -1
- package/dist-lib/lib/tools/office.d.ts +2 -1
- package/dist-lib/lib/tools/office.js +273 -56
- package/dist-lib/lib/tools/operations/builders.d.ts +4 -3
- package/dist-lib/lib/tools/operations/builders.js +41 -3
- package/dist-lib/lib/tools/operations/calendar-range.d.ts +16 -0
- package/dist-lib/lib/tools/operations/calendar-range.js +40 -0
- package/dist-lib/lib/tools/operations/compile.js +8 -6
- package/dist-lib/lib/tools/operations/manifest.d.ts +4 -0
- package/dist-lib/lib/tools/pdf/build.d.ts +17 -3
- package/dist-lib/lib/tools/pdf/build.js +77 -16
- package/dist-lib/lib/tools/pdf/pages.d.ts +12 -0
- package/dist-lib/lib/tools/pdf/pages.js +31 -0
- package/dist-lib/lib/tools/pdf/recognize.d.ts +13 -0
- package/dist-lib/lib/tools/pdf/recognize.js +55 -0
- package/dist-lib/lib/tools/pdf/request.d.ts +3 -8
- package/dist-lib/lib/tools/pdf/request.js +4 -4
- package/dist-lib/lib/tools/pdf.d.ts +0 -1
- package/dist-lib/lib/tools/pdf.js +56 -13
- package/dist-lib/lib/tools/skill.js +23 -11
- package/dist-lib/lib/tools/skills/bundled-dir.d.ts +8 -1
- package/dist-lib/lib/tools/skills/bundled-dir.js +42 -36
- package/dist-lib/lib/tools/skills/bundled-hash.d.ts +1 -0
- package/dist-lib/lib/tools/skills/bundled-hash.js +4 -1
- package/dist-lib/lib/tools/skills/catalog-loader.d.ts +12 -0
- package/dist-lib/lib/tools/skills/catalog-loader.js +173 -0
- package/dist-lib/lib/tools/skills/catalog.d.ts +7 -8
- package/dist-lib/lib/tools/skills/catalog.js +1 -158
- package/dist-lib/lib/tools/skills/cli-argv.js +25 -5
- package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/cli-schema-check.js +3 -0
- package/dist-lib/lib/tools/skills/cli-schema-load.js +10 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +2 -0
- package/dist-lib/lib/tools/skills/cli-schema.js +6 -3
- package/dist-lib/lib/tools/skills/credential-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/credential-check.js +3 -0
- package/dist-lib/lib/tools/skills/credential-health.js +3 -3
- package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +3 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +5 -0
- package/dist-lib/lib/tools/skills/index.d.ts +1 -0
- package/dist-lib/lib/tools/skills/index.js +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.d.ts +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +39 -3
- package/dist-lib/lib/tools/skills/manifest.d.ts +1 -0
- package/dist-lib/lib/tools/skills/mention-name.d.ts +6 -0
- package/dist-lib/lib/tools/skills/mention-name.js +6 -0
- package/dist-lib/lib/tools/skills/mention.d.ts +2 -2
- package/dist-lib/lib/tools/skills/mention.js +11 -4
- package/dist-lib/lib/tools/skills/overlay-crud.d.ts +3 -3
- package/dist-lib/lib/tools/skills/overlay-crud.js +7 -6
- package/dist-lib/lib/tools/skills/overlay-watch.d.ts +2 -2
- package/dist-lib/lib/tools/skills/overlay-watch.js +4 -3
- package/dist-lib/lib/tools/skills/scope-key.d.ts +1 -0
- package/dist-lib/lib/tools/skills/scope-key.js +4 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +1 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.js +4 -0
- package/dist-lib/lib/tools/skills/skill-tree.d.ts +5 -0
- package/dist-lib/lib/tools/skills/skill-tree.js +54 -0
- package/dist-lib/lib/tools/url-guard.d.ts +6 -1
- package/dist-lib/lib/tools/url-guard.js +8 -2
- package/dist-lib/lib/tools/web-fetch.js +50 -133
- package/dist-lib/lib/wire/download.d.ts +10 -0
- package/dist-lib/lib/wire/download.js +35 -0
- package/dist-lib/lib/wire/event.d.ts +41 -0
- package/dist-lib/lib/wire/event.js +306 -0
- package/dist-lib/lib/wire/fields.d.ts +3 -0
- package/dist-lib/lib/wire/fields.js +12 -0
- package/dist-lib/lib/wire/knowledge.d.ts +9 -0
- package/dist-lib/lib/wire/knowledge.js +68 -0
- package/dist-lib/lib/wire/round.d.ts +14 -0
- package/dist-lib/lib/wire/round.js +45 -0
- package/dist-lib/lib/wire/vectors.d.ts +6 -0
- package/dist-lib/lib/wire/vectors.js +33 -0
- package/dist-lib/lib/wire.d.ts +28 -64
- package/dist-lib/lib/wire.js +24 -417
- package/dist-lib/plugins/coding/index.d.ts +1 -1
- package/dist-lib/plugins/coding/index.js +2 -4
- package/dist-lib/plugins/coding/read-only.d.ts +1 -0
- package/dist-lib/plugins/coding/read-only.js +264 -0
- package/dist-lib/plugins/coding/session.d.ts +6 -4
- package/dist-lib/plugins/coding/session.js +45 -16
- package/dist-lib/plugins/coding-guards/index.d.ts +25 -0
- package/dist-lib/plugins/coding-guards/index.js +126 -0
- package/dist-lib/plugins/command-hooks/index.js +5 -3
- package/dist-lib/plugins/egress-proxy/index.d.ts +53 -0
- package/dist-lib/plugins/egress-proxy/index.js +184 -0
- package/dist-lib/plugins/image/edit-image.d.ts +3 -22
- package/dist-lib/plugins/image/edit-image.js +23 -46
- package/dist-lib/plugins/image/fit.d.ts +31 -0
- package/dist-lib/plugins/image/fit.js +28 -0
- package/dist-lib/plugins/image/generate-image.d.ts +27 -6
- package/dist-lib/plugins/image/generate-image.js +201 -74
- package/dist-lib/plugins/image/index.d.ts +2 -1
- package/dist-lib/plugins/image/index.js +29 -12
- package/dist-lib/plugins/knowledge/index.d.ts +3 -0
- package/dist-lib/plugins/knowledge/index.js +5 -0
- package/dist-lib/plugins/knowledge/manifest.d.ts +53 -0
- package/dist-lib/plugins/knowledge/manifest.js +86 -0
- package/dist-lib/plugins/knowledge/search-tool.js +8 -8
- package/dist-lib/plugins/knowledge/store.d.ts +45 -8
- package/dist-lib/plugins/knowledge/store.js +428 -166
- package/dist-lib/plugins/language-hint/index.d.ts +15 -0
- package/dist-lib/plugins/language-hint/index.js +54 -0
- package/dist-lib/plugins/lsp/tool.js +2 -2
- package/dist-lib/plugins/mcp/call.js +15 -4
- package/dist-lib/plugins/mcp/index.js +6 -3
- package/dist-lib/plugins/mcp/protocol.d.ts +10 -2
- package/dist-lib/plugins/mcp/protocol.js +13 -12
- package/dist-lib/plugins/mcp/server.js +1 -1
- package/dist-lib/plugins/mcp/tool-listing.d.ts +6 -0
- package/dist-lib/plugins/mcp/tool-listing.js +97 -0
- package/dist-lib/plugins/music/generate-music.d.ts +24 -5
- package/dist-lib/plugins/music/generate-music.js +170 -64
- package/dist-lib/plugins/music/index.d.ts +2 -1
- package/dist-lib/plugins/music/index.js +23 -11
- package/dist-lib/plugins/obsidian/command.js +2 -2
- package/dist-lib/plugins/obsidian/index.js +14 -4
- package/dist-lib/plugins/obsidian/note-name.js +2 -1
- package/dist-lib/plugins/obsidian/readiness.js +2 -2
- package/dist-lib/plugins/obsidian/safe-path.js +5 -4
- package/dist-lib/plugins/obsidian/vault-create.js +3 -2
- package/dist-lib/plugins/obsidian/vault-fs.js +2 -2
- package/dist-lib/plugins/obsidian/vault-paths.js +3 -2
- package/dist-lib/plugins/obsidian/vault-read.js +20 -18
- package/dist-lib/plugins/obsidian/vault-write.js +13 -12
- package/dist-lib/plugins/ocr/bmp.d.ts +2 -0
- package/dist-lib/plugins/ocr/bmp.js +27 -0
- package/dist-lib/plugins/ocr/coverage.d.ts +3 -0
- package/dist-lib/plugins/ocr/coverage.js +67 -0
- package/dist-lib/plugins/ocr/index.d.ts +12 -0
- package/dist-lib/plugins/ocr/index.js +20 -0
- package/dist-lib/plugins/ocr/ocr-runtime.d.ts +25 -0
- package/dist-lib/plugins/ocr/ocr-runtime.js +103 -0
- package/dist-lib/plugins/ocr/reading-order.d.ts +5 -0
- package/dist-lib/plugins/ocr/reading-order.js +218 -0
- package/dist-lib/plugins/python/bare-floor.d.ts +1 -0
- package/dist-lib/plugins/python/bare-floor.js +2 -0
- package/dist-lib/plugins/python/guarded-fetch.d.ts +2 -1
- package/dist-lib/plugins/python/guarded-fetch.js +5 -1
- package/dist-lib/plugins/python/index.d.ts +4 -1
- package/dist-lib/plugins/python/index.js +6 -1
- package/dist-lib/plugins/python/interrupt-timer.js +2 -2
- package/dist-lib/plugins/python/language.js +11 -10
- package/dist-lib/plugins/python/loader.d.ts +1 -0
- package/dist-lib/plugins/python/loader.js +76 -3
- package/dist-lib/plugins/python/memfs.js +2 -2
- package/dist-lib/plugins/python/pyodide.d.ts +1 -0
- package/dist-lib/plugins/python/pyodide.js +9 -8
- package/dist-lib/plugins/python/python-adapter.d.ts +6 -1
- package/dist-lib/plugins/python/python-adapter.js +37 -2
- package/dist-lib/plugins/python/run-session.d.ts +1 -0
- package/dist-lib/plugins/python/run-session.js +19 -8
- package/dist-lib/plugins/python/wheels.js +8 -6
- package/dist-lib/plugins/python/worker/active.js +2 -2
- package/dist-lib/plugins/python/worker/client.js +10 -9
- package/dist-lib/plugins/python/worker/entry.js +2 -8
- package/dist-lib/plugins/python/worker/preload.d.ts +1 -0
- package/dist-lib/plugins/python/worker/preload.js +2 -0
- package/dist-lib/plugins/python/worker/protocol.d.ts +2 -0
- package/dist-lib/plugins/python/worker/serve.js +23 -4
- package/dist-lib/plugins/python/worker/spawn.d.ts +2 -1
- package/dist-lib/plugins/python/worker/spawn.js +3 -2
- package/dist-lib/plugins/quickjs/index.js +4 -0
- package/dist-lib/plugins/quickjs/runtime.js +8 -3
- package/dist-lib/plugins/run-report/chain.d.ts +2 -0
- package/dist-lib/plugins/run-report/chain.js +73 -0
- package/dist-lib/plugins/run-report/flow-view.js +2 -1
- package/dist-lib/plugins/run-report/flow.d.ts +1 -1
- package/dist-lib/plugins/run-report/flow.js +66 -14
- package/dist-lib/plugins/run-report/index.d.ts +23 -2
- package/dist-lib/plugins/run-report/index.js +32 -13
- package/dist-lib/plugins/run-report/layout.js +1 -1
- package/dist-lib/plugins/run-report/model.d.ts +10 -1
- package/dist-lib/plugins/run-report/model.js +12 -6
- package/dist-lib/plugins/run-report/page.d.ts +9 -0
- package/dist-lib/plugins/run-report/page.js +55 -15
- package/dist-lib/plugins/run-report/script.js +317 -43
- package/dist-lib/plugins/run-report/story.d.ts +2 -1
- package/dist-lib/plugins/run-report/story.js +7 -4
- package/dist-lib/plugins/run-report/style.d.ts +1 -1
- package/dist-lib/plugins/run-report/style.js +126 -0
- package/dist-lib/plugins/run-report/why.js +1 -1
- package/dist-lib/plugins/sandbox-linux/index.d.ts +62 -0
- package/dist-lib/plugins/sandbox-linux/index.js +354 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.d.ts +2 -0
- package/dist-lib/plugins/sandbox-linux/seccomp.js +74 -0
- package/dist-lib/plugins/sandbox-macos/index.d.ts +25 -11
- package/dist-lib/plugins/sandbox-macos/index.js +244 -49
- package/dist-lib/plugins/sandbox-vm/index.d.ts +2 -1
- package/dist-lib/plugins/sandbox-vm/index.js +5 -2
- package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +7 -3
- package/dist-lib/plugins/sandbox-vm/vm-shell.js +54 -20
- package/dist-lib/plugins/sandbox-windows/helper/qvac-sandbox.c +554 -0
- package/dist-lib/plugins/sandbox-windows/index.d.ts +53 -0
- package/dist-lib/plugins/sandbox-windows/index.js +205 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/speech/audio-resample.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-resample.js +8 -8
- package/dist-lib/plugins/speech/audio-transcode-bare.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-bare.js +23 -26
- package/dist-lib/plugins/speech/audio-transcode-node.d.ts +1 -1
- package/dist-lib/plugins/speech/audio-transcode-node.js +1 -3
- package/dist-lib/plugins/speech/index.d.ts +1 -0
- package/dist-lib/plugins/speech/index.js +8 -1
- package/dist-lib/plugins/speech/speech-engine.d.ts +1 -1
- package/dist-lib/plugins/speech/speech-engine.js +10 -5
- package/dist-lib/plugins/speech/speech-runtime.js +37 -37
- package/dist-lib/plugins/speech/speech-text.d.ts +1 -0
- package/dist-lib/plugins/speech/speech-text.js +9 -4
- package/dist-lib/plugins/speech/voice.d.ts +5 -1
- package/dist-lib/plugins/speech/voice.js +107 -33
- package/dist-lib/plugins/translation/index.d.ts +2 -1
- package/dist-lib/plugins/translation/index.js +21 -10
- package/dist-lib/plugins/translation/translate.d.ts +9 -5
- package/dist-lib/plugins/translation/translate.js +69 -64
- package/dist-lib/plugins/walkie-talkie/index.d.ts +4 -2
- package/dist-lib/plugins/walkie-talkie/index.js +19 -6
- package/dist-lib/plugins/walkie-talkie/wire.d.ts +5 -0
- package/dist-lib/plugins/walkie-talkie/wire.js +6 -5
- package/dist-lib/plugins/weather/geocode.js +2 -1
- package/dist-lib/plugins/weather/lookup.js +6 -4
- package/dist-lib/plugins/web-search/engines/bing.js +2 -1
- package/dist-lib/plugins/web-search/engines/google.js +2 -1
- package/dist-lib/plugins/web-search/fetch-html.d.ts +5 -5
- package/dist-lib/plugins/web-search/fetch-html.js +12 -15
- package/dist-lib/plugins/web-search/tool.js +1 -0
- package/dist-lib/schema/generate.js +8 -1
- package/dist-lib/schema/harness.js +94 -12
- package/dist-lib/spec/bind.js +12 -0
- package/dist-lib/spec/calls.js +4 -0
- package/dist-lib/spec/hrpc/hrpc.json +55 -3
- package/dist-lib/spec/hrpc/index.js +58 -10
- package/dist-lib/spec/hrpc/messages.js +485 -209
- package/dist-lib/spec/hyperschema/index.js +485 -209
- package/dist-lib/spec/hyperschema/schema.json +290 -85
- package/dist-lib/spec/hyperschema/types.d.ts +42 -5
- package/package.json +265 -65
- package/patches/pyodide@314.0.2.patch +37 -8
- package/scripts/addon-externals.cjs +16 -5
- package/worker/harness-sidecar.mjs +23 -154
- package/dist-lib/lib/tools/create-documents.d.ts +0 -3
- package/dist-lib/lib/tools/create-documents.js +0 -95
- package/dist-lib/lib/tools/edit-documents.d.ts +0 -3
- package/dist-lib/lib/tools/edit-documents.js +0 -132
- package/dist-lib/lib/tools/exec/shell-argv.d.ts +0 -2
- package/dist-lib/lib/tools/exec/shell-argv.js +0 -61
- package/dist-lib/lib/tools/file-glob.js +0 -118
- package/dist-lib/lib/tools/grep.d.ts +0 -5
- package/dist-lib/lib/tools/grep.js +0 -184
- package/dist-lib/lib/tools/read-files.d.ts +0 -5
- package/dist-lib/lib/tools/read-files.js +0 -160
- package/dist-lib/plugins/coding/write-file.d.ts +0 -3
- package/dist-lib/plugins/coding/write-file.js +0 -52
- package/patches/@qvac%2Finference@0.21.0.patch +0 -67
- package/patches/bare-stow@0.1.5.patch +0 -68
- package/patches/hypercore-blob-server@1.15.0.patch +0 -15
- package/patches/localwatch@1.4.3.patch +0 -13
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { Tool as SdkTool } from '@qvac/
|
|
1
|
+
import type { Tool as SdkTool } from '@qvac/inference';
|
|
2
2
|
import type { HookPipeline } from '../../hooks/index.ts';
|
|
3
3
|
import { type RunOutcomeTracker } from '../../helpers/run-outcome.ts';
|
|
4
|
-
import type { AgentPolicy, AgentPorts, CompletionEvent, CliValidator, CompletionSdk, DriveRoot, LlmGenerationParams, OutboundGuard, RunBackendUse, RunBudget, SkillActivation, ToolDefinition } from '../../contract/index.ts';
|
|
4
|
+
import type { AgentPolicy, AgentPorts, CompletionEvent, CliValidator, CompiledPolicy, CompletionHistoryEntry, CompletionSdk, DriveRoot, LlmGenerationParams, OutboundGuard, RunBackendUse, RunBudget, SkillActivation, ToolDefinition } from '../../contract/index.ts';
|
|
5
5
|
import type { CompletionArgs, ToolContextFactory } from './loop.ts';
|
|
6
6
|
import type { CompletionSkillEntry } from '../skill-entry.ts';
|
|
7
7
|
import type { PromptUsageChars } from '../usage-breakdown.ts';
|
|
8
8
|
import type { EngineOperationPort } from './engine.ts';
|
|
9
9
|
import type { Context } from '../../plugins/index.ts';
|
|
10
10
|
import type { InvokeTracker } from './ports.ts';
|
|
11
|
+
import type { LiveRound } from './round.ts';
|
|
11
12
|
import type { CompletionActorOutput, CompletionContext } from '../../machine/index.ts';
|
|
12
|
-
export declare const RUNTIME_BINDINGS: readonly ['approve', 'attach', 'fetchAttachment', 'askUser'];
|
|
13
|
+
export declare const RUNTIME_BINDINGS: readonly ['approve', 'attach', 'fetchAttachment', 'askUser', 'modelRound'];
|
|
13
14
|
export type RuntimeBinding = (typeof RUNTIME_BINDINGS)[number];
|
|
14
15
|
export interface Session extends InvokeTracker {
|
|
15
16
|
bindings: RuntimeBinding[];
|
|
@@ -18,6 +19,7 @@ export interface Session extends InvokeTracker {
|
|
|
18
19
|
outbound: OutboundGuard;
|
|
19
20
|
enabled: ToolDefinition[];
|
|
20
21
|
sdkTools: SdkTool[] | undefined;
|
|
22
|
+
grantable: ReadonlySet<string>;
|
|
21
23
|
grantedOps: Map<string, CliValidator[]>;
|
|
22
24
|
behaviorDigest: string;
|
|
23
25
|
activation: SkillActivation;
|
|
@@ -30,6 +32,7 @@ export interface Session extends InvokeTracker {
|
|
|
30
32
|
landed: string[];
|
|
31
33
|
runOutcomes: RunOutcomeTracker;
|
|
32
34
|
callKey(name: string, args: Record<string, unknown>): string;
|
|
35
|
+
resultDigest(output: unknown): string;
|
|
33
36
|
skillIcon: string | null;
|
|
34
37
|
writableRoots: DriveRoot[];
|
|
35
38
|
runBudget: RunBudget;
|
|
@@ -39,13 +42,17 @@ export interface Session extends InvokeTracker {
|
|
|
39
42
|
}[];
|
|
40
43
|
generationParams: LlmGenerationParams | undefined;
|
|
41
44
|
policy: AgentPolicy;
|
|
45
|
+
access: CompiledPolicy | undefined;
|
|
46
|
+
accessDigest: string | null;
|
|
42
47
|
agentPorts: AgentPorts<CompletionSkillEntry>;
|
|
43
48
|
runStarted: boolean;
|
|
44
49
|
promptParts: PromptUsageChars | null;
|
|
45
50
|
startedAt: number;
|
|
46
51
|
now: () => number;
|
|
47
52
|
wallStart: number;
|
|
48
|
-
reselectTools: ((loadedSkills: ReadonlySet<string
|
|
53
|
+
reselectTools: ((loadedSkills: ReadonlySet<string>, history: readonly CompletionHistoryEntry[]) => string) | null;
|
|
54
|
+
preloadSystem: ((skill: string, history: readonly CompletionHistoryEntry[]) => string) | null;
|
|
55
|
+
liveRound: LiveRound | null;
|
|
49
56
|
}
|
|
50
57
|
export interface CompletionDeps {
|
|
51
58
|
services?: Context;
|
|
@@ -80,4 +87,5 @@ export interface CreateSessionOptions {
|
|
|
80
87
|
outbound: OutboundGuard;
|
|
81
88
|
agentPorts: AgentPorts<CompletionSkillEntry>;
|
|
82
89
|
}
|
|
90
|
+
export declare function loadedSkills(context: CompletionContext, session: Session): Set<string>;
|
|
83
91
|
export declare function createSession(args: CompletionArgs, options: CreateSessionOptions): Session;
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import { Agent } from '../../agent/index.js';
|
|
2
2
|
import { createRunOutcomeTracker } from '../../helpers/run-outcome.js';
|
|
3
|
+
import { Policy } from '../../policy/index.js';
|
|
3
4
|
import { createRunBudget, runToolContext } from './loop.js';
|
|
4
5
|
import { createHash, createHmac, randomBytes } from 'crypto';
|
|
5
6
|
import { createInvokeTracker } from './actors.js';
|
|
6
7
|
import { stableStringify } from '../../helpers/stable-stringify.js';
|
|
7
|
-
|
|
8
|
+
import { historyPayload } from '../tool-turns.js';
|
|
9
|
+
const HOST_SHELL = { name: 'host' };
|
|
10
|
+
export const RUNTIME_BINDINGS = [
|
|
11
|
+
'approve',
|
|
12
|
+
'attach',
|
|
13
|
+
'fetchAttachment',
|
|
14
|
+
'askUser',
|
|
15
|
+
'modelRound'
|
|
16
|
+
];
|
|
17
|
+
export function loadedSkills(context, session) {
|
|
18
|
+
const files = [...session.loadedFilesThisTurn].map((key) => key.slice(0, key.indexOf('\0')));
|
|
19
|
+
return new Set([...context.activated, ...session.loadedThisTurn, ...files]);
|
|
20
|
+
}
|
|
8
21
|
export function createSession(args, options) {
|
|
9
22
|
const { runId, invokes = createInvokeTracker(), now = () => Date.now(), wallStart = Date.now(), requestDigestKey, digestRunId, pipeline, outbound, agentPorts } = options;
|
|
10
23
|
const runBudget = createRunBudget(now());
|
|
24
|
+
const shell = (args.tools ?? []).some((tool) => tool.name === 'exec') ? [HOST_SHELL] : [];
|
|
25
|
+
const access = args.access ?? Policy.forRun([args.agent?.policy, args.policy], args, shell);
|
|
11
26
|
const runOutcomes = createRunOutcomeTracker();
|
|
12
27
|
const callKeySecret = requestDigestKey
|
|
13
28
|
? createHmac('sha256', requestDigestKey)
|
|
@@ -18,10 +33,11 @@ export function createSession(args, options) {
|
|
|
18
33
|
return {
|
|
19
34
|
bindings: RUNTIME_BINDINGS.filter((name) => typeof args[name] === 'function'),
|
|
20
35
|
runId,
|
|
21
|
-
pipeline,
|
|
36
|
+
pipeline: access?.rules.length ? pipeline.withRules(access.rules) : pipeline,
|
|
22
37
|
outbound,
|
|
23
38
|
enabled: [],
|
|
24
39
|
sdkTools: undefined,
|
|
40
|
+
grantable: new Set(),
|
|
25
41
|
grantedOps: new Map(),
|
|
26
42
|
behaviorDigest: createHash('sha256')
|
|
27
43
|
.update(stableStringify((args.tools ?? [])
|
|
@@ -57,14 +73,27 @@ export function createSession(args, options) {
|
|
|
57
73
|
.update(payload)
|
|
58
74
|
.digest('hex')}`;
|
|
59
75
|
},
|
|
76
|
+
resultDigest(output) {
|
|
77
|
+
return createHmac('sha256', callKeySecret)
|
|
78
|
+
.update('qvac:completion:result:v1\0')
|
|
79
|
+
.update(stableStringify(historyPayload(output)) ?? '')
|
|
80
|
+
.digest('hex')
|
|
81
|
+
.slice(0, 16);
|
|
82
|
+
},
|
|
60
83
|
skillIcon: null,
|
|
61
84
|
reselectTools: null,
|
|
85
|
+
preloadSystem: null,
|
|
86
|
+
liveRound: null,
|
|
62
87
|
writableRoots: [],
|
|
63
88
|
runBudget,
|
|
64
89
|
toolContext: runToolContext(args, runBudget),
|
|
65
90
|
turnImages: [],
|
|
66
91
|
generationParams: undefined,
|
|
67
92
|
policy: Agent.policy(args.agent),
|
|
93
|
+
access,
|
|
94
|
+
accessDigest: access
|
|
95
|
+
? createHash('sha256').update(stableStringify(access)).digest('hex')
|
|
96
|
+
: null,
|
|
68
97
|
agentPorts,
|
|
69
98
|
runStarted: false,
|
|
70
99
|
promptParts: null,
|
|
@@ -7,7 +7,9 @@ import { historyPayload } from '../tool-turns.js';
|
|
|
7
7
|
import { defers, TOOL_SEARCH_TOOL_NAME, unloadedTools } from '../sdk-tool.js';
|
|
8
8
|
import { labelOf } from './loop.js';
|
|
9
9
|
import { ToolPolicyChanged } from './operations.js';
|
|
10
|
-
import {
|
|
10
|
+
import { executeCall, reportFailure } from './tool-execution.js';
|
|
11
|
+
import { callSucceeded } from './tool-outcome.js';
|
|
12
|
+
import { preflightToolCall, ruleInputs } from './tool-preflight.js';
|
|
11
13
|
import { toolContext, trustedSources } from './actors/execution-plan.js';
|
|
12
14
|
export const MAX_SCRIPT_CALLS = 16;
|
|
13
15
|
function callable(tool) {
|
|
@@ -70,7 +72,8 @@ export function toolCaller({ input: deps, context }, { callId, denied, emit }) {
|
|
|
70
72
|
skillNames: session.inContextSkills.map((skill) => skill.name),
|
|
71
73
|
parameters: tool.parameters,
|
|
72
74
|
egress: tool.egress,
|
|
73
|
-
|
|
75
|
+
...ruleInputs(tool, ctx),
|
|
76
|
+
network: session.access?.network.mode ?? 'on',
|
|
74
77
|
signal: args.signal
|
|
75
78
|
});
|
|
76
79
|
const callArgs = detachJson(fold.ok ? fold.args : input);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import type { ToolCallWithCall } from '@qvac/
|
|
1
|
+
import type { ToolCallWithCall } from '@qvac/inference';
|
|
2
2
|
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
3
3
|
import type { HookPipeline } from '../../hooks/index.ts';
|
|
4
|
-
import type { ToolFailurePayload } from '../../contract/index.ts';
|
|
5
|
-
import type { ApproveFn, OutboundGuard, ResolvedCall,
|
|
6
|
-
import type
|
|
7
|
-
|
|
8
|
-
export declare function answerOf(result: unknown): string | undefined;
|
|
9
|
-
export declare function settledFailure(result: unknown, outcome: ToolExecutionOutcome): boolean;
|
|
10
|
-
export interface ExecuteCallOptions {
|
|
4
|
+
import type { NetworkMode, ToolFailurePayload } from '../../contract/index.ts';
|
|
5
|
+
import type { ApproveFn, OutboundGuard, ResolvedCall, ToolActivityFn, ToolCallDisplay, ToolDefinition, ToolEffect, ToolExecuteContext, ToolExecutionOutcome, TrustedSource, TrustedSourceFacts } from '../../contract/index.ts';
|
|
6
|
+
import { type ToolPreflight } from './tool-preflight.ts';
|
|
7
|
+
interface ExecuteCallOptions {
|
|
11
8
|
runId: string;
|
|
12
9
|
deniedMessage: string;
|
|
13
10
|
approve?: ApproveFn | undefined;
|
|
@@ -30,48 +27,16 @@ export interface ExecutedCall {
|
|
|
30
27
|
readonly outcome: ToolExecutionOutcome;
|
|
31
28
|
readonly executed: boolean;
|
|
32
29
|
}
|
|
33
|
-
export type ToolPreflight = {
|
|
34
|
-
status: 'blocked';
|
|
35
|
-
reason: 'validation' | 'refusal';
|
|
36
|
-
result: unknown;
|
|
37
|
-
effect: ToolEffect;
|
|
38
|
-
} | {
|
|
39
|
-
status: 'denied';
|
|
40
|
-
result: {
|
|
41
|
-
error: string;
|
|
42
|
-
denied: true;
|
|
43
|
-
};
|
|
44
|
-
key: string;
|
|
45
|
-
} | {
|
|
46
|
-
status: 'ready';
|
|
47
|
-
key: string;
|
|
48
|
-
effect: ToolEffect;
|
|
49
|
-
resource: ResourceDescriptor | null;
|
|
50
|
-
autoRun: boolean;
|
|
51
|
-
permission?: 'allow' | 'ask' | undefined;
|
|
52
|
-
};
|
|
53
|
-
interface ToolPolicyOptions extends Pick<ExecuteCallOptions, 'sources' | 'sourceFacts' | 'outbound' | 'denied' | 'effect' | 'skipApprovals'> {
|
|
54
|
-
key?: string;
|
|
55
|
-
permission?: 'allow' | 'ask' | undefined;
|
|
56
|
-
}
|
|
57
|
-
interface PreflightOptions extends ToolPolicyOptions, Pick<ExecuteCallOptions, 'deniedMessage'> {
|
|
58
|
-
}
|
|
59
|
-
export declare function preflightToolCall(tool: ToolDefinition, args: Record<string, unknown>, ctx: ToolExecuteContext, options: PreflightOptions): ToolPreflight;
|
|
60
|
-
export declare function inspectToolPolicy(tool: ToolDefinition, args: Record<string, unknown>, ctx: ToolExecuteContext, options: ToolPolicyOptions): ToolPreflightFacts;
|
|
61
|
-
type ReadyToolPreflight = Extract<ToolPreflight, {
|
|
62
|
-
status: 'ready';
|
|
63
|
-
}>;
|
|
64
|
-
export declare function readyPreflightFromFacts(facts: ToolPreflightFacts): ReadyToolPreflight;
|
|
65
30
|
export declare function executeCall(tool: ToolDefinition, args: Record<string, unknown>, ctx: ToolExecuteContext, { runId, deniedMessage, approve, signal, denied, sources, sourceFacts, outbound, pipeline, callId, effect: classified, skipApprovals, preflight: prepared, onToolActivity, intent, display }: ExecuteCallOptions): Promise<ExecutedCall>;
|
|
66
31
|
export declare function reportFailure(pipeline: HookPipeline, failure: Omit<ToolFailurePayload, 'phase'>): Promise<unknown>;
|
|
67
|
-
|
|
32
|
+
interface ResolveToolCallsOptions {
|
|
68
33
|
runId: string;
|
|
69
34
|
agentId: string | null;
|
|
70
35
|
pipeline: HookPipeline;
|
|
71
36
|
skillNames: readonly string[];
|
|
72
|
-
|
|
37
|
+
network: NetworkMode;
|
|
73
38
|
toolContext: (name: string) => ToolExecuteContext;
|
|
74
39
|
signal?: BareAbortSignal | undefined;
|
|
75
40
|
}
|
|
76
|
-
export declare function resolveToolCalls(toolCalls: ToolCallWithCall[], enabled: readonly ToolDefinition[], { runId, agentId, pipeline, skillNames,
|
|
41
|
+
export declare function resolveToolCalls(toolCalls: ToolCallWithCall[], enabled: readonly ToolDefinition[], { runId, agentId, pipeline, skillNames, network, toolContext, signal }: ResolveToolCallsOptions): Promise<ResolvedCall[]>;
|
|
77
42
|
export {};
|
|
@@ -2,133 +2,17 @@ import { HookHalt, RecoveryRequired } from '../../helpers/engine-error.js';
|
|
|
2
2
|
import { AbortedError, raceAbort } from '../../helpers/race-abort.js';
|
|
3
3
|
import { errorCode, errorMessage, isRecord } from '../../guards.js';
|
|
4
4
|
import { detachJson } from '../../helpers/detach-json.js';
|
|
5
|
-
import {
|
|
5
|
+
import { mapStrings, restoreTemplateTokens } from '../../helpers/control-tokens.js';
|
|
6
|
+
import { ToolCallMarkup } from '../../helpers/tool-call-markup.js';
|
|
6
7
|
import { INTENT_PARAM, takeToolIntent } from '../../helpers/tool-intent.js';
|
|
7
8
|
import { withHookContext } from '../tool-turns.js';
|
|
8
|
-
import {
|
|
9
|
-
import { stableStringify } from '../../helpers/stable-stringify.js';
|
|
10
|
-
import { CompletionMachine } from '../../machine/index.js';
|
|
9
|
+
import { HarnessLog } from '../../log.js';
|
|
11
10
|
import { ToolPolicyChanged } from './operations.js';
|
|
11
|
+
import { preflightToolCall, ruleInputs } from './tool-preflight.js';
|
|
12
12
|
import { toolDeniedResult } from '../../helpers/failure-result.js';
|
|
13
13
|
function validationMessage(result) {
|
|
14
14
|
return isRecord(result) && 'error' in result ? result.error : result;
|
|
15
15
|
}
|
|
16
|
-
const RETRYABLE_STATUS = new Set([408, 429]);
|
|
17
|
-
const RETRYABLE_CODE = new Set(['timeout', 'transport', 'busy']);
|
|
18
|
-
export function callSucceeded(result, outcome) {
|
|
19
|
-
if (outcome.kind !== 'success') {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
const exitCode = result === null || result === undefined ? undefined : Reflect.get(Object(result), 'exitCode');
|
|
23
|
-
return typeof exitCode !== 'number' || exitCode === 0;
|
|
24
|
-
}
|
|
25
|
-
export function answerOf(result) {
|
|
26
|
-
if (!isRecord(result) || result.answer !== true || typeof result.content !== 'string') {
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
return result.content.trim() ? result.content : undefined;
|
|
30
|
-
}
|
|
31
|
-
function retryHints(result) {
|
|
32
|
-
if (!isRecord(result) || Array.isArray(result)) {
|
|
33
|
-
return {};
|
|
34
|
-
}
|
|
35
|
-
const hints = {};
|
|
36
|
-
if (typeof result.status === 'number') {
|
|
37
|
-
hints.status = result.status;
|
|
38
|
-
}
|
|
39
|
-
if (typeof result.code === 'string') {
|
|
40
|
-
hints.code = result.code;
|
|
41
|
-
}
|
|
42
|
-
return hints;
|
|
43
|
-
}
|
|
44
|
-
export function settledFailure(result, outcome) {
|
|
45
|
-
if (outcome.kind === 'denied' || callSucceeded(result, outcome)) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
if (outcome.kind === 'error' && outcome.error !== undefined) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
const { code, status } = retryHints(result);
|
|
52
|
-
if (code !== undefined && RETRYABLE_CODE.has(code)) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return status === undefined || (status < 500 && !RETRYABLE_STATUS.has(status));
|
|
56
|
-
}
|
|
57
|
-
export function preflightToolCall(tool, args, ctx, options) {
|
|
58
|
-
const facts = inspectToolPolicy(tool, args, ctx, options);
|
|
59
|
-
if (facts.validationError) {
|
|
60
|
-
return {
|
|
61
|
-
status: 'blocked',
|
|
62
|
-
reason: 'validation',
|
|
63
|
-
result: { error: facts.validationError, guidance: true },
|
|
64
|
-
effect: 'write'
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
if (facts.refusal) {
|
|
68
|
-
return {
|
|
69
|
-
status: 'blocked',
|
|
70
|
-
reason: 'refusal',
|
|
71
|
-
result: { error: facts.refusal, guidance: true },
|
|
72
|
-
effect: facts.effect
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (facts.deniedKey) {
|
|
76
|
-
return {
|
|
77
|
-
status: 'denied',
|
|
78
|
-
result: toolDeniedResult(options.deniedMessage),
|
|
79
|
-
key: facts.deniedKey
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
status: 'ready',
|
|
84
|
-
key: facts.key,
|
|
85
|
-
effect: facts.effect,
|
|
86
|
-
resource: facts.resource,
|
|
87
|
-
autoRun: CompletionMachine.runsUnasked(facts),
|
|
88
|
-
permission: facts.permission
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
export function inspectToolPolicy(tool, args, ctx, options) {
|
|
92
|
-
const validationError = tool.validate?.(detachJson(args), ctx) || null;
|
|
93
|
-
const key = options.key ?? toolCallKey(tool.name, args);
|
|
94
|
-
const refusal = validationError
|
|
95
|
-
? null
|
|
96
|
-
: options.outbound.check(tool.name, args, {
|
|
97
|
-
sources: options.sources ?? [],
|
|
98
|
-
sourceFacts: options.sourceFacts,
|
|
99
|
-
externalWrite: tool.externalWrite === true
|
|
100
|
-
});
|
|
101
|
-
const deniedKey = !validationError && !refusal && options.denied?.has(key) ? key : null;
|
|
102
|
-
const effect = options.effect ?? (validationError ? 'write' : tool.effect(detachJson(args), ctx));
|
|
103
|
-
const resource = validationError || deniedKey ? null : detachJson(tool.resource?.(detachJson(args), ctx) ?? null);
|
|
104
|
-
const facts = {
|
|
105
|
-
key,
|
|
106
|
-
validationError,
|
|
107
|
-
refusal,
|
|
108
|
-
deniedKey,
|
|
109
|
-
effect,
|
|
110
|
-
autoApprove: tool.autoApprove === true,
|
|
111
|
-
skipApprovals: options.skipApprovals === true,
|
|
112
|
-
resource
|
|
113
|
-
};
|
|
114
|
-
if (options.permission) {
|
|
115
|
-
facts.permission = options.permission;
|
|
116
|
-
}
|
|
117
|
-
return facts;
|
|
118
|
-
}
|
|
119
|
-
export function readyPreflightFromFacts(facts) {
|
|
120
|
-
if (facts.validationError || facts.refusal || facts.deniedKey) {
|
|
121
|
-
throw new Error('tool policy facts are not ready for execution');
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
status: 'ready',
|
|
125
|
-
key: facts.key,
|
|
126
|
-
effect: facts.effect,
|
|
127
|
-
resource: facts.resource,
|
|
128
|
-
autoRun: CompletionMachine.runsUnasked(facts),
|
|
129
|
-
permission: facts.permission
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
16
|
function decisionFor(options) {
|
|
133
17
|
if (options.permission !== undefined) {
|
|
134
18
|
return options.approved ? 'allowed' : 'denied';
|
|
@@ -156,7 +40,7 @@ export async function executeCall(tool, args, ctx, { runId, deniedMessage, appro
|
|
|
156
40
|
skipApprovals
|
|
157
41
|
});
|
|
158
42
|
if (preflight.status === 'blocked' && preflight.reason === 'validation') {
|
|
159
|
-
|
|
43
|
+
HarnessLog.info('tool rejected: arguments failed validation', { tool: tool.name });
|
|
160
44
|
return {
|
|
161
45
|
result: preflight.result,
|
|
162
46
|
outcome: { kind: 'guidance', message: String(validationMessage(preflight.result)) },
|
|
@@ -164,7 +48,7 @@ export async function executeCall(tool, args, ctx, { runId, deniedMessage, appro
|
|
|
164
48
|
};
|
|
165
49
|
}
|
|
166
50
|
if (preflight.status === 'blocked') {
|
|
167
|
-
|
|
51
|
+
HarnessLog.info('tool refused: unverifiable value in payload', { tool: tool.name });
|
|
168
52
|
onToolActivity?.({
|
|
169
53
|
type: 'tool-activity',
|
|
170
54
|
name: tool.name,
|
|
@@ -180,7 +64,7 @@ export async function executeCall(tool, args, ctx, { runId, deniedMessage, appro
|
|
|
180
64
|
};
|
|
181
65
|
}
|
|
182
66
|
if (preflight.status === 'denied') {
|
|
183
|
-
|
|
67
|
+
HarnessLog.info('tool denied already, not asking again', { tool: tool.name });
|
|
184
68
|
return {
|
|
185
69
|
result: preflight.result,
|
|
186
70
|
outcome: { kind: 'denied', reason: deniedMessage },
|
|
@@ -188,7 +72,7 @@ export async function executeCall(tool, args, ctx, { runId, deniedMessage, appro
|
|
|
188
72
|
};
|
|
189
73
|
}
|
|
190
74
|
const { key, effect, resource, autoRun, permission } = preflight;
|
|
191
|
-
|
|
75
|
+
HarnessLog.info('tool decision', {
|
|
192
76
|
tool: tool.name,
|
|
193
77
|
effect,
|
|
194
78
|
auto: autoRun,
|
|
@@ -206,7 +90,7 @@ export async function executeCall(tool, args, ctx, { runId, deniedMessage, appro
|
|
|
206
90
|
quote: tool.quote?.(detachJson(args), ctx)
|
|
207
91
|
}), signal);
|
|
208
92
|
}
|
|
209
|
-
|
|
93
|
+
HarnessLog.info(`tool ${approved ? 'approved' : 'denied'}`, { tool: tool.name });
|
|
210
94
|
const decision = decisionFor({
|
|
211
95
|
autoApprove: tool.autoApprove === true,
|
|
212
96
|
effect,
|
|
@@ -228,10 +112,10 @@ export async function executeCall(tool, args, ctx, { runId, deniedMessage, appro
|
|
|
228
112
|
}
|
|
229
113
|
let output;
|
|
230
114
|
let outcome = { kind: 'success' };
|
|
231
|
-
const toolArgs = detachJson(args);
|
|
115
|
+
const toolArgs = mapStrings(detachJson(args), restoreTemplateTokens);
|
|
232
116
|
try {
|
|
233
117
|
output = await tool.execute(toolArgs, { ...ctx, signal, runId, callId, approval: decision });
|
|
234
|
-
|
|
118
|
+
HarnessLog.debug('tool done', { tool: tool.name });
|
|
235
119
|
}
|
|
236
120
|
catch (err) {
|
|
237
121
|
if (err instanceof RecoveryRequired ||
|
|
@@ -243,7 +127,7 @@ export async function executeCall(tool, args, ctx, { runId, deniedMessage, appro
|
|
|
243
127
|
throw new AbortedError();
|
|
244
128
|
}
|
|
245
129
|
const message = errorMessage(err);
|
|
246
|
-
|
|
130
|
+
HarnessLog.warn('tool failed', { tool: tool.name, err: message });
|
|
247
131
|
output = { error: message, code: errorCode(err) };
|
|
248
132
|
outcome = { kind: 'error', message, error: err };
|
|
249
133
|
}
|
|
@@ -270,23 +154,37 @@ export async function reportFailure(pipeline, failure) {
|
|
|
270
154
|
const context = await pipeline.toolFailure(failure);
|
|
271
155
|
return withHookContext(failure.result, context);
|
|
272
156
|
}
|
|
273
|
-
export async function resolveToolCalls(toolCalls, enabled, { runId, agentId, pipeline, skillNames,
|
|
157
|
+
export async function resolveToolCalls(toolCalls, enabled, { runId, agentId, pipeline, skillNames, network, toolContext, signal }) {
|
|
274
158
|
const resolved = [];
|
|
275
159
|
for (const call of toolCalls) {
|
|
276
160
|
if (signal?.aborted) {
|
|
277
161
|
throw new AbortedError();
|
|
278
162
|
}
|
|
279
163
|
const tool = enabled.find((t) => t.name === call.name);
|
|
280
|
-
const rawCall = call.raw === undefined ? {} : { rawCall: clipRawCall(call.raw) };
|
|
164
|
+
const rawCall = call.raw === undefined ? {} : { rawCall: ToolCallMarkup.clipRawCall(call.raw) };
|
|
165
|
+
const object = isRecord(call.arguments) && !Array.isArray(call.arguments);
|
|
281
166
|
if (!tool) {
|
|
282
|
-
|
|
167
|
+
const args = object ? takeToolIntent(call.arguments).args : {};
|
|
168
|
+
resolved.push({ call, args: detachJson(args), ...rawCall });
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (!object) {
|
|
172
|
+
const error = `${tool.name} takes an object of arguments.`;
|
|
173
|
+
const rejection = {
|
|
174
|
+
kind: 'hook-rejection',
|
|
175
|
+
hook: 'arguments',
|
|
176
|
+
phase: 'preToolCall',
|
|
177
|
+
error,
|
|
178
|
+
guidance: true
|
|
179
|
+
};
|
|
180
|
+
resolved.push({ call, tool, args: {}, rejection, ...rawCall });
|
|
283
181
|
continue;
|
|
284
182
|
}
|
|
285
183
|
const taken = INTENT_PARAM in tool.parameters.properties
|
|
286
184
|
? { args: call.arguments }
|
|
287
185
|
: takeToolIntent(call.arguments);
|
|
288
186
|
const intent = taken.intent ? { intent: taken.intent } : {};
|
|
289
|
-
const args = normalizeToolArgs(taken.args, Object.keys(tool.parameters.properties));
|
|
187
|
+
const args = ToolCallMarkup.normalizeToolArgs(taken.args, Object.keys(tool.parameters.properties));
|
|
290
188
|
const ctx = toolContext(tool.name);
|
|
291
189
|
const fold = await pipeline.runPreToolFold({
|
|
292
190
|
runId,
|
|
@@ -299,7 +197,8 @@ export async function resolveToolCalls(toolCalls, enabled, { runId, agentId, pip
|
|
|
299
197
|
skillNames,
|
|
300
198
|
parameters: tool.parameters,
|
|
301
199
|
egress: tool.egress,
|
|
302
|
-
|
|
200
|
+
...ruleInputs(tool, ctx),
|
|
201
|
+
network,
|
|
303
202
|
signal
|
|
304
203
|
});
|
|
305
204
|
const permission = fold.ok && fold.permission ? { permission: fold.permission } : {};
|
|
@@ -309,11 +208,3 @@ export async function resolveToolCalls(toolCalls, enabled, { runId, agentId, pip
|
|
|
309
208
|
}
|
|
310
209
|
return resolved;
|
|
311
210
|
}
|
|
312
|
-
function toolCallKey(name, args) {
|
|
313
|
-
try {
|
|
314
|
-
return `${name}:${stableStringify(args)}`;
|
|
315
|
-
}
|
|
316
|
-
catch {
|
|
317
|
-
return name;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ToolExecutionOutcome } from '../../contract/index.ts';
|
|
2
|
+
export declare function callSucceeded(result: unknown, outcome: ToolExecutionOutcome): boolean;
|
|
3
|
+
export declare function answerOf(result: unknown): string | undefined;
|
|
4
|
+
export declare function settledFailure(result: unknown, outcome: ToolExecutionOutcome): boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { isRecord } from '../../guards.js';
|
|
2
|
+
const RETRYABLE_STATUS = new Set([408, 429]);
|
|
3
|
+
const RETRYABLE_CODE = new Set(['timeout', 'transport', 'busy']);
|
|
4
|
+
export function callSucceeded(result, outcome) {
|
|
5
|
+
if (outcome.kind !== 'success') {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const exitCode = result === null || result === undefined ? undefined : Reflect.get(Object(result), 'exitCode');
|
|
9
|
+
return typeof exitCode !== 'number' || exitCode === 0;
|
|
10
|
+
}
|
|
11
|
+
export function answerOf(result) {
|
|
12
|
+
if (!isRecord(result) || result.answer !== true || typeof result.content !== 'string') {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return result.content.trim() ? result.content : undefined;
|
|
16
|
+
}
|
|
17
|
+
function retryHints(result) {
|
|
18
|
+
if (!isRecord(result) || Array.isArray(result)) {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
const hints = {};
|
|
22
|
+
if (typeof result.status === 'number') {
|
|
23
|
+
hints.status = result.status;
|
|
24
|
+
}
|
|
25
|
+
if (typeof result.code === 'string') {
|
|
26
|
+
hints.code = result.code;
|
|
27
|
+
}
|
|
28
|
+
return hints;
|
|
29
|
+
}
|
|
30
|
+
export function settledFailure(result, outcome) {
|
|
31
|
+
if (outcome.kind === 'denied' || callSucceeded(result, outcome)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (outcome.kind === 'error' && outcome.error !== undefined) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const { code, status } = retryHints(result);
|
|
38
|
+
if (code !== undefined && RETRYABLE_CODE.has(code)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return status === undefined || (status < 500 && !RETRYABLE_STATUS.has(status));
|
|
42
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { OutboundGuard, PreToolCallPayload, ResourceDescriptor, ToolDefinition, ToolEffect, ToolExecuteContext, TrustedSource, TrustedSourceFacts } from '../../contract/index.ts';
|
|
2
|
+
import type { ToolPreflightFacts } from './stages.ts';
|
|
3
|
+
export type ToolPreflight = {
|
|
4
|
+
status: 'blocked';
|
|
5
|
+
reason: 'validation' | 'refusal';
|
|
6
|
+
result: unknown;
|
|
7
|
+
effect: ToolEffect;
|
|
8
|
+
} | {
|
|
9
|
+
status: 'denied';
|
|
10
|
+
result: {
|
|
11
|
+
error: string;
|
|
12
|
+
denied: true;
|
|
13
|
+
};
|
|
14
|
+
key: string;
|
|
15
|
+
} | {
|
|
16
|
+
status: 'ready';
|
|
17
|
+
key: string;
|
|
18
|
+
effect: ToolEffect;
|
|
19
|
+
resource: ResourceDescriptor | null;
|
|
20
|
+
autoRun: boolean;
|
|
21
|
+
permission?: 'allow' | 'ask' | undefined;
|
|
22
|
+
};
|
|
23
|
+
interface ToolPolicyOptions {
|
|
24
|
+
sources?: readonly TrustedSource[];
|
|
25
|
+
sourceFacts?: readonly TrustedSourceFacts[];
|
|
26
|
+
outbound: OutboundGuard;
|
|
27
|
+
denied?: Set<string>;
|
|
28
|
+
effect?: ToolEffect | undefined;
|
|
29
|
+
skipApprovals?: boolean;
|
|
30
|
+
key?: string;
|
|
31
|
+
permission?: 'allow' | 'ask' | undefined;
|
|
32
|
+
}
|
|
33
|
+
interface PreflightOptions extends ToolPolicyOptions {
|
|
34
|
+
deniedMessage: string;
|
|
35
|
+
}
|
|
36
|
+
export declare function preflightToolCall(tool: ToolDefinition, args: Record<string, unknown>, ctx: ToolExecuteContext, options: PreflightOptions): ToolPreflight;
|
|
37
|
+
export declare function inspectToolPolicy(tool: ToolDefinition, args: Record<string, unknown>, ctx: ToolExecuteContext, options: ToolPolicyOptions): ToolPreflightFacts;
|
|
38
|
+
type ReadyToolPreflight = Extract<ToolPreflight, {
|
|
39
|
+
status: 'ready';
|
|
40
|
+
}>;
|
|
41
|
+
export declare function readyPreflightFromFacts(facts: ToolPreflightFacts): ReadyToolPreflight;
|
|
42
|
+
export declare function ruleInputs(tool: ToolDefinition, ctx: ToolExecuteContext | undefined): Pick<PreToolCallPayload, 'command' | 'paths'>;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { detachJson } from '../../helpers/detach-json.js';
|
|
2
|
+
import { stableStringify } from '../../helpers/stable-stringify.js';
|
|
3
|
+
import { CompletionMachine } from '../../machine/index.js';
|
|
4
|
+
import { toolDeniedResult } from '../../helpers/failure-result.js';
|
|
5
|
+
export function preflightToolCall(tool, args, ctx, options) {
|
|
6
|
+
const facts = inspectToolPolicy(tool, args, ctx, options);
|
|
7
|
+
if (facts.validationError) {
|
|
8
|
+
return {
|
|
9
|
+
status: 'blocked',
|
|
10
|
+
reason: 'validation',
|
|
11
|
+
result: { error: facts.validationError, guidance: true },
|
|
12
|
+
effect: 'write'
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
if (facts.refusal) {
|
|
16
|
+
return {
|
|
17
|
+
status: 'blocked',
|
|
18
|
+
reason: 'refusal',
|
|
19
|
+
result: { error: facts.refusal, guidance: true },
|
|
20
|
+
effect: facts.effect
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (facts.deniedKey) {
|
|
24
|
+
return {
|
|
25
|
+
status: 'denied',
|
|
26
|
+
result: toolDeniedResult(options.deniedMessage),
|
|
27
|
+
key: facts.deniedKey
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
status: 'ready',
|
|
32
|
+
key: facts.key,
|
|
33
|
+
effect: facts.effect,
|
|
34
|
+
resource: facts.resource,
|
|
35
|
+
autoRun: CompletionMachine.runsUnasked(facts),
|
|
36
|
+
permission: facts.permission
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function inspectToolPolicy(tool, args, ctx, options) {
|
|
40
|
+
const validationError = tool.validate?.(detachJson(args), ctx) || null;
|
|
41
|
+
const key = options.key ?? toolCallKey(tool.name, args);
|
|
42
|
+
const refusal = validationError
|
|
43
|
+
? null
|
|
44
|
+
: options.outbound.check(tool.name, args, {
|
|
45
|
+
sources: options.sources ?? [],
|
|
46
|
+
sourceFacts: options.sourceFacts,
|
|
47
|
+
externalWrite: tool.externalWrite === true
|
|
48
|
+
});
|
|
49
|
+
const deniedKey = !validationError && !refusal && options.denied?.has(key) ? key : null;
|
|
50
|
+
const effect = options.effect ?? (validationError ? 'write' : tool.effect(detachJson(args), ctx));
|
|
51
|
+
const resource = validationError || deniedKey ? null : detachJson(tool.resource?.(detachJson(args), ctx) ?? null);
|
|
52
|
+
const facts = {
|
|
53
|
+
key,
|
|
54
|
+
validationError,
|
|
55
|
+
refusal,
|
|
56
|
+
deniedKey,
|
|
57
|
+
effect,
|
|
58
|
+
autoApprove: tool.autoApprove === true,
|
|
59
|
+
skipApprovals: options.skipApprovals === true,
|
|
60
|
+
resource
|
|
61
|
+
};
|
|
62
|
+
if (options.permission) {
|
|
63
|
+
facts.permission = options.permission;
|
|
64
|
+
}
|
|
65
|
+
return facts;
|
|
66
|
+
}
|
|
67
|
+
export function readyPreflightFromFacts(facts) {
|
|
68
|
+
if (facts.validationError || facts.refusal || facts.deniedKey) {
|
|
69
|
+
throw new Error('tool policy facts are not ready for execution');
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
status: 'ready',
|
|
73
|
+
key: facts.key,
|
|
74
|
+
effect: facts.effect,
|
|
75
|
+
resource: facts.resource,
|
|
76
|
+
autoRun: CompletionMachine.runsUnasked(facts),
|
|
77
|
+
permission: facts.permission
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function ruleInputs(tool, ctx) {
|
|
81
|
+
const { paths } = tool;
|
|
82
|
+
return { command: tool.command, paths: paths && ((args) => paths(args, ctx)) };
|
|
83
|
+
}
|
|
84
|
+
function toolCallKey(name, args) {
|
|
85
|
+
try {
|
|
86
|
+
return `${name}:${stableStringify(args)}`;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return name;
|
|
90
|
+
}
|
|
91
|
+
}
|