@qvac/harness 1.0.0-rc.2 → 1.0.0-rc.20
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 +3050 -1485
- package/README.md +110 -46
- package/dist-lib/index.d.ts +60 -15
- package/dist-lib/index.js +228 -35
- 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 +29 -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/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/executing.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +129 -12
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +10 -4
- 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 +10 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +137 -50
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +69 -17
- 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 +36 -22
- 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 +95 -35
- 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 +55 -16
- 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 +25 -3
- package/dist-lib/lib/capabilities/completion-engine/loop.js +13 -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 +393 -116
- 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 +3 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +5 -4
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +32 -12
- 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 +96 -87
- 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.d.ts +20 -9
- package/dist-lib/lib/capabilities/tool-turns.js +77 -49
- 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.d.ts +19 -10
- package/dist-lib/lib/connect.js +239 -32
- package/dist-lib/lib/context-window.d.ts +2 -0
- package/dist-lib/lib/context-window.js +9 -3
- package/dist-lib/lib/contract/agent.d.ts +13 -3
- package/dist-lib/lib/contract/completion.d.ts +77 -31
- package/dist-lib/lib/contract/drive.d.ts +4 -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 +13 -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 +46 -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.d.ts +44 -0
- package/dist-lib/lib/helpers/goal-check.js +407 -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/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/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 +11 -6
- package/dist-lib/lib/machine/completion/actions/completion.js +251 -35
- package/dist-lib/lib/machine/completion/actions/prepare.js +1 -1
- package/dist-lib/lib/machine/completion/actions/tools.js +122 -6
- 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 +16 -7
- package/dist-lib/lib/machine/completion/implementations.js +59 -15
- package/dist-lib/lib/machine/completion/machine.d.ts +36 -7
- package/dist-lib/lib/machine/completion/machine.js +58 -9
- package/dist-lib/lib/machine/completion/rules.d.ts +23 -2
- package/dist-lib/lib/machine/completion/rules.js +91 -6
- package/dist-lib/lib/machine/completion/types.d.ts +77 -1
- package/dist-lib/lib/machine/index.d.ts +48 -9
- package/dist-lib/lib/machine/index.js +11 -1
- 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 +15 -5
- package/dist-lib/lib/residency/completion-runtime.js +47 -36
- package/dist-lib/lib/residency/index.d.ts +56 -4
- package/dist-lib/lib/residency/index.js +442 -40
- 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/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.js +242 -50
- 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 +3 -1
- package/dist-lib/lib/skills-host/index.js +27 -14
- 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 +10 -14
- 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 +45 -3
- 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 +5 -1
- package/dist-lib/lib/tools/fs/scope.js +5 -2
- package/dist-lib/lib/tools/fs/search.d.ts +41 -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 +16 -3
- 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 +15 -1
- 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 +59 -0
- package/dist-lib/lib/tools/pdf.js +56 -12
- package/dist-lib/lib/tools/skill.js +10 -7
- package/dist-lib/lib/tools/skills/bundled-dir.d.ts +5 -1
- package/dist-lib/lib/tools/skills/bundled-dir.js +27 -24
- package/dist-lib/lib/tools/skills/catalog.d.ts +3 -1
- package/dist-lib/lib/tools/skills/catalog.js +7 -3
- 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/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/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.d.ts +13 -0
- package/dist-lib/lib/wire.js +78 -6
- 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/index.d.ts +12 -0
- package/dist-lib/plugins/ocr/index.js +20 -0
- package/dist-lib/plugins/ocr/ocr-runtime.d.ts +23 -0
- package/dist-lib/plugins/ocr/ocr-runtime.js +82 -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 +91 -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 +461 -209
- package/dist-lib/spec/hyperschema/index.js +461 -209
- package/dist-lib/spec/hyperschema/schema.json +285 -85
- package/dist-lib/spec/hyperschema/types.d.ts +41 -5
- package/package.json +264 -64
- 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
package/dist-lib/lib/serve.js
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { AbortController } from 'bare-abort-controller';
|
|
3
3
|
import fs from 'fs';
|
|
4
|
+
import { HarnessError } from './errors.js';
|
|
5
|
+
import { AbortedError } from './helpers/engine-error.js';
|
|
4
6
|
import { settleOnClose } from './rpc-session.js';
|
|
5
7
|
import { pipeline, Readable } from 'streamx';
|
|
6
8
|
import { bindApi } from '../spec/bind.js';
|
|
7
9
|
import HRPC from '../spec/hrpc/index.js';
|
|
8
10
|
import { encode } from '../spec/hrpc/messages.js';
|
|
9
|
-
import { checkGoal } from './capabilities/tool-turns.js';
|
|
11
|
+
import { checkGoal, checkMaxToolRounds } from './capabilities/tool-turns.js';
|
|
10
12
|
import { isCapability } from './capabilities/invoke.js';
|
|
11
13
|
import { CUSTOM_TASK_TYPES } from './models/model-catalog.js';
|
|
12
14
|
import { unsupportedKvCacheDeletion } from './capabilities/kv-cache.js';
|
|
13
15
|
import { RunLog } from './run-log/index.js';
|
|
14
16
|
import { errorMessage, isRecord } from './guards.js';
|
|
15
|
-
import {
|
|
17
|
+
import { HarnessLog } from './log.js';
|
|
16
18
|
import { pushQueue } from './queue.js';
|
|
19
|
+
import { MediaPort } from './media-port.js';
|
|
20
|
+
import { mediaRequestFrom, mediaResultWire } from './media-wire.js';
|
|
21
|
+
import { RoundPort } from './round-port.js';
|
|
17
22
|
import { TextCoalescer } from './helpers/text-coalescer.js';
|
|
18
23
|
import { prepareOpenclCache } from './models/opencl-cache.js';
|
|
19
24
|
import { stageFile, sweepStaging } from './staging.js';
|
|
20
25
|
import { sweepSpill } from './spill.js';
|
|
21
26
|
import { readSetup, toWireSetup } from './tools/skills/manifest-parse.js';
|
|
22
|
-
import { fromKnowledgeUpsertWire, packVectors, toDownloadWire, toKnowledgeUpsertResultWire, toWire } from './wire.js';
|
|
27
|
+
import { fromKnowledgeUpsertWire, roundFailureWire, roundRequestFrom, packVectors, toDownloadWire, toKnowledgeUpsertResultWire, toWire } from './wire.js';
|
|
23
28
|
const MODEL_STATUSES = new Set([
|
|
24
29
|
'loading',
|
|
25
30
|
'downloading',
|
|
@@ -27,7 +32,8 @@ const MODEL_STATUSES = new Set([
|
|
|
27
32
|
'ready',
|
|
28
33
|
'error',
|
|
29
34
|
'unloading',
|
|
30
|
-
'unloaded'
|
|
35
|
+
'unloaded',
|
|
36
|
+
'held'
|
|
31
37
|
]);
|
|
32
38
|
const DOWNLOAD_PROGRESS_INTERVAL_MS = 500;
|
|
33
39
|
const WIRE_HIGH_WATER_MARK = 64;
|
|
@@ -89,14 +95,17 @@ function optionalNumber(value) {
|
|
|
89
95
|
return value === undefined || typeof value === 'number';
|
|
90
96
|
}
|
|
91
97
|
function goalFrom(value) {
|
|
92
|
-
const { objective, rounds, ms, tokens } = value;
|
|
98
|
+
const { objective, rounds, ms, tokens, checks, checksProve } = value;
|
|
93
99
|
if (typeof objective !== 'string' ||
|
|
94
100
|
!optionalNumber(rounds) ||
|
|
95
101
|
!optionalNumber(ms) ||
|
|
96
|
-
!optionalNumber(tokens)
|
|
102
|
+
!optionalNumber(tokens) ||
|
|
103
|
+
(checks !== undefined &&
|
|
104
|
+
(!Array.isArray(checks) || !checks.every((check) => typeof check === 'string'))) ||
|
|
105
|
+
(checksProve !== undefined && typeof checksProve !== 'boolean')) {
|
|
97
106
|
throw new TypeError('Invalid goal');
|
|
98
107
|
}
|
|
99
|
-
return { objective, rounds, ms, tokens };
|
|
108
|
+
return { objective, rounds, ms, tokens, checks, checksProve };
|
|
100
109
|
}
|
|
101
110
|
function startPayloadFrom(value) {
|
|
102
111
|
if (!isRecord(value)) {
|
|
@@ -147,21 +156,41 @@ function startPayloadFrom(value) {
|
|
|
147
156
|
});
|
|
148
157
|
}
|
|
149
158
|
if (isRecord(value.knowledge)) {
|
|
150
|
-
|
|
151
|
-
if (!Array.isArray(scopes) || !scopes.every((scope) => typeof scope === 'string')) {
|
|
152
|
-
throw new TypeError('Invalid knowledge grant');
|
|
153
|
-
}
|
|
154
|
-
payload.knowledge = { scopes };
|
|
159
|
+
payload.knowledge = knowledgeGrant(value.knowledge);
|
|
155
160
|
}
|
|
156
161
|
if (value.planMode === true) {
|
|
157
162
|
payload.planMode = true;
|
|
158
163
|
}
|
|
164
|
+
if (value.deferTools === true) {
|
|
165
|
+
payload.deferTools = true;
|
|
166
|
+
}
|
|
159
167
|
if (typeof value.parentRunId === 'string') {
|
|
160
168
|
payload.parentRunId = value.parentRunId;
|
|
161
169
|
}
|
|
162
170
|
if (isRecord(value.goal)) {
|
|
163
171
|
payload.goal = goalFrom(value.goal);
|
|
164
172
|
}
|
|
173
|
+
if (typeof value.typedText === 'string') {
|
|
174
|
+
payload.typedText = value.typedText;
|
|
175
|
+
}
|
|
176
|
+
if (typeof value.maxToolRounds === 'number') {
|
|
177
|
+
payload.maxToolRounds = checkMaxToolRounds(value.maxToolRounds);
|
|
178
|
+
}
|
|
179
|
+
if (value.replaysContext === true) {
|
|
180
|
+
payload.replaysContext = true;
|
|
181
|
+
}
|
|
182
|
+
if (value.modelRound === true) {
|
|
183
|
+
payload.modelRound = true;
|
|
184
|
+
}
|
|
185
|
+
if (value.roundCut === true) {
|
|
186
|
+
payload.roundCut = true;
|
|
187
|
+
}
|
|
188
|
+
if (value.showImage === true) {
|
|
189
|
+
payload.showImage = true;
|
|
190
|
+
}
|
|
191
|
+
if (value.mediaRound === true) {
|
|
192
|
+
payload.mediaRound = true;
|
|
193
|
+
}
|
|
165
194
|
if (value.runLog === null) {
|
|
166
195
|
payload.runLog = null;
|
|
167
196
|
}
|
|
@@ -229,6 +258,10 @@ function normalizeAgentKnobs(agent) {
|
|
|
229
258
|
if (normalized.model === null || normalized.model === undefined) {
|
|
230
259
|
delete normalized.model;
|
|
231
260
|
}
|
|
261
|
+
if (normalized.policy === null || normalized.policy === undefined) {
|
|
262
|
+
delete normalized.policy;
|
|
263
|
+
}
|
|
264
|
+
Reflect.deleteProperty(normalized, 'sandboxMode');
|
|
232
265
|
return normalized;
|
|
233
266
|
}
|
|
234
267
|
function tick() {
|
|
@@ -252,6 +285,20 @@ export function serveHarness(stream, harness) {
|
|
|
252
285
|
await harness.setModelIdleTimeout?.(ms);
|
|
253
286
|
return { ok: true };
|
|
254
287
|
},
|
|
288
|
+
setModelMemoryCap: async ({ percent }) => {
|
|
289
|
+
await harness.setModelMemoryCap?.(percent);
|
|
290
|
+
return { ok: true };
|
|
291
|
+
},
|
|
292
|
+
memoryUsage: async () => {
|
|
293
|
+
if (!harness.memoryUsage) {
|
|
294
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['memoryUsage']);
|
|
295
|
+
}
|
|
296
|
+
return harness.memoryUsage();
|
|
297
|
+
},
|
|
298
|
+
setDownloadsAllowed: async ({ allowed }) => {
|
|
299
|
+
await harness.setDownloadsAllowed?.({ allowed: allowed === true });
|
|
300
|
+
return { ok: true };
|
|
301
|
+
},
|
|
255
302
|
listManagedSkills: async () => ({
|
|
256
303
|
skills: (await harness.listManagedSkills?.()) ?? []
|
|
257
304
|
}),
|
|
@@ -296,7 +343,7 @@ export function serveHarness(stream, harness) {
|
|
|
296
343
|
},
|
|
297
344
|
previewModelSource: async ({ src, mmprojSrc }) => {
|
|
298
345
|
if (!harness.previewModelSource) {
|
|
299
|
-
throw new
|
|
346
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['previewModelSource']);
|
|
300
347
|
}
|
|
301
348
|
return harness.previewModelSource({ src: src ?? '', mmprojSrc: mmprojSrc ?? undefined });
|
|
302
349
|
},
|
|
@@ -314,21 +361,29 @@ export function serveHarness(stream, harness) {
|
|
|
314
361
|
skills: []
|
|
315
362
|
},
|
|
316
363
|
embed: async ({ model, texts }) => {
|
|
317
|
-
if (!harness.embed)
|
|
318
|
-
throw new
|
|
364
|
+
if (!harness.embed) {
|
|
365
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['embed']);
|
|
366
|
+
}
|
|
319
367
|
return packVectors(await harness.embed({ model, texts: texts ?? [] }));
|
|
320
368
|
},
|
|
321
369
|
transcribe: async ({ model, audio }) => {
|
|
322
370
|
if (!harness.transcribe) {
|
|
323
|
-
throw new
|
|
371
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['transcribe']);
|
|
324
372
|
}
|
|
325
373
|
return {
|
|
326
374
|
text: await harness.transcribe({ model: model ?? '', audio: audio ?? b4a.alloc(0) })
|
|
327
375
|
};
|
|
328
376
|
},
|
|
377
|
+
ocrRead: async ({ width, height, data }) => {
|
|
378
|
+
if (!harness.ocrRead) {
|
|
379
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['ocr']);
|
|
380
|
+
}
|
|
381
|
+
const image = { width: width ?? 0, height: height ?? 0, data: data ?? b4a.alloc(0) };
|
|
382
|
+
return { text: await harness.ocrRead({ image }) };
|
|
383
|
+
},
|
|
329
384
|
detectLanguage: async ({ text, topK }) => {
|
|
330
385
|
if (!harness.detectLanguage) {
|
|
331
|
-
throw new
|
|
386
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['detectLanguage']);
|
|
332
387
|
}
|
|
333
388
|
const languages = await harness.detectLanguage({
|
|
334
389
|
text: text ?? '',
|
|
@@ -337,8 +392,9 @@ export function serveHarness(stream, harness) {
|
|
|
337
392
|
return { languages };
|
|
338
393
|
},
|
|
339
394
|
speak: async ({ model, text }) => {
|
|
340
|
-
if (!harness.speak)
|
|
341
|
-
throw new
|
|
395
|
+
if (!harness.speak) {
|
|
396
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['speak']);
|
|
397
|
+
}
|
|
342
398
|
return harness.speak({ model: model ?? '', text: text ?? '' });
|
|
343
399
|
},
|
|
344
400
|
speakStream: speakStream(harness),
|
|
@@ -382,26 +438,26 @@ export function serveHarness(stream, harness) {
|
|
|
382
438
|
}),
|
|
383
439
|
capability: async () => {
|
|
384
440
|
if (!harness.capability) {
|
|
385
|
-
throw new
|
|
441
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['capability']);
|
|
386
442
|
}
|
|
387
443
|
return harness.capability();
|
|
388
444
|
},
|
|
389
445
|
warmModel: async ({ model, agent }) => {
|
|
390
446
|
if (!harness.warmModel) {
|
|
391
|
-
throw new
|
|
447
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['warmModel']);
|
|
392
448
|
}
|
|
393
449
|
await harness.warmModel({ model, agent: agent ?? {} });
|
|
394
450
|
return { ok: true };
|
|
395
451
|
},
|
|
396
452
|
loadModel: async ({ model, agent }) => {
|
|
397
453
|
if (!harness.loadModel) {
|
|
398
|
-
throw new
|
|
454
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['loadModel']);
|
|
399
455
|
}
|
|
400
456
|
return harness.loadModel({ model, agent: agent ?? {} });
|
|
401
457
|
},
|
|
402
458
|
unloadModel: async ({ model }) => {
|
|
403
459
|
if (!harness.unloadModel) {
|
|
404
|
-
throw new
|
|
460
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['unloadModel']);
|
|
405
461
|
}
|
|
406
462
|
return harness.unloadModel({ model });
|
|
407
463
|
},
|
|
@@ -417,11 +473,12 @@ export function serveHarness(stream, harness) {
|
|
|
417
473
|
}
|
|
418
474
|
return harness.knowledgeRemove(artifactId);
|
|
419
475
|
},
|
|
420
|
-
knowledgeSearch: async ({ text, scopes, k }) => {
|
|
476
|
+
knowledgeSearch: async ({ text, scopes, k, focus }) => {
|
|
421
477
|
if (!harness.knowledgeSearch) {
|
|
422
478
|
throw unsupportedKnowledge();
|
|
423
479
|
}
|
|
424
|
-
|
|
480
|
+
const query = { text, scopes, k: k || undefined, focus: focus?.length ? focus : undefined };
|
|
481
|
+
return { hits: await harness.knowledgeSearch(query) };
|
|
425
482
|
},
|
|
426
483
|
knowledgeStatus: async () => {
|
|
427
484
|
if (!harness.knowledgeStatus) {
|
|
@@ -447,6 +504,7 @@ function toWireSkill(skill) {
|
|
|
447
504
|
}));
|
|
448
505
|
return {
|
|
449
506
|
name: skill.name,
|
|
507
|
+
displayName: skill.displayName || undefined,
|
|
450
508
|
description: skill.description,
|
|
451
509
|
tools: skill.tools,
|
|
452
510
|
credentials: skill.credentials,
|
|
@@ -468,7 +526,7 @@ function unsupportedKnowledge() {
|
|
|
468
526
|
return new Error('harness does not support knowledge');
|
|
469
527
|
}
|
|
470
528
|
function unsupportedEmbeddingDeviceControl() {
|
|
471
|
-
return new
|
|
529
|
+
return new HarnessError('CAPABILITY_UNSUPPORTED', ['embedding device control']);
|
|
472
530
|
}
|
|
473
531
|
function modelEvents(harness) {
|
|
474
532
|
let last = '';
|
|
@@ -511,7 +569,8 @@ function modelEvents(harness) {
|
|
|
511
569
|
total,
|
|
512
570
|
message: state.message,
|
|
513
571
|
catalogChanged,
|
|
514
|
-
loaded
|
|
572
|
+
loaded,
|
|
573
|
+
addon: state.addon
|
|
515
574
|
});
|
|
516
575
|
const now = Date.now();
|
|
517
576
|
if (frame.status === 'downloading') {
|
|
@@ -549,7 +608,7 @@ function encodableModelEvent(frame) {
|
|
|
549
608
|
function speakStream(harness) {
|
|
550
609
|
return async function* (duplex) {
|
|
551
610
|
if (!harness.speakStream) {
|
|
552
|
-
throw new
|
|
611
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['speakStream']);
|
|
553
612
|
}
|
|
554
613
|
const text = pushQueue();
|
|
555
614
|
const end = () => text.end();
|
|
@@ -577,11 +636,12 @@ function runFrame(harness, frame, context) {
|
|
|
577
636
|
if (frame.type !== 'invoke') {
|
|
578
637
|
return harness.completion(context);
|
|
579
638
|
}
|
|
580
|
-
if (!harness.invoke)
|
|
581
|
-
throw new
|
|
639
|
+
if (!harness.invoke) {
|
|
640
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['invoke']);
|
|
641
|
+
}
|
|
582
642
|
const capability = frame.capability ?? '';
|
|
583
643
|
if (!isCapability(capability)) {
|
|
584
|
-
throw new
|
|
644
|
+
throw new HarnessError('UNKNOWN_CAPABILITY', [capability]);
|
|
585
645
|
}
|
|
586
646
|
return harness.invoke({
|
|
587
647
|
capability,
|
|
@@ -595,16 +655,21 @@ function runFrame(harness, frame, context) {
|
|
|
595
655
|
});
|
|
596
656
|
}
|
|
597
657
|
function completion(harness) {
|
|
658
|
+
let writeTurn = Promise.resolve();
|
|
659
|
+
const waitForWriteTurn = () => (writeTurn = writeTurn.then(tick));
|
|
598
660
|
return async function* (duplex) {
|
|
599
661
|
const events = pushQueue({ highWaterMark: WIRE_HIGH_WATER_MARK });
|
|
600
662
|
const pending = new Map();
|
|
601
663
|
const pendingAttach = new Map();
|
|
602
664
|
const pendingFetch = new Map();
|
|
665
|
+
const pendingShow = new Map();
|
|
603
666
|
const pendingQuestion = new Map();
|
|
604
667
|
const pendingDrive = new Map();
|
|
605
668
|
const pendingRunLog = new Map();
|
|
606
669
|
const input = pushQueue();
|
|
607
670
|
const controller = new AbortController();
|
|
671
|
+
const rounds = new RoundPort((event) => events.push(event));
|
|
672
|
+
const media = new MediaPort((event) => events.push(event));
|
|
608
673
|
let calls = 0;
|
|
609
674
|
let started = false;
|
|
610
675
|
let clientGone = false;
|
|
@@ -617,13 +682,17 @@ function completion(harness) {
|
|
|
617
682
|
pending.clear();
|
|
618
683
|
for (const { reject, staged } of pendingAttach.values()) {
|
|
619
684
|
void fs.promises.unlink(staged).catch(noop);
|
|
620
|
-
reject(new
|
|
685
|
+
reject(new HarnessError('CLIENT_GONE'));
|
|
621
686
|
}
|
|
622
687
|
pendingAttach.clear();
|
|
623
688
|
for (const { reject } of pendingFetch.values()) {
|
|
624
|
-
reject(new
|
|
689
|
+
reject(new HarnessError('CLIENT_GONE'));
|
|
625
690
|
}
|
|
626
691
|
pendingFetch.clear();
|
|
692
|
+
for (const { reject } of pendingShow.values()) {
|
|
693
|
+
reject(new HarnessError('CLIENT_GONE'));
|
|
694
|
+
}
|
|
695
|
+
pendingShow.clear();
|
|
627
696
|
for (const { resolve } of pendingQuestion.values()) {
|
|
628
697
|
resolve(null);
|
|
629
698
|
}
|
|
@@ -632,13 +701,15 @@ function completion(harness) {
|
|
|
632
701
|
if (path) {
|
|
633
702
|
void fs.promises.unlink(path).catch(noop);
|
|
634
703
|
}
|
|
635
|
-
reject(new
|
|
704
|
+
reject(new HarnessError('CLIENT_GONE'));
|
|
636
705
|
}
|
|
637
706
|
pendingDrive.clear();
|
|
638
707
|
for (const { reject } of pendingRunLog.values()) {
|
|
639
|
-
reject(new
|
|
708
|
+
reject(new HarnessError('CLIENT_GONE'));
|
|
640
709
|
}
|
|
641
710
|
pendingRunLog.clear();
|
|
711
|
+
rounds.close();
|
|
712
|
+
media.close();
|
|
642
713
|
input.end();
|
|
643
714
|
events.end();
|
|
644
715
|
};
|
|
@@ -646,6 +717,22 @@ function completion(harness) {
|
|
|
646
717
|
duplex.on('end', gone);
|
|
647
718
|
duplex.readStream?.on('close', gone);
|
|
648
719
|
duplex.on('data', (frame) => {
|
|
720
|
+
if (rounds.frame(frame) || media.frame(frame)) {
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
if (frame.type === 'media-round-ask' && !started) {
|
|
724
|
+
started = true;
|
|
725
|
+
void serveMedia(harness, frame.payload, { signal: controller.signal, events });
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
if (frame.type === 'model-round-ask' && !started) {
|
|
729
|
+
started = true;
|
|
730
|
+
void serveRound(harness, frame.payload, {
|
|
731
|
+
signal: controller.signal,
|
|
732
|
+
events
|
|
733
|
+
});
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
649
736
|
if (frame.type === 'decision') {
|
|
650
737
|
if (typeof frame.callId !== 'string') {
|
|
651
738
|
return;
|
|
@@ -676,6 +763,13 @@ function completion(harness) {
|
|
|
676
763
|
if (typeof frame.callId !== 'string') {
|
|
677
764
|
return;
|
|
678
765
|
}
|
|
766
|
+
const shown = pendingShow.get(frame.callId);
|
|
767
|
+
if (shown) {
|
|
768
|
+
pendingShow.delete(frame.callId);
|
|
769
|
+
return frame.message
|
|
770
|
+
? shown.reject(new Error(frame.message))
|
|
771
|
+
: shown.resolve(frame.path || null);
|
|
772
|
+
}
|
|
679
773
|
const waiter = pendingFetch.get(frame.callId);
|
|
680
774
|
pendingFetch.delete(frame.callId);
|
|
681
775
|
if (!waiter) {
|
|
@@ -716,7 +810,7 @@ function completion(harness) {
|
|
|
716
810
|
return;
|
|
717
811
|
}
|
|
718
812
|
if (frame.message) {
|
|
719
|
-
|
|
813
|
+
HarnessLog.warn('question failed', { callId: frame.callId, message: frame.message });
|
|
720
814
|
}
|
|
721
815
|
waiter.resolve(frame.answer || null);
|
|
722
816
|
return;
|
|
@@ -802,7 +896,7 @@ function completion(harness) {
|
|
|
802
896
|
const onStep = runLog
|
|
803
897
|
? (step) => {
|
|
804
898
|
if (clientGone) {
|
|
805
|
-
return Promise.reject(new
|
|
899
|
+
return Promise.reject(new HarnessError('CLIENT_GONE'));
|
|
806
900
|
}
|
|
807
901
|
return new Promise((resolve, reject) => {
|
|
808
902
|
const callId = String(calls++);
|
|
@@ -822,16 +916,23 @@ function completion(harness) {
|
|
|
822
916
|
model: frame.model ?? '',
|
|
823
917
|
agent,
|
|
824
918
|
cacheKey: frame.cacheKey ?? (explicitEmptyIdentity.has('cacheKey') ? '' : undefined),
|
|
919
|
+
session: frame.session ?? undefined,
|
|
825
920
|
thinkingDefault: frame.thinkingDefault ?? (explicitEmptyIdentity.has('thinkingDefault') ? '' : undefined),
|
|
826
921
|
generationParams: frame.generationParams ?? undefined,
|
|
827
922
|
responseFormat: frame.responseFormat ?? undefined,
|
|
828
923
|
captureInferenceCalls: frame.captureInferenceCalls ?? undefined,
|
|
829
|
-
maxToolRounds:
|
|
924
|
+
maxToolRounds: startPayload.maxToolRounds,
|
|
925
|
+
typedText: startPayload.typedText,
|
|
926
|
+
replaysContext: startPayload.replaysContext,
|
|
927
|
+
modelRound: startPayload.modelRound ? rounds.port : undefined,
|
|
928
|
+
mediaRound: startPayload.mediaRound ? media.port : undefined,
|
|
929
|
+
roundCut: startPayload.roundCut ? rounds.roundCut : undefined,
|
|
830
930
|
knowledge: startPayload.knowledge,
|
|
831
931
|
planMode: startPayload.planMode,
|
|
932
|
+
deferTools: startPayload.deferTools,
|
|
832
933
|
parentRunId: startPayload.parentRunId,
|
|
833
934
|
goal: startPayload.goal,
|
|
834
|
-
messages: (frame.messages ?? []).map(({ role, content, attachments, toolCalls, toolCallId, name, id }) => ({
|
|
935
|
+
messages: (frame.messages ?? []).map(({ role, content, attachments, toolCalls, toolCallId, name, id, context: added, sentAt }) => ({
|
|
835
936
|
role,
|
|
836
937
|
content,
|
|
837
938
|
attachments: attachments?.length
|
|
@@ -840,19 +941,22 @@ function completion(harness) {
|
|
|
840
941
|
toolCalls: toolCalls ?? undefined,
|
|
841
942
|
toolCallId: toolCallId ?? undefined,
|
|
842
943
|
name: name ?? undefined,
|
|
843
|
-
id: id || undefined
|
|
944
|
+
id: id || undefined,
|
|
945
|
+
context: added ?? undefined,
|
|
946
|
+
sentAt: sentAt || undefined
|
|
844
947
|
})),
|
|
845
948
|
toolConfigs: frame.toolConfigs ?? undefined,
|
|
846
949
|
grantedDirs: frame.grantedDirs ?? undefined,
|
|
847
950
|
grantedDrives: frame.grantedDrives?.length
|
|
848
951
|
? frame.grantedDrives.map((drive) => ({
|
|
849
952
|
key: drive.key,
|
|
850
|
-
writable: drive.writable === true
|
|
953
|
+
writable: drive.writable === true,
|
|
954
|
+
search: drive.search === true
|
|
851
955
|
}))
|
|
852
956
|
: undefined,
|
|
853
957
|
driveOp: frame.grantedDrives?.length
|
|
854
958
|
? (request) => controller.signal.aborted
|
|
855
|
-
? Promise.reject(new
|
|
959
|
+
? Promise.reject(new HarnessError('CLIENT_GONE'))
|
|
856
960
|
: new Promise((resolve, reject) => {
|
|
857
961
|
const callId = String(calls++);
|
|
858
962
|
pendingDrive.set(callId, {
|
|
@@ -889,7 +993,7 @@ function completion(harness) {
|
|
|
889
993
|
const staged = await stageFile('attach', input.bytes);
|
|
890
994
|
if (controller.signal.aborted) {
|
|
891
995
|
void fs.promises.unlink(staged).catch(noop);
|
|
892
|
-
throw new
|
|
996
|
+
throw new HarnessError('CLIENT_GONE');
|
|
893
997
|
}
|
|
894
998
|
return new Promise((resolve, reject) => {
|
|
895
999
|
const callId = String(calls++);
|
|
@@ -905,7 +1009,7 @@ function completion(harness) {
|
|
|
905
1009
|
});
|
|
906
1010
|
},
|
|
907
1011
|
fetchAttachment: ({ attachmentId, meta } = {}) => controller.signal.aborted
|
|
908
|
-
? Promise.reject(new
|
|
1012
|
+
? Promise.reject(new HarnessError('CLIENT_GONE'))
|
|
909
1013
|
: new Promise((resolve, reject) => {
|
|
910
1014
|
const callId = String(calls++);
|
|
911
1015
|
pendingFetch.set(callId, { resolve, reject });
|
|
@@ -916,6 +1020,20 @@ function completion(harness) {
|
|
|
916
1020
|
meta: meta === true ? true : undefined
|
|
917
1021
|
});
|
|
918
1022
|
}),
|
|
1023
|
+
showImage: startPayload.showImage
|
|
1024
|
+
? ({ attachmentId }) => controller.signal.aborted
|
|
1025
|
+
? Promise.reject(new HarnessError('CLIENT_GONE'))
|
|
1026
|
+
: new Promise((resolve, reject) => {
|
|
1027
|
+
const callId = String(calls++);
|
|
1028
|
+
pendingShow.set(callId, { resolve, reject });
|
|
1029
|
+
events.push({
|
|
1030
|
+
type: 'fetch-ask',
|
|
1031
|
+
callId,
|
|
1032
|
+
attachmentId,
|
|
1033
|
+
payload: { show: true }
|
|
1034
|
+
});
|
|
1035
|
+
})
|
|
1036
|
+
: undefined,
|
|
919
1037
|
progress: (update) => {
|
|
920
1038
|
events.push(update
|
|
921
1039
|
? { type: 'progress', percentage: update.percentage }
|
|
@@ -930,7 +1048,8 @@ function completion(harness) {
|
|
|
930
1048
|
type: 'question-ask',
|
|
931
1049
|
callId,
|
|
932
1050
|
question: question.question,
|
|
933
|
-
options: question.options
|
|
1051
|
+
options: question.options,
|
|
1052
|
+
payload: question.form
|
|
934
1053
|
});
|
|
935
1054
|
})
|
|
936
1055
|
};
|
|
@@ -1004,7 +1123,7 @@ function completion(harness) {
|
|
|
1004
1123
|
}
|
|
1005
1124
|
input.end();
|
|
1006
1125
|
events.push({ type: 'done' });
|
|
1007
|
-
|
|
1126
|
+
HarnessLog.debug('wire end', { produced, frames });
|
|
1008
1127
|
events.end();
|
|
1009
1128
|
})();
|
|
1010
1129
|
});
|
|
@@ -1013,18 +1132,80 @@ function completion(harness) {
|
|
|
1013
1132
|
encode('@harness/completion-event', event);
|
|
1014
1133
|
}
|
|
1015
1134
|
catch (err) {
|
|
1135
|
+
await waitForWriteTurn();
|
|
1016
1136
|
yield { type: 'error', message: `cannot encode ${event.type} event: ${errorMessage(err)}` };
|
|
1017
|
-
await
|
|
1137
|
+
await waitForWriteTurn();
|
|
1018
1138
|
yield { type: 'done' };
|
|
1019
|
-
await
|
|
1139
|
+
await waitForWriteTurn();
|
|
1020
1140
|
gone();
|
|
1021
1141
|
return;
|
|
1022
1142
|
}
|
|
1143
|
+
await waitForWriteTurn();
|
|
1023
1144
|
yield event;
|
|
1024
|
-
await tick();
|
|
1025
1145
|
}
|
|
1026
|
-
|
|
1146
|
+
await waitForWriteTurn();
|
|
1147
|
+
HarnessLog.info('wire handed off');
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
async function serveMedia(harness, payload, { signal, events }) {
|
|
1151
|
+
let settled;
|
|
1152
|
+
try {
|
|
1153
|
+
if (!harness.serveMediaRound) {
|
|
1154
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['serveMediaRound']);
|
|
1155
|
+
}
|
|
1156
|
+
const result = await harness.serveMediaRound(await mediaRequestFrom(payload), {
|
|
1157
|
+
signal,
|
|
1158
|
+
tick: (tick) => void events.push({ type: 'media-round-tick', payload: tick })
|
|
1159
|
+
});
|
|
1160
|
+
if (signal.aborted) {
|
|
1161
|
+
throw new AbortedError();
|
|
1162
|
+
}
|
|
1163
|
+
settled = { type: 'media-round-result', ...(await mediaResultWire(result)) };
|
|
1164
|
+
}
|
|
1165
|
+
catch (err) {
|
|
1166
|
+
settled = { type: 'media-round-result', ...roundFailureWire(err) };
|
|
1167
|
+
}
|
|
1168
|
+
await events.push(settled);
|
|
1169
|
+
await events.push({ type: 'done' });
|
|
1170
|
+
events.end();
|
|
1171
|
+
}
|
|
1172
|
+
async function serveRound(harness, request, { signal, events }) {
|
|
1173
|
+
let sent = Promise.resolve();
|
|
1174
|
+
const queue = (step) => {
|
|
1175
|
+
sent = sent.then(step).then(noop);
|
|
1027
1176
|
};
|
|
1177
|
+
const text = new TextCoalescer((type, merged) => events.push({ type, text: merged }), {
|
|
1178
|
+
cap: TEXT_COALESCE_CAP,
|
|
1179
|
+
holdMs: TEXT_COALESCE_MS
|
|
1180
|
+
});
|
|
1181
|
+
const emit = (event) => queue(() => text.add(event.type, event.text));
|
|
1182
|
+
const retake = () => {
|
|
1183
|
+
queue(async () => {
|
|
1184
|
+
await text.flush();
|
|
1185
|
+
await events.push({ type: 'model-round-retake' });
|
|
1186
|
+
});
|
|
1187
|
+
return emit;
|
|
1188
|
+
};
|
|
1189
|
+
let settled;
|
|
1190
|
+
try {
|
|
1191
|
+
if (!harness.serveModelRound) {
|
|
1192
|
+
throw new HarnessError('CAPABILITY_UNSUPPORTED', ['serveModelRound']);
|
|
1193
|
+
}
|
|
1194
|
+
const result = await harness.serveModelRound(roundRequestFrom(request), {
|
|
1195
|
+
signal,
|
|
1196
|
+
emit,
|
|
1197
|
+
retake
|
|
1198
|
+
});
|
|
1199
|
+
settled = { type: 'model-round-result', result };
|
|
1200
|
+
}
|
|
1201
|
+
catch (err) {
|
|
1202
|
+
settled = { type: 'model-round-result', ...roundFailureWire(err) };
|
|
1203
|
+
}
|
|
1204
|
+
queue(() => text.flush());
|
|
1205
|
+
await sent;
|
|
1206
|
+
events.push(settled);
|
|
1207
|
+
events.push({ type: 'done' });
|
|
1208
|
+
events.end();
|
|
1028
1209
|
}
|
|
1029
1210
|
function encodableDownloadEvent(wire) {
|
|
1030
1211
|
try {
|
|
@@ -1111,3 +1292,14 @@ function downloadStream(harness, req) {
|
|
|
1111
1292
|
};
|
|
1112
1293
|
return stream;
|
|
1113
1294
|
}
|
|
1295
|
+
function knowledgeGrant({ scopes, focus, k }) {
|
|
1296
|
+
if (!isStrings(scopes) ||
|
|
1297
|
+
(focus !== undefined && !isStrings(focus)) ||
|
|
1298
|
+
(k !== undefined && !(typeof k === 'number' && Number.isSafeInteger(k) && k > 0))) {
|
|
1299
|
+
throw new TypeError('Invalid knowledge grant');
|
|
1300
|
+
}
|
|
1301
|
+
return { scopes, focus, k };
|
|
1302
|
+
}
|
|
1303
|
+
function isStrings(value) {
|
|
1304
|
+
return Array.isArray(value) && value.every((item) => typeof item === 'string');
|
|
1305
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import '../hardware/gpu-probe-entry.ts';
|
|
2
|
+
import { Harness } from '../../index.ts';
|
|
3
|
+
import type { HarnessPlugin } from '../plugins/index.ts';
|
|
4
|
+
import type { Stream } from '../rpc-session.ts';
|
|
5
|
+
import type { HarnessKnowledgeConfig, HarnessPluginOptions, MusicModelArg } from '../spawn.ts';
|
|
6
|
+
import type { SdkStorage } from '../storage.ts';
|
|
7
|
+
import type { CredentialStoreFn } from '../tools/skills/auth-resolver.ts';
|
|
8
|
+
import { type SkillCatalogEntry } from '../tools/skills/catalog.ts';
|
|
9
|
+
import { type LeftOut } from './user-plugins.ts';
|
|
10
|
+
import { type ImageClamps, type ImageModelSet, type MusicClamps } from '../models/model-catalog.ts';
|
|
11
|
+
export interface SidecarContext {
|
|
12
|
+
pluginOptions: HarnessPluginOptions;
|
|
13
|
+
sdkStorage: SdkStorage;
|
|
14
|
+
skillsDir: string | undefined;
|
|
15
|
+
skillCatalog: SkillCatalogEntry[] | undefined;
|
|
16
|
+
credentialStore: CredentialStoreFn | undefined;
|
|
17
|
+
imageModel: string | ImageModelSet | undefined;
|
|
18
|
+
imageClamps: ImageClamps | undefined;
|
|
19
|
+
musicModel: Exclude<MusicModelArg, string> | undefined;
|
|
20
|
+
musicClamps: MusicClamps | undefined;
|
|
21
|
+
knowledge: HarnessKnowledgeConfig | undefined;
|
|
22
|
+
}
|
|
23
|
+
export type SidecarPlugins = (ctx: SidecarContext) => HarnessPlugin[];
|
|
24
|
+
interface Log {
|
|
25
|
+
info(...args: unknown[]): void;
|
|
26
|
+
debug(...args: unknown[]): void;
|
|
27
|
+
warn(...args: unknown[]): void;
|
|
28
|
+
error(...args: unknown[]): void;
|
|
29
|
+
}
|
|
30
|
+
export declare class HarnessSidecar {
|
|
31
|
+
private readonly _plugins;
|
|
32
|
+
constructor(plugins: SidecarPlugins);
|
|
33
|
+
static start(ipc: Stream, ready: () => void, plugins: SidecarPlugins): Promise<() => void>;
|
|
34
|
+
static loadUserPlugins(dir: string, leftOut: LeftOut): Promise<HarnessPlugin[]>;
|
|
35
|
+
start(ipc: Stream, ready: () => void): Promise<() => void>;
|
|
36
|
+
}
|
|
37
|
+
export declare const HOST_MODULE_ENV = "QVAC_HARNESS_HOST_MODULE";
|
|
38
|
+
export declare function addHostModule(harness: Harness, log: Pick<Log, 'error'>, env?: Record<string, string | undefined>): Promise<void>;
|
|
39
|
+
export {};
|