@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,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { createFileGlobTool } from './file-glob.js';
|
|
1
|
+
import { createAskUserTool } from './ask-user.js';
|
|
2
|
+
import { createFileTools } from './files/index.js';
|
|
4
3
|
import { deniedRootsFor } from './fs/scope.js';
|
|
5
|
-
import { createGrepTool } from './grep.js';
|
|
6
4
|
import { createHttpRequestTool } from './http-request.js';
|
|
7
5
|
import { createOfficeTools } from './office.js';
|
|
8
6
|
import { compileOperationTools } from './operations/compile.js';
|
|
9
7
|
import { createPdfTool } from './pdf.js';
|
|
10
|
-
import { createReadFilesTool } from './read-files.js';
|
|
11
8
|
import { createSkillTool } from './skill.js';
|
|
12
9
|
import { stageInputs } from './attachments/staging.js';
|
|
13
10
|
import { ensureBundledSkillsDir } from './skills/bundled-dir.js';
|
|
@@ -18,7 +15,7 @@ export class Tools {
|
|
|
18
15
|
static bundledSkillsDir = ensureBundledSkillsDir;
|
|
19
16
|
static stageInputs = stageInputs;
|
|
20
17
|
static operations = compileOperationTools;
|
|
21
|
-
static product({ sdkHome, skillsDir, skillCatalog, credentialStore }) {
|
|
18
|
+
static product({ sdkHome, skillsDir, skillCatalog, credentialStore, files = true, ask = false }) {
|
|
22
19
|
const deniedRoots = deniedRootsFor(sdkHome);
|
|
23
20
|
const credentialed = skillCatalog
|
|
24
21
|
? { credentialStore, credentialAllowList: credentialAllowListFor(skillCatalog) }
|
|
@@ -27,20 +24,19 @@ export class Tools {
|
|
|
27
24
|
const tools = [
|
|
28
25
|
httpRequestTool,
|
|
29
26
|
createWebFetchTool(),
|
|
30
|
-
|
|
31
|
-
createFileGlobTool({ deniedRoots }),
|
|
32
|
-
createGrepTool({ deniedRoots }),
|
|
33
|
-
createCreateDocumentsTool({ deniedRoots }),
|
|
34
|
-
createEditDocumentsTool({ deniedRoots }),
|
|
27
|
+
...(files ? createFileTools({ deniedRoots }) : []),
|
|
35
28
|
createPdfTool(),
|
|
36
29
|
...createOfficeTools()
|
|
37
30
|
];
|
|
38
31
|
if (skillCatalog) {
|
|
39
32
|
tools.push(...compileOperationTools(skillCatalog, { httpRequestTool }));
|
|
40
33
|
}
|
|
41
|
-
if (skillsDir) {
|
|
34
|
+
if (skillsDir || skillCatalog?.length) {
|
|
42
35
|
tools.push(createSkillTool({ skillsDir }));
|
|
43
36
|
}
|
|
37
|
+
if (ask) {
|
|
38
|
+
tools.push(createAskUserTool());
|
|
39
|
+
}
|
|
44
40
|
return tools;
|
|
45
41
|
}
|
|
46
42
|
}
|
|
@@ -4,6 +4,7 @@ export interface OpSpec {
|
|
|
4
4
|
readonly inches?: boolean;
|
|
5
5
|
readonly query?: boolean;
|
|
6
6
|
readonly aliases?: Readonly<Record<string, string>>;
|
|
7
|
+
readonly skipsLooks?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export declare const PPTX_OPS: Readonly<Record<string, OpSpec>>;
|
|
9
10
|
export declare const DOCX_OPS: Readonly<Record<string, OpSpec>>;
|
|
@@ -7,7 +7,11 @@ export const PPTX_OPS = {
|
|
|
7
7
|
setText: { slots: [['slide', 'shape'], 'text'] },
|
|
8
8
|
setCellText: { slots: [['slide', 'shape', 'row', 'column'], 'text'] },
|
|
9
9
|
setStyle: { slots: [['slide', 'shape'], 'style', ['paragraph']] },
|
|
10
|
-
addSlide: {
|
|
10
|
+
addSlide: {
|
|
11
|
+
slots: [['like', 'layout', 'at', 'title', 'body', 'image']],
|
|
12
|
+
aliases: { subtitle: 'body' },
|
|
13
|
+
skipsLooks: true
|
|
14
|
+
},
|
|
11
15
|
addPicture: { slots: ['slide', 'image', [...BOX, 'name', 'description']], inches: true },
|
|
12
16
|
addTextBox: { slots: ['slide', [...BOX, 'text', 'style', 'fill', 'name']], inches: true },
|
|
13
17
|
addTable: { slots: ['slide', [...BOX, 'rows', 'header', 'name']], inches: true },
|
|
@@ -4,9 +4,10 @@ type Deck = ReturnType<typeof pptx.open>;
|
|
|
4
4
|
type Workbook = ReturnType<typeof xlsx.open>;
|
|
5
5
|
type FormatName = 'pptx' | 'docx' | 'xlsx';
|
|
6
6
|
type Args = Record<string, unknown>;
|
|
7
|
+
export declare function bodyLines(op: Args): Args;
|
|
7
8
|
export declare function shapeFor(deck: Deck, op: Args): Args;
|
|
8
9
|
export declare function sheetFor(book: Workbook, op: Args, created: boolean): Args;
|
|
9
|
-
export declare function normalizeArgs(
|
|
10
|
+
export declare function normalizeArgs(raw: Args): Args;
|
|
10
11
|
export declare function revisedName(format: FormatName, fileName: string): string;
|
|
11
12
|
export declare function createOfficeTools(): ToolDefinition[];
|
|
12
13
|
export {};
|
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { HarnessError } from '../errors.js';
|
|
2
2
|
import { errorMessage, isRecord } from '../guards.js';
|
|
3
|
-
import { docx, pptx, units, xlsx } from '../office/engine/index.js';
|
|
4
|
-
import { stageInputs } from './attachments/staging.js';
|
|
3
|
+
import { DocsError, docx, pptx, units, xlsx } from '../office/engine/index.js';
|
|
4
|
+
import { stageInputs, uploadsAvailable } from './attachments/staging.js';
|
|
5
5
|
import { checkOutputBytes, RUN_OUTPUT_BUDGET_BYTES } from './attachments/output-policy.js';
|
|
6
|
+
import { attachmentOf, deliveredFile, recordDelivered, sha256 } from './attachments/delivered.js';
|
|
6
7
|
import { DOCX_OPS, opArguments, opKeys, PPTX_OPS, withAliases, XLSX_OPS } from './office/ops.js';
|
|
7
8
|
const READ_CELL_LIMIT = 10_000;
|
|
8
|
-
const attachedThisTurn = new WeakMap();
|
|
9
9
|
const FIRST_SHEET = /^sheet ?1$/i;
|
|
10
|
+
const NEW_DECK_HINT = '; a new deck has only the slides its addSlide ops make, slides count from 0, and an op on a slide goes after the addSlide that makes it';
|
|
10
11
|
const SHAPE_ROLES = new Set(['title', 'subtitle', 'body']);
|
|
11
12
|
const HOISTED = ['attachmentId', 'output'];
|
|
13
|
+
const BLOCK_POSITIONED = new Set(['insertParagraphs', 'addTable', 'addImage', 'addChart']);
|
|
14
|
+
const FILE_NAME = /\.\w+$/;
|
|
12
15
|
const WHERE_IDS_ARE = 'copy the id from the [Attached file "…" — attachmentId: …] line or an earlier tool result';
|
|
13
16
|
function isObject(value) {
|
|
14
17
|
return isRecord(value) && !Array.isArray(value);
|
|
15
18
|
}
|
|
19
|
+
const LOOK_KEY = /colou?r|background|^bg|font|style|theme|^level$/i;
|
|
20
|
+
function isLook(key, value) {
|
|
21
|
+
return value === null || LOOK_KEY.test(key);
|
|
22
|
+
}
|
|
23
|
+
const TYPED_BULLET = /^\s*[•◦▪●]\s+/;
|
|
24
|
+
export function bodyLines(op) {
|
|
25
|
+
const items = typeof op.body === 'string' ? [op.body] : op.body;
|
|
26
|
+
if (op.op !== 'addSlide' || !Array.isArray(items)) {
|
|
27
|
+
return op;
|
|
28
|
+
}
|
|
29
|
+
const body = items.flatMap((item) => typeof item === 'string'
|
|
30
|
+
? item.split('\n').map((line) => line.replace(TYPED_BULLET, ''))
|
|
31
|
+
: [item]);
|
|
32
|
+
return { ...op, body };
|
|
33
|
+
}
|
|
16
34
|
export function shapeFor(deck, op) {
|
|
17
35
|
const { shape, slide } = op;
|
|
18
36
|
if (typeof shape !== 'string' || SHAPE_ROLES.has(shape) || typeof slide !== 'number') {
|
|
@@ -25,6 +43,15 @@ export function shapeFor(deck, op) {
|
|
|
25
43
|
const found = deck.read()[slide]?.shapes.find((entry) => entry.name.toLowerCase() === wanted);
|
|
26
44
|
return found && found.id !== null ? { ...op, shape: found.id } : op;
|
|
27
45
|
}
|
|
46
|
+
function positionFor(doc, op, created) {
|
|
47
|
+
if (!created || !BLOCK_POSITIONED.has(String(op.op)) || typeof op.at !== 'number') {
|
|
48
|
+
return op;
|
|
49
|
+
}
|
|
50
|
+
return op.at > doc.blockCount ? { ...op, at: doc.blockCount } : op;
|
|
51
|
+
}
|
|
52
|
+
function newDeckHint(err, created) {
|
|
53
|
+
return created && err instanceof DocsError && err.code === 'SLIDE_NOT_FOUND' ? NEW_DECK_HINT : '';
|
|
54
|
+
}
|
|
28
55
|
export function sheetFor(book, op, created) {
|
|
29
56
|
if (typeof op.sheet !== 'string')
|
|
30
57
|
return op;
|
|
@@ -64,27 +91,34 @@ function readWorkbook(book) {
|
|
|
64
91
|
const PPTX_FORMAT = {
|
|
65
92
|
name: 'pptx',
|
|
66
93
|
noun: 'PowerPoint deck',
|
|
94
|
+
stem: 'presentation',
|
|
67
95
|
ops: PPTX_OPS,
|
|
68
96
|
createKeys: ['size', 'title', 'fonts', 'colors'],
|
|
97
|
+
looks: ['fonts', 'colors'],
|
|
69
98
|
open: (bytes) => pptx.open(bytes),
|
|
70
99
|
create: (options) => pptx.create(options),
|
|
71
100
|
read: (deck) => deck.read(),
|
|
72
101
|
count: (deck) => ({ slides: deck.slideCount }),
|
|
73
|
-
prepare: (deck, op) => shapeFor(deck, op)
|
|
102
|
+
prepare: (deck, op) => shapeFor(deck, bodyLines(op)),
|
|
103
|
+
retry: withoutLayout,
|
|
104
|
+
hint: newDeckHint
|
|
74
105
|
};
|
|
75
106
|
const DOCX_FORMAT = {
|
|
76
107
|
name: 'docx',
|
|
77
108
|
noun: 'Word document',
|
|
109
|
+
stem: 'document',
|
|
78
110
|
ops: DOCX_OPS,
|
|
79
111
|
createKeys: ['title', 'page', 'size', 'fonts'],
|
|
80
112
|
open: (bytes) => docx.open(bytes),
|
|
81
113
|
create: (options) => docx.create(options),
|
|
82
114
|
read: (doc) => doc.read(),
|
|
83
|
-
count: (doc) => ({ blocks: doc.blockCount })
|
|
115
|
+
count: (doc) => ({ blocks: doc.blockCount }),
|
|
116
|
+
prepare: (doc, op, created) => positionFor(doc, op, created)
|
|
84
117
|
};
|
|
85
118
|
const XLSX_FORMAT = {
|
|
86
119
|
name: 'xlsx',
|
|
87
120
|
noun: 'Excel workbook',
|
|
121
|
+
stem: 'workbook',
|
|
88
122
|
ops: XLSX_OPS,
|
|
89
123
|
createKeys: ['sheets', 'title'],
|
|
90
124
|
open: (bytes) => xlsx.open(bytes),
|
|
@@ -96,13 +130,24 @@ const XLSX_FORMAT = {
|
|
|
96
130
|
? 'the workbook has macros, which cannot be saved as .xlsx — add a removeMacros op'
|
|
97
131
|
: null
|
|
98
132
|
};
|
|
99
|
-
export function normalizeArgs(
|
|
100
|
-
|
|
133
|
+
export function normalizeArgs(raw) {
|
|
134
|
+
const blankId = raw.attachmentId === '' || raw.attachmentId === null;
|
|
135
|
+
const args = blankId && isObject(raw.create) ? withoutKeys(raw, ['attachmentId']) : raw;
|
|
136
|
+
if (!Array.isArray(args.ops)) {
|
|
101
137
|
return args;
|
|
138
|
+
}
|
|
102
139
|
const lifted = { ...args };
|
|
103
140
|
const ops = [];
|
|
104
|
-
|
|
105
|
-
|
|
141
|
+
const entries = args.ops.flat();
|
|
142
|
+
for (const [i, entry] of entries.entries()) {
|
|
143
|
+
if (entries[i - 1] === 'output' && entry === ':') {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (entries[i - 2] === 'output' && entries[i - 1] === ':') {
|
|
147
|
+
lifted.output ??= typeof entry === 'string' && FILE_NAME.test(entry) ? entry : undefined;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const op = typeof entry === 'string' ? { op: entry } : opNamedByKey(entry);
|
|
106
151
|
if (!isObject(op)) {
|
|
107
152
|
ops.push(op);
|
|
108
153
|
continue;
|
|
@@ -119,11 +164,27 @@ export function normalizeArgs(args) {
|
|
|
119
164
|
lifted.create = options;
|
|
120
165
|
continue;
|
|
121
166
|
}
|
|
167
|
+
if (rest.op === 'output') {
|
|
168
|
+
const { op: _output, ...named } = rest;
|
|
169
|
+
lifted.output ??= Object.values(named).find((value) => typeof value === 'string' && FILE_NAME.test(value));
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
122
172
|
ops.push(rest);
|
|
123
173
|
}
|
|
124
|
-
lifted.ops = ops;
|
|
174
|
+
lifted.ops = lifted.attachmentId === undefined ? ops.map(insertedWhereAsked) : ops;
|
|
125
175
|
return lifted;
|
|
126
176
|
}
|
|
177
|
+
function opNamedByKey(entry) {
|
|
178
|
+
if (!isObject(entry) || 'op' in entry)
|
|
179
|
+
return entry;
|
|
180
|
+
const [only, ...more] = Object.entries(entry);
|
|
181
|
+
return only && !more.length && isObject(only[1]) ? { ...only[1], op: only[0] } : entry;
|
|
182
|
+
}
|
|
183
|
+
function insertedWhereAsked(op) {
|
|
184
|
+
return isObject(op) && op.op === 'appendParagraphs' && op.at !== undefined
|
|
185
|
+
? { ...op, op: 'insertParagraphs' }
|
|
186
|
+
: op;
|
|
187
|
+
}
|
|
127
188
|
function parseOp(format, op, i) {
|
|
128
189
|
if (!isObject(op) || typeof op.op !== 'string') {
|
|
129
190
|
return `ops[${i}] must be { op, ...args }`;
|
|
@@ -133,29 +194,42 @@ function parseOp(format, op, i) {
|
|
|
133
194
|
return `ops[${i}]: unknown op "${op.op}"; ops are ${Object.keys(format.ops).join(', ')}`;
|
|
134
195
|
}
|
|
135
196
|
const keys = opKeys(spec);
|
|
136
|
-
const
|
|
197
|
+
const extra = Object.keys(op).filter((key) => key !== 'op' && !keys.includes(key));
|
|
198
|
+
const skippable = spec.skipsLooks ? extra.filter((key) => isLook(key, op[key])) : [];
|
|
199
|
+
const unknown = extra.filter((key) => !skippable.includes(key));
|
|
137
200
|
if (!unknown.length) {
|
|
138
|
-
|
|
201
|
+
const kept = Object.fromEntries(Object.entries(op).filter(([key]) => !skippable.includes(key)));
|
|
202
|
+
const shadowed = Object.entries(spec.aliases ?? {})
|
|
203
|
+
.filter(([alias, key]) => kept[alias] !== undefined && kept[key] !== undefined)
|
|
204
|
+
.map(([alias]) => alias);
|
|
205
|
+
const skipped = [...skippable, ...shadowed].map((key) => `ops[${i}].${key}`);
|
|
206
|
+
return { op: { name: op.op, spec, args: withAliases(spec, kept) }, skipped };
|
|
139
207
|
}
|
|
140
208
|
if (op.op === 'sheets' && 'name' in op && format.ops.addSheet) {
|
|
141
209
|
return `ops[${i}] sheets lists the sheets and takes no arguments; to add a sheet use { op: "addSheet", name }`;
|
|
142
210
|
}
|
|
143
211
|
const takes = keys.length ? `it takes ${keys.join(', ')}` : 'it takes no arguments';
|
|
144
|
-
|
|
212
|
+
const nested = unknown.filter((key) => format.ops[key]);
|
|
213
|
+
const apart = nested.length
|
|
214
|
+
? `; ${nested.map((name) => `{ "op": "${name}", ... }`).join(' and ')} goes in ops as its own entry, next to this one, not inside it`
|
|
215
|
+
: '';
|
|
216
|
+
return `ops[${i}] ${op.op} does not take ${unknown.join(', ')}; ${takes}${apart}`;
|
|
145
217
|
}
|
|
146
218
|
function parseOps(format, ops) {
|
|
147
219
|
if (!Array.isArray(ops)) {
|
|
148
220
|
return 'ops must be an array of { op, ...args }';
|
|
149
221
|
}
|
|
150
222
|
const parsed = [];
|
|
223
|
+
const skipped = [];
|
|
151
224
|
for (const [i, op] of ops.entries()) {
|
|
152
225
|
const result = parseOp(format, op, i);
|
|
153
226
|
if (typeof result === 'string') {
|
|
154
227
|
return result;
|
|
155
228
|
}
|
|
156
|
-
parsed.push(result);
|
|
229
|
+
parsed.push(result.op);
|
|
230
|
+
skipped.push(...result.skipped);
|
|
157
231
|
}
|
|
158
|
-
return parsed;
|
|
232
|
+
return { ops: parsed, skipped };
|
|
159
233
|
}
|
|
160
234
|
function argumentError(format, args) {
|
|
161
235
|
const { attachmentId, create, output } = args;
|
|
@@ -183,24 +257,25 @@ function parseRequest(format, raw) {
|
|
|
183
257
|
if (error) {
|
|
184
258
|
return error;
|
|
185
259
|
}
|
|
186
|
-
const
|
|
187
|
-
if (typeof
|
|
188
|
-
return
|
|
260
|
+
const parsed = parseOps(format, args.ops ?? []);
|
|
261
|
+
if (typeof parsed === 'string') {
|
|
262
|
+
return parsed;
|
|
189
263
|
}
|
|
190
264
|
const attachmentId = typeof args.attachmentId === 'string' ? args.attachmentId : undefined;
|
|
191
|
-
if (attachmentId === undefined && !ops.length) {
|
|
265
|
+
if (attachmentId === undefined && !parsed.ops.length && !isObject(args.create)) {
|
|
192
266
|
return `nothing to read: pass the attachmentId of a ${format.noun} (${WHERE_IDS_ARE}), or ops to build one`;
|
|
193
267
|
}
|
|
194
268
|
return {
|
|
195
269
|
attachmentId,
|
|
196
270
|
create: isObject(args.create) ? args.create : undefined,
|
|
197
|
-
ops,
|
|
198
|
-
output: typeof args.output === 'string' ? args.output : undefined
|
|
271
|
+
ops: parsed.ops,
|
|
272
|
+
output: typeof args.output === 'string' ? args.output : undefined,
|
|
273
|
+
skipped: parsed.skipped
|
|
199
274
|
};
|
|
200
275
|
}
|
|
201
276
|
async function sourceDocument(format, request, ctx) {
|
|
202
277
|
if (request.attachmentId === undefined) {
|
|
203
|
-
return
|
|
278
|
+
return createDocument(format, request.create ?? {});
|
|
204
279
|
}
|
|
205
280
|
const found = await ctx.fetchAttachment?.({
|
|
206
281
|
attachmentId: request.attachmentId,
|
|
@@ -211,7 +286,43 @@ async function sourceDocument(format, request, ctx) {
|
|
|
211
286
|
error: `attachment ${request.attachmentId} not found in this chat; ${WHERE_IDS_ARE}, not a file name`
|
|
212
287
|
};
|
|
213
288
|
}
|
|
214
|
-
return { document: format.open(found.bytes), fileName: found.fileName };
|
|
289
|
+
return { document: format.open(found.bytes), fileName: found.fileName, skipped: [] };
|
|
290
|
+
}
|
|
291
|
+
function createDocument(format, options) {
|
|
292
|
+
try {
|
|
293
|
+
return { document: format.create(options), fileName: null, skipped: [] };
|
|
294
|
+
}
|
|
295
|
+
catch (err) {
|
|
296
|
+
const looks = (format.looks ?? []).filter((key) => options[key] !== undefined);
|
|
297
|
+
if (!invalidOptions(err) || !looks.length) {
|
|
298
|
+
throw err;
|
|
299
|
+
}
|
|
300
|
+
const plain = withoutKeys(options, looks);
|
|
301
|
+
const refused = looks.filter((key) => !creates(format, { ...plain, [key]: options[key] }));
|
|
302
|
+
return {
|
|
303
|
+
document: format.create(withoutKeys(options, refused)),
|
|
304
|
+
fileName: null,
|
|
305
|
+
skipped: refused.map((key) => `create.${key}`)
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function creates(format, options) {
|
|
310
|
+
try {
|
|
311
|
+
format.create(options);
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
catch (err) {
|
|
315
|
+
if (!invalidOptions(err)) {
|
|
316
|
+
throw err;
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function invalidOptions(err) {
|
|
322
|
+
return err instanceof DocsError && err.code === 'INVALID_OPTIONS';
|
|
323
|
+
}
|
|
324
|
+
function withoutKeys(args, keys) {
|
|
325
|
+
return Object.fromEntries(Object.entries(args).filter(([key]) => !keys.includes(key)));
|
|
215
326
|
}
|
|
216
327
|
export function revisedName(format, fileName) {
|
|
217
328
|
const dot = fileName.lastIndexOf('.');
|
|
@@ -226,12 +337,24 @@ export function revisedName(format, fileName) {
|
|
|
226
337
|
}
|
|
227
338
|
return `${revised[1]}_revised-${Number(revised[2] ?? 1) + 1}.${format}`;
|
|
228
339
|
}
|
|
229
|
-
function
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
340
|
+
function newFileName(format, title) {
|
|
341
|
+
const stem = typeof title === 'string'
|
|
342
|
+
? title
|
|
343
|
+
.toLowerCase()
|
|
344
|
+
.replace(/[^a-z0-9]+/g, '_')
|
|
345
|
+
.replace(/^_+|_+$/g, '')
|
|
346
|
+
.slice(0, 48)
|
|
347
|
+
: '';
|
|
348
|
+
return `${stem || format.stem}.${format.name}`;
|
|
349
|
+
}
|
|
350
|
+
function outputFor(format, { output, create }, input) {
|
|
351
|
+
if (!input) {
|
|
352
|
+
return output ?? newFileName(format, create?.title);
|
|
353
|
+
}
|
|
354
|
+
if (output && output.toLowerCase() !== input.toLowerCase()) {
|
|
233
355
|
return output;
|
|
234
|
-
|
|
356
|
+
}
|
|
357
|
+
return revisedName(format.name, input);
|
|
235
358
|
}
|
|
236
359
|
async function imageId(ctx, id) {
|
|
237
360
|
const found = await ctx.fetchAttachment?.({ attachmentId: id, meta: true, signal: ctx.signal });
|
|
@@ -246,14 +369,55 @@ async function imageInput(op, i, ctx) {
|
|
|
246
369
|
if (!isObject(image)) {
|
|
247
370
|
return { error: `ops[${i}]: image must be { attachmentId } or {}` };
|
|
248
371
|
}
|
|
249
|
-
const id = image.attachmentId;
|
|
372
|
+
const id = image.attachmentId ?? undefined;
|
|
250
373
|
if (id !== undefined && (typeof id !== 'string' || !id)) {
|
|
251
374
|
return { error: `ops[${i}]: image.attachmentId must be a non-empty string` };
|
|
252
375
|
}
|
|
253
376
|
return { attachmentId: id ? await imageId(ctx, id) : undefined, path: `image-${i}.png` };
|
|
254
377
|
}
|
|
378
|
+
function takesImage(op) {
|
|
379
|
+
return op.spec.slots.includes('image') || op.args.image !== undefined;
|
|
380
|
+
}
|
|
381
|
+
async function withoutMissingUploads(request, ctx) {
|
|
382
|
+
if (!ctx.fetchAttachment || !request.ops.some((op) => idless(op) && optionalImage(op))) {
|
|
383
|
+
return request;
|
|
384
|
+
}
|
|
385
|
+
const available = await uploadsAvailable(ctx.fetchAttachment, {
|
|
386
|
+
turnImages: ctx.turnImages,
|
|
387
|
+
signal: ctx.signal
|
|
388
|
+
});
|
|
389
|
+
if (available === null) {
|
|
390
|
+
return request;
|
|
391
|
+
}
|
|
392
|
+
const uploading = await Promise.all(request.ops.map((op) => takesUpload(op, ctx)));
|
|
393
|
+
let uploads = 0;
|
|
394
|
+
const skipped = [];
|
|
395
|
+
const ops = request.ops.map((op, i) => {
|
|
396
|
+
if (!uploading[i] || uploads++ < available || !optionalImage(op)) {
|
|
397
|
+
return op;
|
|
398
|
+
}
|
|
399
|
+
skipped.push(`ops[${i}].image`);
|
|
400
|
+
return { ...op, args: withoutKeys(op.args, ['image']) };
|
|
401
|
+
});
|
|
402
|
+
return { ...request, ops, skipped: [...request.skipped, ...skipped] };
|
|
403
|
+
}
|
|
404
|
+
function idless(op) {
|
|
405
|
+
const { image } = op.args;
|
|
406
|
+
const id = isObject(image) ? image.attachmentId : image;
|
|
407
|
+
return takesImage(op) && (id === undefined || id === null);
|
|
408
|
+
}
|
|
409
|
+
async function takesUpload(op, ctx) {
|
|
410
|
+
const id = isObject(op.args.image) ? op.args.image.attachmentId : undefined;
|
|
411
|
+
if (typeof id !== 'string' || !id) {
|
|
412
|
+
return idless(op);
|
|
413
|
+
}
|
|
414
|
+
return (await imageId(ctx, id)) === undefined;
|
|
415
|
+
}
|
|
416
|
+
function optionalImage({ spec }) {
|
|
417
|
+
return spec.slots.some((slot) => typeof slot !== 'string' && slot.includes('image'));
|
|
418
|
+
}
|
|
255
419
|
async function stagedImages(request, ctx) {
|
|
256
|
-
const wanted = request.ops.flatMap((op, i) => (
|
|
420
|
+
const wanted = request.ops.flatMap((op, i) => (takesImage(op) ? [i] : []));
|
|
257
421
|
const images = new Map();
|
|
258
422
|
if (!wanted.length) {
|
|
259
423
|
return images;
|
|
@@ -286,9 +450,6 @@ async function stagedImages(request, ctx) {
|
|
|
286
450
|
return images;
|
|
287
451
|
}
|
|
288
452
|
function saveError({ format, document, output }, ctx) {
|
|
289
|
-
if (!output) {
|
|
290
|
-
return `the ops changed the ${format.noun}; name the file in output`;
|
|
291
|
-
}
|
|
292
453
|
if (!output.toLowerCase().endsWith(`.${format.name}`)) {
|
|
293
454
|
return `output must end in .${format.name}, got "${output}"`;
|
|
294
455
|
}
|
|
@@ -300,26 +461,26 @@ function saveError({ format, document, output }, ctx) {
|
|
|
300
461
|
}
|
|
301
462
|
async function attachOutput(job, ctx) {
|
|
302
463
|
const refused = saveError(job, ctx);
|
|
303
|
-
if (refused || !
|
|
464
|
+
if (refused || !ctx.attach) {
|
|
304
465
|
return { error: refused ?? 'nothing to save' };
|
|
305
466
|
}
|
|
306
467
|
const { output, document } = job;
|
|
307
|
-
const
|
|
308
|
-
const earlier =
|
|
468
|
+
const budget = ctx.runBudget;
|
|
469
|
+
const earlier = deliveredFile(budget, output);
|
|
309
470
|
const bytes = document.save();
|
|
310
|
-
|
|
311
|
-
|
|
471
|
+
const hash = sha256(bytes);
|
|
472
|
+
if (earlier?.sha256 === hash) {
|
|
473
|
+
return { attachment: attachmentOf(earlier), repeated: true };
|
|
312
474
|
}
|
|
313
475
|
if (earlier) {
|
|
314
476
|
return {
|
|
315
|
-
error: `${earlier.
|
|
477
|
+
error: `${earlier.fileName} is already attached with different content; save this version under a new name in output`
|
|
316
478
|
};
|
|
317
479
|
}
|
|
318
480
|
const verdict = checkOutputBytes(output, bytes, 0);
|
|
319
481
|
if ('error' in verdict) {
|
|
320
482
|
return verdict;
|
|
321
483
|
}
|
|
322
|
-
const budget = ctx.runBudget;
|
|
323
484
|
if (budget && budget.outputBytesUsed + bytes.byteLength > RUN_OUTPUT_BUDGET_BYTES) {
|
|
324
485
|
return { error: 'run output budget exceeded' };
|
|
325
486
|
}
|
|
@@ -337,19 +498,19 @@ async function attachOutput(job, ctx) {
|
|
|
337
498
|
fileName: record.fileName,
|
|
338
499
|
byteLength: record.byteLength
|
|
339
500
|
};
|
|
340
|
-
|
|
341
|
-
attachedThisTurn.set(ctx.attach, delivered);
|
|
501
|
+
recordDelivered(budget, { name: output.toLowerCase(), sha256: hash, ...attachment });
|
|
342
502
|
return { attachment, repeated: false };
|
|
343
503
|
}
|
|
344
504
|
function runOp(document, op, input) {
|
|
345
505
|
const method = Reflect.get(document, op.name);
|
|
346
506
|
if (typeof method !== 'function') {
|
|
347
|
-
throw new
|
|
507
|
+
throw new HarnessError('OFFICE_OP_UNAVAILABLE', [op.name]);
|
|
348
508
|
}
|
|
349
509
|
return Reflect.apply(method, document, opArguments(op.spec, input, units.inches));
|
|
350
510
|
}
|
|
351
511
|
function runOps({ format, document, request, images }) {
|
|
352
512
|
const results = [];
|
|
513
|
+
const skipped = [];
|
|
353
514
|
const created = request.attachmentId === undefined;
|
|
354
515
|
for (const [i, op] of request.ops.entries()) {
|
|
355
516
|
const placed = format.prepare?.(document, op.args, created) ?? op.args;
|
|
@@ -358,10 +519,35 @@ function runOps({ format, document, request, images }) {
|
|
|
358
519
|
results.push(runOp(document, op, input));
|
|
359
520
|
}
|
|
360
521
|
catch (err) {
|
|
361
|
-
|
|
522
|
+
const retry = format.retry?.(err, op, input);
|
|
523
|
+
const again = retry ? rerun(document, op, retry.input) : RETRY_FAILED;
|
|
524
|
+
if (retry && again !== RETRY_FAILED) {
|
|
525
|
+
results.push(again);
|
|
526
|
+
skipped.push(`ops[${i}].${retry.skipped}`);
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
const hint = format.hint?.(err, created) ?? '';
|
|
530
|
+
return { error: `ops[${i}] ${op.name}: ${errorMessage(err)}${hint}` };
|
|
362
531
|
}
|
|
363
532
|
}
|
|
364
|
-
return results;
|
|
533
|
+
return { results, skipped };
|
|
534
|
+
}
|
|
535
|
+
const RETRY_FAILED = Symbol('retry failed');
|
|
536
|
+
function rerun(document, op, input) {
|
|
537
|
+
try {
|
|
538
|
+
return runOp(document, op, input);
|
|
539
|
+
}
|
|
540
|
+
catch {
|
|
541
|
+
return RETRY_FAILED;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
function withoutLayout(err, op, input) {
|
|
545
|
+
const shapeMissing = err instanceof DocsError && err.code === 'SHAPE_NOT_FOUND';
|
|
546
|
+
if (op.name !== 'addSlide' || input.layout === undefined || !shapeMissing) {
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
const { layout: _layout, ...rest } = input;
|
|
550
|
+
return { input: rest, skipped: 'layout' };
|
|
365
551
|
}
|
|
366
552
|
function countLine(counts) {
|
|
367
553
|
return Object.entries(counts)
|
|
@@ -399,6 +585,7 @@ function parameters(format) {
|
|
|
399
585
|
items: {
|
|
400
586
|
type: 'object',
|
|
401
587
|
properties: { op: { type: 'string', enum: Object.keys(format.ops) } },
|
|
588
|
+
additionalProperties: true,
|
|
402
589
|
required: ['op']
|
|
403
590
|
}
|
|
404
591
|
},
|
|
@@ -410,10 +597,11 @@ function parameters(format) {
|
|
|
410
597
|
};
|
|
411
598
|
}
|
|
412
599
|
async function execute(format, args, ctx) {
|
|
413
|
-
const
|
|
414
|
-
if (typeof
|
|
415
|
-
return { error:
|
|
600
|
+
const parsed = parseRequest(format, args);
|
|
601
|
+
if (typeof parsed === 'string') {
|
|
602
|
+
return { error: parsed };
|
|
416
603
|
}
|
|
604
|
+
const request = await withoutMissingUploads(parsed, ctx);
|
|
417
605
|
if (request.attachmentId !== undefined && !ctx.fetchAttachment) {
|
|
418
606
|
return { error: 'this device cannot read chat attachments' };
|
|
419
607
|
}
|
|
@@ -432,36 +620,65 @@ async function execute(format, args, ctx) {
|
|
|
432
620
|
return source;
|
|
433
621
|
}
|
|
434
622
|
const { document, fileName } = source;
|
|
623
|
+
if (!request.ops.length && request.attachmentId === undefined) {
|
|
624
|
+
return {
|
|
625
|
+
next: `No ${format.noun} exists yet, so there is nothing to open: make it in one call with create, ops and output.`
|
|
626
|
+
};
|
|
627
|
+
}
|
|
435
628
|
if (!request.ops.length) {
|
|
436
629
|
return { document: format.read(document) };
|
|
437
630
|
}
|
|
438
|
-
const
|
|
439
|
-
if ('error' in
|
|
440
|
-
return
|
|
631
|
+
const ran = runOps({ format, document, request, images });
|
|
632
|
+
if ('error' in ran) {
|
|
633
|
+
return ran;
|
|
441
634
|
}
|
|
442
|
-
|
|
635
|
+
const { results } = ran;
|
|
636
|
+
const onlyQueries = request.ops.every(({ spec }) => spec.query);
|
|
637
|
+
if (onlyQueries || (!document.changed && request.attachmentId !== undefined)) {
|
|
443
638
|
return { results };
|
|
444
639
|
}
|
|
445
|
-
const output = outputFor(format
|
|
640
|
+
const output = outputFor(format, request, fileName);
|
|
446
641
|
const saved = await attachOutput({ format, document, output }, ctx);
|
|
447
642
|
if ('error' in saved) {
|
|
448
643
|
return saved;
|
|
449
644
|
}
|
|
450
645
|
const { attachment, repeated } = saved;
|
|
646
|
+
const skipped = [...source.skipped, ...request.skipped, ...ran.skipped];
|
|
451
647
|
const counts = format.count(document);
|
|
452
|
-
const renamed = output !== request.output
|
|
648
|
+
const renamed = fileName !== null && output !== request.output
|
|
453
649
|
? `Saved as ${output}, so the attached ${fileName} keeps its own name. `
|
|
454
650
|
: '';
|
|
651
|
+
const unplaced = images.size ? null : await leftOutImage(request, ctx);
|
|
455
652
|
return {
|
|
456
653
|
results,
|
|
457
654
|
attachments: [attachment],
|
|
458
655
|
...counts,
|
|
656
|
+
skipped: skipped.length ? skipped : undefined,
|
|
459
657
|
reply: `${attachment.fileName} — ${countLine(counts)}`,
|
|
460
658
|
next: renamed +
|
|
461
659
|
`Done: ${attachment.fileName} ${repeated ? 'was already' : 'is'} attached to the chat and shown to the user. ` +
|
|
462
|
-
|
|
660
|
+
afterSave(format, attachment.attachmentId, unplaced)
|
|
463
661
|
};
|
|
464
662
|
}
|
|
663
|
+
async function leftOutImage(request, ctx) {
|
|
664
|
+
if (ctx.turnImages?.length) {
|
|
665
|
+
return 'The image the user attached to their message';
|
|
666
|
+
}
|
|
667
|
+
if (request.attachmentId !== undefined || !ctx.fetchAttachment) {
|
|
668
|
+
return null;
|
|
669
|
+
}
|
|
670
|
+
const available = await uploadsAvailable(ctx.fetchAttachment, { signal: ctx.signal });
|
|
671
|
+
return available ? 'An image in this chat' : null;
|
|
672
|
+
}
|
|
673
|
+
function afterSave(format, attachmentId, unplaced) {
|
|
674
|
+
const reply = 'Your answer is the reply value alone, word for word.';
|
|
675
|
+
if (!unplaced) {
|
|
676
|
+
return `Do not call ${format.name} again for it. ${reply}`;
|
|
677
|
+
}
|
|
678
|
+
return (`${unplaced} is not in it. If they asked for that image in the ${format.noun}, ` +
|
|
679
|
+
`call ${format.name} once more with attachmentId "${attachmentId}" and one op that adds it with "image": {}. ` +
|
|
680
|
+
`Otherwise: ${reply}`);
|
|
681
|
+
}
|
|
465
682
|
function createOfficeTool(format) {
|
|
466
683
|
return {
|
|
467
684
|
name: format.name,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ToolExecuteContext } from '../../contract/index.ts';
|
|
1
2
|
export interface OperationRequest {
|
|
2
3
|
body?: Record<string, unknown>;
|
|
3
4
|
params?: Record<string, unknown>;
|
|
@@ -10,9 +11,9 @@ export type BuilderOutcome = {
|
|
|
10
11
|
error: string;
|
|
11
12
|
};
|
|
12
13
|
export interface OperationBuilder {
|
|
13
|
-
build: (args: Record<string, unknown
|
|
14
|
+
build: (args: Record<string, unknown>, context?: ToolExecuteContext) => BuilderOutcome;
|
|
14
15
|
}
|
|
15
|
-
export declare const BUILDER_POLICY_VERSION =
|
|
16
|
-
export declare const BUILDER_NAMES: readonly ['gmail-send', 'gmail-draft', 'gmail-get', 'calendar-meet-event', 'calendar-add-meet', 'docs-create', 'docs-append-text', 'sheets-create', 'sheets-write-values', 'sheets-append-values', 'drive-create-folder', 'drive-trash', 'notion-create-page', 'notion-insert-content'];
|
|
16
|
+
export declare const BUILDER_POLICY_VERSION = 3;
|
|
17
|
+
export declare const BUILDER_NAMES: readonly ['gmail-send', 'gmail-draft', 'gmail-get', 'calendar-list-events', 'calendar-list-calendars', 'calendar-meet-event', 'calendar-add-meet', 'docs-create', 'docs-append-text', 'sheets-create', 'sheets-write-values', 'sheets-append-values', 'drive-create-folder', 'drive-trash', 'notion-create-page', 'notion-insert-content'];
|
|
17
18
|
export type BuilderName = (typeof BUILDER_NAMES)[number];
|
|
18
19
|
export declare const BUILDERS: Record<BuilderName, OperationBuilder>;
|