@qvac/harness 1.0.0-rc.9 → 1.0.1
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 +701 -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/shell-guidance.d.ts +2 -0
- package/dist-lib/lib/tools/exec/shell-guidance.js +29 -0
- package/dist-lib/lib/tools/exec.js +4 -2
- 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 +93 -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/tls-failure.d.ts +1 -0
- package/dist-lib/lib/tools/tls-failure.js +8 -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 +46 -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
|
@@ -17,6 +17,8 @@ declare const OperationSchema: z.ZodObject<{
|
|
|
17
17
|
url: z.ZodString;
|
|
18
18
|
builder: z.ZodEnum<{
|
|
19
19
|
"calendar-add-meet": "calendar-add-meet";
|
|
20
|
+
"calendar-list-calendars": "calendar-list-calendars";
|
|
21
|
+
"calendar-list-events": "calendar-list-events";
|
|
20
22
|
"calendar-meet-event": "calendar-meet-event";
|
|
21
23
|
"docs-append-text": "docs-append-text";
|
|
22
24
|
"docs-create": "docs-create";
|
|
@@ -45,6 +47,8 @@ declare const OperationSchema: z.ZodObject<{
|
|
|
45
47
|
urlDefaults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
46
48
|
builder: z.ZodEnum<{
|
|
47
49
|
"calendar-add-meet": "calendar-add-meet";
|
|
50
|
+
"calendar-list-calendars": "calendar-list-calendars";
|
|
51
|
+
"calendar-list-events": "calendar-list-events";
|
|
48
52
|
"calendar-meet-event": "calendar-meet-event";
|
|
49
53
|
"docs-append-text": "docs-append-text";
|
|
50
54
|
"docs-create": "docs-create";
|
|
@@ -7,15 +7,20 @@ export interface Source {
|
|
|
7
7
|
readonly fileName: string;
|
|
8
8
|
readonly bytes: Uint8Array;
|
|
9
9
|
}
|
|
10
|
+
export interface Recognized {
|
|
11
|
+
readonly pages: ReadonlyMap<number, string>;
|
|
12
|
+
readonly unreadFrom: number | null;
|
|
13
|
+
}
|
|
10
14
|
export interface Opened {
|
|
11
15
|
readonly source: Source;
|
|
12
16
|
readonly doc: Doc;
|
|
17
|
+
readonly recognized?: Recognized | undefined;
|
|
13
18
|
}
|
|
14
19
|
export interface Built {
|
|
15
20
|
readonly bytes: Uint8Array;
|
|
16
21
|
readonly pageCount: number;
|
|
17
22
|
}
|
|
18
|
-
|
|
23
|
+
interface ReadField {
|
|
19
24
|
readonly name: string;
|
|
20
25
|
readonly type: string;
|
|
21
26
|
readonly value: Field['value'];
|
|
@@ -34,12 +39,17 @@ export interface ReadDocument {
|
|
|
34
39
|
readonly note: string | undefined;
|
|
35
40
|
readonly truncated: true | undefined;
|
|
36
41
|
}
|
|
37
|
-
|
|
42
|
+
interface ReadDocuments {
|
|
38
43
|
readonly documents: readonly ReadDocument[];
|
|
39
44
|
}
|
|
45
|
+
export interface ReadBudget {
|
|
46
|
+
chars: number;
|
|
47
|
+
}
|
|
48
|
+
export declare const READ_TEXT_LIMIT = 30000;
|
|
49
|
+
export declare function cleanText(text: string): string;
|
|
40
50
|
export declare function pagesLabel(count: number): string;
|
|
41
51
|
export type ShownPage = (fileName: string, page: number) => boolean;
|
|
42
|
-
export declare function textless(
|
|
52
|
+
export declare function textless(opened: Opened): boolean;
|
|
43
53
|
export declare function everyPageShown({ source, doc }: Opened, isShown: ShownPage): boolean;
|
|
44
54
|
export declare function shownNote({ source, doc }: Opened): string;
|
|
45
55
|
export declare function readDocs(opened: readonly Opened[], isShown: ShownPage): ReadDocument | ReadDocuments;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
const READ_TEXT_LIMIT = 30_000;
|
|
2
|
+
export const READ_TEXT_LIMIT = 30_000;
|
|
3
|
+
export function cleanText(text) {
|
|
4
|
+
return text.replace(/\r\n?/g, '\n').trim();
|
|
5
|
+
}
|
|
3
6
|
function plural(count, noun) {
|
|
4
7
|
return `${count} ${noun}${count === 1 ? '' : 's'}`;
|
|
5
8
|
}
|
|
@@ -30,16 +33,39 @@ const SHOWN = {
|
|
|
30
33
|
one: 'shown to you as an image in the user message, so read its content from that image',
|
|
31
34
|
many: 'shown to you as images in the user message, so read their content from those images'
|
|
32
35
|
};
|
|
33
|
-
function scannedNote(scanned, shown) {
|
|
36
|
+
function scannedNote(scanned, { shown, blank }) {
|
|
34
37
|
if (!scanned.length)
|
|
35
38
|
return undefined;
|
|
36
39
|
const one = scanned.length === 1;
|
|
37
40
|
const what = one ? 'it is a scanned image' : 'they are scanned images';
|
|
38
|
-
|
|
41
|
+
let where = 'and there is no OCR here';
|
|
42
|
+
if (shown) {
|
|
43
|
+
where = SHOWN[one ? 'one' : 'many'];
|
|
44
|
+
}
|
|
45
|
+
else if (blank) {
|
|
46
|
+
where = `and OCR found no text on ${one ? 'it' : 'them'}`;
|
|
47
|
+
}
|
|
39
48
|
return `${one ? 'page' : 'pages'} ${scanned.join(', ')} ${one ? 'has' : 'have'} no text layer: ${what}, ${where}`;
|
|
40
49
|
}
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
function recognizedNote(pages) {
|
|
51
|
+
if (!pages.length)
|
|
52
|
+
return undefined;
|
|
53
|
+
const one = pages.length === 1;
|
|
54
|
+
const what = one ? 'is a scanned image' : 'are scanned images';
|
|
55
|
+
return `${one ? 'page' : 'pages'} ${pages.join(', ')} ${what}, read here by OCR, so a word may be misread`;
|
|
56
|
+
}
|
|
57
|
+
function readNote(fileName, { read, scanned, blank }, isShown) {
|
|
58
|
+
const shown = scanned.every((page) => isShown(fileName, page));
|
|
59
|
+
const notes = [recognizedNote(read), scannedNote(scanned, { shown, blank })].filter((note) => note !== undefined);
|
|
60
|
+
return notes.length ? notes.join('; ') : undefined;
|
|
61
|
+
}
|
|
62
|
+
function* pageTexts({ doc, recognized }) {
|
|
63
|
+
for (const { page, text } of doc.textPages()) {
|
|
64
|
+
yield { page, text: recognized?.pages.get(page) ?? text };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function textless(opened) {
|
|
68
|
+
for (const page of pageTexts(opened)) {
|
|
43
69
|
if (page.text.trim())
|
|
44
70
|
return false;
|
|
45
71
|
}
|
|
@@ -57,29 +83,37 @@ export function shownNote({ source, doc }) {
|
|
|
57
83
|
const what = one ? 'it is a scanned image' : 'its pages are scanned images';
|
|
58
84
|
return `${source.fileName} has no text layer: ${what}, ${SHOWN[one ? 'one' : 'many']}`;
|
|
59
85
|
}
|
|
60
|
-
function readOne(
|
|
86
|
+
function readOne(opened, budget, isShown) {
|
|
87
|
+
const { source, doc, recognized } = opened;
|
|
88
|
+
const unreadFrom = recognized?.unreadFrom ?? Infinity;
|
|
61
89
|
const pages = [];
|
|
90
|
+
const read = [];
|
|
62
91
|
const scanned = [];
|
|
63
92
|
let truncated = false;
|
|
64
|
-
for (const { page, text } of
|
|
65
|
-
const
|
|
66
|
-
|
|
93
|
+
for (const { page, text } of pageTexts(opened)) {
|
|
94
|
+
const unread = page >= unreadFrom;
|
|
95
|
+
const clean = cleanText(text);
|
|
96
|
+
if (!clean && !unread) {
|
|
67
97
|
scanned.push(page + 1);
|
|
68
98
|
}
|
|
69
99
|
const kept = clean.slice(0, Math.max(0, budget.chars));
|
|
70
100
|
budget.chars -= kept.length;
|
|
71
|
-
truncated ||= kept.length < clean.length;
|
|
101
|
+
truncated ||= unread || kept.length < clean.length;
|
|
72
102
|
if (budget.chars > 0 || kept) {
|
|
73
103
|
pages.push({ page: page + 1, text: kept });
|
|
104
|
+
if (kept && recognized?.pages.has(page)) {
|
|
105
|
+
read.push(page + 1);
|
|
106
|
+
}
|
|
74
107
|
}
|
|
75
108
|
}
|
|
109
|
+
const blank = scanned.every((page) => recognized?.pages.has(page - 1));
|
|
76
110
|
return {
|
|
77
111
|
attachmentId: source.attachmentId,
|
|
78
112
|
fileName: source.fileName,
|
|
79
113
|
pageCount: doc.pageCount(),
|
|
80
114
|
pages,
|
|
81
115
|
fields: doc.fields().map(describeField),
|
|
82
|
-
note:
|
|
116
|
+
note: readNote(source.fileName, { read, scanned, blank }, isShown),
|
|
83
117
|
truncated: truncated || undefined
|
|
84
118
|
};
|
|
85
119
|
}
|
|
@@ -104,12 +138,14 @@ function joinPages(pdfium, parts, pages) {
|
|
|
104
138
|
out.close();
|
|
105
139
|
}
|
|
106
140
|
}
|
|
107
|
-
function textFile(
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
.join('\n\n');
|
|
141
|
+
function textFile(opened) {
|
|
142
|
+
const { source, doc } = opened;
|
|
143
|
+
const text = [...pageTexts(opened)].map((page) => cleanText(page.text)).join('\n\n');
|
|
111
144
|
if (!text.trim()) {
|
|
112
|
-
|
|
145
|
+
const why = opened.recognized?.pages.size
|
|
146
|
+
? 'and OCR found no text on them'
|
|
147
|
+
: 'and there is no OCR here';
|
|
148
|
+
return `${source.fileName} has no text layer: its pages are scanned images, ${why}`;
|
|
113
149
|
}
|
|
114
150
|
return { bytes: b4a.from(text + '\n', 'utf8'), pageCount: doc.pageCount() };
|
|
115
151
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
2
|
+
import type { OcrService } from '../../contract/ocr.ts';
|
|
3
|
+
export interface PdfPage {
|
|
4
|
+
readonly page: number;
|
|
5
|
+
readonly text: string;
|
|
6
|
+
readonly unread: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface PdfPagesOptions {
|
|
9
|
+
readonly ocr?: OcrService | undefined;
|
|
10
|
+
readonly signal?: BareAbortSignal | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function pdfPages(bytes: Uint8Array, { ocr, signal }?: PdfPagesOptions): Promise<PdfPage[]>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HarnessError } from '../../errors.js';
|
|
2
|
+
import { cleanText } from './build.js';
|
|
3
|
+
import { recognizePages } from './recognize.js';
|
|
4
|
+
let pdfium = null;
|
|
5
|
+
function loadPdfium() {
|
|
6
|
+
pdfium ??= import('bare-pdfium').then((loaded) => loaded, () => null);
|
|
7
|
+
return pdfium;
|
|
8
|
+
}
|
|
9
|
+
export async function pdfPages(bytes, { ocr, signal } = {}) {
|
|
10
|
+
const lib = await loadPdfium();
|
|
11
|
+
if (!lib) {
|
|
12
|
+
throw new HarnessError('PDF_TEXT_UNAVAILABLE');
|
|
13
|
+
}
|
|
14
|
+
const doc = lib.open(bytes);
|
|
15
|
+
try {
|
|
16
|
+
const recognized = ocr
|
|
17
|
+
? (await recognizePages({ doc, bytes }, { ocr, signal })).pages
|
|
18
|
+
: undefined;
|
|
19
|
+
const pages = [];
|
|
20
|
+
for await (const { page, text } of doc.textPagesAsync()) {
|
|
21
|
+
signal?.throwIfAborted();
|
|
22
|
+
const read = recognized?.get(page) ?? cleanText(text);
|
|
23
|
+
const unread = !read && !recognized?.has(page) && doc.pageFlags(page).hasImage;
|
|
24
|
+
pages.push({ page: page + 1, text: read, unread });
|
|
25
|
+
}
|
|
26
|
+
return pages;
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
doc.close();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
2
|
+
import type { OcrService } from '../../contract/ocr.ts';
|
|
3
|
+
import { type Doc, type ReadBudget, type Recognized } from './build.ts';
|
|
4
|
+
export interface ScannedDocument {
|
|
5
|
+
readonly doc: Doc;
|
|
6
|
+
readonly bytes: Uint8Array;
|
|
7
|
+
}
|
|
8
|
+
export interface RecognizeOptions {
|
|
9
|
+
readonly ocr: OcrService;
|
|
10
|
+
readonly signal?: BareAbortSignal | undefined;
|
|
11
|
+
readonly budget?: ReadBudget | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function recognizePages({ doc, bytes }: ScannedDocument, { ocr, signal, budget }: RecognizeOptions): Promise<Recognized>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import { errorMessage } from '../../guards.js';
|
|
3
|
+
import { RecentMap } from '../../helpers/recent-map.js';
|
|
4
|
+
import { HarnessLog } from '../../log.js';
|
|
5
|
+
import { cleanText } from './build.js';
|
|
6
|
+
const OCR_SCALE = 2;
|
|
7
|
+
const KEPT_DOCUMENTS = 8;
|
|
8
|
+
const keptByService = new WeakMap();
|
|
9
|
+
export async function recognizePages({ doc, bytes }, { ocr, signal, budget }) {
|
|
10
|
+
const pages = new Map();
|
|
11
|
+
let kept = null;
|
|
12
|
+
let failed = false;
|
|
13
|
+
for await (const { page, text } of doc.textPagesAsync()) {
|
|
14
|
+
signal?.throwIfAborted();
|
|
15
|
+
if (budget && budget.chars <= 0) {
|
|
16
|
+
return { pages, unreadFrom: page };
|
|
17
|
+
}
|
|
18
|
+
let read = cleanText(text);
|
|
19
|
+
if (!read && !failed && doc.pageFlags(page).hasImage) {
|
|
20
|
+
kept ??= keptPages(ocr, bytes);
|
|
21
|
+
const found = kept.get(page) ?? (await readPage(doc, page, { ocr, signal }));
|
|
22
|
+
failed = found === null;
|
|
23
|
+
if (found !== null) {
|
|
24
|
+
kept.set(page, found);
|
|
25
|
+
pages.set(page, found);
|
|
26
|
+
read = found;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (budget) {
|
|
30
|
+
budget.chars -= read.length;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return { pages, unreadFrom: null };
|
|
34
|
+
}
|
|
35
|
+
async function readPage(doc, page, { ocr, signal }) {
|
|
36
|
+
try {
|
|
37
|
+
const { text } = await ocr.read(await doc.renderAsync(page, { scale: OCR_SCALE }), signal);
|
|
38
|
+
return cleanText(text);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (signal?.aborted) {
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
HarnessLog.warn('ocr failed; scanned pages stay unread', { page, err: errorMessage(err) });
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function keptPages(ocr, bytes) {
|
|
49
|
+
const documents = keptByService.get(ocr) ?? new RecentMap(KEPT_DOCUMENTS);
|
|
50
|
+
keptByService.set(ocr, documents);
|
|
51
|
+
const id = createHash('sha256').update(bytes).digest('hex');
|
|
52
|
+
const pages = documents.get(id) ?? new Map();
|
|
53
|
+
documents.set(id, pages);
|
|
54
|
+
return pages;
|
|
55
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export declare const PDF_ACTIONS: readonly ['create', 'merge', 'split', 'rotate', 'watermark', 'fill', 'encrypt', 'decrypt', 'text'];
|
|
2
2
|
export declare const PAGE_SIZES: readonly ['A4', 'A5', 'Letter', 'Legal'];
|
|
3
|
-
export declare const DEGREES: readonly [90, 180, 270];
|
|
4
3
|
export declare const WHERE_IDS_ARE = "copy the id from the [Attached file \"\u2026\" \u2014 attachmentId: \u2026] line or an earlier tool result";
|
|
5
4
|
export type Action = (typeof PDF_ACTIONS)[number];
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
type PageSize = (typeof PAGE_SIZES)[number];
|
|
6
|
+
type FieldValue = string | number | boolean | string[];
|
|
7
|
+
interface Permissions {
|
|
9
8
|
print?: boolean;
|
|
10
9
|
modify?: boolean;
|
|
11
10
|
copy?: boolean;
|
|
@@ -55,9 +54,5 @@ export type CreateRequest = Extract<PdfRequest, {
|
|
|
55
54
|
action: 'create';
|
|
56
55
|
}>;
|
|
57
56
|
export declare function parsePages(value: unknown): number[] | string;
|
|
58
|
-
type Args = Record<string, unknown>;
|
|
59
|
-
export declare function impliedAction(args: Args): Action | 'read';
|
|
60
|
-
export declare function pageSizeOf(value: unknown): PageSize | undefined;
|
|
61
|
-
export declare function quarterTurn(value: unknown): number | undefined;
|
|
62
57
|
export declare function parseRequest(args: Record<string, unknown>): PdfRequest | string;
|
|
63
58
|
export {};
|
|
@@ -11,7 +11,7 @@ export const PDF_ACTIONS = [
|
|
|
11
11
|
'text'
|
|
12
12
|
];
|
|
13
13
|
export const PAGE_SIZES = ['A4', 'A5', 'Letter', 'Legal'];
|
|
14
|
-
|
|
14
|
+
const DEGREES = [90, 180, 270];
|
|
15
15
|
export const WHERE_IDS_ARE = 'copy the id from the [Attached file "…" — attachmentId: …] line or an earlier tool result';
|
|
16
16
|
const MAX_PAGE_SPAN = 10_000;
|
|
17
17
|
const PAGES_HINT = 'pages must be page numbers counted from 1, like [1, 2, 3]';
|
|
@@ -117,7 +117,7 @@ const IMPLIED = [
|
|
|
117
117
|
[(args) => hasOutput(args, '.pdf') && idCount(args) > 1, 'merge'],
|
|
118
118
|
[(args) => hasOutput(args, '.pdf') && args.pages !== undefined, 'split']
|
|
119
119
|
];
|
|
120
|
-
|
|
120
|
+
function impliedAction(args) {
|
|
121
121
|
return IMPLIED.find(([applies]) => applies(args))?.[1] ?? 'read';
|
|
122
122
|
}
|
|
123
123
|
function actionOf(args) {
|
|
@@ -136,12 +136,12 @@ function actionOf(args) {
|
|
|
136
136
|
error: `unknown action "${action}"; actions are ${PDF_ACTIONS.join(', ')}, or leave action out to read a PDF`
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
function pageSizeOf(value) {
|
|
140
140
|
if (typeof value !== 'string')
|
|
141
141
|
return undefined;
|
|
142
142
|
return PAGE_SIZES.find((size) => size.toLowerCase() === value.trim().toLowerCase());
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
function quarterTurn(value) {
|
|
145
145
|
const degrees = Number(value);
|
|
146
146
|
if (!Number.isInteger(degrees)) {
|
|
147
147
|
return undefined;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ToolDefinition } from '../contract/index.ts';
|
|
2
2
|
import { type Pdfium, type Source } from './pdf/build.ts';
|
|
3
3
|
import { type PdfRequest } from './pdf/request.ts';
|
|
4
|
-
export { parsePages, parseRequest } from './pdf/request.ts';
|
|
5
4
|
export declare function outputName(request: PdfRequest, inputs: readonly Source[]): string;
|
|
6
5
|
export declare function createPdfTool(load?: () => Promise<Pdfium | null>): ToolDefinition;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
1
2
|
import { errorCode, errorMessage } from '../guards.js';
|
|
2
3
|
import { checkOutputBytes, RUN_OUTPUT_BUDGET_BYTES } from './attachments/output-policy.js';
|
|
3
|
-
import {
|
|
4
|
+
import { attachmentOf, deliveredFile, recordDelivered, sha256 } from './attachments/delivered.js';
|
|
5
|
+
import { build, pagesLabel, everyPageShown, readDocs, READ_TEXT_LIMIT, shownNote, textless } from './pdf/build.js';
|
|
4
6
|
import { placeImages } from './pdf/images.js';
|
|
7
|
+
import { recognizePages } from './pdf/recognize.js';
|
|
5
8
|
import { PAGE_SIZES, parseRequest, PDF_ACTIONS, WHERE_IDS_ARE } from './pdf/request.js';
|
|
6
|
-
export { parsePages, parseRequest } from './pdf/request.js';
|
|
7
9
|
const SUFFIXES = {
|
|
8
10
|
create: 'revised',
|
|
9
11
|
merge: 'merged',
|
|
@@ -16,7 +18,6 @@ const SUFFIXES = {
|
|
|
16
18
|
text: 'text',
|
|
17
19
|
read: 'copy'
|
|
18
20
|
};
|
|
19
|
-
const attachedThisTurn = new WeakMap();
|
|
20
21
|
let loaded = null;
|
|
21
22
|
function loadPdfium() {
|
|
22
23
|
loaded ??= import('bare-pdfium').then((pdfium) => pdfium, () => null);
|
|
@@ -102,20 +103,35 @@ function openAll(pdfium, sources, request) {
|
|
|
102
103
|
}
|
|
103
104
|
return { opened, error: null };
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
function madeFrom({ request, opened }) {
|
|
107
|
+
const sources = opened.map(({ source }) => sha256(source.bytes));
|
|
108
|
+
const made = JSON.stringify({ ...request, output: undefined, sources }, sortedKeys);
|
|
109
|
+
return sha256(b4a.from(made));
|
|
110
|
+
}
|
|
111
|
+
function sortedKeys(_key, value) {
|
|
112
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => (a < b ? -1 : 1)));
|
|
116
|
+
}
|
|
117
|
+
async function attachOutput(fileName, { bytes, hash }, ctx) {
|
|
106
118
|
if (!ctx.attach) {
|
|
107
119
|
return { error: 'this device cannot attach a file to the chat' };
|
|
108
120
|
}
|
|
109
|
-
const
|
|
110
|
-
const earlier =
|
|
121
|
+
const budget = ctx.runBudget;
|
|
122
|
+
const earlier = deliveredFile(budget, fileName);
|
|
123
|
+
if (earlier?.sha256 === hash) {
|
|
124
|
+
return { attachment: attachmentOf(earlier), repeated: true };
|
|
125
|
+
}
|
|
111
126
|
if (earlier) {
|
|
112
|
-
return {
|
|
127
|
+
return {
|
|
128
|
+
error: `${earlier.fileName} is already attached with different content; save this version under a new name in output`
|
|
129
|
+
};
|
|
113
130
|
}
|
|
114
131
|
const verdict = checkOutputBytes(fileName, bytes, 0);
|
|
115
132
|
if ('error' in verdict) {
|
|
116
133
|
return verdict;
|
|
117
134
|
}
|
|
118
|
-
const budget = ctx.runBudget;
|
|
119
135
|
if (budget && budget.outputBytesUsed + bytes.byteLength > RUN_OUTPUT_BUDGET_BYTES) {
|
|
120
136
|
return { error: 'run output budget exceeded' };
|
|
121
137
|
}
|
|
@@ -128,8 +144,7 @@ async function attachOutput(fileName, bytes, ctx) {
|
|
|
128
144
|
fileName: record.fileName,
|
|
129
145
|
byteLength: record.byteLength
|
|
130
146
|
};
|
|
131
|
-
|
|
132
|
-
attachedThisTurn.set(ctx.attach, delivered);
|
|
147
|
+
recordDelivered(budget, { name: fileName.toLowerCase(), sha256: hash, ...attachment });
|
|
133
148
|
return { attachment, repeated: false };
|
|
134
149
|
}
|
|
135
150
|
const UNDRAWABLE = /^('[^']+' \(U\+[0-9A-F]+\)(?:, '[^']+' \(U\+[0-9A-F]+\))*) cannot be drawn by the built-in fonts/;
|
|
@@ -178,7 +193,7 @@ async function deliver(job, ctx) {
|
|
|
178
193
|
if (typeof built === 'string') {
|
|
179
194
|
return { error: built };
|
|
180
195
|
}
|
|
181
|
-
const delivered = await attachOutput(output, built.bytes, ctx);
|
|
196
|
+
const delivered = await attachOutput(output, { bytes: built.bytes, hash: madeFrom(job) }, ctx);
|
|
182
197
|
return 'error' in delivered ? delivered : reply(request, { output, built, delivered });
|
|
183
198
|
}
|
|
184
199
|
function isLocked(pdfium, source) {
|
|
@@ -208,6 +223,18 @@ function shownPages(ctx) {
|
|
|
208
223
|
const names = (ctx.turnImages ?? []).map((image) => image.path.split(/[\\/]/).pop()?.slice(33));
|
|
209
224
|
return (fileName, page) => names.includes(renderedPageName(fileName, page));
|
|
210
225
|
}
|
|
226
|
+
async function withRecognized(opened, request, { ocr, signal }) {
|
|
227
|
+
if (!ocr || (request.action !== 'read' && request.action !== 'text')) {
|
|
228
|
+
return opened;
|
|
229
|
+
}
|
|
230
|
+
const budget = request.action === 'read' ? { chars: READ_TEXT_LIMIT } : undefined;
|
|
231
|
+
const out = [];
|
|
232
|
+
for (const one of opened) {
|
|
233
|
+
const scanned = { doc: one.doc, bytes: one.source.bytes };
|
|
234
|
+
out.push({ ...one, recognized: await recognizePages(scanned, { ocr, signal, budget }) });
|
|
235
|
+
}
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
211
238
|
async function run(pdfium, asked, ctx) {
|
|
212
239
|
if (asked.action === 'create') {
|
|
213
240
|
const placed = await placeImages(asked, ctx);
|
|
@@ -223,17 +250,18 @@ async function run(pdfium, asked, ctx) {
|
|
|
223
250
|
if (error) {
|
|
224
251
|
return { error };
|
|
225
252
|
}
|
|
253
|
+
const read = await withRecognized(opened, request, ctx);
|
|
226
254
|
if (request.action === 'read') {
|
|
227
|
-
return readDocs(
|
|
255
|
+
return readDocs(read, shownPages(ctx));
|
|
228
256
|
}
|
|
229
|
-
const [only] =
|
|
257
|
+
const [only] = read;
|
|
230
258
|
if (request.action === 'text' &&
|
|
231
259
|
only &&
|
|
232
260
|
textless(only) &&
|
|
233
261
|
everyPageShown(only, shownPages(ctx))) {
|
|
234
262
|
return { note: shownNote(only) };
|
|
235
263
|
}
|
|
236
|
-
return await deliver({ pdfium, request, opened }, ctx);
|
|
264
|
+
return await deliver({ pdfium, request, opened: read }, ctx);
|
|
237
265
|
}
|
|
238
266
|
finally {
|
|
239
267
|
for (const { doc } of opened) {
|
|
@@ -21,6 +21,9 @@ export function mainFileRequested(name, file) {
|
|
|
21
21
|
export function skillFileArg(args) {
|
|
22
22
|
return args?.file ?? args?.path ?? args?.filename;
|
|
23
23
|
}
|
|
24
|
+
function skillNameArg(args) {
|
|
25
|
+
return unquoteArg(args.name ?? args.skill_name ?? args.skill);
|
|
26
|
+
}
|
|
24
27
|
export function skillFileStem(file) {
|
|
25
28
|
return file
|
|
26
29
|
.toLowerCase()
|
|
@@ -76,7 +79,11 @@ function nearestFile(wanted, available) {
|
|
|
76
79
|
export function createSkillTool({ skillsDir, overlayDir = resolveSkillsOverlayDir(), read } = {}) {
|
|
77
80
|
const baseDrive = skillsDir ? new Localdrive(skillsDir) : null;
|
|
78
81
|
const overlayDrive = overlayDir ? new Localdrive(overlayDir) : null;
|
|
79
|
-
async function resolveSkill(name, file) {
|
|
82
|
+
async function resolveSkill(name, file, tree) {
|
|
83
|
+
const own = tree ? await tree.drive.get(`/${name}/${file}`) : null;
|
|
84
|
+
if (own) {
|
|
85
|
+
return { raw: b4a.toString(own, 'utf8'), root: tree?.root };
|
|
86
|
+
}
|
|
80
87
|
if (read) {
|
|
81
88
|
return { raw: await read(name, file), root: skillsDir };
|
|
82
89
|
}
|
|
@@ -125,14 +132,16 @@ export function createSkillTool({ skillsDir, overlayDir = resolveSkillsOverlayDi
|
|
|
125
132
|
effect: () => 'read',
|
|
126
133
|
autoApprove: true,
|
|
127
134
|
async execute(args, ctx) {
|
|
128
|
-
const name =
|
|
135
|
+
const name = skillNameArg(args);
|
|
136
|
+
const root = ctx?.skillTrees?.get(name)?.root;
|
|
137
|
+
const tree = root ? { root, drive: new Localdrive(root) } : null;
|
|
129
138
|
const fileArg = skillFileArg(args);
|
|
130
139
|
const file = mainFileRequested(name, fileArg) ? MAIN_FILE : unquoteArg(fileArg);
|
|
131
140
|
if (file.startsWith('/') || file.includes('\\') || file.split('/').includes('..')) {
|
|
132
141
|
return { error: `file not found in skill ${name}: ${file}` };
|
|
133
142
|
}
|
|
134
143
|
const load = async (target) => {
|
|
135
|
-
const { raw, root } = await resolveSkill(name, target);
|
|
144
|
+
const { raw, root } = await resolveSkill(name, target, tree);
|
|
136
145
|
const { body, meta } = parseSkillFrontMatter(raw);
|
|
137
146
|
const dir = resolveSkillDir(root, name);
|
|
138
147
|
const content = dir ? body.replaceAll('{{SKILL_DIR}}', ShellLine.escape(dir)) : body;
|
|
@@ -158,7 +167,7 @@ export function createSkillTool({ skillsDir, overlayDir = resolveSkillsOverlayDi
|
|
|
158
167
|
if (file === MAIN_FILE) {
|
|
159
168
|
return { error: `skill not found: ${name}` };
|
|
160
169
|
}
|
|
161
|
-
const available = await listSkillFiles([overlayDrive, baseDrive], name);
|
|
170
|
+
const available = await listSkillFiles([tree?.drive ?? null, overlayDrive, baseDrive], name);
|
|
162
171
|
const near = nearestFile(file, available);
|
|
163
172
|
if (near !== null) {
|
|
164
173
|
try {
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { type BundledFile } from './bundled-hash.ts';
|
|
2
|
+
export interface SkillsBundle {
|
|
3
|
+
readonly skills: Readonly<Record<string, string>>;
|
|
4
|
+
readonly hash: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function ensureBundledSkillsDir(bundle: SkillsBundle): Promise<string>;
|
|
7
|
+
export declare function materializeTree(dir: string, files: ReadonlyArray<BundledFile>, hash: string): Promise<void>;
|
|
2
8
|
export declare function randomSuffix(): string;
|
|
9
|
+
export declare function readTree(dir: string, hash: string): Promise<BundledFile[] | null>;
|