@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,60 @@
|
|
|
1
|
+
import type { CredentialStoreFn } from './auth-resolver.ts';
|
|
2
|
+
import type { SkillSettingsFn } from './skill-settings.ts';
|
|
3
|
+
import type { InstallStep, SkillRequires, SkillSetup } from './manifest.ts';
|
|
4
|
+
import { type CliValidator } from './cli-schema.ts';
|
|
5
|
+
import { type SkillState } from './skill-state.ts';
|
|
6
|
+
import type { BinVersionState } from './bin-check.ts';
|
|
7
|
+
import { type CredentialCheckFetch } from './credential-check.ts';
|
|
8
|
+
import { type OperationSpec } from '../operations/manifest.ts';
|
|
9
|
+
import type { CapabilityProfile } from '../../models/model-catalog.ts';
|
|
10
|
+
export interface SkillCatalogEntry {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
aliases?: string[];
|
|
14
|
+
preloadOnName?: boolean;
|
|
15
|
+
tools: string[];
|
|
16
|
+
credentials: string[];
|
|
17
|
+
allowList: string[];
|
|
18
|
+
mcpReads?: string[];
|
|
19
|
+
platform: string[];
|
|
20
|
+
requires?: SkillRequires;
|
|
21
|
+
install?: InstallStep[];
|
|
22
|
+
setup?: SkillSetup;
|
|
23
|
+
cliValidator?: CliValidator;
|
|
24
|
+
stub?: boolean;
|
|
25
|
+
minCapabilityProfile?: string;
|
|
26
|
+
emoji?: string;
|
|
27
|
+
referenceFiles?: string[];
|
|
28
|
+
operations?: readonly OperationSpec[];
|
|
29
|
+
origin?: 'overlay';
|
|
30
|
+
}
|
|
31
|
+
export interface ResolvedSkillCatalogEntry extends SkillCatalogEntry {
|
|
32
|
+
status: SkillState;
|
|
33
|
+
}
|
|
34
|
+
export declare function skillSupportsPlatform(entry: SkillCatalogEntry, platform: string | undefined): boolean;
|
|
35
|
+
export declare function versionProbeSkills(catalog: readonly SkillCatalogEntry[], installedTools: ReadonlySet<string>, platform: string | undefined): SkillCatalogEntry[];
|
|
36
|
+
export declare function availableSkills(catalog: readonly SkillCatalogEntry[], installedTools: ReadonlySet<string>, activeProfile?: CapabilityProfile): SkillCatalogEntry[];
|
|
37
|
+
export interface ResolveSkillStatusOptions {
|
|
38
|
+
installedTools?: ReadonlySet<string>;
|
|
39
|
+
credentialStore?: CredentialStoreFn;
|
|
40
|
+
settingsStore?: SkillSettingsFn;
|
|
41
|
+
platform?: string;
|
|
42
|
+
agentId?: string | null;
|
|
43
|
+
activeProfile?: CapabilityProfile;
|
|
44
|
+
binVersions?: ReadonlyMap<string, ReadonlyMap<string, BinVersionState>>;
|
|
45
|
+
refresh?: boolean;
|
|
46
|
+
skipCredentialProbe?: boolean;
|
|
47
|
+
fetchImpl?: CredentialCheckFetch;
|
|
48
|
+
}
|
|
49
|
+
export declare function skillsEligibleForCredentialProbe(catalog: readonly SkillCatalogEntry[], { platform, installedTools }?: {
|
|
50
|
+
platform?: string | undefined;
|
|
51
|
+
installedTools?: ReadonlySet<string> | undefined;
|
|
52
|
+
}): SkillCatalogEntry[];
|
|
53
|
+
export declare function resolveSkillStatuses(catalog: readonly SkillCatalogEntry[], { installedTools, credentialStore, settingsStore, platform, agentId, activeProfile, binVersions, refresh, skipCredentialProbe, fetchImpl }?: ResolveSkillStatusOptions): Promise<ResolvedSkillCatalogEntry[]>;
|
|
54
|
+
export interface LoadSkillCatalogOptions {
|
|
55
|
+
platform?: string | null;
|
|
56
|
+
overlayDir?: string | null;
|
|
57
|
+
}
|
|
58
|
+
export declare function loadSkillCatalog(skillsDir: string, { platform, overlayDir }?: LoadSkillCatalogOptions): Promise<SkillCatalogEntry[]>;
|
|
59
|
+
export declare function mcpReadMethods(catalog: readonly SkillCatalogEntry[]): ReadonlyMap<string, ReadonlySet<string>>;
|
|
60
|
+
export declare function detectPlatform(): string;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { platform } from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { parseSkillFrontMatter } from "./frontmatter-parser.js";
|
|
5
|
+
import { buildCliValidator, loadSkillCli } from "./cli-schema.js";
|
|
6
|
+
import { isModelCompatible, isStub, isToolSupported, resolveSkillState, SKILL_STATE, supportsPlatform } from "./skill-state.js";
|
|
7
|
+
import { validateCredentialChecks } from "./credential-check.js";
|
|
8
|
+
import { OBSIDIAN_SKILL_NAME } from "./obsidian-readiness.js";
|
|
9
|
+
import { parseToolGrant } from "./tool-grants.js";
|
|
10
|
+
import { deriveSetup } from "./setup-routes.js";
|
|
11
|
+
import { resolveSkillsOverlayDir } from "./overlay-dir.js";
|
|
12
|
+
import { parseOperationsManifest } from "../operations/manifest.js";
|
|
13
|
+
import { hlog } from "../../log.js";
|
|
14
|
+
export function skillSupportsPlatform(entry, platform) {
|
|
15
|
+
return supportsPlatform(entry, platform);
|
|
16
|
+
}
|
|
17
|
+
export function versionProbeSkills(catalog, installedTools, platform) {
|
|
18
|
+
return catalog.filter((entry) => entry.name !== OBSIDIAN_SKILL_NAME &&
|
|
19
|
+
entry.requires?.binMinVersions &&
|
|
20
|
+
skillSupportsPlatform(entry, platform) &&
|
|
21
|
+
!entry.stub &&
|
|
22
|
+
entry.tools.every((name) => installedTools.has(parseToolGrant(name).name)));
|
|
23
|
+
}
|
|
24
|
+
export function availableSkills(catalog, installedTools, activeProfile) {
|
|
25
|
+
return catalog.filter((skill) => !isStub(skill) &&
|
|
26
|
+
isToolSupported(skill, installedTools) &&
|
|
27
|
+
isModelCompatible(skill, activeProfile));
|
|
28
|
+
}
|
|
29
|
+
export function skillsEligibleForCredentialProbe(catalog, { platform, installedTools } = {}) {
|
|
30
|
+
return catalog.filter((entry) => supportsPlatform(entry, platform) &&
|
|
31
|
+
!isStub(entry) &&
|
|
32
|
+
(!installedTools || isToolSupported(entry, installedTools)));
|
|
33
|
+
}
|
|
34
|
+
export function resolveSkillStatuses(catalog, { installedTools, credentialStore, settingsStore, platform, agentId, activeProfile, binVersions, refresh, skipCredentialProbe, fetchImpl } = {}) {
|
|
35
|
+
const probeCatalog = skillsEligibleForCredentialProbe(catalog, { platform, installedTools });
|
|
36
|
+
const checked = skipCredentialProbe
|
|
37
|
+
? Promise.resolve()
|
|
38
|
+
: validateCredentialChecks(probeCatalog, credentialStore, agentId, fetchImpl, { refresh });
|
|
39
|
+
return checked.then(() => Promise.all(catalog.map(async (entry) => withSetup(entry, installedTools && !isToolSupported(entry, installedTools)
|
|
40
|
+
? SKILL_STATE.unsupported
|
|
41
|
+
: await resolveSkillState(entry, {
|
|
42
|
+
credentialStore,
|
|
43
|
+
settingsStore,
|
|
44
|
+
platform,
|
|
45
|
+
agentId,
|
|
46
|
+
activeProfile,
|
|
47
|
+
binVersions: binVersions?.get(entry.name)
|
|
48
|
+
})))));
|
|
49
|
+
}
|
|
50
|
+
function withSetup(entry, state) {
|
|
51
|
+
const { install, setup: _setup, requires, ...rest } = entry;
|
|
52
|
+
const setup = deriveSetup(entry, state);
|
|
53
|
+
return {
|
|
54
|
+
...rest,
|
|
55
|
+
...(requires ? { requires: stripCredentialChecks(requires) } : {}),
|
|
56
|
+
...(install ? { install } : {}),
|
|
57
|
+
...(setup ? { setup } : {}),
|
|
58
|
+
status: state
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function stripCredentialChecks(requires) {
|
|
62
|
+
const { credentialChecks: _drop, ...rest } = requires;
|
|
63
|
+
return rest;
|
|
64
|
+
}
|
|
65
|
+
export async function loadSkillCatalog(skillsDir, { platform = detectPlatform(), overlayDir = resolveSkillsOverlayDir() } = {}) {
|
|
66
|
+
const byName = await loadRoot(skillsDir);
|
|
67
|
+
if (overlayDir) {
|
|
68
|
+
for (const [name, overlay] of await loadRoot(overlayDir, 'overlay')) {
|
|
69
|
+
byName.set(name, mergeOverlay(byName.get(name), overlay));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return [...byName.values()]
|
|
73
|
+
.filter((entry) => skillSupportsPlatform(entry, platform ?? undefined))
|
|
74
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
75
|
+
}
|
|
76
|
+
function mergeOverlay(base, overlay) {
|
|
77
|
+
if (!base)
|
|
78
|
+
return overlay;
|
|
79
|
+
const { origin: _origin, mcpReads: _mcpReads, operations: _operations, ...rest } = overlay;
|
|
80
|
+
return {
|
|
81
|
+
...rest,
|
|
82
|
+
credentials: base.credentials,
|
|
83
|
+
allowList: base.allowList,
|
|
84
|
+
platform: base.platform,
|
|
85
|
+
...(base.operations ? { operations: base.operations } : {}),
|
|
86
|
+
...(base.mcpReads ? { mcpReads: base.mcpReads } : {})
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const OVERLAY_DEFAULT_PLATFORMS = ['darwin', 'linux', 'win32', 'ios', 'android'];
|
|
90
|
+
async function loadRoot(skillsDir, origin) {
|
|
91
|
+
let dirs;
|
|
92
|
+
try {
|
|
93
|
+
dirs = (await fs.promises.readdir(skillsDir, { withFileTypes: true }))
|
|
94
|
+
.filter((entry) => entry.isDirectory())
|
|
95
|
+
.map((entry) => entry.name);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return new Map();
|
|
99
|
+
}
|
|
100
|
+
const loaded = await Promise.all(dirs.map((dir) => loadEntry(skillsDir, dir, origin)));
|
|
101
|
+
const byName = new Map();
|
|
102
|
+
for (const entry of loaded)
|
|
103
|
+
if (entry)
|
|
104
|
+
byName.set(entry.name, entry);
|
|
105
|
+
return byName;
|
|
106
|
+
}
|
|
107
|
+
export function mcpReadMethods(catalog) {
|
|
108
|
+
const byHost = new Map();
|
|
109
|
+
for (const entry of catalog) {
|
|
110
|
+
if (entry.origin === 'overlay')
|
|
111
|
+
continue;
|
|
112
|
+
if (!entry.mcpReads || entry.mcpReads.length === 0)
|
|
113
|
+
continue;
|
|
114
|
+
for (const url of entry.allowList) {
|
|
115
|
+
const host = hostnameOf(url);
|
|
116
|
+
if (!host)
|
|
117
|
+
continue;
|
|
118
|
+
const methods = byHost.get(host) ?? new Set();
|
|
119
|
+
for (const method of entry.mcpReads)
|
|
120
|
+
methods.add(method);
|
|
121
|
+
byHost.set(host, methods);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return byHost;
|
|
125
|
+
}
|
|
126
|
+
function hostnameOf(url) {
|
|
127
|
+
try {
|
|
128
|
+
return new URL(url).hostname;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export function detectPlatform() {
|
|
135
|
+
return platform();
|
|
136
|
+
}
|
|
137
|
+
async function loadEntry(skillsDir, dir, origin) {
|
|
138
|
+
try {
|
|
139
|
+
const skillDir = path.join(skillsDir, dir);
|
|
140
|
+
const raw = await fs.promises.readFile(path.join(skillDir, 'SKILL.md'), 'utf8');
|
|
141
|
+
const { meta } = parseSkillFrontMatter(raw);
|
|
142
|
+
const tools = meta.tools ?? [];
|
|
143
|
+
const cli = await loadSkillCli(skillDir, tools);
|
|
144
|
+
const referenceFiles = await loadReferenceFiles(skillDir);
|
|
145
|
+
const operations = origin === 'overlay' ? [] : await loadOperations(skillDir, dir);
|
|
146
|
+
const platform = meta.platform && meta.platform.length > 0
|
|
147
|
+
? meta.platform
|
|
148
|
+
: origin === 'overlay'
|
|
149
|
+
? OVERLAY_DEFAULT_PLATFORMS
|
|
150
|
+
: [];
|
|
151
|
+
return {
|
|
152
|
+
name: dir,
|
|
153
|
+
description: meta.description ?? '',
|
|
154
|
+
...(meta.aliases ? { aliases: meta.aliases } : {}),
|
|
155
|
+
...(meta.preloadOnName === false ? { preloadOnName: false } : {}),
|
|
156
|
+
tools,
|
|
157
|
+
credentials: meta.credentials ?? [],
|
|
158
|
+
allowList: meta.allowList ?? [],
|
|
159
|
+
...(meta.mcpReads ? { mcpReads: meta.mcpReads } : {}),
|
|
160
|
+
platform,
|
|
161
|
+
...(meta.requires ? { requires: meta.requires } : {}),
|
|
162
|
+
...(meta.install ? { install: meta.install } : {}),
|
|
163
|
+
...(meta.setup ? { setup: meta.setup } : {}),
|
|
164
|
+
...(cli ? { cliValidator: buildCliValidator(cli) } : {}),
|
|
165
|
+
...(meta.stub !== undefined ? { stub: meta.stub } : {}),
|
|
166
|
+
...(meta.minCapabilityProfile ? { minCapabilityProfile: meta.minCapabilityProfile } : {}),
|
|
167
|
+
...(meta.emoji ? { emoji: meta.emoji } : {}),
|
|
168
|
+
...(referenceFiles.length ? { referenceFiles } : {}),
|
|
169
|
+
...(operations.length ? { operations } : {}),
|
|
170
|
+
...(origin ? { origin } : {})
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async function loadOperations(skillDir, name) {
|
|
178
|
+
let raw;
|
|
179
|
+
try {
|
|
180
|
+
raw = await fs.promises.readFile(path.join(skillDir, 'operations.json'), 'utf8');
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return [];
|
|
184
|
+
}
|
|
185
|
+
const operations = parseOperationsManifest(raw);
|
|
186
|
+
if (!operations) {
|
|
187
|
+
hlog('skill operations manifest rejected', { skill: name });
|
|
188
|
+
return [];
|
|
189
|
+
}
|
|
190
|
+
return operations;
|
|
191
|
+
}
|
|
192
|
+
async function loadReferenceFiles(skillDir) {
|
|
193
|
+
try {
|
|
194
|
+
const entries = await fs.promises.readdir(path.join(skillDir, 'references'));
|
|
195
|
+
return entries
|
|
196
|
+
.filter((entry) => entry.endsWith('.md'))
|
|
197
|
+
.sort()
|
|
198
|
+
.map((entry) => `references/${entry}`);
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return [];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JsonSchema } from './cli-schema-types.ts';
|
|
2
|
+
export declare function walkCommands(argv: readonly string[], schema: JsonSchema): {
|
|
3
|
+
node: JsonSchema;
|
|
4
|
+
pathSegs: string[];
|
|
5
|
+
index: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function argvToObject(argv: readonly string[], schema: JsonSchema): Record<string, unknown> | string;
|
|
8
|
+
export declare function objectProps(schema: JsonSchema): Readonly<Record<string, JsonSchema>>;
|
|
9
|
+
export declare function isObjectSchema(schema: JsonSchema): boolean;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
export function walkCommands(argv, schema) {
|
|
2
|
+
let node = schema;
|
|
3
|
+
const pathSegs = [];
|
|
4
|
+
let i = 0;
|
|
5
|
+
while (i < argv.length) {
|
|
6
|
+
const tok = argv[i] ?? '';
|
|
7
|
+
if (isParamToken(tok))
|
|
8
|
+
break;
|
|
9
|
+
const child = objectProps(node)[tok];
|
|
10
|
+
if (!child || !isObjectSchema(child))
|
|
11
|
+
break;
|
|
12
|
+
pathSegs.push(tok);
|
|
13
|
+
node = child;
|
|
14
|
+
i++;
|
|
15
|
+
}
|
|
16
|
+
return { node, pathSegs, index: i };
|
|
17
|
+
}
|
|
18
|
+
export function argvToObject(argv, schema) {
|
|
19
|
+
const { node, pathSegs, index } = walkCommands(argv, schema);
|
|
20
|
+
const leaf = parseParams(argv.slice(index), node);
|
|
21
|
+
if (typeof leaf === 'string')
|
|
22
|
+
return leaf;
|
|
23
|
+
let out = leaf;
|
|
24
|
+
for (let p = pathSegs.length - 1; p >= 0; p--) {
|
|
25
|
+
out = { [pathSegs[p]]: out };
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
export function objectProps(schema) {
|
|
30
|
+
return schema.properties ?? {};
|
|
31
|
+
}
|
|
32
|
+
export function isObjectSchema(schema) {
|
|
33
|
+
return schema.type === 'object' || (!schema.type && !!schema.properties);
|
|
34
|
+
}
|
|
35
|
+
function isParamToken(tok) {
|
|
36
|
+
if (!tok)
|
|
37
|
+
return false;
|
|
38
|
+
if (tok.startsWith('-'))
|
|
39
|
+
return true;
|
|
40
|
+
if (tok.includes('='))
|
|
41
|
+
return true;
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
function parseParams(tokens, schema) {
|
|
45
|
+
const props = objectProps(schema);
|
|
46
|
+
const propKeys = new Set(Object.keys(props));
|
|
47
|
+
const boolKeys = new Set(Object.entries(props)
|
|
48
|
+
.filter(([, s]) => s.type === 'boolean')
|
|
49
|
+
.map(([k]) => k));
|
|
50
|
+
const positionals = schema['x-positionals'] ?? [];
|
|
51
|
+
const restName = schema['x-rest'];
|
|
52
|
+
const out = {};
|
|
53
|
+
let posIdx = 0;
|
|
54
|
+
const restVals = [];
|
|
55
|
+
let i = 0;
|
|
56
|
+
while (i < tokens.length) {
|
|
57
|
+
const tok = tokens[i] ?? '';
|
|
58
|
+
const canAbsorb = posIdx < positionals.length || restName !== undefined;
|
|
59
|
+
const eq = tok.indexOf('=');
|
|
60
|
+
if (eq > 0 && !tok.startsWith('-')) {
|
|
61
|
+
const key = tok.slice(0, eq);
|
|
62
|
+
if (propKeys.has(key)) {
|
|
63
|
+
out[key] = coerce(tok.slice(eq + 1), props[key]);
|
|
64
|
+
i++;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (!canAbsorb)
|
|
68
|
+
return `unknown parameter "${key}"`;
|
|
69
|
+
}
|
|
70
|
+
if (tok.startsWith('-')) {
|
|
71
|
+
let key;
|
|
72
|
+
let inline;
|
|
73
|
+
if (tok.startsWith('--')) {
|
|
74
|
+
const body = tok.slice(2);
|
|
75
|
+
const ieq = body.indexOf('=');
|
|
76
|
+
if (ieq >= 0) {
|
|
77
|
+
key = body.slice(0, ieq);
|
|
78
|
+
inline = body.slice(ieq + 1);
|
|
79
|
+
}
|
|
80
|
+
else
|
|
81
|
+
key = body;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
key = tok.slice(1);
|
|
85
|
+
}
|
|
86
|
+
if (propKeys.has(key)) {
|
|
87
|
+
if (boolKeys.has(key)) {
|
|
88
|
+
out[key] = inline !== undefined ? inline !== 'false' && inline !== '0' : true;
|
|
89
|
+
i++;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (inline !== undefined) {
|
|
93
|
+
out[key] = coerce(inline, props[key]);
|
|
94
|
+
i++;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const next = tokens[i + 1];
|
|
98
|
+
if (next === undefined || next.startsWith('-')) {
|
|
99
|
+
return `flag --${key} requires a value`;
|
|
100
|
+
}
|
|
101
|
+
out[key] = coerce(next, props[key]);
|
|
102
|
+
i += 2;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (!canAbsorb)
|
|
106
|
+
return `unknown flag "--${key}"`;
|
|
107
|
+
}
|
|
108
|
+
if (boolKeys.has(tok)) {
|
|
109
|
+
out[tok] = true;
|
|
110
|
+
i++;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (propKeys.has(tok) && props[tok]?.type === 'string' && !canAbsorb) {
|
|
114
|
+
out[tok] = '';
|
|
115
|
+
i++;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (posIdx < positionals.length) {
|
|
119
|
+
const name = positionals[posIdx];
|
|
120
|
+
if (!propKeys.has(name))
|
|
121
|
+
return `x-positionals names unknown property "${name}"`;
|
|
122
|
+
out[name] = coerce(tok, props[name]);
|
|
123
|
+
posIdx++;
|
|
124
|
+
i++;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (restName) {
|
|
128
|
+
restVals.push(tok);
|
|
129
|
+
i++;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
return `unexpected argument "${tok}"`;
|
|
133
|
+
}
|
|
134
|
+
if (restName && restVals.length > 0)
|
|
135
|
+
out[restName] = restVals;
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
function coerce(value, schema) {
|
|
139
|
+
if (schema.type === 'number' || schema.type === 'integer') {
|
|
140
|
+
const n = Number(value);
|
|
141
|
+
return Number.isFinite(n) ? n : value;
|
|
142
|
+
}
|
|
143
|
+
if (schema.type === 'boolean') {
|
|
144
|
+
return value !== 'false' && value !== '0';
|
|
145
|
+
}
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { JsonSchema } from './cli-schema-types.ts';
|
|
2
|
+
export declare function buildSchemaAnnotation(schema: JsonSchema): (argv: readonly string[]) => 'read' | 'write';
|
|
3
|
+
export declare function buildSchemaCheck(schema: JsonSchema, resourcePaths: readonly string[] | undefined): (argv: readonly string[]) => string | null;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { argvToObject, isObjectSchema, objectProps, walkCommands } from "./cli-argv.js";
|
|
3
|
+
export function buildSchemaAnnotation(schema) {
|
|
4
|
+
const resourceEffects = schema['x-resource-effects'];
|
|
5
|
+
return (argv) => {
|
|
6
|
+
const first = argv[0];
|
|
7
|
+
if (resourceEffects && typeof first === 'string') {
|
|
8
|
+
if (resourceEffects[basename(first)] === 'read')
|
|
9
|
+
return 'read';
|
|
10
|
+
}
|
|
11
|
+
return walkCommands(argv, schema).node['x-effect'] === 'read' ? 'read' : 'write';
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function basename(p) {
|
|
15
|
+
return p.slice(Math.max(p.lastIndexOf('/'), p.lastIndexOf('\\')) + 1);
|
|
16
|
+
}
|
|
17
|
+
export function buildSchemaCheck(schema, resourcePaths) {
|
|
18
|
+
let zodSchema;
|
|
19
|
+
try {
|
|
20
|
+
zodSchema = z.fromJSONSchema(schema);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
24
|
+
return () => `invalid skill cli JSON Schema: ${msg}`;
|
|
25
|
+
}
|
|
26
|
+
return (argv) => {
|
|
27
|
+
const built = argvToObject(argv, schema);
|
|
28
|
+
if (typeof built === 'string')
|
|
29
|
+
return built;
|
|
30
|
+
const cmdErr = assertSingleCommand(built, schema);
|
|
31
|
+
if (cmdErr)
|
|
32
|
+
return cmdErr;
|
|
33
|
+
const resourceErr = assertResourcePath(built, resourcePaths);
|
|
34
|
+
if (resourceErr)
|
|
35
|
+
return resourceErr;
|
|
36
|
+
const result = zodSchema.safeParse(built);
|
|
37
|
+
if (result.success)
|
|
38
|
+
return null;
|
|
39
|
+
return formatZod(result.error);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function assertResourcePath(obj, resourcePaths) {
|
|
43
|
+
if (!resourcePaths || resourcePaths.length === 0 || typeof obj.script !== 'string')
|
|
44
|
+
return null;
|
|
45
|
+
return resourcePaths.includes(obj.script) ? null : 'script must be a bundled skill resource';
|
|
46
|
+
}
|
|
47
|
+
function assertSingleCommand(obj, schema) {
|
|
48
|
+
const props = objectProps(schema);
|
|
49
|
+
const commandKeys = Object.keys(props).filter((k) => isObjectSchema(props[k]));
|
|
50
|
+
const present = commandKeys.filter((k) => k in obj);
|
|
51
|
+
if (present.length > 1) {
|
|
52
|
+
return `only one command allowed (got ${present.join(', ')})`;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function formatZod(err) {
|
|
57
|
+
const issue = err.issues[0];
|
|
58
|
+
if (!issue)
|
|
59
|
+
return 'invalid parameters';
|
|
60
|
+
const where = issue.path.length ? `${issue.path.join('.')}: ` : '';
|
|
61
|
+
return `${where}${issue.message}`;
|
|
62
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type SkillCli } from './cli-schema-types.ts';
|
|
2
|
+
export declare function resolveCliSchema(skillDir: string, bin: string, readFile?: (p: string) => Promise<string>): Promise<SkillCli>;
|
|
3
|
+
export declare function execBinFromTools(tools: readonly string[]): string | undefined;
|
|
4
|
+
export declare function loadSkillCli(skillDir: string, tools: readonly string[], readFile?: (p: string) => Promise<string>): Promise<SkillCli | undefined>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { CLI_SCHEMA_FILENAME } from "./cli-schema-types.js";
|
|
4
|
+
export async function resolveCliSchema(skillDir, bin, readFile = (p) => fs.promises.readFile(p, 'utf8')) {
|
|
5
|
+
const full = path.join(skillDir, CLI_SCHEMA_FILENAME);
|
|
6
|
+
let raw;
|
|
7
|
+
try {
|
|
8
|
+
raw = await readFile(full);
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
if (isEnoent(err))
|
|
12
|
+
return { bin };
|
|
13
|
+
return { bin, schemaFile: CLI_SCHEMA_FILENAME };
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(raw);
|
|
17
|
+
if (!isObj(parsed))
|
|
18
|
+
return { bin, schemaFile: CLI_SCHEMA_FILENAME };
|
|
19
|
+
const schema = parsed;
|
|
20
|
+
if (!resourceGuardConsistent(schema))
|
|
21
|
+
return { bin, schemaFile: CLI_SCHEMA_FILENAME };
|
|
22
|
+
if (!effectAnnotationsValid(schema))
|
|
23
|
+
return { bin, schemaFile: CLI_SCHEMA_FILENAME };
|
|
24
|
+
if (!resourceEffectsValid(schema))
|
|
25
|
+
return { bin, schemaFile: CLI_SCHEMA_FILENAME };
|
|
26
|
+
const resourcePaths = resolveResourcePaths(skillDir, schema);
|
|
27
|
+
return {
|
|
28
|
+
bin,
|
|
29
|
+
schema,
|
|
30
|
+
schemaFile: CLI_SCHEMA_FILENAME,
|
|
31
|
+
...(resourcePaths.length ? { resourcePaths } : {})
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return { bin, schemaFile: CLI_SCHEMA_FILENAME };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function resourceGuardConsistent(schema) {
|
|
39
|
+
const resources = schema['x-resource-files'];
|
|
40
|
+
if (!resources || resources.length === 0)
|
|
41
|
+
return true;
|
|
42
|
+
return schema.properties?.script?.type === 'string';
|
|
43
|
+
}
|
|
44
|
+
function effectAnnotationsValid(schema) {
|
|
45
|
+
if ('x-effect' in schema && schema['x-effect'] !== 'read')
|
|
46
|
+
return false;
|
|
47
|
+
return Object.values(schema.properties ?? {}).every(effectAnnotationsValid);
|
|
48
|
+
}
|
|
49
|
+
function resourceEffectsValid(schema) {
|
|
50
|
+
const effects = schema['x-resource-effects'];
|
|
51
|
+
if (effects === undefined)
|
|
52
|
+
return true;
|
|
53
|
+
if (typeof effects !== 'object' || effects === null || Array.isArray(effects))
|
|
54
|
+
return false;
|
|
55
|
+
const files = new Set(schema['x-resource-files'] ?? []);
|
|
56
|
+
return Object.entries(effects).every(([file, effect]) => effect === 'read' && files.has(file));
|
|
57
|
+
}
|
|
58
|
+
function resolveResourcePaths(skillDir, schema) {
|
|
59
|
+
const resources = schema['x-resource-files'] ?? [];
|
|
60
|
+
return resources
|
|
61
|
+
.filter((resource) => typeof resource === 'string' && /^[\w-]+\.applescript$/.test(resource))
|
|
62
|
+
.map((resource) => path.join(skillDir, resource));
|
|
63
|
+
}
|
|
64
|
+
export function execBinFromTools(tools) {
|
|
65
|
+
for (const entry of tools) {
|
|
66
|
+
const m = /^exec\((.+)\)$/i.exec(entry.trim());
|
|
67
|
+
const scope = m?.[1]?.trim();
|
|
68
|
+
if (scope)
|
|
69
|
+
return scope;
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
export async function loadSkillCli(skillDir, tools, readFile) {
|
|
74
|
+
const bin = execBinFromTools(tools);
|
|
75
|
+
if (!bin)
|
|
76
|
+
return undefined;
|
|
77
|
+
const resolved = await resolveCliSchema(skillDir, bin, readFile);
|
|
78
|
+
if (resolved.schema || resolved.schemaFile)
|
|
79
|
+
return resolved;
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
function isEnoent(err) {
|
|
83
|
+
return (typeof err === 'object' &&
|
|
84
|
+
err !== null &&
|
|
85
|
+
'code' in err &&
|
|
86
|
+
err.code === 'ENOENT');
|
|
87
|
+
}
|
|
88
|
+
function isObj(v) {
|
|
89
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
90
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type JsonSchema = {
|
|
2
|
+
readonly type?: string;
|
|
3
|
+
readonly properties?: Readonly<Record<string, JsonSchema>>;
|
|
4
|
+
readonly required?: readonly string[];
|
|
5
|
+
readonly additionalProperties?: boolean | JsonSchema;
|
|
6
|
+
readonly oneOf?: readonly JsonSchema[];
|
|
7
|
+
readonly anyOf?: readonly JsonSchema[];
|
|
8
|
+
readonly enum?: readonly unknown[];
|
|
9
|
+
readonly pattern?: string;
|
|
10
|
+
readonly description?: string;
|
|
11
|
+
readonly 'x-positionals'?: readonly string[];
|
|
12
|
+
readonly 'x-rest'?: string;
|
|
13
|
+
readonly 'x-resource-files'?: readonly string[];
|
|
14
|
+
readonly 'x-resource-effects'?: Readonly<Record<string, string>>;
|
|
15
|
+
readonly 'x-effect'?: string;
|
|
16
|
+
readonly [key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
export type SkillCli = {
|
|
19
|
+
readonly bin: string;
|
|
20
|
+
readonly schema?: JsonSchema;
|
|
21
|
+
readonly schemaFile?: string;
|
|
22
|
+
readonly resourcePaths?: readonly string[];
|
|
23
|
+
};
|
|
24
|
+
export declare const CLI_SCHEMA_FILENAME = "cli.schema.json";
|
|
25
|
+
export type CliValidator = {
|
|
26
|
+
readonly bin: string;
|
|
27
|
+
readonly check: (argv: readonly string[]) => string | null;
|
|
28
|
+
readonly annotation: (argv: readonly string[]) => 'read' | 'write';
|
|
29
|
+
readonly effect: (argv: readonly string[]) => 'read' | 'write';
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CLI_SCHEMA_FILENAME = 'cli.schema.json';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { CliValidator, JsonSchema, SkillCli } from './cli-schema-types.ts';
|
|
2
|
+
export { CLI_SCHEMA_FILENAME } from './cli-schema-types.ts';
|
|
3
|
+
export { argvToObject } from './cli-argv.ts';
|
|
4
|
+
export { loadSkillCli, resolveCliSchema, execBinFromTools } from './cli-schema-load.ts';
|
|
5
|
+
import type { CliValidator, SkillCli } from './cli-schema-types.ts';
|
|
6
|
+
export declare function buildCliValidator(def: SkillCli): CliValidator;
|
|
7
|
+
export declare function checkCliOps(argv: readonly string[], compiled: readonly CliValidator[]): string | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export { CLI_SCHEMA_FILENAME } from "./cli-schema-types.js";
|
|
2
|
+
export { argvToObject } from "./cli-argv.js";
|
|
3
|
+
export { loadSkillCli, resolveCliSchema, execBinFromTools } from "./cli-schema-load.js";
|
|
4
|
+
import { buildSchemaAnnotation, buildSchemaCheck } from "./cli-schema-check.js";
|
|
5
|
+
export function buildCliValidator(def) {
|
|
6
|
+
const bin = def.bin.toLowerCase();
|
|
7
|
+
if (!def.schema) {
|
|
8
|
+
return {
|
|
9
|
+
bin,
|
|
10
|
+
check: () => 'skill cli schema is missing',
|
|
11
|
+
annotation: () => 'write',
|
|
12
|
+
effect: () => 'write'
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const check = buildSchemaCheck(def.schema, def.resourcePaths);
|
|
16
|
+
const annotation = buildSchemaAnnotation(def.schema);
|
|
17
|
+
return {
|
|
18
|
+
bin,
|
|
19
|
+
check,
|
|
20
|
+
annotation,
|
|
21
|
+
effect: (argv) => (check(argv) === null ? annotation(argv) : 'write')
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function checkCliOps(argv, compiled) {
|
|
25
|
+
if (compiled.length === 0)
|
|
26
|
+
return null;
|
|
27
|
+
let lastErr = null;
|
|
28
|
+
for (const c of compiled) {
|
|
29
|
+
const err = c.check(argv);
|
|
30
|
+
if (err === null)
|
|
31
|
+
return null;
|
|
32
|
+
lastErr = err;
|
|
33
|
+
}
|
|
34
|
+
return lastErr ?? 'command does not match any allowed skill operation';
|
|
35
|
+
}
|