@qvac/harness 0.1.0 → 0.1.2
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/dist/harness.bundle +13 -64
- package/dist/prebuilds-manifest.json +0 -8
- package/dist-lib/index.d.ts +240 -0
- package/dist-lib/index.js +1063 -0
- package/dist-lib/lib/audio-transcode-bare.d.ts +2 -0
- package/dist-lib/lib/audio-transcode-bare.js +145 -0
- package/dist-lib/lib/audio-transcode-node.d.ts +2 -0
- package/dist-lib/lib/audio-transcode-node.js +6 -0
- package/dist-lib/lib/capabilities/audio-resample.d.ts +14 -0
- package/dist-lib/lib/capabilities/audio-resample.js +72 -0
- package/dist-lib/lib/capabilities/completion.d.ts +288 -0
- package/dist-lib/lib/capabilities/completion.js +1077 -0
- package/dist-lib/lib/capabilities/download.d.ts +46 -0
- package/dist-lib/lib/capabilities/download.js +124 -0
- package/dist-lib/lib/capabilities/embed.d.ts +20 -0
- package/dist-lib/lib/capabilities/embed.js +13 -0
- package/dist-lib/lib/capabilities/kv-cache.d.ts +13 -0
- package/dist-lib/lib/capabilities/kv-cache.js +21 -0
- package/dist-lib/lib/capabilities/prompt-prefix.d.ts +6 -0
- package/dist-lib/lib/capabilities/prompt-prefix.js +10 -0
- package/dist-lib/lib/capabilities/speech-lexicon.d.ts +5 -0
- package/dist-lib/lib/capabilities/speech-lexicon.js +32 -0
- package/dist-lib/lib/capabilities/speech-text.d.ts +6 -0
- package/dist-lib/lib/capabilities/speech-text.js +79 -0
- package/dist-lib/lib/capabilities/tool-names.d.ts +3 -0
- package/dist-lib/lib/capabilities/tool-names.js +3 -0
- package/dist-lib/lib/capabilities/tool-selection.d.ts +43 -0
- package/dist-lib/lib/capabilities/tool-selection.js +60 -0
- package/dist-lib/lib/capabilities/tool-turns.d.ts +9 -0
- package/dist-lib/lib/capabilities/tool-turns.js +101 -0
- package/dist-lib/lib/capabilities/usage-breakdown.d.ts +27 -0
- package/dist-lib/lib/capabilities/usage-breakdown.js +44 -0
- package/dist-lib/lib/capabilities/vision-history.d.ts +3 -0
- package/dist-lib/lib/capabilities/vision-history.js +21 -0
- package/dist-lib/lib/capabilities/voice.d.ts +78 -0
- package/dist-lib/lib/capabilities/voice.js +189 -0
- package/dist-lib/lib/connect.d.ts +76 -0
- package/dist-lib/lib/connect.js +789 -0
- package/dist-lib/lib/context-window.d.ts +7 -0
- package/dist-lib/lib/context-window.js +90 -0
- package/dist-lib/lib/contract-types.d.ts +210 -0
- package/dist-lib/lib/contract-types.js +1 -0
- package/dist-lib/lib/diagram-repair.d.ts +21 -0
- package/dist-lib/lib/diagram-repair.js +58 -0
- package/dist-lib/lib/dns-lookup.d.ts +1 -0
- package/dist-lib/lib/dns-lookup.js +13 -0
- package/dist-lib/lib/error-fields.d.ts +2 -0
- package/dist-lib/lib/error-fields.js +8 -0
- package/dist-lib/lib/fetch-node.d.ts +1 -0
- package/dist-lib/lib/fetch-node.js +1 -0
- package/dist-lib/lib/hardware/capability-probe.d.ts +9 -0
- package/dist-lib/lib/hardware/capability-probe.js +99 -0
- package/dist-lib/lib/hardware/gpu-classify.d.ts +2 -0
- package/dist-lib/lib/hardware/gpu-classify.js +32 -0
- package/dist-lib/lib/hardware/gpu-probe-addon.d.ts +2 -0
- package/dist-lib/lib/hardware/gpu-probe-addon.js +42 -0
- package/dist-lib/lib/hardware/gpu-stats.bare.d.ts +1 -0
- package/dist-lib/lib/hardware/gpu-stats.bare.js +24 -0
- package/dist-lib/lib/hardware/gpu-stats.stub.d.ts +1 -0
- package/dist-lib/lib/hardware/gpu-stats.stub.js +3 -0
- package/dist-lib/lib/hardware/memory-budget.d.ts +8 -0
- package/dist-lib/lib/hardware/memory-budget.js +1 -0
- package/dist-lib/lib/hardware/parsers.d.ts +7 -0
- package/dist-lib/lib/hardware/parsers.js +41 -0
- package/dist-lib/lib/headers-bare.d.ts +1 -0
- package/dist-lib/lib/headers-bare.js +1 -0
- package/dist-lib/lib/headers-node.d.ts +4 -0
- package/dist-lib/lib/headers-node.js +1 -0
- package/dist-lib/lib/helpers/buffer-burst.d.ts +1 -0
- package/dist-lib/lib/helpers/buffer-burst.js +20 -0
- package/dist-lib/lib/helpers/control-tokens.d.ts +7 -0
- package/dist-lib/lib/helpers/control-tokens.js +32 -0
- package/dist-lib/lib/helpers/join-guard.d.ts +6 -0
- package/dist-lib/lib/helpers/join-guard.js +46 -0
- package/dist-lib/lib/helpers/markup-stream-filter.d.ts +5 -0
- package/dist-lib/lib/helpers/markup-stream-filter.js +75 -0
- package/dist-lib/lib/helpers/race-abort.d.ts +5 -0
- package/dist-lib/lib/helpers/race-abort.js +18 -0
- package/dist-lib/lib/helpers/retry-memo.d.ts +5 -0
- package/dist-lib/lib/helpers/retry-memo.js +12 -0
- package/dist-lib/lib/helpers/run-outcome.d.ts +33 -0
- package/dist-lib/lib/helpers/run-outcome.js +204 -0
- package/dist-lib/lib/helpers/spawn-path.d.ts +5 -0
- package/dist-lib/lib/helpers/spawn-path.js +57 -0
- package/dist-lib/lib/helpers/text-coalescer.d.ts +15 -0
- package/dist-lib/lib/helpers/text-coalescer.js +34 -0
- package/dist-lib/lib/helpers/thinking.d.ts +8 -0
- package/dist-lib/lib/helpers/thinking.js +95 -0
- package/dist-lib/lib/helpers/tool-call-markup.d.ts +20 -0
- package/dist-lib/lib/helpers/tool-call-markup.js +201 -0
- package/dist-lib/lib/helpers/tool-intent.d.ts +7 -0
- package/dist-lib/lib/helpers/tool-intent.js +21 -0
- package/dist-lib/lib/helpers/tool-label.d.ts +8 -0
- package/dist-lib/lib/helpers/tool-label.js +131 -0
- package/dist-lib/lib/hooks/built-in/arg-repair.d.ts +5 -0
- package/dist-lib/lib/hooks/built-in/arg-repair.js +88 -0
- package/dist-lib/lib/hooks/built-in/egress.d.ts +5 -0
- package/dist-lib/lib/hooks/built-in/egress.js +29 -0
- package/dist-lib/lib/hooks/built-in/index.d.ts +3 -0
- package/dist-lib/lib/hooks/built-in/index.js +3 -0
- package/dist-lib/lib/hooks/built-in/skill-catalog.d.ts +10 -0
- package/dist-lib/lib/hooks/built-in/skill-catalog.js +17 -0
- package/dist-lib/lib/hooks/pipeline.d.ts +20 -0
- package/dist-lib/lib/hooks/pipeline.js +49 -0
- package/dist-lib/lib/hooks/registry.d.ts +2 -0
- package/dist-lib/lib/hooks/registry.js +6 -0
- package/dist-lib/lib/hooks/run.d.ts +5 -0
- package/dist-lib/lib/hooks/run.js +83 -0
- package/dist-lib/lib/hooks/types.d.ts +57 -0
- package/dist-lib/lib/hooks/types.js +1 -0
- package/dist-lib/lib/log.d.ts +5 -0
- package/dist-lib/lib/log.js +37 -0
- package/dist-lib/lib/model-download-progress.d.ts +22 -0
- package/dist-lib/lib/model-download-progress.js +95 -0
- package/dist-lib/lib/models/context.d.ts +5 -0
- package/dist-lib/lib/models/context.js +12 -0
- package/dist-lib/lib/models/embed-config.d.ts +14 -0
- package/dist-lib/lib/models/embed-config.js +31 -0
- package/dist-lib/lib/models/gpu-selection.d.ts +3 -0
- package/dist-lib/lib/models/gpu-selection.js +26 -0
- package/dist-lib/lib/models/kv-cache.d.ts +4 -0
- package/dist-lib/lib/models/kv-cache.js +6 -0
- package/dist-lib/lib/models/llm-presets.d.ts +10 -0
- package/dist-lib/lib/models/llm-presets.js +58 -0
- package/dist-lib/lib/models/model-catalog-constants.d.ts +29 -0
- package/dist-lib/lib/models/model-catalog-constants.js +103 -0
- package/dist-lib/lib/models/model-catalog.d.ts +125 -0
- package/dist-lib/lib/models/model-catalog.js +371 -0
- package/dist-lib/lib/models/model-delete.d.ts +18 -0
- package/dist-lib/lib/models/model-delete.js +47 -0
- package/dist-lib/lib/models/model-handle.d.ts +18 -0
- package/dist-lib/lib/models/model-handle.js +33 -0
- package/dist-lib/lib/models/model-list.d.ts +42 -0
- package/dist-lib/lib/models/model-list.js +123 -0
- package/dist-lib/lib/models/model-pool.d.ts +116 -0
- package/dist-lib/lib/models/model-pool.js +356 -0
- package/dist-lib/lib/models/model-source.d.ts +6 -0
- package/dist-lib/lib/models/model-source.js +21 -0
- package/dist-lib/lib/models/music-catalog.d.ts +12 -0
- package/dist-lib/lib/models/music-catalog.js +26 -0
- package/dist-lib/lib/models/opencl-cache.d.ts +5 -0
- package/dist-lib/lib/models/opencl-cache.js +50 -0
- package/dist-lib/lib/models/sdk-faults.d.ts +21 -0
- package/dist-lib/lib/models/sdk-faults.js +66 -0
- package/dist-lib/lib/models/tool-dialect.d.ts +2 -0
- package/dist-lib/lib/models/tool-dialect.js +19 -0
- package/dist-lib/lib/models/tts-model-default.d.ts +3 -0
- package/dist-lib/lib/models/tts-model-default.js +13 -0
- package/dist-lib/lib/no-redirect-fetch-bare.d.ts +15 -0
- package/dist-lib/lib/no-redirect-fetch-bare.js +59 -0
- package/dist-lib/lib/no-redirect-fetch-impl.d.ts +39 -0
- package/dist-lib/lib/no-redirect-fetch-impl.js +80 -0
- package/dist-lib/lib/no-redirect-fetch-node.d.ts +4 -0
- package/dist-lib/lib/no-redirect-fetch-node.js +52 -0
- package/dist-lib/lib/prompt.d.ts +22 -0
- package/dist-lib/lib/prompt.js +77 -0
- package/dist-lib/lib/queue.d.ts +9 -0
- package/dist-lib/lib/queue.js +48 -0
- package/dist-lib/lib/resolution-detector.d.ts +5 -0
- package/dist-lib/lib/resolution-detector.js +100 -0
- package/dist-lib/lib/rpc-session.d.ts +8 -0
- package/dist-lib/lib/rpc-session.js +20 -0
- package/dist-lib/lib/sdk-config-loader.bare.d.ts +1 -0
- package/dist-lib/lib/sdk-config-loader.bare.js +9 -0
- package/dist-lib/lib/sdk-config-loader.node.d.ts +1 -0
- package/dist-lib/lib/sdk-config-loader.node.js +1 -0
- package/dist-lib/lib/sdk-loader.d.ts +30 -0
- package/dist-lib/lib/sdk-loader.js +53 -0
- package/dist-lib/lib/sdk-storage.d.ts +8 -0
- package/dist-lib/lib/sdk-storage.js +24 -0
- package/dist-lib/lib/serve.d.ts +3 -0
- package/dist-lib/lib/serve.js +612 -0
- package/dist-lib/lib/spawn.d.ts +62 -0
- package/dist-lib/lib/spawn.js +71 -0
- package/dist-lib/lib/staging.d.ts +4 -0
- package/dist-lib/lib/staging.js +28 -0
- package/dist-lib/lib/storage.d.ts +18 -0
- package/dist-lib/lib/storage.js +26 -0
- package/dist-lib/lib/tmp-path.d.ts +7 -0
- package/dist-lib/lib/tmp-path.js +17 -0
- package/dist-lib/lib/tool-call-display.d.ts +21 -0
- package/dist-lib/lib/tool-call-display.js +1 -0
- package/dist-lib/lib/tools/catalog.d.ts +13 -0
- package/dist-lib/lib/tools/catalog.js +13 -0
- package/dist-lib/lib/tools/create-documents.d.ts +3 -0
- package/dist-lib/lib/tools/create-documents.js +87 -0
- package/dist-lib/lib/tools/edit-documents.d.ts +3 -0
- package/dist-lib/lib/tools/edit-documents.js +122 -0
- package/dist-lib/lib/tools/edit-image.d.ts +25 -0
- package/dist-lib/lib/tools/edit-image.js +271 -0
- package/dist-lib/lib/tools/exec/adapters/adapter.d.ts +27 -0
- package/dist-lib/lib/tools/exec/adapters/adapter.js +1 -0
- package/dist-lib/lib/tools/exec/adapters/python/attachments.d.ts +26 -0
- package/dist-lib/lib/tools/exec/adapters/python/attachments.js +160 -0
- package/dist-lib/lib/tools/exec/adapters/python/create-effect.d.ts +7 -0
- package/dist-lib/lib/tools/exec/adapters/python/create-effect.js +290 -0
- package/dist-lib/lib/tools/exec/adapters/python/loader.d.ts +11 -0
- package/dist-lib/lib/tools/exec/adapters/python/loader.js +94 -0
- package/dist-lib/lib/tools/exec/adapters/python/memfs.d.ts +47 -0
- package/dist-lib/lib/tools/exec/adapters/python/memfs.js +85 -0
- package/dist-lib/lib/tools/exec/adapters/python/output-policy.d.ts +13 -0
- package/dist-lib/lib/tools/exec/adapters/python/output-policy.js +129 -0
- package/dist-lib/lib/tools/exec/adapters/python/pyodide.d.ts +19 -0
- package/dist-lib/lib/tools/exec/adapters/python/pyodide.js +107 -0
- package/dist-lib/lib/tools/exec/adapters/python/python-adapter.d.ts +75 -0
- package/dist-lib/lib/tools/exec/adapters/python/python-adapter.js +1094 -0
- package/dist-lib/lib/tools/exec/adapters/python/run-session.d.ts +75 -0
- package/dist-lib/lib/tools/exec/adapters/python/run-session.js +273 -0
- package/dist-lib/lib/tools/exec/adapters/python/wheels.d.ts +38 -0
- package/dist-lib/lib/tools/exec/adapters/python/wheels.js +102 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/client.d.ts +7 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/client.js +188 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/entry.d.ts +1 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/entry.js +105 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.d.ts +38 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.js +41 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-bare.d.ts +2 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-bare.js +30 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.d.ts +13 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.js +45 -0
- package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.d.ts +12 -0
- package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.js +20 -0
- package/dist-lib/lib/tools/exec/obsidian/cli-process.d.ts +8 -0
- package/dist-lib/lib/tools/exec/obsidian/cli-process.js +74 -0
- package/dist-lib/lib/tools/exec/obsidian/cli.d.ts +18 -0
- package/dist-lib/lib/tools/exec/obsidian/cli.js +153 -0
- package/dist-lib/lib/tools/exec/obsidian/command.d.ts +5 -0
- package/dist-lib/lib/tools/exec/obsidian/command.js +18 -0
- package/dist-lib/lib/tools/exec/obsidian/guidance.d.ts +5 -0
- package/dist-lib/lib/tools/exec/obsidian/guidance.js +18 -0
- package/dist-lib/lib/tools/exec/obsidian/note-name.d.ts +1 -0
- package/dist-lib/lib/tools/exec/obsidian/note-name.js +6 -0
- package/dist-lib/lib/tools/exec/obsidian/output.d.ts +1 -0
- package/dist-lib/lib/tools/exec/obsidian/output.js +31 -0
- package/dist-lib/lib/tools/exec/obsidian/route.d.ts +19 -0
- package/dist-lib/lib/tools/exec/obsidian/route.js +85 -0
- package/dist-lib/lib/tools/exec/obsidian/safe-path.d.ts +3 -0
- package/dist-lib/lib/tools/exec/obsidian/safe-path.js +56 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-create.d.ts +1 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-create.js +40 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-fs.d.ts +3 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-fs.js +57 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-paths.d.ts +20 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-paths.js +171 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-read.d.ts +11 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-read.js +119 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-write.d.ts +7 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-write.js +134 -0
- package/dist-lib/lib/tools/exec/runner.d.ts +62 -0
- package/dist-lib/lib/tools/exec/runner.js +87 -0
- package/dist-lib/lib/tools/exec/scope.d.ts +3 -0
- package/dist-lib/lib/tools/exec/scope.js +97 -0
- package/dist-lib/lib/tools/exec/shell-argv.d.ts +2 -0
- package/dist-lib/lib/tools/exec/shell-argv.js +48 -0
- package/dist-lib/lib/tools/exec.d.ts +29 -0
- package/dist-lib/lib/tools/exec.js +459 -0
- package/dist-lib/lib/tools/file-glob.d.ts +15 -0
- package/dist-lib/lib/tools/file-glob.js +112 -0
- package/dist-lib/lib/tools/fs/drive.d.ts +26 -0
- package/dist-lib/lib/tools/fs/drive.js +1 -0
- package/dist-lib/lib/tools/fs/glob.d.ts +1 -0
- package/dist-lib/lib/tools/fs/glob.js +34 -0
- package/dist-lib/lib/tools/fs/local.d.ts +2 -0
- package/dist-lib/lib/tools/fs/local.js +29 -0
- package/dist-lib/lib/tools/fs/read.d.ts +2 -0
- package/dist-lib/lib/tools/fs/read.js +17 -0
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +40 -0
- package/dist-lib/lib/tools/fs/remote-protocol.js +1 -0
- package/dist-lib/lib/tools/fs/remote.d.ts +17 -0
- package/dist-lib/lib/tools/fs/remote.js +131 -0
- package/dist-lib/lib/tools/fs/scope.d.ts +37 -0
- package/dist-lib/lib/tools/fs/scope.js +130 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +15 -0
- package/dist-lib/lib/tools/fs/walk.js +38 -0
- package/dist-lib/lib/tools/fs/write.d.ts +4 -0
- package/dist-lib/lib/tools/fs/write.js +5 -0
- package/dist-lib/lib/tools/generate-image.d.ts +111 -0
- package/dist-lib/lib/tools/generate-image.js +369 -0
- package/dist-lib/lib/tools/generate-music.d.ts +124 -0
- package/dist-lib/lib/tools/generate-music.js +522 -0
- package/dist-lib/lib/tools/grep.d.ts +5 -0
- package/dist-lib/lib/tools/grep.js +158 -0
- package/dist-lib/lib/tools/http-methods.d.ts +1 -0
- package/dist-lib/lib/tools/http-methods.js +1 -0
- package/dist-lib/lib/tools/http-request/encode-fields.d.ts +2 -0
- package/dist-lib/lib/tools/http-request/encode-fields.js +69 -0
- package/dist-lib/lib/tools/http-request/truncate-response.d.ts +1 -0
- package/dist-lib/lib/tools/http-request/truncate-response.js +83 -0
- package/dist-lib/lib/tools/http-request/utils.d.ts +27 -0
- package/dist-lib/lib/tools/http-request/utils.js +84 -0
- package/dist-lib/lib/tools/http-request.d.ts +20 -0
- package/dist-lib/lib/tools/http-request.js +177 -0
- package/dist-lib/lib/tools/mcp/utils.d.ts +47 -0
- package/dist-lib/lib/tools/mcp/utils.js +172 -0
- package/dist-lib/lib/tools/mcp-call.d.ts +14 -0
- package/dist-lib/lib/tools/mcp-call.js +155 -0
- package/dist-lib/lib/tools/model-args.d.ts +1 -0
- package/dist-lib/lib/tools/model-args.js +4 -0
- package/dist-lib/lib/tools/operations/builders.d.ts +17 -0
- package/dist-lib/lib/tools/operations/builders.js +179 -0
- package/dist-lib/lib/tools/operations/compile.d.ts +7 -0
- package/dist-lib/lib/tools/operations/compile.js +92 -0
- package/dist-lib/lib/tools/operations/gmail-message.d.ts +15 -0
- package/dist-lib/lib/tools/operations/gmail-message.js +62 -0
- package/dist-lib/lib/tools/operations/manifest.d.ts +60 -0
- package/dist-lib/lib/tools/operations/manifest.js +50 -0
- package/dist-lib/lib/tools/outbound-guard.d.ts +10 -0
- package/dist-lib/lib/tools/outbound-guard.js +127 -0
- package/dist-lib/lib/tools/private-ip.d.ts +4 -0
- package/dist-lib/lib/tools/private-ip.js +126 -0
- package/dist-lib/lib/tools/rag-search.d.ts +2 -0
- package/dist-lib/lib/tools/rag-search.js +98 -0
- package/dist-lib/lib/tools/read-files.d.ts +5 -0
- package/dist-lib/lib/tools/read-files.js +153 -0
- package/dist-lib/lib/tools/skill.d.ts +10 -0
- package/dist-lib/lib/tools/skill.js +123 -0
- package/dist-lib/lib/tools/skills/auth-resolver.d.ts +43 -0
- package/dist-lib/lib/tools/skills/auth-resolver.js +121 -0
- package/dist-lib/lib/tools/skills/bin-check.d.ts +9 -0
- package/dist-lib/lib/tools/skills/bin-check.js +56 -0
- package/dist-lib/lib/tools/skills/bundled-dir.d.ts +2 -0
- package/dist-lib/lib/tools/skills/bundled-dir.js +117 -0
- package/dist-lib/lib/tools/skills/bundled-hash.d.ts +4 -0
- package/dist-lib/lib/tools/skills/bundled-hash.js +12 -0
- package/dist-lib/lib/tools/skills/catalog.d.ts +60 -0
- package/dist-lib/lib/tools/skills/catalog.js +203 -0
- package/dist-lib/lib/tools/skills/cli-argv.d.ts +9 -0
- package/dist-lib/lib/tools/skills/cli-argv.js +147 -0
- package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +3 -0
- package/dist-lib/lib/tools/skills/cli-schema-check.js +62 -0
- package/dist-lib/lib/tools/skills/cli-schema-load.d.ts +4 -0
- package/dist-lib/lib/tools/skills/cli-schema-load.js +90 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +30 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.js +1 -0
- package/dist-lib/lib/tools/skills/cli-schema.d.ts +7 -0
- package/dist-lib/lib/tools/skills/cli-schema.js +35 -0
- package/dist-lib/lib/tools/skills/credential-check.d.ts +20 -0
- package/dist-lib/lib/tools/skills/credential-check.js +94 -0
- package/dist-lib/lib/tools/skills/credential-grants.d.ts +9 -0
- package/dist-lib/lib/tools/skills/credential-grants.js +25 -0
- package/dist-lib/lib/tools/skills/credential-health.d.ts +8 -0
- package/dist-lib/lib/tools/skills/credential-health.js +51 -0
- package/dist-lib/lib/tools/skills/credential-slots.d.ts +7 -0
- package/dist-lib/lib/tools/skills/credential-slots.js +8 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +23 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +68 -0
- package/dist-lib/lib/tools/skills/index.d.ts +5 -0
- package/dist-lib/lib/tools/skills/index.js +5 -0
- package/dist-lib/lib/tools/skills/manifest-parse.d.ts +12 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +199 -0
- package/dist-lib/lib/tools/skills/manifest.d.ts +47 -0
- package/dist-lib/lib/tools/skills/manifest.js +1 -0
- package/dist-lib/lib/tools/skills/mention-name.d.ts +1 -0
- package/dist-lib/lib/tools/skills/mention-name.js +4 -0
- package/dist-lib/lib/tools/skills/mention.d.ts +6 -0
- package/dist-lib/lib/tools/skills/mention.js +42 -0
- package/dist-lib/lib/tools/skills/obsidian-readiness.d.ts +16 -0
- package/dist-lib/lib/tools/skills/obsidian-readiness.js +95 -0
- package/dist-lib/lib/tools/skills/overlay-crud.d.ts +18 -0
- package/dist-lib/lib/tools/skills/overlay-crud.js +98 -0
- package/dist-lib/lib/tools/skills/overlay-dir.d.ts +2 -0
- package/dist-lib/lib/tools/skills/overlay-dir.js +22 -0
- package/dist-lib/lib/tools/skills/overlay-watch.d.ts +13 -0
- package/dist-lib/lib/tools/skills/overlay-watch.js +44 -0
- package/dist-lib/lib/tools/skills/scope-key.d.ts +7 -0
- package/dist-lib/lib/tools/skills/scope-key.js +7 -0
- package/dist-lib/lib/tools/skills/setup-routes.d.ts +4 -0
- package/dist-lib/lib/tools/skills/setup-routes.js +14 -0
- package/dist-lib/lib/tools/skills/skill-settings.d.ts +16 -0
- package/dist-lib/lib/tools/skills/skill-settings.js +33 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +12 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.js +14 -0
- package/dist-lib/lib/tools/skills/skill-state.d.ts +40 -0
- package/dist-lib/lib/tools/skills/skill-state.js +117 -0
- package/dist-lib/lib/tools/skills/tool-grants.d.ts +5 -0
- package/dist-lib/lib/tools/skills/tool-grants.js +14 -0
- package/dist-lib/lib/tools/toolsets.d.ts +8 -0
- package/dist-lib/lib/tools/toolsets.js +20 -0
- package/dist-lib/lib/tools/url-guard.d.ts +8 -0
- package/dist-lib/lib/tools/url-guard.js +40 -0
- package/dist-lib/lib/tools/web-fetch.d.ts +8 -0
- package/dist-lib/lib/tools/web-fetch.js +302 -0
- package/dist-lib/lib/tools/web-search.d.ts +6 -0
- package/dist-lib/lib/tools/web-search.js +55 -0
- package/dist-lib/lib/transport.d.ts +12 -0
- package/dist-lib/lib/transport.js +59 -0
- package/dist-lib/lib/user-agent.d.ts +1 -0
- package/dist-lib/lib/user-agent.js +1 -0
- package/dist-lib/lib/validating-lookup.d.ts +17 -0
- package/dist-lib/lib/validating-lookup.js +25 -0
- package/dist-lib/lib/wav-encode.d.ts +5 -0
- package/dist-lib/lib/wav-encode.js +24 -0
- package/dist-lib/lib/web-fetch/embedded-state.d.ts +1 -0
- package/dist-lib/lib/web-fetch/embedded-state.js +131 -0
- package/dist-lib/lib/web-fetch/extract.d.ts +6 -0
- package/dist-lib/lib/web-fetch/extract.js +65 -0
- package/dist-lib/lib/web-fetch/images.d.ts +3 -0
- package/dist-lib/lib/web-fetch/images.js +43 -0
- package/dist-lib/lib/web-fetch/video.d.ts +5 -0
- package/dist-lib/lib/web-fetch/video.js +42 -0
- package/dist-lib/lib/web-search/engine-registry.d.ts +7 -0
- package/dist-lib/lib/web-search/engine-registry.js +17 -0
- package/dist-lib/lib/web-search/engines/aol.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/aol.js +81 -0
- package/dist-lib/lib/web-search/engines/bing.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/bing.js +111 -0
- package/dist-lib/lib/web-search/engines/brave.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/brave.js +59 -0
- package/dist-lib/lib/web-search/engines/duckduckgo.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/duckduckgo.js +112 -0
- package/dist-lib/lib/web-search/engines/google.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/google.js +92 -0
- package/dist-lib/lib/web-search/engines/wikipedia.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/wikipedia.js +37 -0
- package/dist-lib/lib/web-search/engines/yahoo.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/yahoo.js +81 -0
- package/dist-lib/lib/web-search/fetch-html.d.ts +25 -0
- package/dist-lib/lib/web-search/fetch-html.js +97 -0
- package/dist-lib/lib/web-search/format-results.d.ts +3 -0
- package/dist-lib/lib/web-search/format-results.js +14 -0
- package/dist-lib/lib/web-search/html-helpers.d.ts +3 -0
- package/dist-lib/lib/web-search/html-helpers.js +24 -0
- package/dist-lib/lib/web-search/merge-results.d.ts +2 -0
- package/dist-lib/lib/web-search/merge-results.js +53 -0
- package/dist-lib/lib/web-search/orchestrator.d.ts +14 -0
- package/dist-lib/lib/web-search/orchestrator.js +50 -0
- package/dist-lib/lib/web-search/types.d.ts +34 -0
- package/dist-lib/lib/web-search/types.js +1 -0
- package/dist-lib/lib/web-search/url-helpers.d.ts +1 -0
- package/dist-lib/lib/web-search/url-helpers.js +11 -0
- package/dist-lib/lib/web-search/url-normalize.d.ts +1 -0
- package/dist-lib/lib/web-search/url-normalize.js +25 -0
- package/dist-lib/lib/web-search/user-agents.d.ts +3 -0
- package/dist-lib/lib/web-search/user-agents.js +3 -0
- package/dist-lib/lib/wire.d.ts +50 -0
- package/dist-lib/lib/wire.js +145 -0
- package/dist-lib/schema/baseline.d.ts +8 -0
- package/dist-lib/schema/baseline.js +35 -0
- package/dist-lib/schema/build.d.ts +1 -0
- package/dist-lib/schema/build.js +39 -0
- package/dist-lib/schema/generate.d.ts +20 -0
- package/dist-lib/schema/generate.js +149 -0
- package/dist-lib/schema/harness.d.ts +2 -0
- package/dist-lib/schema/harness.js +745 -0
- package/dist-lib/schema/release-tags.d.ts +5 -0
- package/dist-lib/schema/release-tags.js +58 -0
- package/dist-lib/spec/bind.d.ts +2 -0
- package/dist-lib/spec/bind.js +124 -0
- package/dist-lib/spec/calls.d.ts +3 -0
- package/dist-lib/spec/calls.js +41 -0
- package/dist-lib/spec/hrpc/hrpc.json +356 -0
- package/dist-lib/spec/hrpc/index.d.ts +3 -0
- package/dist-lib/spec/hrpc/index.js +463 -0
- package/dist-lib/spec/hrpc/messages.d.ts +4 -0
- package/dist-lib/spec/hrpc/messages.js +3102 -0
- package/dist-lib/spec/hyperschema/index.js +3102 -0
- package/dist-lib/spec/hyperschema/schema.json +2290 -0
- package/dist-lib/spec/hyperschema/types.d.ts +554 -0
- package/dist-lib/spec/index.d.ts +8 -0
- package/dist-lib/spec/index.js +1 -0
- package/package.json +239 -64
- package/.gitattributes +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface TextEvent {
|
|
2
|
+
type: 'thinking' | 'content';
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface SplitThinkingOptions {
|
|
6
|
+
startInThink?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function splitThinking(tokens: AsyncIterable<string>, opts?: SplitThinkingOptions): AsyncGenerator<TextEvent, string | null>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { firstMarker } from 'asenion/guards';
|
|
2
|
+
import { holdback } from 'asenion/scan';
|
|
3
|
+
import { STOP_MARKERS } from "./control-tokens.js";
|
|
4
|
+
import { createJoinGuard } from "./join-guard.js";
|
|
5
|
+
const OPEN_TAGS = ['<think>', '<thinking>'];
|
|
6
|
+
const CLOSE_TAGS = ['</think>', '</thinking>'];
|
|
7
|
+
const ALL_TAGS = [...OPEN_TAGS, ...CLOSE_TAGS];
|
|
8
|
+
const NEVER_ASSEMBLE = [...ALL_TAGS, ...STOP_MARKERS];
|
|
9
|
+
function findEarliest(buffer, tags) {
|
|
10
|
+
const found = firstMarker(buffer, tags);
|
|
11
|
+
return found === null ? null : { idx: found.index, len: found.marker.length };
|
|
12
|
+
}
|
|
13
|
+
export async function* splitThinking(tokens, opts) {
|
|
14
|
+
let buffer = '';
|
|
15
|
+
let inThink = opts?.startInThink === true;
|
|
16
|
+
let unproven = inThink ? '' : null;
|
|
17
|
+
const guards = {
|
|
18
|
+
thinking: createJoinGuard(NEVER_ASSEMBLE),
|
|
19
|
+
content: createJoinGuard(NEVER_ASSEMBLE)
|
|
20
|
+
};
|
|
21
|
+
const emit = (type, text) => {
|
|
22
|
+
const shown = guards[type].push(text);
|
|
23
|
+
if (!shown)
|
|
24
|
+
return null;
|
|
25
|
+
if (type === 'thinking' && unproven !== null)
|
|
26
|
+
unproven += shown;
|
|
27
|
+
return { type, text: shown };
|
|
28
|
+
};
|
|
29
|
+
for await (const token of tokens) {
|
|
30
|
+
buffer += token;
|
|
31
|
+
while (true) {
|
|
32
|
+
if (inThink) {
|
|
33
|
+
const open = findEarliest(buffer, OPEN_TAGS);
|
|
34
|
+
const close = findEarliest(buffer, CLOSE_TAGS);
|
|
35
|
+
if (open && (!close || open.idx < close.idx)) {
|
|
36
|
+
const event = emit('thinking', buffer.slice(0, open.idx));
|
|
37
|
+
if (event)
|
|
38
|
+
yield event;
|
|
39
|
+
guards.thinking.cut();
|
|
40
|
+
buffer = buffer.slice(open.idx + open.len);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (!close)
|
|
44
|
+
break;
|
|
45
|
+
const event = emit('thinking', buffer.slice(0, close.idx));
|
|
46
|
+
if (event)
|
|
47
|
+
yield event;
|
|
48
|
+
guards.thinking.cut();
|
|
49
|
+
buffer = buffer.slice(close.idx + close.len);
|
|
50
|
+
inThink = false;
|
|
51
|
+
unproven = null;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const open = findEarliest(buffer, OPEN_TAGS);
|
|
55
|
+
const close = findEarliest(buffer, CLOSE_TAGS);
|
|
56
|
+
if (close && (!open || close.idx < open.idx)) {
|
|
57
|
+
const event = emit('content', buffer.slice(0, close.idx));
|
|
58
|
+
if (event)
|
|
59
|
+
yield event;
|
|
60
|
+
guards.content.cut();
|
|
61
|
+
buffer = buffer.slice(close.idx + close.len);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (open) {
|
|
65
|
+
const event = emit('content', buffer.slice(0, open.idx));
|
|
66
|
+
if (event)
|
|
67
|
+
yield event;
|
|
68
|
+
guards.content.cut();
|
|
69
|
+
buffer = buffer.slice(open.idx + open.len);
|
|
70
|
+
inThink = true;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
const held = holdback(buffer, inThink ? CLOSE_TAGS : ALL_TAGS);
|
|
76
|
+
if (buffer.length > held) {
|
|
77
|
+
const event = emit(inThink ? 'thinking' : 'content', buffer.slice(0, buffer.length - held));
|
|
78
|
+
if (event)
|
|
79
|
+
yield event;
|
|
80
|
+
buffer = buffer.slice(buffer.length - held);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const last = emit(inThink ? 'thinking' : 'content', buffer);
|
|
84
|
+
if (last)
|
|
85
|
+
yield last;
|
|
86
|
+
for (const type of ['thinking', 'content']) {
|
|
87
|
+
const rest = guards[type].flush();
|
|
88
|
+
if (!rest)
|
|
89
|
+
continue;
|
|
90
|
+
if (type === 'thinking' && unproven !== null)
|
|
91
|
+
unproven += rest;
|
|
92
|
+
yield { type, text: rest };
|
|
93
|
+
}
|
|
94
|
+
return unproven;
|
|
95
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface RecoveredToolCall {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
arguments: Record<string, unknown>;
|
|
5
|
+
raw?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const MAX_RAW_CALL_CHARS = 4096;
|
|
8
|
+
export declare function clipRawCall(raw: string): string;
|
|
9
|
+
export declare function recoverMarkupToolCalls(text: string, knownTools: ReadonlyArray<{
|
|
10
|
+
name: string;
|
|
11
|
+
}>): RecoveredToolCall[];
|
|
12
|
+
export declare function stripToolCallMarkup(text: string): string;
|
|
13
|
+
export declare function stripToolResponseBlocks(text: string): string;
|
|
14
|
+
export declare function toolCallMarkup(calls: ReadonlyArray<{
|
|
15
|
+
name: string;
|
|
16
|
+
arguments?: Record<string, unknown>;
|
|
17
|
+
}>): string;
|
|
18
|
+
export declare function normalizeToolArgs(args: Record<string, unknown>, declaredKeys: ReadonlyArray<string>): Record<string, unknown>;
|
|
19
|
+
export declare function recoverSkillNamedCall(text: string, skillNames: ReadonlyArray<string>, skillToolName: string): RecoveredToolCall[];
|
|
20
|
+
export declare function recoverPrintedSkillLoad(text: string, skillToolName: string): RecoveredToolCall[];
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
const FUNCTION_OPEN = '<function=';
|
|
2
|
+
const FUNCTION_CLOSE = '</function>';
|
|
3
|
+
const RESPONSE_OPEN = '<tool_response>';
|
|
4
|
+
const RESPONSE_CLOSE = '</tool_response>';
|
|
5
|
+
const PARAMETER_OPEN = '<parameter=';
|
|
6
|
+
const PARAMETER_CLOSE = '</parameter>';
|
|
7
|
+
const MAX_NAME_LENGTH = 64;
|
|
8
|
+
function* markupBlocks(text, open, close) {
|
|
9
|
+
let cursor = 0;
|
|
10
|
+
for (;;) {
|
|
11
|
+
const start = text.indexOf(open, cursor);
|
|
12
|
+
if (start === -1)
|
|
13
|
+
return;
|
|
14
|
+
const nameStart = start + open.length;
|
|
15
|
+
cursor = nameStart;
|
|
16
|
+
const name = nameOf(text, nameStart);
|
|
17
|
+
if (name === null)
|
|
18
|
+
continue;
|
|
19
|
+
const bodyStart = nameStart + name.length + 1;
|
|
20
|
+
const bodyEnd = text.indexOf(close, bodyStart);
|
|
21
|
+
if (bodyEnd === -1)
|
|
22
|
+
return;
|
|
23
|
+
yield {
|
|
24
|
+
name: name.trim(),
|
|
25
|
+
body: text.slice(bodyStart, bodyEnd),
|
|
26
|
+
start,
|
|
27
|
+
end: bodyEnd + close.length
|
|
28
|
+
};
|
|
29
|
+
cursor = bodyEnd + close.length;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function nameOf(text, nameStart) {
|
|
33
|
+
const window = text.slice(nameStart, nameStart + MAX_NAME_LENGTH + 1);
|
|
34
|
+
const nameEnd = window.indexOf('>');
|
|
35
|
+
if (nameEnd === -1)
|
|
36
|
+
return null;
|
|
37
|
+
const name = window.slice(0, nameEnd);
|
|
38
|
+
return name.includes('\n') ? null : name;
|
|
39
|
+
}
|
|
40
|
+
export const MAX_RAW_CALL_CHARS = 4096;
|
|
41
|
+
export function clipRawCall(raw) {
|
|
42
|
+
return raw.length > MAX_RAW_CALL_CHARS ? raw.slice(0, MAX_RAW_CALL_CHARS) : raw;
|
|
43
|
+
}
|
|
44
|
+
export function recoverMarkupToolCalls(text, knownTools) {
|
|
45
|
+
const known = new Set(knownTools.map((tool) => tool.name));
|
|
46
|
+
const calls = [];
|
|
47
|
+
for (const block of markupBlocks(text, FUNCTION_OPEN, FUNCTION_CLOSE)) {
|
|
48
|
+
if (!block.name || !known.has(block.name))
|
|
49
|
+
continue;
|
|
50
|
+
calls.push({
|
|
51
|
+
id: `recovered-markup-${calls.length}`,
|
|
52
|
+
name: block.name,
|
|
53
|
+
arguments: decodeArguments(block.body),
|
|
54
|
+
raw: clipRawCall(text.slice(block.start, block.end))
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return calls;
|
|
58
|
+
}
|
|
59
|
+
export function stripToolCallMarkup(text) {
|
|
60
|
+
let out = '';
|
|
61
|
+
let cursor = 0;
|
|
62
|
+
for (const block of markupBlocks(text, FUNCTION_OPEN, FUNCTION_CLOSE)) {
|
|
63
|
+
out += text.slice(cursor, block.start);
|
|
64
|
+
cursor = block.end;
|
|
65
|
+
}
|
|
66
|
+
out += text.slice(cursor);
|
|
67
|
+
const dangling = danglingIndex(out);
|
|
68
|
+
const withoutCalls = dangling === -1 ? out : out.slice(0, dangling);
|
|
69
|
+
return stripToolResponseBlocks(withoutCalls)
|
|
70
|
+
.replace(/<\/?(tool_call|tool_response)>/gi, '')
|
|
71
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
72
|
+
.trim();
|
|
73
|
+
}
|
|
74
|
+
export function stripToolResponseBlocks(text) {
|
|
75
|
+
let out = '';
|
|
76
|
+
let cursor = 0;
|
|
77
|
+
for (;;) {
|
|
78
|
+
const start = text.indexOf(RESPONSE_OPEN, cursor);
|
|
79
|
+
if (start === -1)
|
|
80
|
+
break;
|
|
81
|
+
out += text.slice(cursor, start);
|
|
82
|
+
const end = text.indexOf(RESPONSE_CLOSE, start + RESPONSE_OPEN.length);
|
|
83
|
+
if (end === -1)
|
|
84
|
+
return out;
|
|
85
|
+
cursor = end + RESPONSE_CLOSE.length;
|
|
86
|
+
}
|
|
87
|
+
return out + text.slice(cursor);
|
|
88
|
+
}
|
|
89
|
+
function danglingIndex(text) {
|
|
90
|
+
let cursor = 0;
|
|
91
|
+
for (;;) {
|
|
92
|
+
const start = text.indexOf(FUNCTION_OPEN, cursor);
|
|
93
|
+
if (start === -1)
|
|
94
|
+
return -1;
|
|
95
|
+
const nameStart = start + FUNCTION_OPEN.length;
|
|
96
|
+
if (nameOf(text, nameStart) !== null)
|
|
97
|
+
return start;
|
|
98
|
+
cursor = nameStart;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export function toolCallMarkup(calls) {
|
|
102
|
+
return calls.map(markupForCall).join('\n');
|
|
103
|
+
}
|
|
104
|
+
function markupForCall(call) {
|
|
105
|
+
const params = Object.entries(call.arguments ?? {})
|
|
106
|
+
.map(([key, value]) => `<parameter=${key}>${encodeMarkupValue(value)}</parameter>`)
|
|
107
|
+
.join('');
|
|
108
|
+
return `<function=${call.name}>${params}</function>`;
|
|
109
|
+
}
|
|
110
|
+
function encodeMarkupValue(value) {
|
|
111
|
+
return JSON.stringify(value ?? null).replace(/</g, '\\u003c');
|
|
112
|
+
}
|
|
113
|
+
const ARG_WRAPPER_KEYS = new Set(['parameters', 'arguments', 'args', 'input', 'params']);
|
|
114
|
+
function isRecord(value) {
|
|
115
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
116
|
+
}
|
|
117
|
+
export function normalizeToolArgs(args, declaredKeys) {
|
|
118
|
+
const keys = Object.keys(args);
|
|
119
|
+
if (keys.length !== 1)
|
|
120
|
+
return args;
|
|
121
|
+
const only = keys[0];
|
|
122
|
+
if (!ARG_WRAPPER_KEYS.has(only) || declaredKeys.includes(only))
|
|
123
|
+
return args;
|
|
124
|
+
const inner = args[only];
|
|
125
|
+
if (isRecord(inner))
|
|
126
|
+
return inner;
|
|
127
|
+
if (typeof inner === 'string') {
|
|
128
|
+
try {
|
|
129
|
+
const parsed = JSON.parse(inner);
|
|
130
|
+
if (isRecord(parsed))
|
|
131
|
+
return parsed;
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return args;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return args;
|
|
138
|
+
}
|
|
139
|
+
function decodeArguments(block) {
|
|
140
|
+
const args = {};
|
|
141
|
+
for (const param of markupBlocks(block, PARAMETER_OPEN, PARAMETER_CLOSE)) {
|
|
142
|
+
if (!param.name)
|
|
143
|
+
continue;
|
|
144
|
+
const raw = param.body.trim();
|
|
145
|
+
try {
|
|
146
|
+
args[param.name] = JSON.parse(raw);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
args[param.name] = raw;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return args;
|
|
153
|
+
}
|
|
154
|
+
export function recoverSkillNamedCall(text, skillNames, skillToolName) {
|
|
155
|
+
const known = new Set(skillNames);
|
|
156
|
+
for (const block of markupBlocks(text, FUNCTION_OPEN, FUNCTION_CLOSE)) {
|
|
157
|
+
if (!known.has(block.name))
|
|
158
|
+
continue;
|
|
159
|
+
return [
|
|
160
|
+
{
|
|
161
|
+
id: 'recovered-skill-named-call',
|
|
162
|
+
name: skillToolName,
|
|
163
|
+
arguments: { name: block.name },
|
|
164
|
+
raw: clipRawCall(text.slice(block.start, block.end))
|
|
165
|
+
}
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
const SKILL_LOAD_KEYS = new Set(['name', 'skill', 'skill_name', 'file', 'path', 'filename']);
|
|
171
|
+
export function recoverPrintedSkillLoad(text, skillToolName) {
|
|
172
|
+
for (const match of text.matchAll(/\{[^{}]*\}/g)) {
|
|
173
|
+
let candidate;
|
|
174
|
+
try {
|
|
175
|
+
candidate = JSON.parse(match[0]);
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (!isRecord(candidate))
|
|
181
|
+
continue;
|
|
182
|
+
const keys = Object.keys(candidate);
|
|
183
|
+
if (keys.length === 0 || !keys.every((key) => SKILL_LOAD_KEYS.has(key)))
|
|
184
|
+
continue;
|
|
185
|
+
const name = candidate.name ?? candidate.skill ?? candidate.skill_name;
|
|
186
|
+
const file = candidate.file ?? candidate.path ?? candidate.filename;
|
|
187
|
+
if (typeof name !== 'string' || typeof file !== 'string')
|
|
188
|
+
continue;
|
|
189
|
+
if (!/\.(md|py)\s*$/i.test(file.replaceAll('"', '').trim()))
|
|
190
|
+
continue;
|
|
191
|
+
return [
|
|
192
|
+
{
|
|
193
|
+
id: 'recovered-printed-skill-load',
|
|
194
|
+
name: skillToolName,
|
|
195
|
+
arguments: { name, file },
|
|
196
|
+
raw: clipRawCall(match[0])
|
|
197
|
+
}
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const INTENT_PARAM = "intent";
|
|
2
|
+
export declare const INTENT_PARAM_DESCRIPTION: string;
|
|
3
|
+
export declare function sanitizeToolIntent(value: unknown): string | undefined;
|
|
4
|
+
export declare function takeToolIntent(args: Record<string, unknown>): {
|
|
5
|
+
args: Record<string, unknown>;
|
|
6
|
+
intent?: string;
|
|
7
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { stripControlTokens } from "./control-tokens.js";
|
|
2
|
+
export const INTENT_PARAM = 'intent';
|
|
3
|
+
export const INTENT_PARAM_DESCRIPTION = 'One short sentence, addressed to the user, saying plainly what this call will ' +
|
|
4
|
+
'do for them — the outcome, never the code. It is the only thing the approval ' +
|
|
5
|
+
'prompt shows them.';
|
|
6
|
+
const MAX_INTENT_LENGTH = 160;
|
|
7
|
+
export function sanitizeToolIntent(value) {
|
|
8
|
+
if (typeof value !== 'string')
|
|
9
|
+
return undefined;
|
|
10
|
+
const collapsed = stripControlTokens(value).replace(/\s+/g, ' ').trim();
|
|
11
|
+
if (!collapsed)
|
|
12
|
+
return undefined;
|
|
13
|
+
return collapsed.length > MAX_INTENT_LENGTH ? collapsed.slice(0, MAX_INTENT_LENGTH) : collapsed;
|
|
14
|
+
}
|
|
15
|
+
export function takeToolIntent(args) {
|
|
16
|
+
if (!(INTENT_PARAM in args))
|
|
17
|
+
return { args };
|
|
18
|
+
const { [INTENT_PARAM]: raw, ...rest } = args;
|
|
19
|
+
const intent = sanitizeToolIntent(raw);
|
|
20
|
+
return intent === undefined ? { args: rest } : { args: rest, intent };
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResponseFormat } from '../capabilities/completion.ts';
|
|
2
|
+
import type { ToolCallDisplay } from '../tool-call-display.ts';
|
|
3
|
+
export declare const TOOL_LABEL_SCHEMA: ResponseFormat;
|
|
4
|
+
export declare function buildToolLabelPrompt(name: string, args: Record<string, unknown>): string;
|
|
5
|
+
export declare function skillCallLabel(args: Record<string, unknown>): string;
|
|
6
|
+
export declare function isSkillTool(name: string): boolean;
|
|
7
|
+
export declare function parseToolLabelResponse(raw: string): ToolCallDisplay | null;
|
|
8
|
+
export declare function fallbackToolLabel(name: string, args?: Record<string, unknown>): string;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { unwrap } from 'asenion';
|
|
2
|
+
import { SKILL_TOOL_NAME } from "../capabilities/tool-names.js";
|
|
3
|
+
import { unquoteArg } from "../tools/model-args.js";
|
|
4
|
+
import { stripControlTokens } from "./control-tokens.js";
|
|
5
|
+
const MAX_LABEL_WORDS = 6;
|
|
6
|
+
const MAX_LABEL_LENGTH = 60;
|
|
7
|
+
const MAX_DESCRIPTION_LENGTH = 200;
|
|
8
|
+
const MAX_ARGS_JSON = 1500;
|
|
9
|
+
const LABEL_INSTRUCTION = 'Write a 3 to 6 word label a person watching the run would read, and one sentence describing ' +
|
|
10
|
+
'what the call does and to what, for a person deciding whether to approve it. ' +
|
|
11
|
+
'Do not mention tools, code, JSON, or these instructions. ' +
|
|
12
|
+
'Examples: Load apple-notes; Search today’s space news; Read example.com/docs.';
|
|
13
|
+
const ECHOED_INSTRUCTION = /3 to 6 words?|name the action|do not mention tools|person watching|tool call in|describe the outcome|not the code|run outcome description|^(skill )?tool call$/i;
|
|
14
|
+
export const TOOL_LABEL_SCHEMA = {
|
|
15
|
+
type: 'json_schema',
|
|
16
|
+
json_schema: {
|
|
17
|
+
name: 'tool_label',
|
|
18
|
+
schema: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: { label: { type: 'string' }, description: { type: 'string' } },
|
|
21
|
+
required: ['label', 'description'],
|
|
22
|
+
additionalProperties: false
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export function buildToolLabelPrompt(name, args) {
|
|
27
|
+
const json = JSON.stringify(args);
|
|
28
|
+
const clipped = json.length > MAX_ARGS_JSON ? json.slice(0, MAX_ARGS_JSON) : json;
|
|
29
|
+
return `${LABEL_INSTRUCTION}\nTool: ${name}\nArguments:\n${clipped}`;
|
|
30
|
+
}
|
|
31
|
+
function normalizeModelLabel(raw) {
|
|
32
|
+
const firstLine = stripControlTokens(raw)
|
|
33
|
+
.split(/\r?\n/)
|
|
34
|
+
.map((line) => line.trim())
|
|
35
|
+
.find(Boolean);
|
|
36
|
+
if (!firstLine)
|
|
37
|
+
return null;
|
|
38
|
+
const unlabeled = firstLine.replace(/^label\s*[:\-–]\s*/i, '');
|
|
39
|
+
const unquoted = unwrap(unlabeled)
|
|
40
|
+
.replace(/^["'`]+|["'`]+$/g, '')
|
|
41
|
+
.trim();
|
|
42
|
+
const words = unquoted.split(/\s+/).filter(Boolean).slice(0, MAX_LABEL_WORDS);
|
|
43
|
+
if (words.length === 0)
|
|
44
|
+
return null;
|
|
45
|
+
const label = words
|
|
46
|
+
.join(' ')
|
|
47
|
+
.replace(/[.,;:!?]+$/, '')
|
|
48
|
+
.trim()
|
|
49
|
+
.slice(0, MAX_LABEL_LENGTH)
|
|
50
|
+
.trim();
|
|
51
|
+
if (!label || ECHOED_INSTRUCTION.test(label))
|
|
52
|
+
return null;
|
|
53
|
+
return label;
|
|
54
|
+
}
|
|
55
|
+
export function skillCallLabel(args) {
|
|
56
|
+
const name = stringArg(args, 'name') || stringArg(args, 'skill_name') || stringArg(args, 'skill');
|
|
57
|
+
if (!name)
|
|
58
|
+
return 'Load skill instructions';
|
|
59
|
+
const title = titleSkillName(name);
|
|
60
|
+
const file = stringArg(args, 'file');
|
|
61
|
+
return file ? `Read ${title}/${fileName(file)}` : `Load ${title}`;
|
|
62
|
+
}
|
|
63
|
+
export function isSkillTool(name) {
|
|
64
|
+
return name === SKILL_TOOL_NAME;
|
|
65
|
+
}
|
|
66
|
+
function stringArg(args, key) {
|
|
67
|
+
const value = args[key];
|
|
68
|
+
if (typeof value !== 'string')
|
|
69
|
+
return '';
|
|
70
|
+
return unquoteArg(value).trim();
|
|
71
|
+
}
|
|
72
|
+
function fileName(path) {
|
|
73
|
+
const parts = path.split(/[/\\]/);
|
|
74
|
+
return parts.at(-1) || path;
|
|
75
|
+
}
|
|
76
|
+
function titleSkillName(name) {
|
|
77
|
+
return name
|
|
78
|
+
.split(/[-_\s]+/)
|
|
79
|
+
.filter(Boolean)
|
|
80
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
81
|
+
.join(' ');
|
|
82
|
+
}
|
|
83
|
+
function normalizeModelDescription(raw) {
|
|
84
|
+
const text = stripControlTokens(raw).replace(/\s+/g, ' ').trim();
|
|
85
|
+
if (!text || ECHOED_INSTRUCTION.test(text))
|
|
86
|
+
return undefined;
|
|
87
|
+
return text.length > MAX_DESCRIPTION_LENGTH
|
|
88
|
+
? `${text.slice(0, MAX_DESCRIPTION_LENGTH).trimEnd()}…`
|
|
89
|
+
: text;
|
|
90
|
+
}
|
|
91
|
+
export function parseToolLabelResponse(raw) {
|
|
92
|
+
const trimmed = raw.trim();
|
|
93
|
+
if (trimmed.startsWith('{')) {
|
|
94
|
+
try {
|
|
95
|
+
const parsed = JSON.parse(trimmed);
|
|
96
|
+
const label = typeof parsed.label === 'string' ? normalizeModelLabel(parsed.label) : null;
|
|
97
|
+
if (!label)
|
|
98
|
+
return null;
|
|
99
|
+
const description = typeof parsed.description === 'string'
|
|
100
|
+
? normalizeModelDescription(parsed.description)
|
|
101
|
+
: undefined;
|
|
102
|
+
return description ? { label, description } : { label };
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const label = normalizeModelLabel(trimmed);
|
|
108
|
+
return label ? { label } : null;
|
|
109
|
+
}
|
|
110
|
+
export function fallbackToolLabel(name, args = {}) {
|
|
111
|
+
if (isSkillTool(name))
|
|
112
|
+
return skillCallLabel(args);
|
|
113
|
+
const query = stringArg(args, 'query');
|
|
114
|
+
if (query)
|
|
115
|
+
return `Search ${query}`.slice(0, MAX_LABEL_LENGTH).trim();
|
|
116
|
+
const url = stringArg(args, 'url');
|
|
117
|
+
if (url) {
|
|
118
|
+
const method = stringArg(args, 'method').toUpperCase();
|
|
119
|
+
const target = displayUrl(url);
|
|
120
|
+
return `${method ? `${method} ` : 'Read '}${target}`.slice(0, MAX_LABEL_LENGTH).trim();
|
|
121
|
+
}
|
|
122
|
+
const words = name.replace(/[_-]+/g, ' ').trim();
|
|
123
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
124
|
+
}
|
|
125
|
+
function displayUrl(url) {
|
|
126
|
+
const trimmed = url
|
|
127
|
+
.trim()
|
|
128
|
+
.replace(/^https?:\/\//, '')
|
|
129
|
+
.replace(/\/$/, '');
|
|
130
|
+
return trimmed || url;
|
|
131
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsonrepair } from 'jsonrepair';
|
|
2
|
+
import { hlog } from "../../log.js";
|
|
3
|
+
const STRUCTURED_TYPES = new Set(['object', 'array']);
|
|
4
|
+
export class ArgRepairHook {
|
|
5
|
+
phase = 'preToolCall';
|
|
6
|
+
run(ctx) {
|
|
7
|
+
if (ctx.phase !== 'preToolCall' || !ctx.parameters)
|
|
8
|
+
return;
|
|
9
|
+
let args = ctx.args;
|
|
10
|
+
for (const [key, schema] of Object.entries(ctx.parameters.properties)) {
|
|
11
|
+
const value = args[key];
|
|
12
|
+
if (typeof value !== 'string')
|
|
13
|
+
continue;
|
|
14
|
+
const types = structuredTypes(schema);
|
|
15
|
+
if (types.size === 0)
|
|
16
|
+
continue;
|
|
17
|
+
const parsed = parseStructured(value, types);
|
|
18
|
+
if (parsed === null) {
|
|
19
|
+
hlog('arg repair declined', { tool: ctx.toolName, param: key, length: value.length });
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
args = { ...args, [key]: parsed };
|
|
23
|
+
}
|
|
24
|
+
if (args !== ctx.args)
|
|
25
|
+
return { args };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function parseStructured(value, types) {
|
|
29
|
+
const text = value.trim();
|
|
30
|
+
const parsed = read(text);
|
|
31
|
+
if (typeof parsed === 'string') {
|
|
32
|
+
const inner = parsed.trim();
|
|
33
|
+
if (inner !== text && (inner[0] === '{' || inner[0] === '[' || inner[0] === '"')) {
|
|
34
|
+
return parseStructured(parsed, types);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const accepted = accept(parsed, types);
|
|
39
|
+
if (accepted !== null)
|
|
40
|
+
return accepted;
|
|
41
|
+
if (Array.isArray(parsed) &&
|
|
42
|
+
types.has('object') &&
|
|
43
|
+
isRecord(parsed[0]) &&
|
|
44
|
+
typeof parsed.at(-1) === 'string') {
|
|
45
|
+
return parsed[0];
|
|
46
|
+
}
|
|
47
|
+
if (text[0] === '"' && types.has('object'))
|
|
48
|
+
return accept(read(`{${text}}`), types);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
function read(text) {
|
|
52
|
+
try {
|
|
53
|
+
return JSON.parse(jsonrepair(text));
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function accept(value, types) {
|
|
60
|
+
if (isRecord(value) && types.has('object'))
|
|
61
|
+
return value;
|
|
62
|
+
if (Array.isArray(value) && types.has('array'))
|
|
63
|
+
return value;
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
function structuredTypes(schema) {
|
|
67
|
+
const found = new Set();
|
|
68
|
+
if (!isRecord(schema))
|
|
69
|
+
return found;
|
|
70
|
+
const declared = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
71
|
+
for (const type of declared) {
|
|
72
|
+
if (typeof type === 'string' && STRUCTURED_TYPES.has(type))
|
|
73
|
+
found.add(type);
|
|
74
|
+
}
|
|
75
|
+
for (const key of ['oneOf', 'anyOf']) {
|
|
76
|
+
const branches = schema[key];
|
|
77
|
+
if (!Array.isArray(branches))
|
|
78
|
+
continue;
|
|
79
|
+
for (const branch of branches) {
|
|
80
|
+
for (const type of structuredTypes(branch))
|
|
81
|
+
found.add(type);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return found;
|
|
85
|
+
}
|
|
86
|
+
function isRecord(value) {
|
|
87
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
88
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { mcpTargetUrl } from "../../tools/mcp-call.js";
|
|
2
|
+
import { checkOutboundHost } from "../../tools/url-guard.js";
|
|
3
|
+
export class EgressGuardHook {
|
|
4
|
+
phase = 'preToolCall';
|
|
5
|
+
run(ctx) {
|
|
6
|
+
if (ctx.phase !== 'preToolCall')
|
|
7
|
+
return;
|
|
8
|
+
let target;
|
|
9
|
+
if (ctx.toolName === 'http_request' || ctx.toolName === 'web_fetch') {
|
|
10
|
+
target = typeof ctx.args.url === 'string' ? ctx.args.url : '';
|
|
11
|
+
}
|
|
12
|
+
else if (ctx.toolName === 'mcp_call') {
|
|
13
|
+
target = mcpTargetUrl(ctx.args);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
let url;
|
|
19
|
+
try {
|
|
20
|
+
url = new URL(target);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const blocked = checkOutboundHost(url);
|
|
26
|
+
if (blocked)
|
|
27
|
+
return { error: blocked, guidance: true };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SkillCatalogEntry } from '../../tools/skills/catalog.ts';
|
|
2
|
+
import type { HarnessHook, HookContext, HookResult } from '../types.ts';
|
|
3
|
+
type SkillCatalogInput = readonly SkillCatalogEntry[] | (() => readonly SkillCatalogEntry[] | readonly string[]);
|
|
4
|
+
export declare class SkillCatalogGuardHook implements HarnessHook {
|
|
5
|
+
readonly phase: "preToolCall";
|
|
6
|
+
private readonly _catalog;
|
|
7
|
+
constructor(catalog?: SkillCatalogInput);
|
|
8
|
+
run(ctx: HookContext): HookResult;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class SkillCatalogGuardHook {
|
|
2
|
+
phase = 'preToolCall';
|
|
3
|
+
_catalog;
|
|
4
|
+
constructor(catalog = []) {
|
|
5
|
+
this._catalog = catalog;
|
|
6
|
+
}
|
|
7
|
+
run(ctx) {
|
|
8
|
+
if (ctx.phase !== 'preToolCall' || ctx.toolName !== 'skill')
|
|
9
|
+
return;
|
|
10
|
+
const entries = ctx.skillNames ?? (typeof this._catalog === 'function' ? this._catalog() : this._catalog);
|
|
11
|
+
const known = new Set(entries.map((entry) => (typeof entry === 'string' ? entry : entry.name)));
|
|
12
|
+
const raw = ctx.args.name ?? ctx.args.skill_name ?? ctx.args.skill;
|
|
13
|
+
const name = typeof raw === 'string' ? raw : '';
|
|
14
|
+
if (!known.has(name))
|
|
15
|
+
return { error: `skill not found: ${name}`, guidance: true };
|
|
16
|
+
}
|
|
17
|
+
}
|