@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,134 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { markdownFileName } from "./note-name.js";
|
|
4
|
+
import { appendToFile, dailyCandidates, ensureWithinRoot, FRONTMATTER_RE, getArg, getContentArg, moveFile, readFileSnapshot, resolveNotePath, todayStamp, updateFileText, writeIfUnchanged } from "./vault-paths.js";
|
|
5
|
+
export function handleAppend(vaultPath, args) {
|
|
6
|
+
const notePath = resolveNotePath(vaultPath, args);
|
|
7
|
+
if (!notePath || !fs.existsSync(notePath)) {
|
|
8
|
+
throw new Error(`Note not found. Args: ${args.join(', ')}`);
|
|
9
|
+
}
|
|
10
|
+
const content = getContentArg(args);
|
|
11
|
+
if (!content)
|
|
12
|
+
throw new Error('Missing required argument: content=');
|
|
13
|
+
appendToFile(notePath, content);
|
|
14
|
+
return `Appended to: ${path.relative(vaultPath, notePath)}`;
|
|
15
|
+
}
|
|
16
|
+
export function handlePrepend(vaultPath, args) {
|
|
17
|
+
const notePath = resolveNotePath(vaultPath, args);
|
|
18
|
+
if (!notePath || !fs.existsSync(notePath)) {
|
|
19
|
+
throw new Error(`Note not found. Args: ${args.join(', ')}`);
|
|
20
|
+
}
|
|
21
|
+
const content = getContentArg(args);
|
|
22
|
+
if (!content)
|
|
23
|
+
throw new Error('Missing required argument: content=');
|
|
24
|
+
updateFileText(notePath, (existing) => content + existing);
|
|
25
|
+
return `Prepended to: ${path.relative(vaultPath, notePath)}`;
|
|
26
|
+
}
|
|
27
|
+
function uniqueTrashPath(base) {
|
|
28
|
+
if (!fs.existsSync(base))
|
|
29
|
+
return base;
|
|
30
|
+
const ext = base.endsWith('.md') ? '.md' : '';
|
|
31
|
+
const stem = ext ? base.slice(0, -ext.length) : base;
|
|
32
|
+
let n = 1;
|
|
33
|
+
while (fs.existsSync(`${stem} (${n})${ext}`))
|
|
34
|
+
n += 1;
|
|
35
|
+
return `${stem} (${n})${ext}`;
|
|
36
|
+
}
|
|
37
|
+
export function handleDelete(vaultPath, args) {
|
|
38
|
+
const notePath = resolveNotePath(vaultPath, args);
|
|
39
|
+
if (!notePath || !fs.existsSync(notePath)) {
|
|
40
|
+
throw new Error(`Note not found. Args: ${args.join(', ')}`);
|
|
41
|
+
}
|
|
42
|
+
const root = path.resolve(vaultPath);
|
|
43
|
+
const trashPath = uniqueTrashPath(ensureWithinRoot(vaultPath, path.join('.trash', path.relative(root, notePath))));
|
|
44
|
+
fs.mkdirSync(path.dirname(trashPath), { recursive: true });
|
|
45
|
+
moveFile(notePath, trashPath);
|
|
46
|
+
return `Moved to trash: ${path.relative(vaultPath, notePath)}`;
|
|
47
|
+
}
|
|
48
|
+
export function handleMove(vaultPath, args) {
|
|
49
|
+
const notePath = resolveNotePath(vaultPath, args);
|
|
50
|
+
if (!notePath || !fs.existsSync(notePath)) {
|
|
51
|
+
throw new Error(`Note not found. Args: ${args.join(', ')}`);
|
|
52
|
+
}
|
|
53
|
+
const to = getArg(args, 'to');
|
|
54
|
+
if (!to)
|
|
55
|
+
throw new Error('Missing required argument: to=');
|
|
56
|
+
const destDir = ensureWithinRoot(vaultPath, to);
|
|
57
|
+
if (!fs.existsSync(destDir))
|
|
58
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
59
|
+
const destPath = path.join(destDir, path.basename(notePath));
|
|
60
|
+
moveFile(notePath, destPath);
|
|
61
|
+
return `Moved to: ${path.relative(vaultPath, destPath)}`;
|
|
62
|
+
}
|
|
63
|
+
export function handleRename(vaultPath, args) {
|
|
64
|
+
const notePath = resolveNotePath(vaultPath, args);
|
|
65
|
+
if (!notePath || !fs.existsSync(notePath)) {
|
|
66
|
+
throw new Error(`Note not found. Args: ${args.join(', ')}`);
|
|
67
|
+
}
|
|
68
|
+
const newName = getArg(args, 'name');
|
|
69
|
+
if (!newName)
|
|
70
|
+
throw new Error('Missing required argument: name=');
|
|
71
|
+
const fileName = markdownFileName(newName);
|
|
72
|
+
const relativeDir = path.relative(path.resolve(vaultPath), path.dirname(notePath));
|
|
73
|
+
const destPath = ensureWithinRoot(vaultPath, path.join(relativeDir, fileName));
|
|
74
|
+
moveFile(notePath, destPath);
|
|
75
|
+
return `Renamed to: ${path.relative(vaultPath, destPath)}`;
|
|
76
|
+
}
|
|
77
|
+
function mergeIntoFrontmatter(fmBlock, newProps) {
|
|
78
|
+
let result = fmBlock;
|
|
79
|
+
for (const { key, value } of newProps) {
|
|
80
|
+
const lineRe = new RegExp(`^${key}:.*$`, 'm');
|
|
81
|
+
if (lineRe.test(result))
|
|
82
|
+
result = result.replace(lineRe, `${key}: ${value}`);
|
|
83
|
+
else
|
|
84
|
+
result += `\n${key}: ${value}`;
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
export function handlePropertySet(vaultPath, args) {
|
|
89
|
+
const notePath = resolveNotePath(vaultPath, args);
|
|
90
|
+
if (!notePath || !fs.existsSync(notePath)) {
|
|
91
|
+
throw new Error(`Note not found. Args: ${args.join(', ')}`);
|
|
92
|
+
}
|
|
93
|
+
const propArgs = args.filter((a) => !a.startsWith('file=') && !a.startsWith('path=') && a.includes('='));
|
|
94
|
+
if (propArgs.length === 0)
|
|
95
|
+
throw new Error('No property key=value pairs provided.');
|
|
96
|
+
const newProps = propArgs.map((a) => {
|
|
97
|
+
const eqIdx = a.indexOf('=');
|
|
98
|
+
return { key: a.slice(0, eqIdx), value: a.slice(eqIdx + 1) };
|
|
99
|
+
});
|
|
100
|
+
updateFileText(notePath, (content) => {
|
|
101
|
+
const fmBlock = content.match(FRONTMATTER_RE)?.[1];
|
|
102
|
+
if (fmBlock === undefined) {
|
|
103
|
+
const lines = newProps.map(({ key, value }) => `${key}: ${value}`);
|
|
104
|
+
return `---\n${lines.join('\n')}\n---\n${content}`;
|
|
105
|
+
}
|
|
106
|
+
const merged = mergeIntoFrontmatter(fmBlock, newProps);
|
|
107
|
+
return content.replace(FRONTMATTER_RE, `---\n${merged}\n---`);
|
|
108
|
+
});
|
|
109
|
+
return `Properties updated: ${newProps.map((p) => p.key).join(', ')}`;
|
|
110
|
+
}
|
|
111
|
+
export function handleDailyAppend(vaultPath, args) {
|
|
112
|
+
const content = getContentArg(args);
|
|
113
|
+
if (!content)
|
|
114
|
+
throw new Error('Missing required argument: content=');
|
|
115
|
+
const dateStr = todayStamp();
|
|
116
|
+
let target = null;
|
|
117
|
+
for (const candidate of dailyCandidates(vaultPath, dateStr)) {
|
|
118
|
+
if (fs.existsSync(candidate)) {
|
|
119
|
+
target = candidate;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (!target) {
|
|
124
|
+
const dailyDir = ensureWithinRoot(vaultPath, 'Daily Notes');
|
|
125
|
+
if (!fs.existsSync(dailyDir))
|
|
126
|
+
fs.mkdirSync(dailyDir, { recursive: true });
|
|
127
|
+
target = ensureWithinRoot(vaultPath, path.join('Daily Notes', `${dateStr}.md`));
|
|
128
|
+
const snap = readFileSnapshot(target);
|
|
129
|
+
if (!snap)
|
|
130
|
+
writeIfUnchanged(target, '', null);
|
|
131
|
+
}
|
|
132
|
+
appendToFile(target, content);
|
|
133
|
+
return `Appended to daily note: ${dateStr}`;
|
|
134
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
2
|
+
export type ExecAttachment = {
|
|
3
|
+
readonly attachmentId: string;
|
|
4
|
+
readonly fileName: string;
|
|
5
|
+
readonly byteLength: number;
|
|
6
|
+
};
|
|
7
|
+
export type RejectedOutput = {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly reason: string;
|
|
10
|
+
};
|
|
11
|
+
export type ExecResult = {
|
|
12
|
+
readonly stdout: string;
|
|
13
|
+
readonly stderr: string;
|
|
14
|
+
readonly exitCode: number;
|
|
15
|
+
readonly attachments?: readonly ExecAttachment[];
|
|
16
|
+
readonly missingOutputs?: readonly string[];
|
|
17
|
+
readonly rejectedOutputs?: readonly RejectedOutput[];
|
|
18
|
+
};
|
|
19
|
+
export type SpawnOptions = {
|
|
20
|
+
cwd?: string;
|
|
21
|
+
shell?: boolean;
|
|
22
|
+
detached?: boolean;
|
|
23
|
+
stdio?: [string, string, string] | string;
|
|
24
|
+
env?: Record<string, string>;
|
|
25
|
+
};
|
|
26
|
+
export type Child = {
|
|
27
|
+
readonly pid?: number;
|
|
28
|
+
readonly stdout: {
|
|
29
|
+
on(event: 'data', handler: (chunk: Buffer | string) => void): void;
|
|
30
|
+
} | null;
|
|
31
|
+
readonly stderr: {
|
|
32
|
+
on(event: 'data', handler: (chunk: Buffer | string) => void): void;
|
|
33
|
+
} | null;
|
|
34
|
+
kill(signum?: number | string): void;
|
|
35
|
+
on(event: 'exit', handler: (code: number | null, signal?: string | null) => void): void;
|
|
36
|
+
on(event: 'error', handler: (err: Error) => void): void;
|
|
37
|
+
};
|
|
38
|
+
export type SpawnFn = (command: string, opts?: SpawnOptions) => Child;
|
|
39
|
+
export type RunCommandOptions = {
|
|
40
|
+
readonly cwd?: string;
|
|
41
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
42
|
+
readonly timeoutMs?: number;
|
|
43
|
+
readonly maxOutputChars?: number;
|
|
44
|
+
readonly signal?: BareAbortSignal;
|
|
45
|
+
readonly spawn: SpawnFn;
|
|
46
|
+
readonly killProcess?: KillProcess;
|
|
47
|
+
readonly platform?: string;
|
|
48
|
+
};
|
|
49
|
+
export declare const MAX_OUTPUT_CHARS = 8192;
|
|
50
|
+
export declare const MAX_OUTPUT_CHARS_LIMIT = 65536;
|
|
51
|
+
export declare const TRUNCATED_OUTPUT_SUFFIX = "\u2026 [truncated]";
|
|
52
|
+
export type KillProcess = (pid: number, signal: string) => void;
|
|
53
|
+
type CapturedOutput = {
|
|
54
|
+
value: string;
|
|
55
|
+
truncated: boolean;
|
|
56
|
+
};
|
|
57
|
+
export declare function capOutput(text: string, limit: number): string;
|
|
58
|
+
export declare function appendOutput(output: CapturedOutput, chunk: Buffer | string, limit: number): void;
|
|
59
|
+
export declare function formatOutput(output: CapturedOutput): string;
|
|
60
|
+
export declare function createCapturedOutput(): CapturedOutput;
|
|
61
|
+
export declare function runCommand(command: string, options: RunCommandOptions): Promise<ExecResult>;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import process from 'process';
|
|
2
|
+
import { AbortedError } from "../../helpers/race-abort.js";
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
4
|
+
export const MAX_OUTPUT_CHARS = 8_192;
|
|
5
|
+
export const MAX_OUTPUT_CHARS_LIMIT = 65_536;
|
|
6
|
+
export const TRUNCATED_OUTPUT_SUFFIX = '… [truncated]';
|
|
7
|
+
export function capOutput(text, limit) {
|
|
8
|
+
const body = text.endsWith(TRUNCATED_OUTPUT_SUFFIX)
|
|
9
|
+
? text.slice(0, -TRUNCATED_OUTPUT_SUFFIX.length)
|
|
10
|
+
: text;
|
|
11
|
+
if (body.length <= limit) {
|
|
12
|
+
return body === text ? text : `${body}${TRUNCATED_OUTPUT_SUFFIX}`;
|
|
13
|
+
}
|
|
14
|
+
return `${body.slice(0, limit)}${TRUNCATED_OUTPUT_SUFFIX}`;
|
|
15
|
+
}
|
|
16
|
+
export function appendOutput(output, chunk, limit) {
|
|
17
|
+
if (output.truncated)
|
|
18
|
+
return;
|
|
19
|
+
const available = limit - output.value.length;
|
|
20
|
+
if (available <= 0) {
|
|
21
|
+
output.truncated = true;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');
|
|
25
|
+
output.value += text.slice(0, available);
|
|
26
|
+
output.truncated = text.length > available;
|
|
27
|
+
}
|
|
28
|
+
export function formatOutput(output) {
|
|
29
|
+
return output.truncated ? `${output.value}${TRUNCATED_OUTPUT_SUFFIX}` : output.value;
|
|
30
|
+
}
|
|
31
|
+
export function createCapturedOutput() {
|
|
32
|
+
return { value: '', truncated: false };
|
|
33
|
+
}
|
|
34
|
+
function terminateProcessTree(child, killProcess) {
|
|
35
|
+
if (child.pid !== undefined && killProcess) {
|
|
36
|
+
try {
|
|
37
|
+
killProcess(-child.pid, 'SIGTERM');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
child.kill('SIGTERM');
|
|
44
|
+
}
|
|
45
|
+
export function runCommand(command, options) {
|
|
46
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
47
|
+
const maxOutputChars = options.maxOutputChars ?? MAX_OUTPUT_CHARS;
|
|
48
|
+
if (options.signal?.aborted)
|
|
49
|
+
return Promise.reject(new AbortedError());
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
const stdout = { value: '', truncated: false };
|
|
52
|
+
const stderr = { value: '', truncated: false };
|
|
53
|
+
let settled = false;
|
|
54
|
+
const child = options.spawn(command, {
|
|
55
|
+
shell: true,
|
|
56
|
+
detached: (options.platform ?? process.platform) !== 'win32',
|
|
57
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
58
|
+
cwd: options.cwd,
|
|
59
|
+
...(options.env ? { env: { ...options.env } } : {})
|
|
60
|
+
});
|
|
61
|
+
const finish = (fn) => {
|
|
62
|
+
if (settled)
|
|
63
|
+
return;
|
|
64
|
+
settled = true;
|
|
65
|
+
clearTimeout(timer);
|
|
66
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
67
|
+
fn();
|
|
68
|
+
};
|
|
69
|
+
const onAbort = () => {
|
|
70
|
+
finish(() => reject(new AbortedError()));
|
|
71
|
+
terminateProcessTree(child, options.killProcess);
|
|
72
|
+
};
|
|
73
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
74
|
+
const timer = setTimeout(() => {
|
|
75
|
+
finish(() => reject(new Error(`Command timed out after ${timeoutMs}ms`)));
|
|
76
|
+
terminateProcessTree(child, options.killProcess);
|
|
77
|
+
}, timeoutMs);
|
|
78
|
+
child.stdout?.on('data', (chunk) => appendOutput(stdout, chunk, maxOutputChars));
|
|
79
|
+
child.stderr?.on('data', (chunk) => appendOutput(stderr, chunk, maxOutputChars));
|
|
80
|
+
child.on('error', (err) => finish(() => reject(err)));
|
|
81
|
+
child.on('exit', (code) => finish(() => resolve({
|
|
82
|
+
stdout: formatOutput(stdout),
|
|
83
|
+
stderr: formatOutput(stderr),
|
|
84
|
+
exitCode: code ?? 1
|
|
85
|
+
})));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export function bareBin(token) {
|
|
2
|
+
if (!token || /[/\\~$]/.test(token))
|
|
3
|
+
return null;
|
|
4
|
+
return token.replace(/\.exe$/i, '').toLowerCase();
|
|
5
|
+
}
|
|
6
|
+
export function firstCommandToken(command) {
|
|
7
|
+
const chars = [...command];
|
|
8
|
+
let i = 0;
|
|
9
|
+
while (i < chars.length && (chars[i] === ' ' || chars[i] === '\t'))
|
|
10
|
+
i++;
|
|
11
|
+
let token = '';
|
|
12
|
+
while (i < chars.length) {
|
|
13
|
+
const c = chars[i];
|
|
14
|
+
if (c === '"' || c === "'") {
|
|
15
|
+
const quote = c;
|
|
16
|
+
i++;
|
|
17
|
+
while (i < chars.length && chars[i] !== quote) {
|
|
18
|
+
token += chars[i];
|
|
19
|
+
i++;
|
|
20
|
+
}
|
|
21
|
+
i++;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (c === ' ' || c === '\t' || c === '\n')
|
|
25
|
+
break;
|
|
26
|
+
if (c === ';' || c === '&' || c === '|' || c === '>' || c === '<' || c === '`')
|
|
27
|
+
break;
|
|
28
|
+
token += c;
|
|
29
|
+
i++;
|
|
30
|
+
}
|
|
31
|
+
return token;
|
|
32
|
+
}
|
|
33
|
+
function isPad(c) {
|
|
34
|
+
return c === ' ' || c === '\t' || c === '\n';
|
|
35
|
+
}
|
|
36
|
+
export function sanitizeCommand(command) {
|
|
37
|
+
const chars = [...command];
|
|
38
|
+
let i = 0;
|
|
39
|
+
while (i < chars.length) {
|
|
40
|
+
const c = chars[i];
|
|
41
|
+
if (c === '\n') {
|
|
42
|
+
i++;
|
|
43
|
+
while (i < chars.length && isPad(chars[i]))
|
|
44
|
+
i++;
|
|
45
|
+
if (i < chars.length)
|
|
46
|
+
return 'command must not span multiple lines';
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (c === "'") {
|
|
50
|
+
i++;
|
|
51
|
+
while (i < chars.length && chars[i] !== "'")
|
|
52
|
+
i++;
|
|
53
|
+
i++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (c === '"') {
|
|
57
|
+
i++;
|
|
58
|
+
while (i < chars.length && chars[i] !== '"') {
|
|
59
|
+
if (chars[i] === '\\') {
|
|
60
|
+
if (chars[i + 1] === '\n')
|
|
61
|
+
return 'command must not use line continuations';
|
|
62
|
+
i += 2;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (chars[i] === '`')
|
|
66
|
+
return 'command must not use backtick substitution';
|
|
67
|
+
if (chars[i] === '$')
|
|
68
|
+
return 'command must not use shell expansion';
|
|
69
|
+
i++;
|
|
70
|
+
}
|
|
71
|
+
i++;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (c === '\\') {
|
|
75
|
+
if (chars[i + 1] === '\n')
|
|
76
|
+
return 'command must not use line continuations';
|
|
77
|
+
i += 2;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (c === '`')
|
|
81
|
+
return 'command must not use backtick substitution';
|
|
82
|
+
if (c === '$')
|
|
83
|
+
return 'command must not use shell expansion';
|
|
84
|
+
if (c === ';')
|
|
85
|
+
return 'command must not chain with ;';
|
|
86
|
+
if (c === '&')
|
|
87
|
+
return 'command must not use & or &&';
|
|
88
|
+
if (c === '|')
|
|
89
|
+
return 'command must not use pipes';
|
|
90
|
+
if (c === '>')
|
|
91
|
+
return 'command must not redirect output';
|
|
92
|
+
if (c === '<')
|
|
93
|
+
return 'command must not redirect input';
|
|
94
|
+
i++;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function shellEscapeArg(value) {
|
|
2
|
+
return value.replace(/[\\'" \t\n]/g, '\\$&');
|
|
3
|
+
}
|
|
4
|
+
export function shellArgv(command) {
|
|
5
|
+
const chars = [...command];
|
|
6
|
+
const out = [];
|
|
7
|
+
let i = 0;
|
|
8
|
+
while (i < chars.length) {
|
|
9
|
+
while (i < chars.length && (chars[i] === ' ' || chars[i] === '\t'))
|
|
10
|
+
i++;
|
|
11
|
+
if (i >= chars.length)
|
|
12
|
+
break;
|
|
13
|
+
if (chars[i] === '\n')
|
|
14
|
+
break;
|
|
15
|
+
let token = '';
|
|
16
|
+
while (i < chars.length) {
|
|
17
|
+
const c = chars[i];
|
|
18
|
+
if (c === ' ' || c === '\t' || c === '\n')
|
|
19
|
+
break;
|
|
20
|
+
if (c === "'" || c === '"') {
|
|
21
|
+
const quote = c;
|
|
22
|
+
i++;
|
|
23
|
+
while (i < chars.length && chars[i] !== quote) {
|
|
24
|
+
if (quote === '"' && chars[i] === '\\' && i + 1 < chars.length) {
|
|
25
|
+
token += chars[i + 1];
|
|
26
|
+
i += 2;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
token += chars[i];
|
|
30
|
+
i++;
|
|
31
|
+
}
|
|
32
|
+
if (i < chars.length)
|
|
33
|
+
i++;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (c === '\\' && i + 1 < chars.length) {
|
|
37
|
+
token += chars[i + 1];
|
|
38
|
+
i += 2;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
token += c;
|
|
42
|
+
i++;
|
|
43
|
+
}
|
|
44
|
+
if (token.length > 0 || out.length > 0)
|
|
45
|
+
out.push(token);
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../capabilities/completion.ts';
|
|
2
|
+
import type { LoadPyodideFn } from './exec/adapters/python/pyodide.ts';
|
|
3
|
+
import { type KillProcess, type SpawnFn } from './exec/runner.ts';
|
|
4
|
+
import { type Realpath } from './fs/scope.ts';
|
|
5
|
+
import type { CredentialStoreFn } from './skills/auth-resolver.ts';
|
|
6
|
+
import { type SkillSettingsFn } from './skills/skill-settings.ts';
|
|
7
|
+
export type { ExecResult, KillProcess, SpawnFn } from './exec/runner.ts';
|
|
8
|
+
export interface ExecToolOptions {
|
|
9
|
+
readonly spawn?: SpawnFn;
|
|
10
|
+
readonly killProcess?: KillProcess;
|
|
11
|
+
readonly loadPyodide?: LoadPyodideFn;
|
|
12
|
+
readonly disablePyodide?: boolean;
|
|
13
|
+
readonly credentialStore?: CredentialStoreFn;
|
|
14
|
+
readonly skillSettings?: SkillSettingsFn;
|
|
15
|
+
readonly realpath?: Realpath;
|
|
16
|
+
readonly deniedRoots?: readonly string[];
|
|
17
|
+
readonly skillsDir?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function bareRuntime(): Promise<{
|
|
20
|
+
readonly spawn: SpawnFn;
|
|
21
|
+
readonly killProcess: KillProcess;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function resolveScriptRun(rawArgs: Record<string, unknown>, skillsDir: string | undefined): {
|
|
24
|
+
args: Record<string, unknown>;
|
|
25
|
+
trusted: boolean;
|
|
26
|
+
} | {
|
|
27
|
+
error: string;
|
|
28
|
+
} | null;
|
|
29
|
+
export declare function createExecTool({ spawn, killProcess, loadPyodide, disablePyodide, credentialStore, skillSettings, realpath, deniedRoots, skillsDir }?: ExecToolOptions): ToolDefinition;
|