@qvac/harness 1.0.0-rc.9 → 1.0.0
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/CHANGELOG.md +696 -7
- package/NOTICE.md +0 -16
- package/README.md +46 -5
- package/dist-lib/index.d.ts +23 -16
- package/dist-lib/index.js +127 -23
- package/dist-lib/lib/agent/delegate.d.ts +1 -0
- package/dist-lib/lib/agent/delegate.js +10 -9
- package/dist-lib/lib/agent/follow.d.ts +1 -0
- package/dist-lib/lib/agent/follow.js +12 -2
- package/dist-lib/lib/agent/resolve.js +11 -3
- package/dist-lib/lib/agent/tools.d.ts +1 -0
- package/dist-lib/lib/agent/tools.js +1 -1
- package/dist-lib/lib/capabilities/agent-ports.d.ts +1 -1
- package/dist-lib/lib/capabilities/agent-ports.js +8 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/answering.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +1 -1
- 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 +79 -9
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +12 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +13 -8
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +47 -22
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +5 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +19 -11
- package/dist-lib/lib/capabilities/completion-engine/actors/run-prepare.js +38 -23
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +31 -10
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +5 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +61 -7
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +41 -16
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +26 -10
- package/dist-lib/lib/capabilities/completion-engine/actors.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors.js +8 -8
- package/dist-lib/lib/capabilities/completion-engine/driver.d.ts +0 -1
- package/dist-lib/lib/capabilities/completion-engine/driver.js +30 -6
- package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/durable.js +7 -1
- package/dist-lib/lib/capabilities/completion-engine/engine.d.ts +2 -0
- package/dist-lib/lib/capabilities/completion-engine/engine.js +35 -15
- package/dist-lib/lib/capabilities/completion-engine/index.d.ts +0 -1
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +13 -3
- package/dist-lib/lib/capabilities/completion-engine/loop.js +7 -2
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/model-round.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.js +29 -9
- package/dist-lib/lib/capabilities/completion-engine/ports.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/ports.js +6 -4
- package/dist-lib/lib/capabilities/completion-engine/prepare-step.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +14 -0
- package/dist-lib/lib/capabilities/completion-engine/round.js +102 -47
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +5 -3
- package/dist-lib/lib/capabilities/completion-engine/session.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -1
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +5 -41
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +21 -135
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.d.ts +4 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.js +40 -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/transition-log.d.ts +14 -0
- package/dist-lib/lib/capabilities/completion-engine/transition-log.js +44 -0
- package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +4 -0
- package/dist-lib/lib/capabilities/completion-engine/turns.js +36 -8
- package/dist-lib/lib/capabilities/enhance.js +3 -3
- package/dist-lib/lib/capabilities/kv-cache.js +11 -3
- package/dist-lib/lib/capabilities/prefix-template.d.ts +34 -0
- package/dist-lib/lib/capabilities/prefix-template.js +175 -0
- package/dist-lib/lib/capabilities/prompt-prefix.d.ts +2 -0
- package/dist-lib/lib/capabilities/prompt-prefix.js +8 -0
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +4 -4
- package/dist-lib/lib/capabilities/sdk-tool.js +22 -6
- 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-turns/answered.d.ts +15 -0
- package/dist-lib/lib/capabilities/tool-turns/answered.js +16 -0
- 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 +10 -43
- package/dist-lib/lib/capabilities/tool-turns.js +7 -262
- 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.js +6 -5
- 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 +20 -0
- package/dist-lib/lib/connect/host-run-log.js +89 -0
- package/dist-lib/lib/connect/round-log.d.ts +8 -0
- package/dist-lib/lib/connect/round-log.js +33 -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 +5 -1
- package/dist-lib/lib/connect.js +102 -444
- package/dist-lib/lib/context-window.d.ts +13 -6
- package/dist-lib/lib/context-window.js +18 -5
- package/dist-lib/lib/contract/agent.d.ts +18 -1
- package/dist-lib/lib/contract/completion.d.ts +35 -3
- package/dist-lib/lib/contract/drive.d.ts +154 -4
- package/dist-lib/lib/contract/exec.d.ts +1 -0
- package/dist-lib/lib/contract/index.d.ts +1 -0
- package/dist-lib/lib/contract/knowledge.d.ts +10 -0
- package/dist-lib/lib/contract/media.d.ts +58 -0
- package/dist-lib/lib/contract/models.d.ts +6 -2
- package/dist-lib/lib/contract/ocr.d.ts +17 -0
- package/dist-lib/lib/contract/ocr.js +1 -0
- package/dist-lib/lib/contract/root-search.d.ts +34 -0
- package/dist-lib/lib/contract/root-search.js +1 -0
- package/dist-lib/lib/contract/run.d.ts +13 -0
- package/dist-lib/lib/contract-types.d.ts +10 -2
- package/dist-lib/lib/docx/index.js +1 -1
- package/dist-lib/lib/errors.d.ts +8 -4
- package/dist-lib/lib/errors.js +12 -8
- package/dist-lib/lib/fold/index.d.ts +4 -2
- package/dist-lib/lib/fold/index.js +15 -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/gpu-probe-addon.js +26 -11
- package/dist-lib/lib/hardware/gpu-stats.native.cjs +17 -1
- package/dist-lib/lib/helpers/completion-params.d.ts +2 -1
- package/dist-lib/lib/helpers/completion-params.js +18 -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/drain.d.ts +1 -1
- package/dist-lib/lib/helpers/drain.js +1 -1
- 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 -6
- package/dist-lib/lib/helpers/goal-check.js +34 -98
- package/dist-lib/lib/helpers/html-helpers.js +9 -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 +9 -2
- package/dist-lib/lib/helpers/root-search.d.ts +3 -0
- package/dist-lib/lib/helpers/root-search.js +74 -0
- package/dist-lib/lib/helpers/run-latency.d.ts +14 -0
- package/dist-lib/lib/helpers/run-latency.js +63 -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/stable-stringify.js +10 -2
- package/dist-lib/lib/helpers/text-coalescer.d.ts +6 -0
- package/dist-lib/lib/helpers/text-coalescer.js +44 -4
- 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 +157 -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/lifecycle/completion-run.js +2 -2
- package/dist-lib/lib/log.d.ts +3 -0
- package/dist-lib/lib/log.js +17 -1
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +13 -16
- package/dist-lib/lib/machine/completion/actions/completion.js +110 -138
- 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 +2 -1
- 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 +73 -151
- package/dist-lib/lib/machine/completion/context.js +6 -1
- package/dist-lib/lib/machine/completion/guards/retry.d.ts +2 -1
- package/dist-lib/lib/machine/completion/guards/retry.js +4 -3
- package/dist-lib/lib/machine/completion/implementations.d.ts +8 -5
- package/dist-lib/lib/machine/completion/implementations.js +22 -7
- package/dist-lib/lib/machine/completion/machine.d.ts +15 -6
- package/dist-lib/lib/machine/completion/machine.js +25 -5
- package/dist-lib/lib/machine/completion/metrics.d.ts +25 -0
- package/dist-lib/lib/machine/completion/metrics.js +70 -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 +10 -33
- package/dist-lib/lib/machine/completion/rules.js +27 -103
- 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 +37 -13
- package/dist-lib/lib/machine/index.d.ts +21 -7
- package/dist-lib/lib/machine/index.js +7 -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.js +8 -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/gguf-header.d.ts +6 -0
- package/dist-lib/lib/models/gguf-header.js +38 -1
- 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.js +27 -1
- 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/model-catalog-constants.d.ts +3 -2
- package/dist-lib/lib/models/model-catalog-constants.js +8 -5
- package/dist-lib/lib/models/model-catalog.d.ts +12 -3
- package/dist-lib/lib/models/model-catalog.js +40 -16
- package/dist-lib/lib/models/model-delete.js +3 -0
- package/dist-lib/lib/models/model-handle.d.ts +1 -0
- package/dist-lib/lib/models/model-list.d.ts +2 -1
- package/dist-lib/lib/models/model-list.js +5 -1
- package/dist-lib/lib/models/model-pool.d.ts +7 -1
- package/dist-lib/lib/models/model-pool.js +34 -13
- 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-impl.d.ts +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.js +45 -8
- package/dist-lib/lib/office/index.js +1 -1
- package/dist-lib/lib/plugins/registry.d.ts +12 -0
- package/dist-lib/lib/plugins/registry.js +71 -15
- 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/prompt.d.ts +7 -4
- package/dist-lib/lib/prompt.js +81 -24
- package/dist-lib/lib/residency/completion-runtime.d.ts +8 -6
- package/dist-lib/lib/residency/completion-runtime.js +53 -9
- package/dist-lib/lib/residency/index.d.ts +12 -3
- package/dist-lib/lib/residency/index.js +52 -16
- package/dist-lib/lib/round-host.js +3 -3
- package/dist-lib/lib/round-port.js +3 -3
- package/dist-lib/lib/run-log/boundary.d.ts +1 -4
- package/dist-lib/lib/run-log/boundary.js +4 -21
- package/dist-lib/lib/run-log/history-codec.d.ts +1 -1
- package/dist-lib/lib/run-log/history-codec.js +3 -3
- package/dist-lib/lib/run-log/protocol.js +17 -16
- package/dist-lib/lib/run-log/redact.d.ts +10 -1
- package/dist-lib/lib/run-log/redact.js +99 -9
- package/dist-lib/lib/run-log/request-codec.d.ts +3 -0
- package/dist-lib/lib/run-log/request-codec.js +19 -4
- package/dist-lib/lib/run-log/run-journal.js +1 -1
- package/dist-lib/lib/sdk-loader.d.ts +1 -0
- package/dist-lib/lib/sdk-loader.js +14 -0
- package/dist-lib/lib/serve/completion.d.ts +7 -0
- package/dist-lib/lib/serve/completion.js +571 -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 +148 -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 +37 -0
- package/dist-lib/lib/serve/run-log-start.js +253 -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 +23 -995
- package/dist-lib/lib/sidecar/index.d.ts +1 -1
- package/dist-lib/lib/sidecar/index.js +11 -19
- package/dist-lib/lib/sidecar/user-plugins.js +6 -4
- package/dist-lib/lib/skills-host/index.d.ts +6 -3
- package/dist-lib/lib/skills-host/index.js +39 -18
- package/dist-lib/lib/spawn.d.ts +14 -0
- package/dist-lib/lib/spawn.js +9 -5
- 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 +18 -22
- package/dist-lib/lib/tools/exec/runner.d.ts +4 -0
- package/dist-lib/lib/tools/exec/runner.js +20 -3
- package/dist-lib/lib/tools/exec.js +2 -1
- package/dist-lib/lib/tools/files/edit-file.d.ts +4 -1
- package/dist-lib/lib/tools/files/edit-file.js +220 -28
- package/dist-lib/lib/tools/files/glob.js +72 -11
- package/dist-lib/lib/tools/files/grep.js +65 -22
- package/dist-lib/lib/tools/files/index.js +3 -1
- package/dist-lib/lib/tools/files/read-file.js +199 -36
- package/dist-lib/lib/tools/fs/document-text.d.ts +7 -1
- package/dist-lib/lib/tools/fs/document-text.js +5 -21
- package/dist-lib/lib/tools/fs/drive.d.ts +1 -17
- package/dist-lib/lib/tools/fs/edit-match.d.ts +22 -0
- package/dist-lib/lib/tools/fs/edit-match.js +337 -45
- package/dist-lib/lib/tools/fs/engine.d.ts +9 -0
- package/dist-lib/lib/tools/fs/engine.js +28 -0
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +1 -81
- package/dist-lib/lib/tools/fs/scope.d.ts +2 -17
- package/dist-lib/lib/tools/fs/search.d.ts +2 -18
- package/dist-lib/lib/tools/fs/suggest.d.ts +8 -0
- package/dist-lib/lib/tools/fs/suggest.js +110 -0
- package/dist-lib/lib/tools/fs/tool-path.d.ts +3 -0
- package/dist-lib/lib/tools/fs/tool-path.js +13 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +5 -5
- package/dist-lib/lib/tools/fs/walk.js +22 -21
- 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 +88 -14
- package/dist-lib/lib/tools/index.d.ts +3 -1
- package/dist-lib/lib/tools/index.js +6 -2
- 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 +3 -2
- package/dist-lib/lib/tools/office.js +200 -39
- 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 +13 -3
- package/dist-lib/lib/tools/pdf/build.js +52 -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 +42 -14
- package/dist-lib/lib/tools/skill.js +13 -4
- package/dist-lib/lib/tools/skills/bundled-dir.d.ts +8 -1
- package/dist-lib/lib/tools/skills/bundled-dir.js +38 -32
- 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 +5 -8
- package/dist-lib/lib/tools/skills/catalog.js +1 -162
- 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/index.d.ts +1 -0
- package/dist-lib/lib/tools/skills/index.js +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +27 -3
- package/dist-lib/lib/tools/skills/manifest.d.ts +1 -0
- package/dist-lib/lib/tools/skills/overlay-crud.d.ts +3 -3
- package/dist-lib/lib/tools/skills/overlay-crud.js +4 -4
- 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-tree.d.ts +5 -0
- package/dist-lib/lib/tools/skills/skill-tree.js +54 -0
- package/dist-lib/lib/tools/toolsets.d.ts +1 -1
- package/dist-lib/lib/tools/toolsets.js +2 -0
- package/dist-lib/lib/tools/web-fetch.js +41 -130
- 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 -77
- package/dist-lib/lib/wire.js +24 -463
- package/dist-lib/plugins/charts/chart-tool.d.ts +8 -0
- package/dist-lib/plugins/charts/chart-tool.js +175 -0
- package/dist-lib/plugins/charts/index.d.ts +16 -0
- package/dist-lib/plugins/charts/index.js +21 -0
- 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/diagrams/draw.d.ts +10 -0
- package/dist-lib/plugins/diagrams/draw.js +90 -0
- package/dist-lib/plugins/diagrams/index.d.ts +13 -0
- package/dist-lib/plugins/diagrams/index.js +15 -0
- package/dist-lib/plugins/diagrams/render.d.ts +16 -0
- package/dist-lib/plugins/diagrams/render.js +285 -0
- package/dist-lib/plugins/image/edit-image.d.ts +3 -22
- package/dist-lib/plugins/image/edit-image.js +20 -44
- 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 +24 -4
- package/dist-lib/plugins/image/generate-image.js +198 -72
- package/dist-lib/plugins/image/index.d.ts +2 -1
- package/dist-lib/plugins/image/index.js +17 -8
- 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/mcp/call.js +15 -4
- package/dist-lib/plugins/mcp/protocol.d.ts +10 -2
- package/dist-lib/plugins/mcp/protocol.js +13 -12
- 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 +21 -4
- package/dist-lib/plugins/music/generate-music.js +168 -65
- package/dist-lib/plugins/music/index.d.ts +2 -1
- package/dist-lib/plugins/music/index.js +11 -6
- package/dist-lib/plugins/obsidian/index.js +14 -4
- 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/index.d.ts +4 -1
- package/dist-lib/plugins/python/index.js +5 -1
- package/dist-lib/plugins/python/language.js +11 -10
- package/dist-lib/plugins/python/python-adapter.d.ts +6 -1
- package/dist-lib/plugins/python/python-adapter.js +34 -1
- package/dist-lib/plugins/python/worker/client.js +1 -1
- 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/spawn.js +1 -1
- package/dist-lib/plugins/ripgrep/index.d.ts +15 -0
- package/dist-lib/plugins/ripgrep/index.js +28 -0
- package/dist-lib/plugins/run-report/story.js +4 -1
- package/dist-lib/plugins/sandbox-linux/index.js +2 -2
- package/dist-lib/plugins/sandbox-macos/index.js +2 -2
- package/dist-lib/plugins/sandbox-vm/index.d.ts +2 -1
- package/dist-lib/plugins/sandbox-vm/index.js +2 -2
- package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +3 -1
- package/dist-lib/plugins/sandbox-vm/vm-shell.js +45 -16
- package/dist-lib/plugins/sandbox-windows/index.js +2 -2
- 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/speech-engine.d.ts +1 -1
- package/dist-lib/plugins/speech/speech-engine.js +10 -5
- 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.js +7 -2
- package/dist-lib/plugins/walkie-talkie/index.d.ts +2 -0
- package/dist-lib/plugins/walkie-talkie/index.js +6 -1
- package/dist-lib/plugins/weather/lookup.js +1 -0
- package/dist-lib/schema/baseline.d.ts +2 -1
- package/dist-lib/schema/baseline.js +2 -2
- package/dist-lib/schema/generate.js +8 -1
- package/dist-lib/schema/harness.js +34 -5
- package/dist-lib/schema/release-tags.d.ts +2 -1
- package/dist-lib/schema/release-tags.js +9 -10
- package/dist-lib/spec/bind.js +3 -0
- package/dist-lib/spec/calls.js +1 -0
- package/dist-lib/spec/hrpc/hrpc.json +13 -0
- package/dist-lib/spec/hrpc/index.js +15 -3
- package/dist-lib/spec/hrpc/messages.js +126 -13
- package/dist-lib/spec/hyperschema/index.js +126 -13
- package/dist-lib/spec/hyperschema/schema.json +86 -2
- package/dist-lib/spec/hyperschema/types.d.ts +18 -3
- package/package.json +96 -36
- package/scripts/addon-externals.cjs +7 -1
- package/worker/harness-sidecar.mjs +10 -0
- package/dist-lib/lib/helpers/buffer-burst.d.ts +0 -1
- package/dist-lib/lib/helpers/buffer-burst.js +0 -22
- package/dist-lib/lib/office/engine/codes.d.ts +0 -62
- package/dist-lib/lib/office/engine/codes.js +0 -61
- package/dist-lib/lib/office/engine/docx/document.d.ts +0 -216
- package/dist-lib/lib/office/engine/docx/document.js +0 -1152
- package/dist-lib/lib/office/engine/docx/index.d.ts +0 -7
- package/dist-lib/lib/office/engine/docx/index.js +0 -8
- package/dist-lib/lib/office/engine/docx/styles.d.ts +0 -31
- package/dist-lib/lib/office/engine/docx/styles.js +0 -173
- package/dist-lib/lib/office/engine/docx/template.d.ts +0 -18
- package/dist-lib/lib/office/engine/docx/template.js +0 -133
- package/dist-lib/lib/office/engine/docx/text.d.ts +0 -55
- package/dist-lib/lib/office/engine/docx/text.js +0 -538
- package/dist-lib/lib/office/engine/drawingml/chart.d.ts +0 -63
- package/dist-lib/lib/office/engine/drawingml/chart.js +0 -539
- package/dist-lib/lib/office/engine/drawingml/text.d.ts +0 -35
- package/dist-lib/lib/office/engine/drawingml/text.js +0 -352
- package/dist-lib/lib/office/engine/errors.d.ts +0 -6
- package/dist-lib/lib/office/engine/errors.js +0 -12
- package/dist-lib/lib/office/engine/image.d.ts +0 -8
- package/dist-lib/lib/office/engine/image.js +0 -48
- package/dist-lib/lib/office/engine/index.d.ts +0 -12
- package/dist-lib/lib/office/engine/index.js +0 -7
- package/dist-lib/lib/office/engine/opc/content-types.d.ts +0 -17
- package/dist-lib/lib/office/engine/opc/content-types.js +0 -74
- package/dist-lib/lib/office/engine/opc/media.d.ts +0 -13
- package/dist-lib/lib/office/engine/opc/media.js +0 -11
- package/dist-lib/lib/office/engine/opc/package.d.ts +0 -51
- package/dist-lib/lib/office/engine/opc/package.js +0 -324
- package/dist-lib/lib/office/engine/opc/paths.d.ts +0 -7
- package/dist-lib/lib/office/engine/opc/paths.js +0 -46
- package/dist-lib/lib/office/engine/opc/properties.d.ts +0 -7
- package/dist-lib/lib/office/engine/opc/properties.js +0 -75
- package/dist-lib/lib/office/engine/opc/relationships.d.ts +0 -23
- package/dist-lib/lib/office/engine/opc/relationships.js +0 -65
- package/dist-lib/lib/office/engine/opc/zip.d.ts +0 -15
- package/dist-lib/lib/office/engine/opc/zip.js +0 -264
- package/dist-lib/lib/office/engine/pptx/fit.d.ts +0 -12
- package/dist-lib/lib/office/engine/pptx/fit.js +0 -37
- package/dist-lib/lib/office/engine/pptx/index.d.ts +0 -8
- package/dist-lib/lib/office/engine/pptx/index.js +0 -8
- package/dist-lib/lib/office/engine/pptx/inherit.d.ts +0 -29
- package/dist-lib/lib/office/engine/pptx/inherit.js +0 -155
- package/dist-lib/lib/office/engine/pptx/notes.d.ts +0 -5
- package/dist-lib/lib/office/engine/pptx/notes.js +0 -85
- package/dist-lib/lib/office/engine/pptx/picture-area.d.ts +0 -23
- package/dist-lib/lib/office/engine/pptx/picture-area.js +0 -84
- package/dist-lib/lib/office/engine/pptx/presentation.d.ts +0 -56
- package/dist-lib/lib/office/engine/pptx/presentation.js +0 -787
- package/dist-lib/lib/office/engine/pptx/read.d.ts +0 -9
- package/dist-lib/lib/office/engine/pptx/read.js +0 -66
- package/dist-lib/lib/office/engine/pptx/shapes.d.ts +0 -52
- package/dist-lib/lib/office/engine/pptx/shapes.js +0 -276
- package/dist-lib/lib/office/engine/pptx/slides.d.ts +0 -27
- package/dist-lib/lib/office/engine/pptx/slides.js +0 -123
- package/dist-lib/lib/office/engine/pptx/template.d.ts +0 -20
- package/dist-lib/lib/office/engine/pptx/template.js +0 -391
- package/dist-lib/lib/office/engine/pptx/types.d.ts +0 -121
- package/dist-lib/lib/office/engine/units.d.ts +0 -3
- package/dist-lib/lib/office/engine/units.js +0 -12
- package/dist-lib/lib/office/engine/utf8.d.ts +0 -2
- package/dist-lib/lib/office/engine/utf8.js +0 -103
- package/dist-lib/lib/office/engine/xlsx/formula.d.ts +0 -49
- package/dist-lib/lib/office/engine/xlsx/formula.js +0 -381
- package/dist-lib/lib/office/engine/xlsx/index.d.ts +0 -8
- package/dist-lib/lib/office/engine/xlsx/index.js +0 -8
- package/dist-lib/lib/office/engine/xlsx/refs.d.ts +0 -22
- package/dist-lib/lib/office/engine/xlsx/refs.js +0 -82
- package/dist-lib/lib/office/engine/xlsx/reshape.d.ts +0 -21
- package/dist-lib/lib/office/engine/xlsx/reshape.js +0 -424
- package/dist-lib/lib/office/engine/xlsx/sheet.d.ts +0 -108
- package/dist-lib/lib/office/engine/xlsx/sheet.js +0 -662
- package/dist-lib/lib/office/engine/xlsx/strings.d.ts +0 -15
- package/dist-lib/lib/office/engine/xlsx/strings.js +0 -93
- package/dist-lib/lib/office/engine/xlsx/styles.d.ts +0 -38
- package/dist-lib/lib/office/engine/xlsx/styles.js +0 -369
- package/dist-lib/lib/office/engine/xlsx/template.d.ts +0 -7
- package/dist-lib/lib/office/engine/xlsx/template.js +0 -54
- package/dist-lib/lib/office/engine/xlsx/workbook.d.ts +0 -162
- package/dist-lib/lib/office/engine/xlsx/workbook.js +0 -881
- package/dist-lib/lib/office/engine/xlsx/write.d.ts +0 -2
- package/dist-lib/lib/office/engine/xlsx/write.js +0 -42
- package/dist-lib/lib/office/engine/xml.d.ts +0 -45
- package/dist-lib/lib/office/engine/xml.js +0 -258
- package/patches/localwatch@1.4.3.patch +0 -13
- /package/dist-lib/lib/{office/engine/pptx/types.js → contract/media.js} +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { goalStatus } from './completion/actions/goal.ts';
|
|
1
2
|
import { emptyCompletionContext } from './completion/context.ts';
|
|
2
3
|
import { atContextBoundary, cutOffMessage, cutShort, runsUnasked } from './completion/rules.ts';
|
|
4
|
+
import { repeatsBlocked } from './completion/guards/retry.ts';
|
|
3
5
|
import { completionMachineDefinition, transitionName } from './definition.ts';
|
|
4
6
|
export declare class CompletionMachine {
|
|
5
7
|
static VERSION: number;
|
|
@@ -119,7 +121,7 @@ export declare class CompletionMachine {
|
|
|
119
121
|
}, import("./index.ts").InvocationInput>;
|
|
120
122
|
id: string | undefined;
|
|
121
123
|
}, {
|
|
122
|
-
type: "
|
|
124
|
+
type: "ackFollowUps";
|
|
123
125
|
params: undefined;
|
|
124
126
|
} | {
|
|
125
127
|
type: "ackSteering";
|
|
@@ -139,11 +141,14 @@ export declare class CompletionMachine {
|
|
|
139
141
|
} | {
|
|
140
142
|
type: "continueGoal";
|
|
141
143
|
params: undefined;
|
|
144
|
+
} | {
|
|
145
|
+
type: "continueStalledGoal";
|
|
146
|
+
params: undefined;
|
|
142
147
|
} | {
|
|
143
148
|
type: "continueStop";
|
|
144
149
|
params: import("./completion/types.ts").AnsweredPayload;
|
|
145
150
|
} | {
|
|
146
|
-
type: "
|
|
151
|
+
type: "continueWithFollowUps";
|
|
147
152
|
params: undefined;
|
|
148
153
|
} | {
|
|
149
154
|
type: "endRunOnTool";
|
|
@@ -173,6 +178,12 @@ export declare class CompletionMachine {
|
|
|
173
178
|
} | {
|
|
174
179
|
type: "finishWrapRound";
|
|
175
180
|
params: import("./completion/types.ts").RoundDonePayload;
|
|
181
|
+
} | {
|
|
182
|
+
type: "markGoalStalled";
|
|
183
|
+
params: undefined;
|
|
184
|
+
} | {
|
|
185
|
+
type: "markHalfTime";
|
|
186
|
+
params: undefined;
|
|
176
187
|
} | {
|
|
177
188
|
type: "markTimeUp";
|
|
178
189
|
params: undefined;
|
|
@@ -199,13 +210,13 @@ export declare class CompletionMachine {
|
|
|
199
210
|
params: import("./completion/types.ts").RejectDeniedApprovalParams;
|
|
200
211
|
} | {
|
|
201
212
|
type: "rejectPlanModeWrite";
|
|
202
|
-
params: import("./completion/actions/
|
|
213
|
+
params: import("./completion/actions/reject-tool.ts").RejectPlanModeWriteParams;
|
|
203
214
|
} | {
|
|
204
215
|
type: "rejectRepeatedTool";
|
|
205
216
|
params: import("./completion/types.ts").RepeatOfFailedCallParams;
|
|
206
217
|
} | {
|
|
207
218
|
type: "rejectTool";
|
|
208
|
-
params: import("./completion/actions/
|
|
219
|
+
params: import("./completion/actions/reject-tool.ts").RejectToolParams;
|
|
209
220
|
} | {
|
|
210
221
|
type: "requestApproval";
|
|
211
222
|
params: import("./completion/types.ts").ApprovalCall;
|
|
@@ -350,7 +361,7 @@ export declare class CompletionMachine {
|
|
|
350
361
|
type: "hasAnswer";
|
|
351
362
|
params: unknown;
|
|
352
363
|
} | {
|
|
353
|
-
type: "
|
|
364
|
+
type: "hasFollowUp";
|
|
354
365
|
params: unknown;
|
|
355
366
|
} | {
|
|
356
367
|
type: "hasQueuedTool";
|
|
@@ -424,7 +435,7 @@ export declare class CompletionMachine {
|
|
|
424
435
|
} | {
|
|
425
436
|
type: "toolRejected";
|
|
426
437
|
params: unknown;
|
|
427
|
-
}, "deadline", "done" | "failed" | "paused" | "pausing" | "resuming" | {
|
|
438
|
+
}, "deadline" | "halfTime", "done" | "failed" | "paused" | "pausing" | "resuming" | {
|
|
428
439
|
active: "answering" | "finishing" | "generating" | "idle" | "prepareChecking" | "prepareRunning" | "preparing" | "resolving" | "retrieving" | "round" | "searching" | "wrapping" | {
|
|
429
440
|
tools: "approving" | "batching" | "executing" | "inspecting" | "rejecting" | "selecting";
|
|
430
441
|
};
|
|
@@ -474,15 +485,18 @@ export declare class CompletionMachine {
|
|
|
474
485
|
}, import("xstate").MetaObject>;
|
|
475
486
|
static definition: typeof completionMachineDefinition;
|
|
476
487
|
static emptyContext: typeof emptyCompletionContext;
|
|
488
|
+
static goalStatus: typeof goalStatus;
|
|
477
489
|
static transitionName: typeof transitionName;
|
|
478
490
|
static runsUnasked: typeof runsUnasked;
|
|
479
491
|
static cutOffMessage: typeof cutOffMessage;
|
|
480
492
|
static cutShort: typeof cutShort;
|
|
481
493
|
static atContextBoundary: typeof atContextBoundary;
|
|
494
|
+
static repeatsBlocked: typeof repeatsBlocked;
|
|
482
495
|
static MAX_ROUND_CALLS: number;
|
|
496
|
+
static MAX_SHOWN_IMAGES: number;
|
|
483
497
|
static MAX_ROUND_REPEATS: number;
|
|
484
498
|
}
|
|
485
499
|
export type { MachineDefinitionNode } from './definition.ts';
|
|
486
500
|
export type { EmptyCompletionContextOptions } from './completion/context.ts';
|
|
487
501
|
export type { CompletionActorLogic, CompletionParent, InvocationInput, Stage } from './completion/ports.ts';
|
|
488
|
-
export type { CompletionContext, RunPolicy, CompletionActorOutput, CompletionActorOutputs, EngineEvent } from './completion/types.ts';
|
|
502
|
+
export type { CompletionContext, RunPolicy, CompletionActorOutput, CompletionActorOutputs, EngineEvent, ShownImage } from './completion/types.ts';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { goalStatus } from './completion/actions/goal.js';
|
|
2
|
+
import { PLAN_MODE_REFUSAL } from './completion/actions/reject-tool.js';
|
|
2
3
|
import { emptyCompletionContext } from './completion/context.js';
|
|
3
4
|
import { createCompletionMachine } from './completion/machine.js';
|
|
4
|
-
import { atContextBoundary, cutOffMessage, cutShort, MAX_ROUND_CALLS, MAX_ROUND_REPEATS, runsUnasked } from './completion/rules.js';
|
|
5
|
+
import { atContextBoundary, cutOffMessage, cutShort, MAX_ROUND_CALLS, MAX_ROUND_REPEATS, MAX_SHOWN_IMAGES, runsUnasked } from './completion/rules.js';
|
|
6
|
+
import { repeatsBlocked } from './completion/guards/retry.js';
|
|
5
7
|
import { MACHINE_VERSION } from './completion/version.js';
|
|
6
8
|
import { completionMachineDefinition, transitionName } from './definition.js';
|
|
7
9
|
export class CompletionMachine {
|
|
@@ -10,11 +12,14 @@ export class CompletionMachine {
|
|
|
10
12
|
static create = createCompletionMachine;
|
|
11
13
|
static definition = completionMachineDefinition;
|
|
12
14
|
static emptyContext = emptyCompletionContext;
|
|
15
|
+
static goalStatus = goalStatus;
|
|
13
16
|
static transitionName = transitionName;
|
|
14
17
|
static runsUnasked = runsUnasked;
|
|
15
18
|
static cutOffMessage = cutOffMessage;
|
|
16
19
|
static cutShort = cutShort;
|
|
17
20
|
static atContextBoundary = atContextBoundary;
|
|
21
|
+
static repeatsBlocked = repeatsBlocked;
|
|
18
22
|
static MAX_ROUND_CALLS = MAX_ROUND_CALLS;
|
|
23
|
+
static MAX_SHOWN_IMAGES = MAX_SHOWN_IMAGES;
|
|
19
24
|
static MAX_ROUND_REPEATS = MAX_ROUND_REPEATS;
|
|
20
25
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MediaRoundPort } from './contract/index.ts';
|
|
2
|
+
export declare class MediaHost {
|
|
3
|
+
private readonly _port;
|
|
4
|
+
private readonly _out;
|
|
5
|
+
private readonly _rounds;
|
|
6
|
+
constructor(port: MediaRoundPort, send: (frame: object) => void);
|
|
7
|
+
ask(callId: string, payload: unknown): void;
|
|
8
|
+
cancel(callId: string): void;
|
|
9
|
+
close(): void;
|
|
10
|
+
private _settle;
|
|
11
|
+
private _drain;
|
|
12
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AbortController } from 'bare-abort-controller';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { mediaRequestFrom, mediaResultWire } from './media-wire.js';
|
|
4
|
+
import { pushQueue } from './queue.js';
|
|
5
|
+
import { Wire } from './wire.js';
|
|
6
|
+
export class MediaHost {
|
|
7
|
+
_port;
|
|
8
|
+
_out = pushQueue();
|
|
9
|
+
_rounds = new Map();
|
|
10
|
+
constructor(port, send) {
|
|
11
|
+
this._port = port;
|
|
12
|
+
void this._drain(send);
|
|
13
|
+
}
|
|
14
|
+
ask(callId, payload) {
|
|
15
|
+
const controller = new AbortController();
|
|
16
|
+
this._rounds.set(callId, controller);
|
|
17
|
+
const tick = (payload) => {
|
|
18
|
+
if (this._rounds.has(callId)) {
|
|
19
|
+
void this._out.push({ type: 'media-round-tick', callId, payload });
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
void mediaRequestFrom(payload)
|
|
23
|
+
.then((request) => this._port(request, { signal: controller.signal, tick }))
|
|
24
|
+
.then(mediaResultWire)
|
|
25
|
+
.then((wire) => this._settle(callId, wire, wire.path), (err) => this._settle(callId, Wire.roundFailureWire(err)));
|
|
26
|
+
}
|
|
27
|
+
cancel(callId) {
|
|
28
|
+
this._rounds.get(callId)?.abort(undefined);
|
|
29
|
+
this._rounds.delete(callId);
|
|
30
|
+
}
|
|
31
|
+
close() {
|
|
32
|
+
for (const callId of [...this._rounds.keys()]) {
|
|
33
|
+
this.cancel(callId);
|
|
34
|
+
}
|
|
35
|
+
this._out.end();
|
|
36
|
+
}
|
|
37
|
+
_settle(callId, frame, staged) {
|
|
38
|
+
if (this._rounds.delete(callId)) {
|
|
39
|
+
void this._out.push({ type: 'media-round-result', callId, ...frame });
|
|
40
|
+
}
|
|
41
|
+
else if (staged) {
|
|
42
|
+
void fs.promises.unlink(staged).catch(noop);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async _drain(send) {
|
|
46
|
+
for await (const frame of this._out) {
|
|
47
|
+
send(frame);
|
|
48
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function noop() { }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MediaRoundPort } from './contract/index.ts';
|
|
2
|
+
import type { RoundFrame } from './round-port.ts';
|
|
3
|
+
import type { WireEvent } from './wire.ts';
|
|
4
|
+
interface MediaFrame extends RoundFrame {
|
|
5
|
+
path?: string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare class MediaPort {
|
|
8
|
+
private readonly _push;
|
|
9
|
+
private readonly _asked;
|
|
10
|
+
private _calls;
|
|
11
|
+
private _closed;
|
|
12
|
+
constructor(push: (event: WireEvent) => unknown);
|
|
13
|
+
port: MediaRoundPort;
|
|
14
|
+
frame(frame: MediaFrame): boolean;
|
|
15
|
+
close(): void;
|
|
16
|
+
private _settle;
|
|
17
|
+
private _assertLive;
|
|
18
|
+
private _take;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { HarnessError } from './errors.js';
|
|
2
|
+
import { AbortedError } from './helpers/engine-error.js';
|
|
3
|
+
import { discardRequestWire, mediaRequestWire, mediaResultFrom, mediaTickFrom } from './media-wire.js';
|
|
4
|
+
export class MediaPort {
|
|
5
|
+
_push;
|
|
6
|
+
_asked = new Map();
|
|
7
|
+
_calls = 0;
|
|
8
|
+
_closed = false;
|
|
9
|
+
constructor(push) {
|
|
10
|
+
this._push = push;
|
|
11
|
+
}
|
|
12
|
+
port = async (request, io) => {
|
|
13
|
+
this._assertLive(io);
|
|
14
|
+
const payload = await mediaRequestWire(request);
|
|
15
|
+
try {
|
|
16
|
+
this._assertLive(io);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
await discardRequestWire(payload);
|
|
20
|
+
throw err;
|
|
21
|
+
}
|
|
22
|
+
const callId = String(this._calls++);
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const cancel = () => {
|
|
25
|
+
if (!this._take(callId))
|
|
26
|
+
return;
|
|
27
|
+
this._push({ type: 'media-round-cancel', callId });
|
|
28
|
+
reject(new AbortedError());
|
|
29
|
+
};
|
|
30
|
+
this._asked.set(callId, { io, cancel, resolve, reject });
|
|
31
|
+
io.signal.addEventListener('abort', cancel, { once: true });
|
|
32
|
+
this._push({ type: 'media-round-ask', callId, payload });
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
frame(frame) {
|
|
36
|
+
switch (frame.type) {
|
|
37
|
+
case 'media-round-tick':
|
|
38
|
+
this._asked.get(frame.callId ?? '')?.io.tick(mediaTickFrom(frame.payload));
|
|
39
|
+
return true;
|
|
40
|
+
case 'media-round-result':
|
|
41
|
+
void this._settle(frame);
|
|
42
|
+
return true;
|
|
43
|
+
default:
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
close() {
|
|
48
|
+
this._closed = true;
|
|
49
|
+
for (const callId of [...this._asked.keys()]) {
|
|
50
|
+
this._take(callId)?.reject(new HarnessError('CLIENT_GONE'));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async _settle(frame) {
|
|
54
|
+
const asked = this._take(frame.callId ?? '');
|
|
55
|
+
try {
|
|
56
|
+
const result = await mediaResultFrom(frame);
|
|
57
|
+
asked?.resolve(result);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
asked?.reject(err);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
_assertLive(io) {
|
|
64
|
+
if (this._closed) {
|
|
65
|
+
throw new HarnessError('CLIENT_GONE');
|
|
66
|
+
}
|
|
67
|
+
if (io.signal.aborted) {
|
|
68
|
+
throw new AbortedError();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
_take(callId) {
|
|
72
|
+
const asked = this._asked.get(callId);
|
|
73
|
+
this._asked.delete(callId);
|
|
74
|
+
asked?.io.signal.removeEventListener('abort', asked.cancel);
|
|
75
|
+
return asked;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MediaRoundRequest, MediaRoundResult, MediaTick } from './contract/index.ts';
|
|
2
|
+
import { type WireEvent } from './wire.ts';
|
|
3
|
+
export declare function mediaRequestWire(request: MediaRoundRequest): Promise<Record<string, unknown>>;
|
|
4
|
+
export declare function discardRequestWire(payload: Record<string, unknown>): Promise<void>;
|
|
5
|
+
export declare function mediaRequestFrom(payload: unknown): Promise<MediaRoundRequest>;
|
|
6
|
+
export declare function mediaResultWire(result: MediaRoundResult): Promise<Pick<WireEvent, 'path' | 'result'>>;
|
|
7
|
+
export declare function mediaResultFrom(wire: Pick<WireEvent, 'path' | 'result' | 'message' | 'payload'>): Promise<MediaRoundResult>;
|
|
8
|
+
export declare function mediaTickFrom(payload: unknown): MediaTick;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { isRecord } from './guards.js';
|
|
3
|
+
import { stageFile } from './staging.js';
|
|
4
|
+
import { Wire } from './wire.js';
|
|
5
|
+
const KINDS = ['image', 'music'];
|
|
6
|
+
export async function mediaRequestWire(request) {
|
|
7
|
+
const { images, ...json } = request;
|
|
8
|
+
const imagePaths = images
|
|
9
|
+
? await Promise.all(images.map((bytes) => stageFile('media-source', bytes)))
|
|
10
|
+
: undefined;
|
|
11
|
+
return { ...json, imagePaths };
|
|
12
|
+
}
|
|
13
|
+
export async function discardRequestWire(payload) {
|
|
14
|
+
const paths = Array.isArray(payload.imagePaths) ? payload.imagePaths.map(String) : [];
|
|
15
|
+
await Promise.all(paths.map((file) => fs.promises.unlink(file).catch(noop)));
|
|
16
|
+
}
|
|
17
|
+
export async function mediaRequestFrom(payload) {
|
|
18
|
+
if (!isRecord(payload) || !KINDS.some((kind) => kind === payload.kind)) {
|
|
19
|
+
throw new TypeError('invalid media round request');
|
|
20
|
+
}
|
|
21
|
+
const paths = Array.isArray(payload.imagePaths) ? payload.imagePaths.map(String) : [];
|
|
22
|
+
const images = await Promise.all(paths.map(readStaged));
|
|
23
|
+
return {
|
|
24
|
+
kind: payload.kind === 'music' ? 'music' : 'image',
|
|
25
|
+
runId: String(payload.runId ?? ''),
|
|
26
|
+
modelChoice: typeof payload.modelChoice === 'string' ? payload.modelChoice : undefined,
|
|
27
|
+
params: isRecord(payload.params) ? payload.params : {},
|
|
28
|
+
images: paths.length ? images : undefined,
|
|
29
|
+
sources: Array.isArray(payload.sources) ? payload.sources.flatMap(sourceRefFrom) : undefined
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function sourceRefFrom(ref) {
|
|
33
|
+
if (!isRecord(ref) || typeof ref.width !== 'number' || typeof ref.height !== 'number') {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
const name = (value) => (typeof value === 'string' ? value : undefined);
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
attachmentId: name(ref.attachmentId),
|
|
40
|
+
path: name(ref.path),
|
|
41
|
+
width: ref.width,
|
|
42
|
+
height: ref.height
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
export async function mediaResultWire(result) {
|
|
47
|
+
if ('error' in result) {
|
|
48
|
+
return { result: { error: result.error, code: result.code } };
|
|
49
|
+
}
|
|
50
|
+
const { bytes, ...json } = result;
|
|
51
|
+
return { path: await stageFile('media-output', bytes), result: json };
|
|
52
|
+
}
|
|
53
|
+
export async function mediaResultFrom(wire) {
|
|
54
|
+
const result = isRecord(wire.result) ? wire.result : {};
|
|
55
|
+
if (wire.path) {
|
|
56
|
+
return outputFrom(result, await readStaged(wire.path));
|
|
57
|
+
}
|
|
58
|
+
if (typeof result.error === 'string') {
|
|
59
|
+
return { error: result.error, code: typeof result.code === 'string' ? result.code : undefined };
|
|
60
|
+
}
|
|
61
|
+
throw Wire.roundFailureFrom(wire);
|
|
62
|
+
}
|
|
63
|
+
function outputFrom(result, bytes) {
|
|
64
|
+
if (result.kind === 'image') {
|
|
65
|
+
return { kind: 'image', bytes };
|
|
66
|
+
}
|
|
67
|
+
const format = isRecord(result.format) ? result.format : {};
|
|
68
|
+
const sampleRate = positive(format.sampleRate);
|
|
69
|
+
const channels = positive(format.channels);
|
|
70
|
+
const bitsPerSample = positive(format.bitsPerSample);
|
|
71
|
+
if (result.kind !== 'music' || !sampleRate || !channels || !bitsPerSample) {
|
|
72
|
+
throw new TypeError('invalid media round output');
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
kind: 'music',
|
|
76
|
+
bytes,
|
|
77
|
+
format: { sampleRate, channels, bitsPerSample },
|
|
78
|
+
gpuRequested: result.gpuRequested === true,
|
|
79
|
+
stats: isRecord(result.stats) ? statsFrom(result.stats) : undefined
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function statsFrom(stats) {
|
|
83
|
+
const number = (value) => (typeof value === 'number' ? value : undefined);
|
|
84
|
+
return {
|
|
85
|
+
audioDurationMs: number(stats.audioDurationMs),
|
|
86
|
+
totalTimeMs: number(stats.totalTimeMs),
|
|
87
|
+
realTimeFactor: number(stats.realTimeFactor),
|
|
88
|
+
backendDevice: number(stats.backendDevice),
|
|
89
|
+
backendId: number(stats.backendId)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function positive(value) {
|
|
93
|
+
return typeof value === 'number' && value > 0 ? value : undefined;
|
|
94
|
+
}
|
|
95
|
+
export function mediaTickFrom(payload) {
|
|
96
|
+
const tick = isRecord(payload) ? payload : {};
|
|
97
|
+
return {
|
|
98
|
+
step: Number(tick.step ?? 0),
|
|
99
|
+
total: Number(tick.total ?? 0),
|
|
100
|
+
stage: typeof tick.stage === 'string' ? tick.stage : undefined
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async function readStaged(file) {
|
|
104
|
+
try {
|
|
105
|
+
return await fs.promises.readFile(file);
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
void fs.promises.unlink(file).catch(noop);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function noop() { }
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HarnessLog } from '../log.js';
|
|
1
2
|
const RUNGS = [262_144, 131_072, 65_536];
|
|
2
3
|
const CEILINGS = {
|
|
3
4
|
mid: 65_536,
|
|
@@ -34,14 +35,18 @@ export class ContextChoice {
|
|
|
34
35
|
return choice;
|
|
35
36
|
}
|
|
36
37
|
async _climb(tier, ask) {
|
|
37
|
-
const
|
|
38
|
+
const profile = await this._profile();
|
|
39
|
+
const ceiling = ContextChoice.ceiling(profile);
|
|
38
40
|
if (!ceiling || ceiling <= tier) {
|
|
41
|
+
HarnessLog.info('context climb', { tier, profile: profile ?? null, stop: 'ceiling' });
|
|
39
42
|
return tier;
|
|
40
43
|
}
|
|
41
44
|
const trained = await ask.trained();
|
|
42
45
|
if (!trained) {
|
|
46
|
+
HarnessLog.info('context climb', { tier, ceiling, stop: 'trained-unknown' });
|
|
43
47
|
return undefined;
|
|
44
48
|
}
|
|
49
|
+
const tried = [];
|
|
45
50
|
for (const rung of RUNGS) {
|
|
46
51
|
if (rung > ceiling || rung > trained || rung <= tier) {
|
|
47
52
|
continue;
|
|
@@ -49,7 +54,9 @@ export class ContextChoice {
|
|
|
49
54
|
if (await ask.fits(rung)) {
|
|
50
55
|
return rung;
|
|
51
56
|
}
|
|
57
|
+
tried.push(rung);
|
|
52
58
|
}
|
|
59
|
+
HarnessLog.info('context climb', { tier, ceiling, trained, tried, stop: 'no-fit' });
|
|
53
60
|
return tier;
|
|
54
61
|
}
|
|
55
62
|
}
|
|
@@ -9,5 +9,6 @@ export interface CustomShardCache {
|
|
|
9
9
|
readonly files: ReadonlyArray<string>;
|
|
10
10
|
}
|
|
11
11
|
export declare function customShardCache(src: string, modelsDir: string | undefined): CustomShardCache | null;
|
|
12
|
+
export declare function localWeightFile(src: string, modelsDir: string | undefined): string | null;
|
|
12
13
|
export declare function customDownloads(entry: CustomModelEntry, modelsDir: string | undefined): Promise<CustomDownloads>;
|
|
13
14
|
export declare function isCustomModelCached(entry: CustomModelEntry, modelsDir: string | undefined): Promise<boolean>;
|
|
@@ -22,6 +22,9 @@ export function customShardCache(src, modelsDir) {
|
|
|
22
22
|
const dir = path.join(modelsDir, 'sharded', shortHash(`${set.baseUrl}/${set.base}`));
|
|
23
23
|
return { dir, files: set.shards.map((shard) => path.join(dir, shard.filename)) };
|
|
24
24
|
}
|
|
25
|
+
export function localWeightFile(src, modelsDir) {
|
|
26
|
+
return customShardCache(src, modelsDir)?.files[0] ?? customFileCachePath(src, modelsDir);
|
|
27
|
+
}
|
|
25
28
|
export async function customDownloads(entry, modelsDir) {
|
|
26
29
|
const remote = sourcesOf(entry).filter(isRemoteSource);
|
|
27
30
|
const shardDirs = remote.flatMap((src) => customShardCache(src, modelsDir)?.dir ?? []);
|
|
@@ -7,6 +7,12 @@ export interface GgufHeader {
|
|
|
7
7
|
readonly contextLength?: number;
|
|
8
8
|
readonly sizeLabel?: string;
|
|
9
9
|
readonly tags?: ReadonlyArray<string>;
|
|
10
|
+
readonly headDims?: HeadDims;
|
|
11
|
+
readonly chatTemplate?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface HeadDims {
|
|
14
|
+
readonly k?: number;
|
|
15
|
+
readonly v?: number;
|
|
10
16
|
}
|
|
11
17
|
export type GgufRangeFetch = (url: string, init: {
|
|
12
18
|
headers: Record<string, string>;
|
|
@@ -262,6 +262,7 @@ export function parseGgufHeader(bytes) {
|
|
|
262
262
|
const count = readU64(c);
|
|
263
263
|
const header = {};
|
|
264
264
|
const contextLengths = new Map();
|
|
265
|
+
const dims = new Map();
|
|
265
266
|
for (let i = 0; i < count; i += 1) {
|
|
266
267
|
const key = readString(c);
|
|
267
268
|
if (key === null || !has(c, 4)) {
|
|
@@ -289,15 +290,40 @@ export function parseGgufHeader(bytes) {
|
|
|
289
290
|
else if (key === 'general.tags') {
|
|
290
291
|
header.tags = value.strs;
|
|
291
292
|
}
|
|
293
|
+
else if (key === 'tokenizer.chat_template') {
|
|
294
|
+
header.chatTemplate = value.str;
|
|
295
|
+
}
|
|
292
296
|
else if (key.endsWith('.context_length')) {
|
|
293
297
|
contextLengths.set(key, value.num);
|
|
294
298
|
}
|
|
299
|
+
else if (HEAD_KEYS.some((suffix) => key.endsWith(suffix))) {
|
|
300
|
+
dims.set(key, value.num);
|
|
301
|
+
}
|
|
295
302
|
}
|
|
296
303
|
header.contextLength =
|
|
297
304
|
contextLengths.get(`${header.architecture}.context_length`) ??
|
|
298
305
|
contextLengths.values().next().value;
|
|
306
|
+
const headDims = headDimsOf(dims, header.architecture);
|
|
307
|
+
if (headDims) {
|
|
308
|
+
header.headDims = headDims;
|
|
309
|
+
}
|
|
299
310
|
return header;
|
|
300
311
|
}
|
|
312
|
+
const HEAD_KEYS = [
|
|
313
|
+
'.attention.key_length',
|
|
314
|
+
'.attention.value_length',
|
|
315
|
+
'.attention.head_count',
|
|
316
|
+
'.embedding_length'
|
|
317
|
+
];
|
|
318
|
+
function headDimsOf(dims, architecture) {
|
|
319
|
+
const of = (suffix) => dims.get(`${architecture}${suffix}`);
|
|
320
|
+
const embedding = of('.embedding_length');
|
|
321
|
+
const heads = of('.attention.head_count');
|
|
322
|
+
const split = embedding && heads ? embedding / heads : undefined;
|
|
323
|
+
const k = of('.attention.key_length') ?? split;
|
|
324
|
+
const v = of('.attention.value_length') ?? split;
|
|
325
|
+
return k || v ? { k, v } : undefined;
|
|
326
|
+
}
|
|
301
327
|
function readValue(c, type, collect = false) {
|
|
302
328
|
switch (type) {
|
|
303
329
|
case UINT8:
|
|
@@ -332,7 +358,7 @@ function readValue(c, type, collect = false) {
|
|
|
332
358
|
const length = readU64(c);
|
|
333
359
|
const strs = new Array();
|
|
334
360
|
for (let i = 0; i < length; i += 1) {
|
|
335
|
-
const element = readValue(c, elementType);
|
|
361
|
+
const element = elementType === STRING && !collect ? skipString(c) : readValue(c, elementType);
|
|
336
362
|
if (!element.ok) {
|
|
337
363
|
return { ok: false };
|
|
338
364
|
}
|
|
@@ -379,3 +405,14 @@ function readString(c) {
|
|
|
379
405
|
c.offset += length;
|
|
380
406
|
return str;
|
|
381
407
|
}
|
|
408
|
+
function skipString(c) {
|
|
409
|
+
if (!has(c, 8)) {
|
|
410
|
+
return { ok: false };
|
|
411
|
+
}
|
|
412
|
+
const length = readU64(c);
|
|
413
|
+
if (!has(c, length)) {
|
|
414
|
+
return { ok: false };
|
|
415
|
+
}
|
|
416
|
+
c.offset += length;
|
|
417
|
+
return { ok: true };
|
|
418
|
+
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export type MainGpuProbe = () => Promise<string | undefined>;
|
|
2
|
-
|
|
2
|
+
interface GpuHost {
|
|
3
|
+
readonly platform?: string;
|
|
4
|
+
readonly root?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function resolveMainGpu(host?: GpuHost): Promise<string | undefined>;
|
|
3
7
|
export declare function resetMainGpuCache(): void;
|
|
8
|
+
export {};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
2
|
import { platform } from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
const NVIDIA_VENDOR = '0x10de';
|
|
3
5
|
let cachedDedicated = null;
|
|
4
|
-
export async function resolveMainGpu() {
|
|
5
|
-
if (platform() !== 'linux')
|
|
6
|
+
export async function resolveMainGpu(host = {}) {
|
|
7
|
+
if ((host.platform ?? platform()) !== 'linux')
|
|
6
8
|
return undefined;
|
|
7
9
|
if (cachedDedicated !== null)
|
|
8
10
|
return cachedDedicated;
|
|
9
|
-
|
|
11
|
+
const root = host.root ?? '/';
|
|
12
|
+
if ((await hasNvidiaGpu(root)) && (await hasOtherGpu(root))) {
|
|
10
13
|
cachedDedicated = 'dedicated';
|
|
11
14
|
return cachedDedicated;
|
|
12
15
|
}
|
|
@@ -15,12 +18,33 @@ export async function resolveMainGpu() {
|
|
|
15
18
|
export function resetMainGpuCache() {
|
|
16
19
|
cachedDedicated = null;
|
|
17
20
|
}
|
|
18
|
-
async function hasNvidiaGpu() {
|
|
21
|
+
async function hasNvidiaGpu(root) {
|
|
19
22
|
try {
|
|
20
|
-
const entries = await promises.readdir('
|
|
23
|
+
const entries = await promises.readdir(path.join(root, 'proc/driver/nvidia/gpus'));
|
|
21
24
|
return entries.length > 0;
|
|
22
25
|
}
|
|
23
26
|
catch {
|
|
24
27
|
return false;
|
|
25
28
|
}
|
|
26
29
|
}
|
|
30
|
+
async function hasOtherGpu(root) {
|
|
31
|
+
const drm = path.join(root, 'sys/class/drm');
|
|
32
|
+
let entries;
|
|
33
|
+
try {
|
|
34
|
+
entries = await promises.readdir(drm);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const cards = entries.filter((name) => /^card\d+$/.test(name));
|
|
40
|
+
const vendors = await Promise.all(cards.map((card) => vendorOf(path.join(drm, card, 'device/vendor'))));
|
|
41
|
+
return vendors.some((vendor) => vendor !== '' && vendor !== NVIDIA_VENDOR);
|
|
42
|
+
}
|
|
43
|
+
async function vendorOf(file) {
|
|
44
|
+
try {
|
|
45
|
+
return (await promises.readFile(file, 'utf8')).trim().toLowerCase();
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { HeadDims } from './gguf-header.ts';
|
|
1
2
|
export interface KvCacheTypes {
|
|
2
3
|
k: string | undefined;
|
|
3
4
|
v: string | undefined;
|
|
4
5
|
}
|
|
6
|
+
export declare function headSafeKvCache({ k, v }: KvCacheTypes, heads: HeadDims | undefined): KvCacheTypes;
|
|
5
7
|
export declare function adrenoSafeKvCache(device: 'cpu' | 'gpu' | undefined, { k, v }: KvCacheTypes, hostPlatform?: string): KvCacheTypes;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { platform } from 'os';
|
|
2
|
+
const QUANT_BLOCK = 32;
|
|
3
|
+
const UNBLOCKED = new Set(['f32', 'f16', 'bf16']);
|
|
4
|
+
export function headSafeKvCache({ k, v }, heads) {
|
|
5
|
+
return { k: blockFits(k, heads?.k) ? k : 'f16', v: blockFits(v, heads?.v) ? v : 'f16' };
|
|
6
|
+
}
|
|
7
|
+
function blockFits(type, width) {
|
|
8
|
+
return !type || !width || UNBLOCKED.has(type) || width % QUANT_BLOCK === 0;
|
|
9
|
+
}
|
|
2
10
|
export function adrenoSafeKvCache(device, { k, v }, hostPlatform = platform()) {
|
|
3
11
|
if (device === 'cpu' || hostPlatform !== 'android') {
|
|
4
12
|
return { k, v };
|