@qvac/harness 1.0.0-rc.8 → 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 +722 -20
- 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 +89 -10
- 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 -20
- 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 +31 -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 +14 -3
- package/dist-lib/lib/capabilities/completion-engine/loop.js +7 -2
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +5 -2
- 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 +15 -1
- package/dist-lib/lib/capabilities/completion-engine/round.js +124 -53
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +6 -4
- 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 +6 -42
- 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/tool-sets.d.ts +1 -1
- 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/download.d.ts +1 -1
- package/dist-lib/lib/capabilities/enhance.js +3 -3
- package/dist-lib/lib/capabilities/kv-cache.d.ts +1 -1
- 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 +3 -1
- package/dist-lib/lib/capabilities/prompt-prefix.js +8 -0
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +5 -5
- 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-prompt-log.d.ts +1 -1
- 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 -41
- package/dist-lib/lib/capabilities/tool-turns.js +7 -258
- 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 +36 -4
- 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 +7 -3
- 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/speech.d.ts +1 -1
- 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 +84 -150
- 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 +39 -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/context.d.ts +1 -1
- package/dist-lib/lib/models/custom-model-cache.d.ts +1 -0
- package/dist-lib/lib/models/custom-model-cache.js +3 -0
- package/dist-lib/lib/models/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 +13 -4
- package/dist-lib/lib/models/model-catalog.js +40 -16
- package/dist-lib/lib/models/model-delete.d.ts +1 -1
- package/dist-lib/lib/models/model-delete.js +3 -0
- package/dist-lib/lib/models/model-fit.d.ts +1 -1
- package/dist-lib/lib/models/model-handle.d.ts +1 -0
- package/dist-lib/lib/models/model-list.d.ts +3 -2
- package/dist-lib/lib/models/model-list.js +5 -1
- package/dist-lib/lib/models/model-pool.d.ts +10 -4
- package/dist-lib/lib/models/model-pool.js +34 -13
- package/dist-lib/lib/models/model-source.d.ts +2 -2
- package/dist-lib/lib/models/tool-dialect.d.ts +1 -1
- package/dist-lib/lib/models/tts-model-default.d.ts +2 -1
- package/dist-lib/lib/models/tts-model-default.js +8 -6
- package/dist-lib/lib/no-redirect-fetch-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/policy/index.d.ts +2 -1
- package/dist-lib/lib/policy/index.js +6 -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.d.ts +3 -1
- package/dist-lib/plugins/sandbox-linux/index.js +12 -5
- package/dist-lib/plugins/sandbox-macos/index.d.ts +3 -1
- package/dist-lib/plugins/sandbox-macos/index.js +12 -7
- 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 +98 -40
- 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/@qvac%2Finference@0.22.0.patch +0 -59
- 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,74 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
export function withRootSearch(roots, engine) {
|
|
3
|
+
if (!engine) {
|
|
4
|
+
return roots;
|
|
5
|
+
}
|
|
6
|
+
return roots.map((root) => (root.kind === 'local' ? searchable(root, engine) : root));
|
|
7
|
+
}
|
|
8
|
+
function searchable(root, engine) {
|
|
9
|
+
return {
|
|
10
|
+
...root,
|
|
11
|
+
async search({ maxMs, signal, ...query }) {
|
|
12
|
+
const found = await bounded((stop) => engine.search({
|
|
13
|
+
...query,
|
|
14
|
+
root: root.root,
|
|
15
|
+
folder: query.folder.slice(1),
|
|
16
|
+
signal: stop
|
|
17
|
+
}), { maxMs, signal, late: { hits: [], truncated: true, cut: false } });
|
|
18
|
+
const capped = found.hits.length >= query.maxMatches;
|
|
19
|
+
return {
|
|
20
|
+
hits: found.hits.map(({ path: rel, line, text }) => ({
|
|
21
|
+
file: path.join(root.root, rel),
|
|
22
|
+
line,
|
|
23
|
+
text
|
|
24
|
+
})),
|
|
25
|
+
capped,
|
|
26
|
+
cut: found.cut,
|
|
27
|
+
truncated: found.truncated && !capped,
|
|
28
|
+
skippedLinks: 0
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
async walk({ maxMs, signal, ...query }) {
|
|
32
|
+
const found = await bounded((stop) => engine.walk({
|
|
33
|
+
...query,
|
|
34
|
+
root: root.root,
|
|
35
|
+
folder: query.folder.slice(1),
|
|
36
|
+
signal: stop
|
|
37
|
+
}), { maxMs, signal, late: { files: [], truncated: true } });
|
|
38
|
+
return {
|
|
39
|
+
files: found.files.map(({ path: rel, mtime }) => ({
|
|
40
|
+
path: path.join(root.root, rel),
|
|
41
|
+
key: `/${rel}`,
|
|
42
|
+
mtime
|
|
43
|
+
})),
|
|
44
|
+
truncated: found.truncated
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async function bounded(run, { maxMs, signal, late }) {
|
|
50
|
+
const controller = new AbortController();
|
|
51
|
+
const abort = () => controller.abort();
|
|
52
|
+
let expired = false;
|
|
53
|
+
const timer = setTimeout(() => {
|
|
54
|
+
expired = true;
|
|
55
|
+
abort();
|
|
56
|
+
}, maxMs);
|
|
57
|
+
signal?.addEventListener('abort', abort);
|
|
58
|
+
if (signal?.aborted) {
|
|
59
|
+
abort();
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
return await run(controller.signal);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
if (expired && !signal?.aborted) {
|
|
66
|
+
return late;
|
|
67
|
+
}
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
clearTimeout(timer);
|
|
72
|
+
signal?.removeEventListener('abort', abort);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Milestone = 'admittedMs' | 'preparedMs' | 'leasedMs' | 'recordedMs' | 'submittedMs' | 'firstDeltaMs' | 'firstThinkingMs' | 'firstContentMs' | 'toolDispatchMs' | 'handoffMs';
|
|
2
|
+
export interface LatencyAt {
|
|
3
|
+
round: number;
|
|
4
|
+
attempt?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class RunLatency {
|
|
7
|
+
#private;
|
|
8
|
+
private constructor();
|
|
9
|
+
static start(): RunLatency | undefined;
|
|
10
|
+
identify(runId: string, resumed: boolean): void;
|
|
11
|
+
mark(name: Milestone, at?: LatencyAt): void;
|
|
12
|
+
logAfter<Event>(events: AsyncIterable<Event>): AsyncGenerator<Event>;
|
|
13
|
+
log(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import process from 'process';
|
|
2
|
+
import { HarnessLog } from '../log.js';
|
|
3
|
+
export class RunLatency {
|
|
4
|
+
#origin = process.hrtime.bigint();
|
|
5
|
+
#run = {};
|
|
6
|
+
#rounds = new Map();
|
|
7
|
+
#runId;
|
|
8
|
+
#resumed = false;
|
|
9
|
+
#logged = false;
|
|
10
|
+
constructor() { }
|
|
11
|
+
static start() {
|
|
12
|
+
return HarnessLog.enabled('debug') ? new RunLatency() : undefined;
|
|
13
|
+
}
|
|
14
|
+
identify(runId, resumed) {
|
|
15
|
+
this.#runId = runId;
|
|
16
|
+
this.#resumed = resumed;
|
|
17
|
+
}
|
|
18
|
+
mark(name, at) {
|
|
19
|
+
if (this.#logged)
|
|
20
|
+
return;
|
|
21
|
+
const marks = at === undefined ? this.#run : this.#marksAt(at);
|
|
22
|
+
marks[name] ??= Math.round(Number(process.hrtime.bigint() - this.#origin) / 1e5) / 10;
|
|
23
|
+
}
|
|
24
|
+
async *logAfter(events) {
|
|
25
|
+
try {
|
|
26
|
+
yield* events;
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
this.log();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
log() {
|
|
33
|
+
if (this.#logged)
|
|
34
|
+
return;
|
|
35
|
+
this.#logged = true;
|
|
36
|
+
HarnessLog.debug('latency', {
|
|
37
|
+
runId: this.#runId,
|
|
38
|
+
resumed: this.#resumed,
|
|
39
|
+
...this.#run,
|
|
40
|
+
rounds: [...this.#rounds].map(([round, { marks, attempts }]) => ({
|
|
41
|
+
round,
|
|
42
|
+
...marks,
|
|
43
|
+
attempts: [...attempts].map(([attempt, own]) => ({ attempt, ...own }))
|
|
44
|
+
}))
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
#marksAt({ round, attempt }) {
|
|
48
|
+
let found = this.#rounds.get(round);
|
|
49
|
+
if (!found) {
|
|
50
|
+
found = { marks: {}, attempts: new Map() };
|
|
51
|
+
this.#rounds.set(round, found);
|
|
52
|
+
}
|
|
53
|
+
if (attempt === undefined) {
|
|
54
|
+
return found.marks;
|
|
55
|
+
}
|
|
56
|
+
let own = found.attempts.get(attempt);
|
|
57
|
+
if (!own) {
|
|
58
|
+
own = {};
|
|
59
|
+
found.attempts.set(attempt, own);
|
|
60
|
+
}
|
|
61
|
+
return own;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { RunOutcome, ToolExecutionOutcome } from '../contract/index.ts';
|
|
|
2
2
|
export type { RunOutcome };
|
|
3
3
|
export declare const DEGENERATE_ANSWER_FALLBACK = "I couldn't complete that step and don't have a useful result to share.";
|
|
4
4
|
export declare const ROUND_CAP_ANSWER = "I ran out of steps before I could finish that. Ask me to continue and I'll pick up where I left off.";
|
|
5
|
+
export declare const REPEATED_CALL_ANSWER = "I stopped because I kept repeating the same step without getting anywhere. Tell me more about what you want, or put it another way, and I'll try something else.";
|
|
5
6
|
export declare const SEARCH_CAPPED_ANSWER = "I searched the web but couldn't find the answer in the results I got.";
|
|
6
7
|
export declare const DELIVERED_ANSWER = "Your file is attached to the chat.";
|
|
7
8
|
export declare const WRITE_RESULT_LEAD = "Here's what came back:";
|
|
@@ -10,6 +11,7 @@ export interface RunOutcomeFacts {
|
|
|
10
11
|
readonly latestFailure: string | null;
|
|
11
12
|
readonly confirmedWrites: ReadonlyArray<string>;
|
|
12
13
|
readonly delivered?: boolean;
|
|
14
|
+
readonly repeated?: boolean;
|
|
13
15
|
}
|
|
14
16
|
export interface HistoryTurn {
|
|
15
17
|
readonly role: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isRecord } from '../guards.js';
|
|
2
2
|
export const DEGENERATE_ANSWER_FALLBACK = "I couldn't complete that step and don't have a useful result to share.";
|
|
3
3
|
export const ROUND_CAP_ANSWER = "I ran out of steps before I could finish that. Ask me to continue and I'll pick up where I left off.";
|
|
4
|
+
export const REPEATED_CALL_ANSWER = "I stopped because I kept repeating the same step without getting anywhere. Tell me more about what you want, or put it another way, and I'll try something else.";
|
|
4
5
|
export const SEARCH_CAPPED_ANSWER = "I searched the web but couldn't find the answer in the results I got.";
|
|
5
6
|
export const DELIVERED_ANSWER = 'Your file is attached to the chat.';
|
|
6
7
|
export const WRITE_RESULT_LEAD = "Here's what came back:";
|
|
@@ -66,7 +67,7 @@ export function failureFromToolExecution(result, outcome) {
|
|
|
66
67
|
return resultFailure(result);
|
|
67
68
|
}
|
|
68
69
|
export function degenerateAnswer(outcome, history, facts) {
|
|
69
|
-
const rest = facts.latestFailure ?? cappedAnswer(outcome, history);
|
|
70
|
+
const rest = facts.latestFailure ?? cappedAnswer(outcome, history, facts.repeated === true);
|
|
70
71
|
const lines = [
|
|
71
72
|
writeReport(facts.confirmedWrites),
|
|
72
73
|
facts.delivered ? DELIVERED_ANSWER : null,
|
|
@@ -74,7 +75,10 @@ export function degenerateAnswer(outcome, history, facts) {
|
|
|
74
75
|
].filter((line) => line !== null);
|
|
75
76
|
return lines.length ? lines.join('\n\n') : DEGENERATE_ANSWER_FALLBACK;
|
|
76
77
|
}
|
|
77
|
-
function cappedAnswer(outcome, history) {
|
|
78
|
+
function cappedAnswer(outcome, history, repeated) {
|
|
79
|
+
if (outcome === 'exhausted' && repeated) {
|
|
80
|
+
return REPEATED_CALL_ANSWER;
|
|
81
|
+
}
|
|
78
82
|
if (outcome === 'search-capped') {
|
|
79
83
|
return searchCappedAnswer(history);
|
|
80
84
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const HOMEBREW_BIN_DIRS: readonly string[];
|
|
2
2
|
export declare function withHomebrewPath(path: string | undefined, platformName: string): string | undefined;
|
|
3
3
|
export declare const EXEC_ENV_ALLOWLIST: readonly ['PATH', 'HOME', 'TMPDIR', 'TMP', 'TEMP', 'LANG', 'LC_ALL', 'LC_CTYPE', 'TZ', 'USER', 'LOGNAME', 'HTTP_PROXY', 'http_proxy', 'HTTPS_PROXY', 'https_proxy', 'ALL_PROXY', 'all_proxy', 'NO_PROXY', 'no_proxy', 'SSL_CERT_FILE', 'SSL_CERT_DIR', 'CURL_CA_BUNDLE', 'REQUESTS_CA_BUNDLE', 'NODE_EXTRA_CA_CERTS'];
|
|
4
|
+
export declare const EXEC_ENV_DEFAULTS: Readonly<Record<string, string>>;
|
|
4
5
|
export declare function execEnv(env: Readonly<Record<string, string | undefined>>, platformName: string): Record<string, string>;
|
|
5
6
|
export declare function spawnEnv(env: Readonly<Record<string, string | undefined>>, platformName: string, overrides?: Readonly<Record<string, string>>): Record<string, string>;
|
|
@@ -40,8 +40,9 @@ const PLATFORM_EXEC_ENV_ALLOWLIST = {
|
|
|
40
40
|
win32: ['SystemRoot', 'COMSPEC', 'PATHEXT', 'USERPROFILE'],
|
|
41
41
|
linux: ['DISPLAY', 'WAYLAND_DISPLAY', 'XDG_RUNTIME_DIR']
|
|
42
42
|
};
|
|
43
|
+
export const EXEC_ENV_DEFAULTS = { PYTHONUNBUFFERED: '1' };
|
|
43
44
|
export function execEnv(env, platformName) {
|
|
44
|
-
const out = {};
|
|
45
|
+
const out = { ...EXEC_ENV_DEFAULTS };
|
|
45
46
|
const keys = [...EXEC_ENV_ALLOWLIST, ...(PLATFORM_EXEC_ENV_ALLOWLIST[platformName] ?? [])];
|
|
46
47
|
for (const key of keys) {
|
|
47
48
|
const value = env[key];
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { isRecord } from '../guards.js';
|
|
2
2
|
export function stableStringify(value) {
|
|
3
3
|
if (Array.isArray(value)) {
|
|
4
|
-
|
|
4
|
+
let out = '[';
|
|
5
|
+
for (let at = 0; at < value.length; at++) {
|
|
6
|
+
out += (at ? ',' : '') + (stableStringify(value[at]) ?? '');
|
|
7
|
+
}
|
|
8
|
+
return out + ']';
|
|
5
9
|
}
|
|
6
10
|
if (isRecord(value)) {
|
|
7
11
|
const keys = Object.keys(value).sort();
|
|
8
|
-
|
|
12
|
+
let out = '';
|
|
13
|
+
for (const key of keys) {
|
|
14
|
+
out += (out ? ',' : '') + JSON.stringify(key) + ':' + stableStringify(value[key]);
|
|
15
|
+
}
|
|
16
|
+
return `{${out}}`;
|
|
9
17
|
}
|
|
10
18
|
return JSON.stringify(value);
|
|
11
19
|
}
|
|
@@ -9,7 +9,13 @@ export declare class TextCoalescer {
|
|
|
9
9
|
private readonly _holdMs;
|
|
10
10
|
private _buffered;
|
|
11
11
|
private _hold;
|
|
12
|
+
private readonly _started;
|
|
13
|
+
private _timed;
|
|
14
|
+
private _failure;
|
|
12
15
|
constructor(write: (type: TextType, text: string) => Promise<void>, { cap, holdMs }?: TextCoalescerOptions);
|
|
13
16
|
add(type: TextType, text: string): Promise<void>;
|
|
17
|
+
reset(): Promise<void>;
|
|
14
18
|
flush(): Promise<void>;
|
|
19
|
+
private _send;
|
|
20
|
+
private _raise;
|
|
15
21
|
}
|
|
@@ -4,34 +4,74 @@ export class TextCoalescer {
|
|
|
4
4
|
_holdMs;
|
|
5
5
|
_buffered = null;
|
|
6
6
|
_hold = null;
|
|
7
|
+
_started = new Set();
|
|
8
|
+
_timed = null;
|
|
9
|
+
_failure = null;
|
|
7
10
|
constructor(write, { cap = 8192, holdMs = 60 } = {}) {
|
|
8
11
|
this._write = write;
|
|
9
12
|
this._cap = cap;
|
|
10
13
|
this._holdMs = holdMs;
|
|
11
14
|
}
|
|
12
15
|
async add(type, text) {
|
|
16
|
+
this._raise();
|
|
17
|
+
if (text === '') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
13
20
|
if (this._buffered && this._buffered.type !== type) {
|
|
14
21
|
await this.flush();
|
|
15
22
|
}
|
|
23
|
+
if (!this._buffered && !this._started.has(type)) {
|
|
24
|
+
this._started.add(type);
|
|
25
|
+
return this._write(type, text);
|
|
26
|
+
}
|
|
16
27
|
if (!this._buffered) {
|
|
17
28
|
this._buffered = { type, text: '' };
|
|
18
|
-
this._hold = setTimeout(() =>
|
|
29
|
+
this._hold = setTimeout(() => {
|
|
30
|
+
const timed = this._send().catch((error) => {
|
|
31
|
+
this._failure ??= { error };
|
|
32
|
+
});
|
|
33
|
+
const chained = Promise.all([this._timed, timed]).then(() => {
|
|
34
|
+
if (this._timed === chained) {
|
|
35
|
+
this._timed = null;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
this._timed = chained;
|
|
39
|
+
}, this._holdMs);
|
|
19
40
|
}
|
|
20
41
|
this._buffered.text += text;
|
|
21
42
|
if (this._buffered.text.length >= this._cap) {
|
|
22
43
|
await this.flush();
|
|
23
44
|
}
|
|
24
45
|
}
|
|
25
|
-
|
|
46
|
+
async reset() {
|
|
47
|
+
await this.flush();
|
|
48
|
+
this._started.clear();
|
|
49
|
+
}
|
|
50
|
+
async flush() {
|
|
51
|
+
const [sent] = await Promise.allSettled([this._send(), this._timed]);
|
|
52
|
+
if (sent.status === 'rejected') {
|
|
53
|
+
this._failure = null;
|
|
54
|
+
throw sent.reason;
|
|
55
|
+
}
|
|
56
|
+
this._raise();
|
|
57
|
+
}
|
|
58
|
+
async _send() {
|
|
26
59
|
if (this._hold) {
|
|
27
60
|
clearTimeout(this._hold);
|
|
28
61
|
this._hold = null;
|
|
29
62
|
}
|
|
30
63
|
if (!this._buffered) {
|
|
31
|
-
return
|
|
64
|
+
return;
|
|
32
65
|
}
|
|
33
66
|
const { type, text } = this._buffered;
|
|
34
67
|
this._buffered = null;
|
|
35
|
-
|
|
68
|
+
await this._write(type, text);
|
|
69
|
+
}
|
|
70
|
+
_raise() {
|
|
71
|
+
if (this._failure) {
|
|
72
|
+
const { error } = this._failure;
|
|
73
|
+
this._failure = null;
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
36
76
|
}
|
|
37
77
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface MarkupToolCall {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
readonly arguments?: Record<string, unknown>;
|
|
4
|
+
}
|
|
5
|
+
export declare function toolCallMarkup(calls: ReadonlyArray<MarkupToolCall>): string;
|
|
6
|
+
export declare function functionMarkup(call: MarkupToolCall): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function toolCallMarkup(calls) {
|
|
2
|
+
return calls.map(markupForCall).join('\n');
|
|
3
|
+
}
|
|
4
|
+
function markupForCall(call) {
|
|
5
|
+
return `<tool_call>\n${functionMarkup(call)}\n</tool_call>`;
|
|
6
|
+
}
|
|
7
|
+
export function functionMarkup(call) {
|
|
8
|
+
const params = Object.entries(call.arguments ?? {})
|
|
9
|
+
.map(([key, value]) => `<parameter=${key}>\n${markupValue(value)}\n</parameter>\n`)
|
|
10
|
+
.join('');
|
|
11
|
+
return `<function=${call.name}>\n${params}</function>`;
|
|
12
|
+
}
|
|
13
|
+
function markupValue(value) {
|
|
14
|
+
return typeof value === 'string' ? value : JSON.stringify(value ?? null);
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const MAX_NAME_LENGTH = 64;
|
|
2
|
+
export interface RecoveredToolCall {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
arguments: Record<string, unknown>;
|
|
6
|
+
raw?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const MAX_RAW_CALL_CHARS = 4096;
|
|
9
|
+
export declare const MALFORMED_CALL_ID = "call-malformed";
|
|
10
|
+
export declare function clipRawCall(raw: string): string;
|
|
11
|
+
export interface KnownTool {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function recoverMarkupToolCalls(text: string, knownTools: ReadonlyArray<KnownTool>): RecoveredToolCall[];
|
|
15
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
16
|
+
export declare function normalizeToolArgs(args: Record<string, unknown>, declaredKeys: ReadonlyArray<string>): Record<string, unknown>;
|
|
17
|
+
interface DecodedArguments {
|
|
18
|
+
readonly args: Record<string, unknown>;
|
|
19
|
+
readonly ambiguous: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function decodeArguments(block: string, maxNameLength?: number): DecodedArguments;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { isRecord } from '../../guards.js';
|
|
2
|
+
import { namedMarkupBlocks } from '../markup-scanner.js';
|
|
3
|
+
export const MAX_NAME_LENGTH = 64;
|
|
4
|
+
export const MAX_RAW_CALL_CHARS = 4096;
|
|
5
|
+
export const MALFORMED_CALL_ID = 'call-malformed';
|
|
6
|
+
export function clipRawCall(raw) {
|
|
7
|
+
return raw.length > MAX_RAW_CALL_CHARS ? raw.slice(0, MAX_RAW_CALL_CHARS) : raw;
|
|
8
|
+
}
|
|
9
|
+
export function recoverMarkupToolCalls(text, knownTools) {
|
|
10
|
+
const known = new Set(knownTools.map((tool) => tool.name));
|
|
11
|
+
const calls = [];
|
|
12
|
+
for (const block of namedMarkupBlocks(text, 'function', MAX_NAME_LENGTH)) {
|
|
13
|
+
if (block.nested) {
|
|
14
|
+
calls.push(...recoverLegacyCalls(text.slice(block.start, block.end), known));
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (!block.name || !known.has(block.name)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
calls.push({
|
|
21
|
+
id: '',
|
|
22
|
+
name: block.name,
|
|
23
|
+
arguments: decodeArguments(block.body).args,
|
|
24
|
+
raw: clipRawCall(text.slice(block.start, block.end))
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return calls.map((call, index) => ({ ...call, id: `recovered-markup-${index}` }));
|
|
28
|
+
}
|
|
29
|
+
function recoverLegacyCalls(text, known) {
|
|
30
|
+
const calls = [];
|
|
31
|
+
let cursor = 0;
|
|
32
|
+
for (;;) {
|
|
33
|
+
const start = text.indexOf('<function=', cursor);
|
|
34
|
+
if (start === -1) {
|
|
35
|
+
return calls;
|
|
36
|
+
}
|
|
37
|
+
const nameStart = start + '<function='.length;
|
|
38
|
+
const nameEnd = text.indexOf('>', nameStart);
|
|
39
|
+
const close = nameEnd === -1 ? -1 : text.indexOf('</function>', nameEnd + 1);
|
|
40
|
+
if (nameEnd === -1 || nameEnd - nameStart > MAX_NAME_LENGTH || close === -1) {
|
|
41
|
+
return calls;
|
|
42
|
+
}
|
|
43
|
+
const name = text.slice(nameStart, nameEnd).trim();
|
|
44
|
+
const end = close + '</function>'.length;
|
|
45
|
+
if (name && known.has(name)) {
|
|
46
|
+
calls.push({
|
|
47
|
+
id: '',
|
|
48
|
+
name,
|
|
49
|
+
arguments: decodeLegacyArguments(text.slice(nameEnd + 1, close), 64),
|
|
50
|
+
raw: clipRawCall(text.slice(start, end))
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
cursor = end;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const ARG_WRAPPER_KEYS = new Set(['parameters', 'arguments', 'args', 'input', 'params']);
|
|
57
|
+
export function isPlainObject(value) {
|
|
58
|
+
return isRecord(value) && !Array.isArray(value);
|
|
59
|
+
}
|
|
60
|
+
export function normalizeToolArgs(args, declaredKeys) {
|
|
61
|
+
const [only, ...rest] = Object.keys(args);
|
|
62
|
+
if (only === undefined || rest.length) {
|
|
63
|
+
return args;
|
|
64
|
+
}
|
|
65
|
+
if (!ARG_WRAPPER_KEYS.has(only) || declaredKeys.includes(only)) {
|
|
66
|
+
return args;
|
|
67
|
+
}
|
|
68
|
+
const inner = args[only];
|
|
69
|
+
if (isPlainObject(inner)) {
|
|
70
|
+
return inner;
|
|
71
|
+
}
|
|
72
|
+
if (typeof inner === 'string') {
|
|
73
|
+
try {
|
|
74
|
+
const parsed = JSON.parse(inner);
|
|
75
|
+
if (isPlainObject(parsed)) {
|
|
76
|
+
return parsed;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return args;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return args;
|
|
84
|
+
}
|
|
85
|
+
export function decodeArguments(block, maxNameLength = MAX_NAME_LENGTH) {
|
|
86
|
+
const args = {};
|
|
87
|
+
let ambiguous = false;
|
|
88
|
+
for (const param of namedMarkupBlocks(block, 'parameter', maxNameLength)) {
|
|
89
|
+
if (!param.name)
|
|
90
|
+
continue;
|
|
91
|
+
ambiguous ||= param.nested;
|
|
92
|
+
defineArgument(args, param.name, param.body);
|
|
93
|
+
}
|
|
94
|
+
return { args: ambiguous ? decodeLegacyArguments(block, maxNameLength) : args, ambiguous };
|
|
95
|
+
}
|
|
96
|
+
function decodeLegacyArguments(block, maxNameLength) {
|
|
97
|
+
const args = {};
|
|
98
|
+
let cursor = 0;
|
|
99
|
+
for (;;) {
|
|
100
|
+
const start = block.indexOf('<parameter=', cursor);
|
|
101
|
+
if (start === -1) {
|
|
102
|
+
return args;
|
|
103
|
+
}
|
|
104
|
+
const nameStart = start + '<parameter='.length;
|
|
105
|
+
const nameEnd = block.indexOf('>', nameStart);
|
|
106
|
+
if (nameEnd === -1 || nameEnd - nameStart > maxNameLength) {
|
|
107
|
+
return args;
|
|
108
|
+
}
|
|
109
|
+
const end = block.indexOf('</parameter>', nameEnd + 1);
|
|
110
|
+
if (end === -1) {
|
|
111
|
+
return args;
|
|
112
|
+
}
|
|
113
|
+
const name = block.slice(nameStart, nameEnd).trim();
|
|
114
|
+
if (name) {
|
|
115
|
+
defineArgument(args, name, block.slice(nameEnd + 1, end));
|
|
116
|
+
}
|
|
117
|
+
cursor = end + '</parameter>'.length;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function defineArgument(args, name, body) {
|
|
121
|
+
const raw = body.trim();
|
|
122
|
+
let value;
|
|
123
|
+
try {
|
|
124
|
+
value = JSON.parse(raw);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
value = raw;
|
|
128
|
+
}
|
|
129
|
+
Object.defineProperty(args, name, { value, enumerable: true, configurable: true, writable: true });
|
|
130
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RecoveredToolCall } from './recover.ts';
|
|
2
|
+
export declare function recoverSkillNamedCall(text: string, skillNames: ReadonlyArray<string>, skillToolName: string): RecoveredToolCall[];
|
|
3
|
+
export declare function recoverPrintedSkillLoad(text: string, skillToolName: string): RecoveredToolCall[];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { namedMarkupBlocks } from '../markup-scanner.js';
|
|
2
|
+
import { MAX_NAME_LENGTH, clipRawCall, isPlainObject } from './recover.js';
|
|
3
|
+
export function recoverSkillNamedCall(text, skillNames, skillToolName) {
|
|
4
|
+
const known = new Set(skillNames);
|
|
5
|
+
for (const block of namedMarkupBlocks(text, 'function', MAX_NAME_LENGTH)) {
|
|
6
|
+
if (!known.has(block.name))
|
|
7
|
+
continue;
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
id: 'recovered-skill-named-call',
|
|
11
|
+
name: skillToolName,
|
|
12
|
+
arguments: { name: block.name },
|
|
13
|
+
raw: clipRawCall(text.slice(block.start, block.end))
|
|
14
|
+
}
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
const SKILL_LOAD_KEYS = new Set(['name', 'skill', 'skill_name', 'file', 'path', 'filename']);
|
|
20
|
+
export function recoverPrintedSkillLoad(text, skillToolName) {
|
|
21
|
+
for (const match of text.matchAll(/\{[^{}]*\}/g)) {
|
|
22
|
+
const candidate = parsePrintedCandidate(match[0]);
|
|
23
|
+
if (!isPlainObject(candidate)) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const keys = Object.keys(candidate);
|
|
27
|
+
if (keys.length === 0 || !keys.every((key) => SKILL_LOAD_KEYS.has(key))) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const name = candidate.name ?? candidate.skill ?? candidate.skill_name;
|
|
31
|
+
const file = candidate.file ?? candidate.path ?? candidate.filename;
|
|
32
|
+
if (typeof name !== 'string' || typeof file !== 'string') {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (!/\.(md|py)\s*$/i.test(file.replaceAll('"', '').trim())) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
return [
|
|
39
|
+
{
|
|
40
|
+
id: 'recovered-printed-skill-load',
|
|
41
|
+
name: skillToolName,
|
|
42
|
+
arguments: { name, file },
|
|
43
|
+
raw: clipRawCall(match[0])
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
function parsePrintedCandidate(text) {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(text);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function redactToolCallMarkup(text: string, redactArgs: (name: string, args: Record<string, unknown>) => Record<string, unknown>): string;
|
|
2
|
+
export declare function redactBareParameterMarkup(text: string, isSensitiveName: (name: string) => boolean): string;
|
|
3
|
+
export declare function stripToolCallMarkup(text: string): string;
|
|
4
|
+
export declare function stripToolResponseBlocks(text: string): string;
|