@qvac/harness 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/harness.bundle +8 -59
- 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.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,172 @@
|
|
|
1
|
+
import { MAX_RESPONSE_CHARS } from "../http-request/utils.js";
|
|
2
|
+
export const MCP_PROTOCOL_VERSION = '2025-03-26';
|
|
3
|
+
export const TIMEOUT_MS = 30_000;
|
|
4
|
+
const METADATA_METHODS = new Set([
|
|
5
|
+
'initialize',
|
|
6
|
+
'ping',
|
|
7
|
+
'tools/list',
|
|
8
|
+
'resources/list',
|
|
9
|
+
'resources/read',
|
|
10
|
+
'resources/templates/list',
|
|
11
|
+
'prompts/list',
|
|
12
|
+
'prompts/get',
|
|
13
|
+
'completion/complete'
|
|
14
|
+
]);
|
|
15
|
+
const PROTOCOL_METHODS = new Set([...METADATA_METHODS, 'tools/call']);
|
|
16
|
+
export function isNotification(method) {
|
|
17
|
+
return method.startsWith('notifications/');
|
|
18
|
+
}
|
|
19
|
+
export function isMetadataMethod(method) {
|
|
20
|
+
return typeof method === 'string' && METADATA_METHODS.has(method);
|
|
21
|
+
}
|
|
22
|
+
export function normalizeMethod(method, params) {
|
|
23
|
+
if (method === 'tools/call') {
|
|
24
|
+
const p = params ?? {};
|
|
25
|
+
return { method, params: p.arguments === undefined ? { ...p, arguments: {} } : p };
|
|
26
|
+
}
|
|
27
|
+
if (PROTOCOL_METHODS.has(method) || isNotification(method))
|
|
28
|
+
return { method, params };
|
|
29
|
+
return { method: 'tools/call', params: { name: method, arguments: params ?? {} } };
|
|
30
|
+
}
|
|
31
|
+
let nextId = 1;
|
|
32
|
+
function buildEnvelope(method, params) {
|
|
33
|
+
const envelope = { jsonrpc: '2.0', method };
|
|
34
|
+
if (params !== undefined)
|
|
35
|
+
envelope.params = params;
|
|
36
|
+
if (!isNotification(method))
|
|
37
|
+
envelope.id = String(nextId++);
|
|
38
|
+
return JSON.stringify(envelope);
|
|
39
|
+
}
|
|
40
|
+
function headers(authHeader, sessionId) {
|
|
41
|
+
const h = {
|
|
42
|
+
'content-type': 'application/json',
|
|
43
|
+
accept: 'application/json, text/event-stream'
|
|
44
|
+
};
|
|
45
|
+
if (authHeader)
|
|
46
|
+
h.authorization = authHeader;
|
|
47
|
+
if (sessionId)
|
|
48
|
+
h['mcp-session-id'] = sessionId;
|
|
49
|
+
return h;
|
|
50
|
+
}
|
|
51
|
+
function eventData(event) {
|
|
52
|
+
return event
|
|
53
|
+
.split(/\r?\n/)
|
|
54
|
+
.filter((line) => line.startsWith('data:'))
|
|
55
|
+
.map((line) => line.slice(line.startsWith('data: ') ? 6 : 5))
|
|
56
|
+
.join('\n');
|
|
57
|
+
}
|
|
58
|
+
function decodePayload(body, contentType) {
|
|
59
|
+
let payload = body;
|
|
60
|
+
if (contentType.includes('text/event-stream')) {
|
|
61
|
+
const events = body.split(/\r?\n\r?\n/);
|
|
62
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
63
|
+
const data = eventData(events[i] ?? '');
|
|
64
|
+
if (data) {
|
|
65
|
+
payload = data;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
return JSON.stringify(JSON.parse(payload), null, 2);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return payload;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function asRecord(value) {
|
|
78
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
79
|
+
? value
|
|
80
|
+
: null;
|
|
81
|
+
}
|
|
82
|
+
function contentText(result) {
|
|
83
|
+
const content = result?.content;
|
|
84
|
+
if (!Array.isArray(content))
|
|
85
|
+
return null;
|
|
86
|
+
const texts = content.flatMap((entry) => {
|
|
87
|
+
const item = asRecord(entry);
|
|
88
|
+
return item?.type === 'text' && typeof item.text === 'string' ? [item.text] : [];
|
|
89
|
+
});
|
|
90
|
+
return texts.length > 0 ? texts.join('\n\n') : null;
|
|
91
|
+
}
|
|
92
|
+
function rpcErrorText(error) {
|
|
93
|
+
const message = typeof error.message === 'string' ? error.message.trim() : '';
|
|
94
|
+
if (error.data === undefined)
|
|
95
|
+
return message;
|
|
96
|
+
return `${message} ${JSON.stringify(error.data)}`.trim();
|
|
97
|
+
}
|
|
98
|
+
export function flattenMcpResponse(body) {
|
|
99
|
+
let parsed;
|
|
100
|
+
try {
|
|
101
|
+
parsed = JSON.parse(body);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return { body: truncate(body) };
|
|
105
|
+
}
|
|
106
|
+
const record = asRecord(parsed);
|
|
107
|
+
if (!record)
|
|
108
|
+
return { body: truncate(body) };
|
|
109
|
+
const rpcError = asRecord(record.error);
|
|
110
|
+
if (rpcError)
|
|
111
|
+
return { error: truncate(rpcErrorText(rpcError) || body.trim()) };
|
|
112
|
+
const result = asRecord(record.result);
|
|
113
|
+
const text = contentText(result)?.trim();
|
|
114
|
+
if (result?.isError === true)
|
|
115
|
+
return { error: truncate(text || body.trim()) };
|
|
116
|
+
return { body: truncate(text || body) };
|
|
117
|
+
}
|
|
118
|
+
function truncate(text) {
|
|
119
|
+
return text.length > MAX_RESPONSE_CHARS
|
|
120
|
+
? `${text.slice(0, MAX_RESPONSE_CHARS)}… [truncated]`
|
|
121
|
+
: text;
|
|
122
|
+
}
|
|
123
|
+
const SESSION_CACHE = new Map();
|
|
124
|
+
const SESSION_CACHE_MAX = 256;
|
|
125
|
+
export function sessionKey(url, ctx, credentialKey) {
|
|
126
|
+
return `${url}|${ctx?.agentId ?? ''}|${credentialKey ?? ''}`;
|
|
127
|
+
}
|
|
128
|
+
export function getSession(key) {
|
|
129
|
+
return SESSION_CACHE.get(key) ?? '';
|
|
130
|
+
}
|
|
131
|
+
export function deleteSession(key) {
|
|
132
|
+
SESSION_CACHE.delete(key);
|
|
133
|
+
}
|
|
134
|
+
export function cacheSession(key, sessionId) {
|
|
135
|
+
SESSION_CACHE.set(key, sessionId);
|
|
136
|
+
if (SESSION_CACHE.size > SESSION_CACHE_MAX) {
|
|
137
|
+
const oldest = SESSION_CACHE.keys().next().value;
|
|
138
|
+
if (oldest !== undefined)
|
|
139
|
+
SESSION_CACHE.delete(oldest);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export function post(fetch, url, method, params, authHeader, sessionId, signal) {
|
|
143
|
+
return fetch(url, {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
headers: headers(authHeader, sessionId),
|
|
146
|
+
body: buildEnvelope(method, params),
|
|
147
|
+
signal,
|
|
148
|
+
redirect: 'manual'
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
export async function readBody(response) {
|
|
152
|
+
return decodePayload(await response.text(), response.headers.get('content-type') ?? '');
|
|
153
|
+
}
|
|
154
|
+
export function needsSession(status, cached) {
|
|
155
|
+
return status === 400 || (status === 404 && cached !== '');
|
|
156
|
+
}
|
|
157
|
+
export async function establishSession(fetch, url, authHeader, signal) {
|
|
158
|
+
const init = await post(fetch, url, 'initialize', {
|
|
159
|
+
protocolVersion: MCP_PROTOCOL_VERSION,
|
|
160
|
+
capabilities: {},
|
|
161
|
+
clientInfo: { name: 'QV.AC', version: '0.8.x' }
|
|
162
|
+
}, authHeader, undefined, signal);
|
|
163
|
+
const sessionId = init.headers.get('mcp-session-id');
|
|
164
|
+
if (init.status < 200 || init.status >= 300) {
|
|
165
|
+
return { error: `initialize failed: ${init.status}\n${await readBody(init)}` };
|
|
166
|
+
}
|
|
167
|
+
if (!sessionId) {
|
|
168
|
+
return { error: 'initialize returned no Mcp-Session-Id header', stateless: true };
|
|
169
|
+
}
|
|
170
|
+
await post(fetch, url, 'notifications/initialized', undefined, authHeader, sessionId, signal);
|
|
171
|
+
return sessionId;
|
|
172
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../capabilities/completion.ts';
|
|
2
|
+
import { type McpFetchFn } from './mcp/utils.ts';
|
|
3
|
+
import { type CredentialAllowListFn, type CredentialStoreFn } from './skills/auth-resolver.ts';
|
|
4
|
+
import { type HostResolver } from './url-guard.ts';
|
|
5
|
+
export type { McpFetchFn };
|
|
6
|
+
export interface McpCallToolOptions {
|
|
7
|
+
fetch?: McpFetchFn;
|
|
8
|
+
credentialStore?: CredentialStoreFn;
|
|
9
|
+
credentialAllowList?: CredentialAllowListFn;
|
|
10
|
+
readMethods?: ReadonlyMap<string, ReadonlySet<string>>;
|
|
11
|
+
resolveHost?: HostResolver;
|
|
12
|
+
}
|
|
13
|
+
export declare function mcpTargetUrl(args: Record<string, unknown>): string;
|
|
14
|
+
export declare function createMcpCallTool({ fetch: fetchImpl, credentialStore, credentialAllowList, readMethods, resolveHost }?: McpCallToolOptions): ToolDefinition;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import defaultFetch from '#no-redirect-fetch';
|
|
2
|
+
import { AbortController } from 'bare-abort-controller';
|
|
3
|
+
import { MCP_CALL_TOOL_NAME } from "../capabilities/tool-names.js";
|
|
4
|
+
import { lookupHost } from "../dns-lookup.js";
|
|
5
|
+
import { AbortedError } from "../helpers/race-abort.js";
|
|
6
|
+
import { isRedirectStatus, parseObjectArg } from "./http-request/utils.js";
|
|
7
|
+
import { cacheSession, deleteSession, establishSession, flattenMcpResponse, getSession, isNotification, needsSession, normalizeMethod, post, readBody, sessionKey, TIMEOUT_MS } from "./mcp/utils.js";
|
|
8
|
+
import { parseAuth, resolveBearerHeader } from "./skills/auth-resolver.js";
|
|
9
|
+
import { recordCredentialHealth } from "./skills/credential-health.js";
|
|
10
|
+
import { resolveOutboundUrl } from "./url-guard.js";
|
|
11
|
+
function nestedUrl(params) {
|
|
12
|
+
return typeof params?.url === 'string' && params.url.length > 0 ? params.url : undefined;
|
|
13
|
+
}
|
|
14
|
+
function parseMcpParams(value) {
|
|
15
|
+
const parsed = parseObjectArg(value, 'params');
|
|
16
|
+
if (parsed.ok || typeof value !== 'string')
|
|
17
|
+
return parsed;
|
|
18
|
+
return parseObjectArg(value.replace(/[“”]/g, '"'), 'params');
|
|
19
|
+
}
|
|
20
|
+
function toolParams(params, liftedNestedUrl) {
|
|
21
|
+
if (!params || !liftedNestedUrl)
|
|
22
|
+
return params;
|
|
23
|
+
const result = { ...params };
|
|
24
|
+
delete result.url;
|
|
25
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
26
|
+
}
|
|
27
|
+
export function mcpTargetUrl(args) {
|
|
28
|
+
if (typeof args.url === 'string' && args.url.length > 0)
|
|
29
|
+
return args.url;
|
|
30
|
+
const parsed = parseMcpParams(args.params);
|
|
31
|
+
return parsed.ok ? (nestedUrl(parsed.value) ?? '') : '';
|
|
32
|
+
}
|
|
33
|
+
export function createMcpCallTool({ fetch: fetchImpl, credentialStore, credentialAllowList, readMethods, resolveHost = lookupHost } = {}) {
|
|
34
|
+
return {
|
|
35
|
+
name: MCP_CALL_TOOL_NAME,
|
|
36
|
+
toolset: 'mcp-call',
|
|
37
|
+
description: 'Make a JSON-RPC 2.0 call to a Model Context Protocol (MCP) server. Load the matching skill first — it documents the server tool names and their args. Pass a server tool name as `method` and its args as `params`; the JSON-RPC envelope, session handshake, and bearer auth are handled for you (the stored credential for the host is attached automatically, so no `auth` is needed).',
|
|
38
|
+
parameters: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
url: { type: 'string', description: 'Required top-level MCP server URL (https://)' },
|
|
42
|
+
method: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: 'A server tool name (wrapped into tools/call) or a raw MCP method'
|
|
45
|
+
},
|
|
46
|
+
params: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
description: "The server tool's arguments only; put the MCP server URL in top-level url"
|
|
49
|
+
},
|
|
50
|
+
auth: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
description: 'Optional bearer auth: {"type": "bearer", "tokenCredentialKey": "<key>"}. Pass ONLY the credential key name — never a token value.'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
required: ['url', 'method']
|
|
56
|
+
},
|
|
57
|
+
autoApprove: false,
|
|
58
|
+
effect(args) {
|
|
59
|
+
if (typeof args.method !== 'string')
|
|
60
|
+
return 'write';
|
|
61
|
+
try {
|
|
62
|
+
const host = new URL(mcpTargetUrl(args)).hostname;
|
|
63
|
+
return readMethods?.get(host)?.has(args.method) ? 'read' : 'write';
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return 'write';
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
resource(args) {
|
|
70
|
+
try {
|
|
71
|
+
return { kind: 'host', label: new URL(mcpTargetUrl(args)).hostname };
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
async execute(rawArgs, ctx) {
|
|
78
|
+
const args = rawArgs;
|
|
79
|
+
const rawParams = parseMcpParams(args.params);
|
|
80
|
+
if (!rawParams.ok)
|
|
81
|
+
return { error: rawParams.error };
|
|
82
|
+
const topLevelUrl = typeof args.url === 'string' && args.url.length > 0 ? args.url : undefined;
|
|
83
|
+
const urlValue = topLevelUrl ?? nestedUrl(rawParams.value);
|
|
84
|
+
let url;
|
|
85
|
+
try {
|
|
86
|
+
url = new URL(urlValue ?? '');
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return { error: `invalid URL: ${String(urlValue)}` };
|
|
90
|
+
}
|
|
91
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:') {
|
|
92
|
+
return { error: `unsupported protocol: ${url.protocol}` };
|
|
93
|
+
}
|
|
94
|
+
if (typeof args.method !== 'string' || args.method.length === 0) {
|
|
95
|
+
return { error: 'method must be a non-empty string' };
|
|
96
|
+
}
|
|
97
|
+
const parsedAuth = parseAuth(args.auth);
|
|
98
|
+
if (!parsedAuth.ok)
|
|
99
|
+
return { error: parsedAuth.error };
|
|
100
|
+
const { method, params } = normalizeMethod(args.method, toolParams(rawParams.value, topLevelUrl === undefined && urlValue !== undefined));
|
|
101
|
+
const controller = new AbortController();
|
|
102
|
+
const timeout = setTimeout(() => controller.abort(undefined), TIMEOUT_MS);
|
|
103
|
+
try {
|
|
104
|
+
const urlCheck = await resolveOutboundUrl(url, resolveHost, controller.signal);
|
|
105
|
+
if (urlCheck.blocked)
|
|
106
|
+
return { error: urlCheck.blocked };
|
|
107
|
+
const bearer = await resolveBearerHeader(parsedAuth.value, url, credentialStore, credentialAllowList?.(ctx), ctx, controller.signal);
|
|
108
|
+
if ('error' in bearer)
|
|
109
|
+
return { error: bearer.error };
|
|
110
|
+
const authHeader = bearer.header;
|
|
111
|
+
const fetch = fetchImpl ?? defaultFetch;
|
|
112
|
+
const guardedFetch = (target, init) => fetch(target, { ...init, validatedAddresses: urlCheck.addresses });
|
|
113
|
+
const key = sessionKey(url.href, ctx, bearer.credentialKey);
|
|
114
|
+
const cached = getSession(key);
|
|
115
|
+
let response = await post(guardedFetch, url, method, params, authHeader, cached || undefined, controller.signal);
|
|
116
|
+
if (needsSession(response.status, cached)) {
|
|
117
|
+
deleteSession(key);
|
|
118
|
+
const session = await establishSession(guardedFetch, url, authHeader, controller.signal);
|
|
119
|
+
if (typeof session === 'string') {
|
|
120
|
+
cacheSession(key, session);
|
|
121
|
+
response = await post(guardedFetch, url, method, params, authHeader, session, controller.signal);
|
|
122
|
+
}
|
|
123
|
+
else if (!session.stateless) {
|
|
124
|
+
return { error: session.error };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const issued = response.headers.get('mcp-session-id');
|
|
129
|
+
if (issued)
|
|
130
|
+
cacheSession(key, issued);
|
|
131
|
+
}
|
|
132
|
+
if (isRedirectStatus(response.status)) {
|
|
133
|
+
return { error: `MCP server responded with an unexpected redirect (${response.status})` };
|
|
134
|
+
}
|
|
135
|
+
if (bearer.credentialKey) {
|
|
136
|
+
recordCredentialHealth(bearer.credentialKey, response.status, ctx?.agentId);
|
|
137
|
+
}
|
|
138
|
+
if (isNotification(method))
|
|
139
|
+
return { status: response.status, body: '' };
|
|
140
|
+
return { status: response.status, ...flattenMcpResponse(await readBody(response)) };
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
144
|
+
return {
|
|
145
|
+
error: error.name === 'AbortError' || error instanceof AbortedError
|
|
146
|
+
? 'request timed out'
|
|
147
|
+
: `request failed: ${error.message}`
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
clearTimeout(timeout);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function unquoteArg(value: unknown): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface OperationRequest {
|
|
2
|
+
body?: Record<string, unknown>;
|
|
3
|
+
params?: Record<string, unknown>;
|
|
4
|
+
encode?: Record<string, string>;
|
|
5
|
+
query?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export type BuilderOutcome = {
|
|
8
|
+
request: OperationRequest;
|
|
9
|
+
} | {
|
|
10
|
+
error: string;
|
|
11
|
+
};
|
|
12
|
+
export interface OperationBuilder {
|
|
13
|
+
build: (args: Record<string, unknown>) => BuilderOutcome;
|
|
14
|
+
}
|
|
15
|
+
export declare const BUILDER_NAMES: readonly ["gmail-send", "gmail-draft", "calendar-meet-event", "calendar-add-meet", "docs-create", "docs-append-text", "sheets-create", "sheets-write-values", "sheets-append-values", "drive-create-folder", "drive-trash", "notion-create-page", "notion-insert-content"];
|
|
16
|
+
export type BuilderName = (typeof BUILDER_NAMES)[number];
|
|
17
|
+
export declare const BUILDERS: Record<BuilderName, OperationBuilder>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { randomBytes } from 'crypto';
|
|
2
|
+
import b4a from 'b4a';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { buildGmailMessage, GmailEnvelopeSchema } from "./gmail-message.js";
|
|
5
|
+
export const BUILDER_NAMES = [
|
|
6
|
+
'gmail-send',
|
|
7
|
+
'gmail-draft',
|
|
8
|
+
'calendar-meet-event',
|
|
9
|
+
'calendar-add-meet',
|
|
10
|
+
'docs-create',
|
|
11
|
+
'docs-append-text',
|
|
12
|
+
'sheets-create',
|
|
13
|
+
'sheets-write-values',
|
|
14
|
+
'sheets-append-values',
|
|
15
|
+
'drive-create-folder',
|
|
16
|
+
'drive-trash',
|
|
17
|
+
'notion-create-page',
|
|
18
|
+
'notion-insert-content'
|
|
19
|
+
];
|
|
20
|
+
function builder(schema, build) {
|
|
21
|
+
return {
|
|
22
|
+
build(args) {
|
|
23
|
+
const parsed = schema.safeParse(args);
|
|
24
|
+
if (!parsed.success)
|
|
25
|
+
return { error: parsed.error.issues[0]?.message ?? 'invalid arguments' };
|
|
26
|
+
return { request: build(parsed.data) };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const GmailMessageSchema = z
|
|
31
|
+
.object({ ...GmailEnvelopeSchema.shape, threadId: z.string().optional() })
|
|
32
|
+
.refine((value) => Boolean(value.text?.length) || Boolean(value.html?.length), {
|
|
33
|
+
message: 'either text or html is required'
|
|
34
|
+
});
|
|
35
|
+
const gmailSend = builder(GmailMessageSchema, (args) => ({
|
|
36
|
+
body: { raw: buildGmailMessage(args), threadId: args.threadId },
|
|
37
|
+
encode: { raw: 'base64url' }
|
|
38
|
+
}));
|
|
39
|
+
const gmailDraft = builder(GmailMessageSchema, (args) => ({
|
|
40
|
+
body: { message: { raw: buildGmailMessage(args), threadId: args.threadId } },
|
|
41
|
+
encode: { 'message.raw': 'base64url' }
|
|
42
|
+
}));
|
|
43
|
+
function createRequest() {
|
|
44
|
+
return {
|
|
45
|
+
createRequest: {
|
|
46
|
+
requestId: b4a.toString(randomBytes(16), 'hex'),
|
|
47
|
+
conferenceSolutionKey: { type: 'hangoutsMeet' }
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const MeetEventSchema = z.object({
|
|
52
|
+
summary: z.string(),
|
|
53
|
+
start: z.iso.datetime({ offset: true }),
|
|
54
|
+
end: z.iso.datetime({ offset: true }),
|
|
55
|
+
timeZone: z.string().optional(),
|
|
56
|
+
description: z.string().optional(),
|
|
57
|
+
location: z.string().optional(),
|
|
58
|
+
attendees: z.array(z.string()).optional(),
|
|
59
|
+
calendarId: z.string().optional()
|
|
60
|
+
});
|
|
61
|
+
const calendarMeetEvent = builder(MeetEventSchema, (args) => ({
|
|
62
|
+
body: {
|
|
63
|
+
summary: args.summary,
|
|
64
|
+
description: args.description,
|
|
65
|
+
location: args.location,
|
|
66
|
+
start: { dateTime: args.start, timeZone: args.timeZone },
|
|
67
|
+
end: { dateTime: args.end, timeZone: args.timeZone },
|
|
68
|
+
attendees: args.attendees?.map((email) => ({ email })),
|
|
69
|
+
conferenceData: createRequest()
|
|
70
|
+
},
|
|
71
|
+
query: { conferenceDataVersion: 1 }
|
|
72
|
+
}));
|
|
73
|
+
const AddMeetSchema = z.object({
|
|
74
|
+
eventId: z.string(),
|
|
75
|
+
calendarId: z.string().optional()
|
|
76
|
+
});
|
|
77
|
+
const calendarAddMeet = builder(AddMeetSchema, () => ({
|
|
78
|
+
body: { conferenceData: createRequest() },
|
|
79
|
+
query: { conferenceDataVersion: 1 }
|
|
80
|
+
}));
|
|
81
|
+
const docsCreate = builder(z.object({ title: z.string().min(1) }), (args) => ({
|
|
82
|
+
body: { title: args.title }
|
|
83
|
+
}));
|
|
84
|
+
const DocsAppendSchema = z.object({
|
|
85
|
+
documentId: z.string().min(1),
|
|
86
|
+
text: z.string().min(1),
|
|
87
|
+
pageBreak: z.boolean().optional()
|
|
88
|
+
});
|
|
89
|
+
const docsAppendText = builder(DocsAppendSchema, (args) => {
|
|
90
|
+
const requests = [
|
|
91
|
+
{ insertText: { endOfSegmentLocation: {}, text: args.text } }
|
|
92
|
+
];
|
|
93
|
+
if (args.pageBreak)
|
|
94
|
+
requests.push({ insertPageBreak: { endOfSegmentLocation: {} } });
|
|
95
|
+
return { body: { requests } };
|
|
96
|
+
});
|
|
97
|
+
const sheetsCreate = builder(z.object({ name: z.string().min(1) }), (args) => ({
|
|
98
|
+
body: { name: args.name, mimeType: 'application/vnd.google-apps.spreadsheet' }
|
|
99
|
+
}));
|
|
100
|
+
const Cell = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
|
101
|
+
const SheetsValuesSchema = z.object({
|
|
102
|
+
spreadsheetId: z.string().min(1),
|
|
103
|
+
range: z.string().min(1),
|
|
104
|
+
values: z.array(z.array(Cell)).min(1),
|
|
105
|
+
valueInputOption: z.enum(['RAW', 'USER_ENTERED']).optional()
|
|
106
|
+
});
|
|
107
|
+
const sheetsWriteValues = builder(SheetsValuesSchema, (args) => ({
|
|
108
|
+
body: { range: args.range, values: args.values },
|
|
109
|
+
query: { valueInputOption: args.valueInputOption ?? 'USER_ENTERED' }
|
|
110
|
+
}));
|
|
111
|
+
const sheetsAppendValues = builder(SheetsValuesSchema, (args) => ({
|
|
112
|
+
body: { values: args.values },
|
|
113
|
+
query: { valueInputOption: args.valueInputOption ?? 'USER_ENTERED' }
|
|
114
|
+
}));
|
|
115
|
+
const DriveFolderSchema = z.object({
|
|
116
|
+
name: z.string().min(1),
|
|
117
|
+
parentId: z.string().optional()
|
|
118
|
+
});
|
|
119
|
+
const driveCreateFolder = builder(DriveFolderSchema, (args) => ({
|
|
120
|
+
body: {
|
|
121
|
+
name: args.name,
|
|
122
|
+
mimeType: 'application/vnd.google-apps.folder',
|
|
123
|
+
parents: args.parentId ? [args.parentId] : undefined
|
|
124
|
+
}
|
|
125
|
+
}));
|
|
126
|
+
const driveTrash = builder(z.object({ fileId: z.string().min(1) }), () => ({
|
|
127
|
+
body: { trashed: true }
|
|
128
|
+
}));
|
|
129
|
+
const NotionCreatePageSchema = z
|
|
130
|
+
.object({
|
|
131
|
+
title: z.string().min(1),
|
|
132
|
+
content: z.string().optional(),
|
|
133
|
+
parentPageId: z.string().optional(),
|
|
134
|
+
parentDatabaseId: z.string().optional()
|
|
135
|
+
})
|
|
136
|
+
.refine((value) => !(value.parentPageId && value.parentDatabaseId), {
|
|
137
|
+
message: 'pass parentPageId or parentDatabaseId, not both'
|
|
138
|
+
});
|
|
139
|
+
function notionParent(args) {
|
|
140
|
+
if (args.parentPageId)
|
|
141
|
+
return { page_id: args.parentPageId };
|
|
142
|
+
if (args.parentDatabaseId)
|
|
143
|
+
return { database_id: args.parentDatabaseId };
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
const notionCreatePage = builder(NotionCreatePageSchema, (args) => ({
|
|
147
|
+
params: {
|
|
148
|
+
parent: notionParent(args),
|
|
149
|
+
pages: [{ properties: { title: args.title }, content: args.content }]
|
|
150
|
+
}
|
|
151
|
+
}));
|
|
152
|
+
const NotionInsertSchema = z.object({
|
|
153
|
+
pageId: z.string().min(1),
|
|
154
|
+
content: z.string().min(1),
|
|
155
|
+
position: z.enum(['start', 'end']).optional()
|
|
156
|
+
});
|
|
157
|
+
const notionInsertContent = builder(NotionInsertSchema, (args) => ({
|
|
158
|
+
params: {
|
|
159
|
+
page_id: args.pageId,
|
|
160
|
+
command: 'insert_content',
|
|
161
|
+
content: args.content,
|
|
162
|
+
position: args.position === 'start' ? { type: 'start' } : undefined
|
|
163
|
+
}
|
|
164
|
+
}));
|
|
165
|
+
export const BUILDERS = {
|
|
166
|
+
'gmail-send': gmailSend,
|
|
167
|
+
'gmail-draft': gmailDraft,
|
|
168
|
+
'calendar-meet-event': calendarMeetEvent,
|
|
169
|
+
'calendar-add-meet': calendarAddMeet,
|
|
170
|
+
'docs-create': docsCreate,
|
|
171
|
+
'docs-append-text': docsAppendText,
|
|
172
|
+
'sheets-create': sheetsCreate,
|
|
173
|
+
'sheets-write-values': sheetsWriteValues,
|
|
174
|
+
'sheets-append-values': sheetsAppendValues,
|
|
175
|
+
'drive-create-folder': driveCreateFolder,
|
|
176
|
+
'drive-trash': driveTrash,
|
|
177
|
+
'notion-create-page': notionCreatePage,
|
|
178
|
+
'notion-insert-content': notionInsertContent
|
|
179
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../../capabilities/completion.ts';
|
|
2
|
+
import type { SkillCatalogEntry } from '../skills/catalog.ts';
|
|
3
|
+
export interface CompileOperationToolsOptions {
|
|
4
|
+
httpRequestTool: ToolDefinition;
|
|
5
|
+
mcpCallTool?: ToolDefinition;
|
|
6
|
+
}
|
|
7
|
+
export declare function compileOperationTools(catalog: readonly SkillCatalogEntry[], { httpRequestTool, mcpCallTool }: CompileOperationToolsOptions): ToolDefinition[];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { BUILDERS } from "./builders.js";
|
|
2
|
+
export function compileOperationTools(catalog, { httpRequestTool, mcpCallTool }) {
|
|
3
|
+
return catalog.flatMap((entry) => (entry.operations ?? []).flatMap((operation) => {
|
|
4
|
+
const transport = operation.request.transport === 'mcp' ? mcpCallTool : httpRequestTool;
|
|
5
|
+
return transport ? [operationTool(entry.name, operation, transport)] : [];
|
|
6
|
+
}));
|
|
7
|
+
}
|
|
8
|
+
function operationTool(owningSkill, operation, transportTool) {
|
|
9
|
+
const builder = BUILDERS[operation.request.builder];
|
|
10
|
+
const mcp = operation.request.transport === 'mcp';
|
|
11
|
+
return {
|
|
12
|
+
name: operation.tool,
|
|
13
|
+
owningSkill,
|
|
14
|
+
description: operation.description,
|
|
15
|
+
parameters: operation.parameters,
|
|
16
|
+
autoApprove: false,
|
|
17
|
+
skillGated: true,
|
|
18
|
+
externalWrite: true,
|
|
19
|
+
toolset: mcp ? 'mcp-call' : 'http-request',
|
|
20
|
+
compiled: true,
|
|
21
|
+
effect() {
|
|
22
|
+
return 'write';
|
|
23
|
+
},
|
|
24
|
+
resource() {
|
|
25
|
+
return hostOf(operation.request.url);
|
|
26
|
+
},
|
|
27
|
+
async execute(args, ctx) {
|
|
28
|
+
const skillContext = { ...ctx, skills: [owningSkill] };
|
|
29
|
+
const built = builder.build(args);
|
|
30
|
+
if ('error' in built)
|
|
31
|
+
return { error: `${operation.tool}: ${built.error}` };
|
|
32
|
+
const request = operation.request;
|
|
33
|
+
if (request.transport === 'mcp') {
|
|
34
|
+
return transportTool.execute({ url: request.url, method: request.method, params: built.request.params }, skillContext);
|
|
35
|
+
}
|
|
36
|
+
const url = fillTemplate(request.url, args, request.urlDefaults);
|
|
37
|
+
if ('error' in url)
|
|
38
|
+
return { error: `${operation.tool}: ${url.error}` };
|
|
39
|
+
const result = await transportTool.execute({
|
|
40
|
+
url: url.value,
|
|
41
|
+
method: request.method,
|
|
42
|
+
query: { ...request.query, ...built.request.query },
|
|
43
|
+
body: built.request.body,
|
|
44
|
+
encode: built.request.encode
|
|
45
|
+
}, skillContext);
|
|
46
|
+
return operation.response ? pickResponse(result, operation.response.pick) : result;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function pickResponse(result, keys) {
|
|
51
|
+
if (!result || typeof result !== 'object')
|
|
52
|
+
return result;
|
|
53
|
+
const { body, status } = result;
|
|
54
|
+
if (typeof body !== 'string' || (typeof status === 'number' && status >= 400))
|
|
55
|
+
return result;
|
|
56
|
+
let parsed;
|
|
57
|
+
try {
|
|
58
|
+
parsed = JSON.parse(body);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
64
|
+
return result;
|
|
65
|
+
const record = parsed;
|
|
66
|
+
const picked = {};
|
|
67
|
+
for (const key of keys)
|
|
68
|
+
if (key in record)
|
|
69
|
+
picked[key] = record[key];
|
|
70
|
+
return { ...result, body: JSON.stringify(picked) };
|
|
71
|
+
}
|
|
72
|
+
const PLACEHOLDER = /\{(\w+)\}/g;
|
|
73
|
+
function fillTemplate(template, args, defaults) {
|
|
74
|
+
const missing = [];
|
|
75
|
+
const value = template.replace(PLACEHOLDER, (_match, name) => {
|
|
76
|
+
const filled = args[name] ?? defaults?.[name];
|
|
77
|
+
if (filled === undefined)
|
|
78
|
+
missing.push(name);
|
|
79
|
+
return encodeURIComponent(String(filled));
|
|
80
|
+
});
|
|
81
|
+
if (missing.length)
|
|
82
|
+
return { error: `missing required argument ${missing.join(', ')}` };
|
|
83
|
+
return { value };
|
|
84
|
+
}
|
|
85
|
+
function hostOf(url) {
|
|
86
|
+
try {
|
|
87
|
+
return { kind: 'host', label: new URL(url).hostname };
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const GmailEnvelopeSchema: z.ZodObject<{
|
|
3
|
+
to: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
4
|
+
cc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
5
|
+
bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
6
|
+
subject: z.ZodString;
|
|
7
|
+
text: z.ZodOptional<z.ZodString>;
|
|
8
|
+
html: z.ZodOptional<z.ZodString>;
|
|
9
|
+
from: z.ZodOptional<z.ZodString>;
|
|
10
|
+
replyTo: z.ZodOptional<z.ZodString>;
|
|
11
|
+
inReplyTo: z.ZodOptional<z.ZodString>;
|
|
12
|
+
references: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type GmailEnvelope = z.infer<typeof GmailEnvelopeSchema>;
|
|
15
|
+
export declare function buildGmailMessage(envelope: GmailEnvelope): string;
|