@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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PluginRegistry } from '../../lib/plugins/index.js';
|
|
2
|
+
import { createChartTool } from './chart-tool.js';
|
|
3
|
+
PluginRegistry.requirePeers('charts', {
|
|
4
|
+
'qvac-charts': () => import.meta.resolve('qvac-charts')
|
|
5
|
+
});
|
|
6
|
+
export class Charts {
|
|
7
|
+
name = 'charts';
|
|
8
|
+
api = PluginRegistry.API_VERSION;
|
|
9
|
+
read;
|
|
10
|
+
_theme;
|
|
11
|
+
_mark;
|
|
12
|
+
constructor({ read, theme = 'dark', mark } = {}) {
|
|
13
|
+
this.read = read;
|
|
14
|
+
this._theme = theme;
|
|
15
|
+
this._mark = mark;
|
|
16
|
+
}
|
|
17
|
+
async setup() {
|
|
18
|
+
const { Chart } = await import('qvac-charts');
|
|
19
|
+
return { tools: [createChartTool({ chart: Chart, theme: this._theme, mark: this._mark })] };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HarnessPlugin, PluginSetup } from '../../lib/plugins/index.ts';
|
|
2
|
+
export interface CodingGuardsOptions {
|
|
3
|
+
sameWrite?: boolean | string;
|
|
4
|
+
promptNote?: boolean | string;
|
|
5
|
+
noRunner?: boolean | string;
|
|
6
|
+
}
|
|
7
|
+
export declare const SAME_WRITE: string;
|
|
8
|
+
export declare const PROMPT_NOTE: string;
|
|
9
|
+
export declare const NO_RUNNER: string;
|
|
10
|
+
export declare class CodingGuards implements HarnessPlugin {
|
|
11
|
+
readonly name = "coding-guards";
|
|
12
|
+
readonly api = 1;
|
|
13
|
+
private readonly _sameWrite;
|
|
14
|
+
private readonly _promptNote;
|
|
15
|
+
private readonly _noRunner;
|
|
16
|
+
private readonly _written;
|
|
17
|
+
constructor(options?: CodingGuardsOptions);
|
|
18
|
+
setup(): PluginSetup;
|
|
19
|
+
private readonly _prompt;
|
|
20
|
+
private _run;
|
|
21
|
+
private _pre;
|
|
22
|
+
private readonly _post;
|
|
23
|
+
private readonly _failure;
|
|
24
|
+
private readonly _end;
|
|
25
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { isRecord } from '../../lib/guards.js';
|
|
3
|
+
import { PluginRegistry } from '../../lib/plugins/index.js';
|
|
4
|
+
export const SAME_WRITE = 'This run already wrote exactly this content to {path}, so this call would repeat that write. ' +
|
|
5
|
+
'Work out what is still wrong from the task or the errors, then change that.';
|
|
6
|
+
export const PROMPT_NOTE = 'If this message reports failing tests or errors, first write one line per failure: the ' +
|
|
7
|
+
'test, what it expected, what the code did, and why. Then fix the causes, not each symptom.';
|
|
8
|
+
export const NO_RUNNER = 'Nothing can be built, compiled, run or tested in this session. Check your work by reasoning ' +
|
|
9
|
+
'from the code and the task.';
|
|
10
|
+
const CHANGES = new Set([
|
|
11
|
+
'edit_file',
|
|
12
|
+
'insert_text',
|
|
13
|
+
'edit_many',
|
|
14
|
+
'move_file',
|
|
15
|
+
'trash_file',
|
|
16
|
+
'copy_file',
|
|
17
|
+
'shell',
|
|
18
|
+
'exec'
|
|
19
|
+
]);
|
|
20
|
+
export class CodingGuards {
|
|
21
|
+
name = 'coding-guards';
|
|
22
|
+
api = PluginRegistry.API_VERSION;
|
|
23
|
+
_sameWrite;
|
|
24
|
+
_promptNote;
|
|
25
|
+
_noRunner;
|
|
26
|
+
_written = new Map();
|
|
27
|
+
constructor(options = {}) {
|
|
28
|
+
this._sameWrite = wording(options.sameWrite, SAME_WRITE);
|
|
29
|
+
this._promptNote = wording(options.promptNote, PROMPT_NOTE);
|
|
30
|
+
this._noRunner = wording(options.noRunner, NO_RUNNER);
|
|
31
|
+
}
|
|
32
|
+
setup() {
|
|
33
|
+
const hooks = [];
|
|
34
|
+
if (this._sameWrite) {
|
|
35
|
+
const refusal = this._sameWrite;
|
|
36
|
+
hooks.push({
|
|
37
|
+
name: 'coding-guards',
|
|
38
|
+
phase: 'preToolCall',
|
|
39
|
+
matcher: 'write_file',
|
|
40
|
+
run: (ctx) => this._pre(ctx, refusal)
|
|
41
|
+
}, { name: 'coding-guards', phase: 'postToolCall', run: this._post }, { name: 'coding-guards', phase: 'toolFailure', run: this._failure }, { name: 'coding-guards', phase: 'runEnd', run: this._end });
|
|
42
|
+
}
|
|
43
|
+
if (this._promptNote || this._noRunner) {
|
|
44
|
+
hooks.push({ name: 'coding-guards', phase: 'promptSubmit', run: this._prompt });
|
|
45
|
+
}
|
|
46
|
+
return { hooks };
|
|
47
|
+
}
|
|
48
|
+
_prompt = (ctx) => {
|
|
49
|
+
if (ctx.phase !== 'promptSubmit' || ctx.mode !== 'prompt')
|
|
50
|
+
return;
|
|
51
|
+
const notes = [this._noRunner, this._promptNote].filter((note) => note !== null);
|
|
52
|
+
return { context: notes.join('\n\n') };
|
|
53
|
+
};
|
|
54
|
+
_run(runId) {
|
|
55
|
+
let written = this._written.get(runId);
|
|
56
|
+
if (!written) {
|
|
57
|
+
written = new Map();
|
|
58
|
+
this._written.set(runId, written);
|
|
59
|
+
}
|
|
60
|
+
return written;
|
|
61
|
+
}
|
|
62
|
+
_pre(ctx, refusal) {
|
|
63
|
+
if (ctx.phase !== 'preToolCall')
|
|
64
|
+
return;
|
|
65
|
+
const { path, content } = writeArgs(ctx);
|
|
66
|
+
if (path !== null && this._run(ctx.runId).get(clean(path)) === content) {
|
|
67
|
+
return refuse(refusal, path);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
_post = (ctx) => {
|
|
71
|
+
if (ctx.phase !== 'postToolCall')
|
|
72
|
+
return;
|
|
73
|
+
const written = this._run(ctx.runId);
|
|
74
|
+
if (!succeeded(ctx)) {
|
|
75
|
+
if (ctx.toolName === 'write_file' || CHANGES.has(ctx.toolName)) {
|
|
76
|
+
written.clear();
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (ctx.toolName === 'write_file') {
|
|
81
|
+
const { path, content } = writeArgs(ctx);
|
|
82
|
+
if (path !== null) {
|
|
83
|
+
written.set(clean(path), content);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else if (CHANGES.has(ctx.toolName)) {
|
|
87
|
+
written.clear();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
_failure = (ctx) => {
|
|
91
|
+
if (ctx.phase !== 'toolFailure' || !ctx.executed)
|
|
92
|
+
return;
|
|
93
|
+
if (ctx.toolName === 'write_file' || CHANGES.has(ctx.toolName)) {
|
|
94
|
+
this._run(ctx.runId).clear();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
_end = (ctx) => {
|
|
98
|
+
this._written.delete(ctx.runId);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function clean(requested) {
|
|
102
|
+
if (requested.startsWith('hyper://')) {
|
|
103
|
+
return `hyper:${requested}`;
|
|
104
|
+
}
|
|
105
|
+
const normalized = path.normalize(requested);
|
|
106
|
+
return `${path.isAbsolute(requested) ? 'absolute' : 'relative'}:${normalized}`;
|
|
107
|
+
}
|
|
108
|
+
function wording(option, text) {
|
|
109
|
+
if (!option)
|
|
110
|
+
return null;
|
|
111
|
+
return option === true ? text : option;
|
|
112
|
+
}
|
|
113
|
+
function refuse(text, path) {
|
|
114
|
+
return { kind: 'hook-rejection', error: text.replaceAll('{path}', path), guidance: true };
|
|
115
|
+
}
|
|
116
|
+
function writeArgs(ctx) {
|
|
117
|
+
const { path, content } = ctx.args;
|
|
118
|
+
return typeof path === 'string' && typeof content === 'string'
|
|
119
|
+
? { path, content }
|
|
120
|
+
: { path: null, content: '' };
|
|
121
|
+
}
|
|
122
|
+
function succeeded(ctx) {
|
|
123
|
+
return (ctx.executed &&
|
|
124
|
+
ctx.outcome?.kind === 'success' &&
|
|
125
|
+
!(isRecord(ctx.result) && 'error' in ctx.result));
|
|
126
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../../lib/contract/index.ts';
|
|
2
|
+
type DrawResult = {
|
|
3
|
+
content: string;
|
|
4
|
+
answer: true;
|
|
5
|
+
} | {
|
|
6
|
+
error: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function drawDiagram(args: Record<string, unknown>, userTurns?: readonly string[]): DrawResult;
|
|
9
|
+
export declare const drawDiagramTool: ToolDefinition;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { DIAGRAM_TYPES, renderMermaid, sliceValue } from './render.js';
|
|
2
|
+
function isType(value) {
|
|
3
|
+
return DIAGRAM_TYPES.some((type) => type === value);
|
|
4
|
+
}
|
|
5
|
+
function stringOr(value) {
|
|
6
|
+
return typeof value === 'string' ? value : undefined;
|
|
7
|
+
}
|
|
8
|
+
function linksOf(raw) {
|
|
9
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
10
|
+
return 'links must be a non-empty list of {"from", "to", "label"}';
|
|
11
|
+
}
|
|
12
|
+
const links = [];
|
|
13
|
+
for (const item of raw) {
|
|
14
|
+
const from = stringOr(item?.from)?.trim();
|
|
15
|
+
if (!from) {
|
|
16
|
+
return 'every link needs a "from" name';
|
|
17
|
+
}
|
|
18
|
+
links.push({ from, to: stringOr(item.to), label: stringOr(item.label) });
|
|
19
|
+
}
|
|
20
|
+
return links;
|
|
21
|
+
}
|
|
22
|
+
const HORIZONTAL_ASK = /horizontal|orizzontal|left[\s-]*to[\s-]*right|sideways|landscape|\bLR\b/i;
|
|
23
|
+
function askedHorizontal(userTurns) {
|
|
24
|
+
return userTurns === undefined || userTurns.some((turn) => HORIZONTAL_ASK.test(turn));
|
|
25
|
+
}
|
|
26
|
+
export function drawDiagram(args, userTurns) {
|
|
27
|
+
if (!isType(args.type)) {
|
|
28
|
+
return { error: `type must be one of ${DIAGRAM_TYPES.join(', ')}` };
|
|
29
|
+
}
|
|
30
|
+
const links = linksOf(args.links);
|
|
31
|
+
if (typeof links === 'string') {
|
|
32
|
+
return { error: links };
|
|
33
|
+
}
|
|
34
|
+
if (args.type === 'pie' && !links.some((link) => sliceValue(link) !== undefined)) {
|
|
35
|
+
return { error: 'every pie slice needs its number: {"from": "Rent", "to": "40"}' };
|
|
36
|
+
}
|
|
37
|
+
const direction = args.direction === 'horizontal' && askedHorizontal(userTurns) ? 'horizontal' : 'vertical';
|
|
38
|
+
const code = renderMermaid({ type: args.type, direction, links });
|
|
39
|
+
const caption = stringOr(args.caption)?.trim();
|
|
40
|
+
return {
|
|
41
|
+
content: `\`\`\`mermaid\n${code}\n\`\`\`${caption ? `\n\n${caption}` : ''}\n`,
|
|
42
|
+
answer: true
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export const drawDiagramTool = {
|
|
46
|
+
name: 'draw_diagram',
|
|
47
|
+
toolset: 'diagrams',
|
|
48
|
+
group: 'diagrams',
|
|
49
|
+
skillGated: true,
|
|
50
|
+
autoApprove: true,
|
|
51
|
+
description: 'Draw any diagram in the chat. Give its type and its links; the app renders the picture. ' +
|
|
52
|
+
'Every box, step, date or slice is a name; every arrow or entry is one link.',
|
|
53
|
+
parameters: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
properties: {
|
|
56
|
+
type: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
enum: [...DIAGRAM_TYPES],
|
|
59
|
+
description: 'flowchart: steps or parts and arrows. sequence: who calls whom, in order. ' +
|
|
60
|
+
'state: modes and the events between them. mindmap: an idea tree from one root. ' +
|
|
61
|
+
'er: tables, from a table to a table it owns. class: from a parent class to a child. ' +
|
|
62
|
+
'timeline: from a date to what happened. gantt: from a task to its length, like "5d". ' +
|
|
63
|
+
'pie: from a slice to its number.'
|
|
64
|
+
},
|
|
65
|
+
direction: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
enum: ['vertical', 'horizontal'],
|
|
68
|
+
description: 'Only when the user asks: "horizontal" for horizontal, left to right, or sideways; ' +
|
|
69
|
+
'"vertical" for top to bottom. Leave it out otherwise.'
|
|
70
|
+
},
|
|
71
|
+
links: {
|
|
72
|
+
type: 'array',
|
|
73
|
+
description: 'One entry per arrow, in order. A name ending in ? is a decision.',
|
|
74
|
+
items: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
from: { type: 'string' },
|
|
78
|
+
to: { type: 'string' },
|
|
79
|
+
label: { type: 'string', description: 'the text on the arrow, any characters' }
|
|
80
|
+
},
|
|
81
|
+
required: ['from', 'to']
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
caption: { type: 'string', description: 'One sentence saying what the diagram shows' }
|
|
85
|
+
},
|
|
86
|
+
required: ['type', 'links']
|
|
87
|
+
},
|
|
88
|
+
effect: () => 'read',
|
|
89
|
+
execute: async (args, context) => drawDiagram(args, context?.userTurns)
|
|
90
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HarnessPlugin, PluginSetup } from '../../lib/plugins/index.ts';
|
|
2
|
+
export { drawDiagram, drawDiagramTool } from './draw.ts';
|
|
3
|
+
export { renderMermaid } from './render.ts';
|
|
4
|
+
export interface DiagramsOptions {
|
|
5
|
+
readonly read?: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export declare class Diagrams implements HarnessPlugin {
|
|
8
|
+
readonly name = "diagrams";
|
|
9
|
+
readonly api = 1;
|
|
10
|
+
readonly read: readonly string[] | undefined;
|
|
11
|
+
constructor({ read }?: DiagramsOptions);
|
|
12
|
+
setup(): PluginSetup;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PluginRegistry } from '../../lib/plugins/index.js';
|
|
2
|
+
import { drawDiagramTool } from './draw.js';
|
|
3
|
+
export { drawDiagram, drawDiagramTool } from './draw.js';
|
|
4
|
+
export { renderMermaid } from './render.js';
|
|
5
|
+
export class Diagrams {
|
|
6
|
+
name = 'diagrams';
|
|
7
|
+
api = PluginRegistry.API_VERSION;
|
|
8
|
+
read;
|
|
9
|
+
constructor({ read } = {}) {
|
|
10
|
+
this.read = read;
|
|
11
|
+
}
|
|
12
|
+
setup() {
|
|
13
|
+
return { tools: [drawDiagramTool] };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const DIAGRAM_TYPES: readonly ['flowchart', 'sequence', 'state', 'mindmap', 'er', 'class', 'timeline', 'gantt', 'pie'];
|
|
2
|
+
export type DiagramType = (typeof DIAGRAM_TYPES)[number];
|
|
3
|
+
export type Direction = 'vertical' | 'horizontal';
|
|
4
|
+
export interface Link {
|
|
5
|
+
readonly from: string;
|
|
6
|
+
readonly to?: string | undefined;
|
|
7
|
+
readonly label?: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface DiagramSpec {
|
|
10
|
+
readonly type: DiagramType;
|
|
11
|
+
readonly direction: Direction;
|
|
12
|
+
readonly links: readonly Link[];
|
|
13
|
+
readonly today?: Date | undefined;
|
|
14
|
+
}
|
|
15
|
+
export declare function sliceValue(link: Link): number | undefined;
|
|
16
|
+
export declare function renderMermaid({ type, direction, links, today }: DiagramSpec): string;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
export const DIAGRAM_TYPES = [
|
|
2
|
+
'flowchart',
|
|
3
|
+
'sequence',
|
|
4
|
+
'state',
|
|
5
|
+
'mindmap',
|
|
6
|
+
'er',
|
|
7
|
+
'class',
|
|
8
|
+
'timeline',
|
|
9
|
+
'gantt',
|
|
10
|
+
'pie'
|
|
11
|
+
];
|
|
12
|
+
const LABEL_LIMIT = 80;
|
|
13
|
+
function text(raw) {
|
|
14
|
+
const flat = (raw ?? '').replace(/\s+/g, ' ').trim();
|
|
15
|
+
const bounded = flat.length > LABEL_LIMIT ? `${flat.slice(0, LABEL_LIMIT - 1)}…` : flat;
|
|
16
|
+
return bounded.replace(/"/g, "'").replace(/#/g, '#');
|
|
17
|
+
}
|
|
18
|
+
function key(name) {
|
|
19
|
+
return name.replace(/\s+/g, ' ').trim().toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
class Ids {
|
|
22
|
+
_ids = new Map();
|
|
23
|
+
_prefix;
|
|
24
|
+
names = [];
|
|
25
|
+
constructor(prefix) {
|
|
26
|
+
this._prefix = prefix;
|
|
27
|
+
}
|
|
28
|
+
has(name) {
|
|
29
|
+
return this._ids.has(key(name));
|
|
30
|
+
}
|
|
31
|
+
of(name) {
|
|
32
|
+
const k = key(name);
|
|
33
|
+
let id = this._ids.get(k);
|
|
34
|
+
if (id === undefined) {
|
|
35
|
+
id = `${this._prefix}${this._ids.size + 1}`;
|
|
36
|
+
this._ids.set(k, id);
|
|
37
|
+
this.names.push(name);
|
|
38
|
+
}
|
|
39
|
+
return id;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function present(name) {
|
|
43
|
+
return name !== undefined && key(name).length > 0;
|
|
44
|
+
}
|
|
45
|
+
function flowchart(links, direction, { numbered = false } = {}) {
|
|
46
|
+
const ids = new Ids('n');
|
|
47
|
+
const lines = [`flowchart ${direction === 'horizontal' ? 'LR' : 'TD'}`];
|
|
48
|
+
const node = (name) => {
|
|
49
|
+
const seen = ids.has(name);
|
|
50
|
+
const id = ids.of(name);
|
|
51
|
+
if (seen) {
|
|
52
|
+
return id;
|
|
53
|
+
}
|
|
54
|
+
const label = text(name);
|
|
55
|
+
return name.trim().endsWith('?') ? `${id}{"${label}"}` : `${id}["${label}"]`;
|
|
56
|
+
};
|
|
57
|
+
links.forEach((link, at) => {
|
|
58
|
+
const from = node(link.from);
|
|
59
|
+
const target = present(link.to) || !numbered ? link.to : link.from;
|
|
60
|
+
if (!present(target)) {
|
|
61
|
+
lines.push(` ${from}`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const to = node(target);
|
|
65
|
+
const label = numbered ? `${at + 1}. ${link.label ?? ''}`.trim() : (link.label ?? '');
|
|
66
|
+
lines.push(present(label) ? ` ${from} -->|"${text(label)}"| ${to}` : ` ${from} --> ${to}`);
|
|
67
|
+
});
|
|
68
|
+
return lines;
|
|
69
|
+
}
|
|
70
|
+
function sequence(links) {
|
|
71
|
+
const ids = new Ids('p');
|
|
72
|
+
for (const link of links) {
|
|
73
|
+
ids.of(link.from);
|
|
74
|
+
if (present(link.to)) {
|
|
75
|
+
ids.of(link.to);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const lines = [
|
|
79
|
+
'sequenceDiagram',
|
|
80
|
+
...ids.names.map((name) => ` participant ${ids.of(name)} as ${text(name).replace(/;/g, ',')}`)
|
|
81
|
+
];
|
|
82
|
+
const calls = new Set();
|
|
83
|
+
for (const link of links) {
|
|
84
|
+
const from = ids.of(link.from);
|
|
85
|
+
const to = present(link.to) ? ids.of(link.to) : from;
|
|
86
|
+
const arrow = calls.has(`${to}>${from}`) ? '-->>' : '->>';
|
|
87
|
+
calls.add(`${from}>${to}`);
|
|
88
|
+
lines.push(` ${from}${arrow}${to}: ${text(link.label).replace(/;/g, ',') || ' '}`);
|
|
89
|
+
}
|
|
90
|
+
return lines;
|
|
91
|
+
}
|
|
92
|
+
const TERMINAL = new Set(['[*]', 'start', 'end']);
|
|
93
|
+
function state(links, direction) {
|
|
94
|
+
const ids = new Ids('s');
|
|
95
|
+
const lines = ['stateDiagram-v2'];
|
|
96
|
+
if (direction === 'horizontal') {
|
|
97
|
+
lines.push(' direction LR');
|
|
98
|
+
}
|
|
99
|
+
const ref = (name) => {
|
|
100
|
+
if (TERMINAL.has(key(name))) {
|
|
101
|
+
return '[*]';
|
|
102
|
+
}
|
|
103
|
+
const seen = ids.has(name);
|
|
104
|
+
const id = ids.of(name);
|
|
105
|
+
if (!seen) {
|
|
106
|
+
lines.push(` state "${text(name)}" as ${id}`);
|
|
107
|
+
}
|
|
108
|
+
return id;
|
|
109
|
+
};
|
|
110
|
+
for (const link of links) {
|
|
111
|
+
const from = ref(link.from);
|
|
112
|
+
if (!present(link.to)) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const to = ref(link.to);
|
|
116
|
+
const label = item(link.label);
|
|
117
|
+
lines.push(label ? ` ${from} --> ${to} : ${label}` : ` ${from} --> ${to}`);
|
|
118
|
+
}
|
|
119
|
+
return lines;
|
|
120
|
+
}
|
|
121
|
+
function mindmap(links) {
|
|
122
|
+
const children = new Map();
|
|
123
|
+
const names = new Map();
|
|
124
|
+
const targets = new Set();
|
|
125
|
+
for (const link of links) {
|
|
126
|
+
names.set(key(link.from), names.get(key(link.from)) ?? link.from);
|
|
127
|
+
if (!present(link.to)) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
names.set(key(link.to), names.get(key(link.to)) ?? link.to);
|
|
131
|
+
targets.add(key(link.to));
|
|
132
|
+
const list = children.get(key(link.from)) ?? [];
|
|
133
|
+
if (!list.includes(key(link.to))) {
|
|
134
|
+
list.push(key(link.to));
|
|
135
|
+
}
|
|
136
|
+
children.set(key(link.from), list);
|
|
137
|
+
}
|
|
138
|
+
const order = [...names.keys()];
|
|
139
|
+
const root = order.find((k) => !targets.has(k)) ?? order[0];
|
|
140
|
+
const lines = ['mindmap'];
|
|
141
|
+
const placed = new Set();
|
|
142
|
+
let count = 0;
|
|
143
|
+
const place = (k, depth) => {
|
|
144
|
+
if (placed.has(k)) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
placed.add(k);
|
|
148
|
+
count++;
|
|
149
|
+
lines.push(`${' '.repeat(depth + 1)}m${count}["${text(names.get(k))}"]`);
|
|
150
|
+
for (const child of children.get(k) ?? []) {
|
|
151
|
+
place(child, depth + 1);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
if (root !== undefined) {
|
|
155
|
+
place(root, 0);
|
|
156
|
+
}
|
|
157
|
+
for (const k of order) {
|
|
158
|
+
place(k, 1);
|
|
159
|
+
}
|
|
160
|
+
return lines;
|
|
161
|
+
}
|
|
162
|
+
function er(links) {
|
|
163
|
+
const ids = new Ids('e');
|
|
164
|
+
const declared = [];
|
|
165
|
+
const relations = [];
|
|
166
|
+
const ref = (name) => {
|
|
167
|
+
const seen = ids.has(name);
|
|
168
|
+
const id = ids.of(name);
|
|
169
|
+
if (!seen) {
|
|
170
|
+
declared.push(` ${id}["${text(name).replace(/\\/g, '/').replace(/%/g, '%')}"]`);
|
|
171
|
+
}
|
|
172
|
+
return id;
|
|
173
|
+
};
|
|
174
|
+
for (const link of links) {
|
|
175
|
+
const from = ref(link.from);
|
|
176
|
+
if (present(link.to)) {
|
|
177
|
+
relations.push(` ${from} ||--o{ ${ref(link.to)} : "${text(link.label) || 'has'}"`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return ['erDiagram', ...declared, ...relations];
|
|
181
|
+
}
|
|
182
|
+
function classes(links) {
|
|
183
|
+
const ids = new Ids('c');
|
|
184
|
+
const declared = [];
|
|
185
|
+
const relations = [];
|
|
186
|
+
const ref = (name) => {
|
|
187
|
+
const seen = ids.has(name);
|
|
188
|
+
const id = ids.of(name);
|
|
189
|
+
if (!seen) {
|
|
190
|
+
declared.push(` class ${id}["${text(name)}"]`);
|
|
191
|
+
}
|
|
192
|
+
return id;
|
|
193
|
+
};
|
|
194
|
+
for (const link of links) {
|
|
195
|
+
const parent = ref(link.from);
|
|
196
|
+
if (present(link.to)) {
|
|
197
|
+
const label = item(link.label).replace(/\{/g, '(').replace(/\}/g, ')').replace(/\\/g, '/');
|
|
198
|
+
relations.push(` ${parent} <|-- ${ref(link.to)}${label ? ` : ${label}` : ''}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return ['classDiagram', ...declared, ...relations];
|
|
202
|
+
}
|
|
203
|
+
function item(raw) {
|
|
204
|
+
return text(raw).replace(/:/g, '꞉').replace(/;/g, ',');
|
|
205
|
+
}
|
|
206
|
+
const GANTT_KEYWORD = /^(click|section|title|dateformat|axisformat|tickinterval|excludes|includes|todaymarker|weekday|weekend|inclusiveenddates|topaxis|displaymode|acctitle|accdescr)\b/i;
|
|
207
|
+
function task(raw) {
|
|
208
|
+
const name = item(raw);
|
|
209
|
+
return GANTT_KEYWORD.test(name) ? `‣ ${name}` : name;
|
|
210
|
+
}
|
|
211
|
+
function timeline(links) {
|
|
212
|
+
const periods = new Map();
|
|
213
|
+
for (const link of links) {
|
|
214
|
+
const period = periods.get(key(link.from)) ?? { name: link.from, events: [] };
|
|
215
|
+
const event = present(link.to) ? link.to : link.label;
|
|
216
|
+
if (present(event)) {
|
|
217
|
+
period.events.push(item(event));
|
|
218
|
+
}
|
|
219
|
+
periods.set(key(link.from), period);
|
|
220
|
+
}
|
|
221
|
+
return [
|
|
222
|
+
'timeline',
|
|
223
|
+
...[...periods.values()].map(({ name, events }) => [` ${item(name)}`, ...events].join(' : '))
|
|
224
|
+
];
|
|
225
|
+
}
|
|
226
|
+
function days(raw) {
|
|
227
|
+
const match = /(\d+(?:\.\d+)?)\s*(d|days?|w|weeks?)?(?![a-z])/i.exec((raw ?? '').slice(0, LABEL_LIMIT));
|
|
228
|
+
if (!match) {
|
|
229
|
+
return 1;
|
|
230
|
+
}
|
|
231
|
+
const perUnit = match[2]?.toLowerCase().startsWith('w') ? 7 : 1;
|
|
232
|
+
return Math.max(1, Math.round(Number(match[1]) * perUnit));
|
|
233
|
+
}
|
|
234
|
+
function gantt(links, today) {
|
|
235
|
+
const start = today.toISOString().slice(0, 10);
|
|
236
|
+
const lines = ['gantt', ' dateFormat YYYY-MM-DD'];
|
|
237
|
+
let section;
|
|
238
|
+
links.forEach((link, at) => {
|
|
239
|
+
if (present(link.label) && link.label !== section) {
|
|
240
|
+
section = link.label;
|
|
241
|
+
lines.push(` section ${task(section)}`);
|
|
242
|
+
}
|
|
243
|
+
const when = at === 0 ? start : `after t${at}`;
|
|
244
|
+
lines.push(` ${task(link.from)} :t${at + 1}, ${when}, ${days(link.to)}d`);
|
|
245
|
+
});
|
|
246
|
+
return lines;
|
|
247
|
+
}
|
|
248
|
+
export function sliceValue(link) {
|
|
249
|
+
const match = /-?\d+(?:\.\d+)?/.exec(`${link.to ?? ''} ${link.label ?? ''}`);
|
|
250
|
+
const value = match ? Number(match[0]) : Number.NaN;
|
|
251
|
+
return value > 0 ? value : undefined;
|
|
252
|
+
}
|
|
253
|
+
function pie(links) {
|
|
254
|
+
return [
|
|
255
|
+
'pie',
|
|
256
|
+
...links.flatMap((link) => {
|
|
257
|
+
const value = sliceValue(link);
|
|
258
|
+
return value === undefined ? [] : [` "${text(link.from)}" : ${value}`];
|
|
259
|
+
})
|
|
260
|
+
];
|
|
261
|
+
}
|
|
262
|
+
export function renderMermaid({ type, direction, links, today }) {
|
|
263
|
+
switch (type) {
|
|
264
|
+
case 'flowchart':
|
|
265
|
+
return flowchart(links, direction).join('\n');
|
|
266
|
+
case 'sequence':
|
|
267
|
+
return (direction === 'horizontal'
|
|
268
|
+
? flowchart(links, direction, { numbered: true })
|
|
269
|
+
: sequence(links)).join('\n');
|
|
270
|
+
case 'state':
|
|
271
|
+
return state(links, direction).join('\n');
|
|
272
|
+
case 'mindmap':
|
|
273
|
+
return mindmap(links).join('\n');
|
|
274
|
+
case 'er':
|
|
275
|
+
return er(links).join('\n');
|
|
276
|
+
case 'class':
|
|
277
|
+
return classes(links).join('\n');
|
|
278
|
+
case 'timeline':
|
|
279
|
+
return timeline(links).join('\n');
|
|
280
|
+
case 'gantt':
|
|
281
|
+
return gantt(links, today ?? new Date()).join('\n');
|
|
282
|
+
case 'pie':
|
|
283
|
+
return pie(links).join('\n');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
import type { ToolDefinition } from '../../lib/contract/index.ts';
|
|
2
2
|
import type { ImageClamps } from '../../lib/models/model-catalog.ts';
|
|
3
3
|
import { type DiffusionRuntime } from './generate-image.ts';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
height: number;
|
|
7
|
-
data: Uint8Array;
|
|
8
|
-
frames?: Rgba[];
|
|
9
|
-
}
|
|
10
|
-
interface Media {
|
|
11
|
-
image: {
|
|
12
|
-
decode(input: Uint8Array, opts?: {
|
|
13
|
-
maxFrames?: number;
|
|
14
|
-
}): Promise<Rgba>;
|
|
15
|
-
encode(rgba: Rgba, opts: {
|
|
16
|
-
mimetype: string;
|
|
17
|
-
}): Promise<Uint8Array>;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export interface EditImageDeps {
|
|
21
|
-
loadMedia?: () => Promise<Media | null>;
|
|
22
|
-
resample?: (rgba: Rgba, width: number, height: number) => Rgba | Promise<Rgba>;
|
|
23
|
-
}
|
|
4
|
+
import { type FitDeps } from './fit.ts';
|
|
5
|
+
export type EditImageDeps = FitDeps;
|
|
24
6
|
export declare function loadMediaCodecs(): Promise<void>;
|
|
25
|
-
export declare function createEditImageTool(runtime: DiffusionRuntime,
|
|
26
|
-
export {};
|
|
7
|
+
export declare function createEditImageTool(runtime: DiffusionRuntime, deps?: EditImageDeps, clamps?: ImageClamps): ToolDefinition;
|