@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,105 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import process from 'process';
|
|
10
|
+
import { setHarnessLog, setHarnessLogSink } from "../../../../../log.js";
|
|
11
|
+
import { defaultLoad } from "../loader.js";
|
|
12
|
+
import { performRun } from "../run-session.js";
|
|
13
|
+
import { asHostMessage, toWireResult } from "./protocol.js";
|
|
14
|
+
function narrowThreadData(data) {
|
|
15
|
+
if (typeof data === 'object' && data !== null && 'sab' in data && 'handle' in data) {
|
|
16
|
+
const sab = data.sab;
|
|
17
|
+
const log = 'log' in data && data.log === true;
|
|
18
|
+
if (sab instanceof SharedArrayBuffer)
|
|
19
|
+
return { handle: data.handle, sab, log };
|
|
20
|
+
}
|
|
21
|
+
throw new Error('python worker started without { handle, sab } thread data');
|
|
22
|
+
}
|
|
23
|
+
async function openBarePort() {
|
|
24
|
+
const { default: Channel } = await import('bare-channel');
|
|
25
|
+
const self = Bare.Thread.self;
|
|
26
|
+
if (!self)
|
|
27
|
+
throw new Error('python worker entry loaded on the main thread');
|
|
28
|
+
const { handle, sab, log } = narrowThreadData(self.data);
|
|
29
|
+
const port = Channel.from(handle).connect();
|
|
30
|
+
return {
|
|
31
|
+
port: {
|
|
32
|
+
read: () => port.read(),
|
|
33
|
+
write: (message) => void port.write(message),
|
|
34
|
+
close: () => void port.close()
|
|
35
|
+
},
|
|
36
|
+
handle,
|
|
37
|
+
sab,
|
|
38
|
+
log
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async function openNodePort() {
|
|
42
|
+
const { parentPort, workerData } = await import('worker_threads');
|
|
43
|
+
if (!parentPort)
|
|
44
|
+
throw new Error('python worker entry loaded on the main thread');
|
|
45
|
+
const data = narrowThreadData({ handle: parentPort, ...(workerData ?? {}) });
|
|
46
|
+
const queued = [];
|
|
47
|
+
const waiting = [];
|
|
48
|
+
parentPort.on('message', (value) => {
|
|
49
|
+
const next = waiting.shift();
|
|
50
|
+
if (next)
|
|
51
|
+
next(value);
|
|
52
|
+
else
|
|
53
|
+
queued.push(value);
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
port: {
|
|
57
|
+
read() {
|
|
58
|
+
if (queued.length > 0)
|
|
59
|
+
return Promise.resolve(queued.shift());
|
|
60
|
+
return new Promise((resolve) => waiting.push(resolve));
|
|
61
|
+
},
|
|
62
|
+
write: (message) => parentPort.postMessage(message),
|
|
63
|
+
close: () => parentPort.close()
|
|
64
|
+
},
|
|
65
|
+
...data
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async function loadInterpreter() {
|
|
69
|
+
const testLoader = process.env.QVAC_PYODIDE_TEST_LOADER;
|
|
70
|
+
if (!testLoader)
|
|
71
|
+
return defaultLoad;
|
|
72
|
+
const loaded = await import(__rewriteRelativeImportExtension(testLoader));
|
|
73
|
+
if (typeof loaded === 'object' &&
|
|
74
|
+
loaded !== null &&
|
|
75
|
+
'default' in loaded &&
|
|
76
|
+
typeof loaded.default === 'function') {
|
|
77
|
+
return loaded.default;
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`QVAC_PYODIDE_TEST_LOADER module has no default export: ${testLoader}`);
|
|
80
|
+
}
|
|
81
|
+
const { port, sab, log } = typeof globalThis.Bare !== 'undefined' ? await openBarePort() : await openNodePort();
|
|
82
|
+
setHarnessLog(log);
|
|
83
|
+
setHarnessLogSink((message) => port.write({ type: 'log', message }));
|
|
84
|
+
try {
|
|
85
|
+
const load = await loadInterpreter();
|
|
86
|
+
const py = await load();
|
|
87
|
+
py.setInterruptBuffer(new Uint8Array(sab));
|
|
88
|
+
port.write({ type: 'ready' });
|
|
89
|
+
for (;;) {
|
|
90
|
+
const message = asHostMessage(await port.read());
|
|
91
|
+
if (!message || message.type === 'close')
|
|
92
|
+
break;
|
|
93
|
+
const { result, evict } = await performRun(py, message.spec);
|
|
94
|
+
port.write({ type: 'result', id: message.id, result: toWireResult(result), evict });
|
|
95
|
+
if (evict)
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
101
|
+
port.write({ type: 'boot-error', message });
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
port.close();
|
|
105
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PythonRunResult, RunSpec } from '../run-session.ts';
|
|
2
|
+
export type HostMessage = {
|
|
3
|
+
readonly type: 'run';
|
|
4
|
+
readonly id: number;
|
|
5
|
+
readonly spec: RunSpec;
|
|
6
|
+
} | {
|
|
7
|
+
readonly type: 'close';
|
|
8
|
+
};
|
|
9
|
+
export type WireResult = {
|
|
10
|
+
readonly stdout: string;
|
|
11
|
+
readonly stderr: string;
|
|
12
|
+
readonly exitCode: number;
|
|
13
|
+
readonly files?: ReadonlyArray<readonly [string, Uint8Array]>;
|
|
14
|
+
readonly missing?: readonly string[];
|
|
15
|
+
readonly rejected?: readonly {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly reason: string;
|
|
18
|
+
}[];
|
|
19
|
+
readonly undeclared?: readonly string[];
|
|
20
|
+
};
|
|
21
|
+
export type WorkerMessage = {
|
|
22
|
+
readonly type: 'log';
|
|
23
|
+
readonly message: string;
|
|
24
|
+
} | {
|
|
25
|
+
readonly type: 'ready';
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: 'boot-error';
|
|
28
|
+
readonly message: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: 'result';
|
|
31
|
+
readonly id: number;
|
|
32
|
+
readonly result: WireResult;
|
|
33
|
+
readonly evict: boolean;
|
|
34
|
+
};
|
|
35
|
+
export declare function toWireResult(result: PythonRunResult): WireResult;
|
|
36
|
+
export declare function fromWireResult(wire: WireResult): PythonRunResult;
|
|
37
|
+
export declare function asHostMessage(value: unknown): HostMessage | null;
|
|
38
|
+
export declare function asWorkerMessage(value: unknown): WorkerMessage | null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export function toWireResult(result) {
|
|
2
|
+
return {
|
|
3
|
+
stdout: result.stdout,
|
|
4
|
+
stderr: result.stderr,
|
|
5
|
+
exitCode: result.exitCode,
|
|
6
|
+
files: result.files ? [...result.files.entries()] : undefined,
|
|
7
|
+
missing: result.missing,
|
|
8
|
+
rejected: result.rejected,
|
|
9
|
+
undeclared: result.undeclared
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function fromWireResult(wire) {
|
|
13
|
+
return {
|
|
14
|
+
stdout: wire.stdout,
|
|
15
|
+
stderr: wire.stderr,
|
|
16
|
+
exitCode: wire.exitCode,
|
|
17
|
+
files: wire.files ? new Map(wire.files) : undefined,
|
|
18
|
+
missing: wire.missing,
|
|
19
|
+
rejected: wire.rejected,
|
|
20
|
+
undeclared: wire.undeclared
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function messageType(value) {
|
|
24
|
+
if (typeof value !== 'object' || value === null)
|
|
25
|
+
return null;
|
|
26
|
+
const type = value.type;
|
|
27
|
+
return typeof type === 'string' ? type : null;
|
|
28
|
+
}
|
|
29
|
+
export function asHostMessage(value) {
|
|
30
|
+
const type = messageType(value);
|
|
31
|
+
if (type === 'run' || type === 'close')
|
|
32
|
+
return value;
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
export function asWorkerMessage(value) {
|
|
36
|
+
const type = messageType(value);
|
|
37
|
+
if (type === 'log' || type === 'ready' || type === 'boot-error' || type === 'result') {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Channel from 'bare-channel';
|
|
2
|
+
import safetyCatch from 'safety-catch';
|
|
3
|
+
export function spawnPythonWorker(entry, data) {
|
|
4
|
+
const channel = new Channel();
|
|
5
|
+
const thread = new Bare.Thread(entry, { data: { handle: channel.handle, ...data } });
|
|
6
|
+
const port = channel.connect();
|
|
7
|
+
return {
|
|
8
|
+
read: () => port.read().then((value) => {
|
|
9
|
+
if (value === null)
|
|
10
|
+
throw new Error('python worker channel closed');
|
|
11
|
+
return value;
|
|
12
|
+
}),
|
|
13
|
+
write: (message) => port.write(message),
|
|
14
|
+
kill() {
|
|
15
|
+
try {
|
|
16
|
+
thread.terminate();
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
safetyCatch(error);
|
|
20
|
+
}
|
|
21
|
+
port.close().catch(safetyCatch);
|
|
22
|
+
},
|
|
23
|
+
reap() {
|
|
24
|
+
port.close().catch(safetyCatch);
|
|
25
|
+
thread.join();
|
|
26
|
+
},
|
|
27
|
+
ref() { },
|
|
28
|
+
unref() { }
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type WorkerLink = {
|
|
2
|
+
read(): Promise<unknown>;
|
|
3
|
+
write(message: unknown): Promise<void>;
|
|
4
|
+
kill(): void;
|
|
5
|
+
reap(): void;
|
|
6
|
+
ref(): void;
|
|
7
|
+
unref(): void;
|
|
8
|
+
};
|
|
9
|
+
export type WorkerData = {
|
|
10
|
+
readonly sab: SharedArrayBuffer;
|
|
11
|
+
readonly log: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function spawnPythonWorker(entry: string, data: WorkerData): WorkerLink;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Worker } from 'worker_threads';
|
|
2
|
+
export function spawnPythonWorker(entry, data) {
|
|
3
|
+
const worker = new Worker(entry, {
|
|
4
|
+
workerData: data,
|
|
5
|
+
resourceLimits: { maxOldGenerationSizeMb: 512, maxYoungGenerationSizeMb: 64, stackSizeMb: 8 }
|
|
6
|
+
});
|
|
7
|
+
const queued = [];
|
|
8
|
+
const waiting = [];
|
|
9
|
+
let died = null;
|
|
10
|
+
const push = (value) => {
|
|
11
|
+
const next = waiting.shift();
|
|
12
|
+
if (next)
|
|
13
|
+
next.resolve(value);
|
|
14
|
+
else
|
|
15
|
+
queued.push(value);
|
|
16
|
+
};
|
|
17
|
+
const fail = (error) => {
|
|
18
|
+
if (died)
|
|
19
|
+
return;
|
|
20
|
+
died = error;
|
|
21
|
+
for (const pending of waiting.splice(0))
|
|
22
|
+
pending.reject(error);
|
|
23
|
+
};
|
|
24
|
+
worker.on('message', push);
|
|
25
|
+
worker.on('error', (error) => fail(error instanceof Error ? error : new Error(String(error))));
|
|
26
|
+
worker.on('exit', (code) => fail(new Error(`python worker exited with code ${code}`)));
|
|
27
|
+
worker.unref();
|
|
28
|
+
return {
|
|
29
|
+
read() {
|
|
30
|
+
if (queued.length > 0)
|
|
31
|
+
return Promise.resolve(queued.shift());
|
|
32
|
+
if (died)
|
|
33
|
+
return Promise.reject(died);
|
|
34
|
+
return new Promise((resolve, reject) => waiting.push({ resolve, reject }));
|
|
35
|
+
},
|
|
36
|
+
write(message) {
|
|
37
|
+
worker.postMessage(message);
|
|
38
|
+
return Promise.resolve();
|
|
39
|
+
},
|
|
40
|
+
kill: () => void worker.terminate(),
|
|
41
|
+
reap: () => void worker.terminate(),
|
|
42
|
+
ref: () => worker.ref(),
|
|
43
|
+
unref: () => worker.unref()
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type KillProcess, type SpawnFn } from '../../runner.ts';
|
|
2
|
+
import type { FallbackExecutionAdapter } from '../adapter.ts';
|
|
3
|
+
export type ShellRuntime = {
|
|
4
|
+
readonly spawn: SpawnFn;
|
|
5
|
+
readonly killProcess?: KillProcess;
|
|
6
|
+
};
|
|
7
|
+
export type ShellAdapterOptions = {
|
|
8
|
+
readonly spawn?: SpawnFn;
|
|
9
|
+
readonly killProcess?: KillProcess;
|
|
10
|
+
readonly loadRuntime: () => Promise<ShellRuntime>;
|
|
11
|
+
};
|
|
12
|
+
export declare function createShellAdapter(options: ShellAdapterOptions): FallbackExecutionAdapter;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { runCommand } from "../../runner.js";
|
|
2
|
+
export function createShellAdapter(options) {
|
|
3
|
+
return {
|
|
4
|
+
resolve(args) {
|
|
5
|
+
const command = String(args.command ?? '').trim();
|
|
6
|
+
return {
|
|
7
|
+
async run(execution) {
|
|
8
|
+
const runtime = options.spawn
|
|
9
|
+
? { spawn: options.spawn, killProcess: options.killProcess }
|
|
10
|
+
: await options.loadRuntime();
|
|
11
|
+
return runCommand(command, {
|
|
12
|
+
...execution,
|
|
13
|
+
spawn: runtime.spawn,
|
|
14
|
+
killProcess: runtime.killProcess
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
2
|
+
import { type ObsidianPathProbe } from '../../skills/obsidian-readiness.ts';
|
|
3
|
+
import type { KillProcess, SpawnFn } from '../runner.ts';
|
|
4
|
+
export declare function runningCheckCommand(os: string): string;
|
|
5
|
+
export declare function launchCommand(os: string): string;
|
|
6
|
+
export declare function obsidianPathEnv(platform?: NodeJS.Platform, env?: Record<string, string | undefined>, probe?: ObsidianPathProbe): Record<string, string> | undefined;
|
|
7
|
+
export declare function isObsidianRunning(spawn: SpawnFn, killProcess: KillProcess | undefined, signal?: BareAbortSignal, platform?: NodeJS.Platform): Promise<boolean>;
|
|
8
|
+
export declare function launchObsidianApp(spawn: SpawnFn, platform?: NodeJS.Platform): void;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import process from 'process';
|
|
4
|
+
import { execEnv } from "../../../helpers/spawn-path.js";
|
|
5
|
+
import { expandObsidianPath, firstExistingPath, OBSIDIAN_BIN_CANDIDATES } from "../../skills/obsidian-readiness.js";
|
|
6
|
+
const RUNNING_CHECK_MS = 3_000;
|
|
7
|
+
export function runningCheckCommand(os) {
|
|
8
|
+
if (os === 'win32') {
|
|
9
|
+
return 'tasklist /FI "IMAGENAME eq Obsidian.exe" /NH | find /I "Obsidian.exe"';
|
|
10
|
+
}
|
|
11
|
+
return 'pgrep -x Obsidian || pgrep -i obsidian';
|
|
12
|
+
}
|
|
13
|
+
export function launchCommand(os) {
|
|
14
|
+
if (os === 'darwin')
|
|
15
|
+
return 'open -a Obsidian';
|
|
16
|
+
if (os === 'win32')
|
|
17
|
+
return 'start "" obsidian';
|
|
18
|
+
return 'obsidian >/dev/null 2>&1 &';
|
|
19
|
+
}
|
|
20
|
+
export function obsidianPathEnv(platform = process.platform, env = process.env, probe = {}) {
|
|
21
|
+
const expand = probe.expand ?? ((candidate) => expandObsidianPath(candidate, env));
|
|
22
|
+
const exists = probe.exists ?? ((candidate) => fs.existsSync(candidate));
|
|
23
|
+
const bin = firstExistingPath(OBSIDIAN_BIN_CANDIDATES[platform] ?? [], expand, exists);
|
|
24
|
+
if (!bin)
|
|
25
|
+
return undefined;
|
|
26
|
+
const binDir = path.dirname(bin);
|
|
27
|
+
const scrubbed = execEnv(env, platform);
|
|
28
|
+
const prev = scrubbed.PATH ?? '';
|
|
29
|
+
return { ...scrubbed, PATH: prev ? `${binDir}${path.delimiter}${prev}` : binDir };
|
|
30
|
+
}
|
|
31
|
+
export function isObsidianRunning(spawn, killProcess, signal, platform = process.platform) {
|
|
32
|
+
return new Promise((resolve) => {
|
|
33
|
+
if (signal?.aborted) {
|
|
34
|
+
resolve(false);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const child = spawn(runningCheckCommand(platform), { shell: true });
|
|
38
|
+
let settled = false;
|
|
39
|
+
const finish = (running) => {
|
|
40
|
+
if (settled)
|
|
41
|
+
return;
|
|
42
|
+
settled = true;
|
|
43
|
+
globalThis.clearTimeout(timer);
|
|
44
|
+
signal?.removeEventListener('abort', onAbort);
|
|
45
|
+
try {
|
|
46
|
+
if (child.pid !== undefined && killProcess)
|
|
47
|
+
killProcess(-child.pid, 'SIGKILL');
|
|
48
|
+
else
|
|
49
|
+
child.kill('SIGKILL');
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
child.kill('SIGKILL');
|
|
53
|
+
}
|
|
54
|
+
resolve(running);
|
|
55
|
+
};
|
|
56
|
+
const timer = globalThis.setTimeout(() => finish(false), RUNNING_CHECK_MS);
|
|
57
|
+
const onAbort = () => finish(false);
|
|
58
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
59
|
+
child.on('exit', (code) => finish(code === 0));
|
|
60
|
+
child.on('error', () => finish(false));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export function launchObsidianApp(spawn, platform = process.platform) {
|
|
64
|
+
try {
|
|
65
|
+
const env = obsidianPathEnv(platform);
|
|
66
|
+
const child = spawn(launchCommand(platform), {
|
|
67
|
+
shell: true,
|
|
68
|
+
...(env ? { env } : {})
|
|
69
|
+
});
|
|
70
|
+
child.on('error', () => { });
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
2
|
+
import { type ExecResult, type KillProcess, type SpawnFn } from '../runner.ts';
|
|
3
|
+
export type RunObsidianCliOptions = {
|
|
4
|
+
readonly timeoutMs?: number;
|
|
5
|
+
readonly maxOutputChars?: number;
|
|
6
|
+
readonly signal?: BareAbortSignal;
|
|
7
|
+
};
|
|
8
|
+
export type RunOutcome = {
|
|
9
|
+
readonly result: string;
|
|
10
|
+
readonly stderr: string;
|
|
11
|
+
readonly exitCode: number | null;
|
|
12
|
+
};
|
|
13
|
+
export type ObsidianCliRuntime = {
|
|
14
|
+
readonly spawn: SpawnFn;
|
|
15
|
+
readonly killProcess?: KillProcess;
|
|
16
|
+
};
|
|
17
|
+
export declare function toResult(outcome: RunOutcome): ExecResult;
|
|
18
|
+
export declare function runObsidianCli(command: string, runtime: ObsidianCliRuntime, options?: RunObsidianCliOptions): Promise<ExecResult>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { appendOutput, capOutput, createCapturedOutput, MAX_OUTPUT_CHARS } from "../runner.js";
|
|
2
|
+
import { isObsidianRunning, launchObsidianApp, obsidianPathEnv } from "./cli-process.js";
|
|
3
|
+
import { OBSIDIAN_CLI_FAILURE_GUIDANCE } from "./guidance.js";
|
|
4
|
+
import { cleanObsidianOutput } from "./output.js";
|
|
5
|
+
const READY_WAIT_MS = 5_000;
|
|
6
|
+
const COMMAND_MS = 15_000;
|
|
7
|
+
const OUTPUT_QUIET_MS = 700;
|
|
8
|
+
function delay(ms, signal) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
if (signal?.aborted) {
|
|
11
|
+
resolve();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const onAbort = () => {
|
|
15
|
+
globalThis.clearTimeout(timer);
|
|
16
|
+
resolve();
|
|
17
|
+
};
|
|
18
|
+
const timer = globalThis.setTimeout(() => {
|
|
19
|
+
signal?.removeEventListener('abort', onAbort);
|
|
20
|
+
resolve();
|
|
21
|
+
}, ms);
|
|
22
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function failedResult(outcome, exitCode) {
|
|
26
|
+
const detail = [
|
|
27
|
+
outcome.result ? `stdout:\n${outcome.result}` : '',
|
|
28
|
+
outcome.stderr ? `stderr:\n${outcome.stderr}` : ''
|
|
29
|
+
]
|
|
30
|
+
.filter(Boolean)
|
|
31
|
+
.join('\n\n');
|
|
32
|
+
const body = detail ? `\n\n${detail}` : '';
|
|
33
|
+
return {
|
|
34
|
+
stdout: '',
|
|
35
|
+
stderr: `Obsidian command failed (exit code ${exitCode}).${body}\n\n${OBSIDIAN_CLI_FAILURE_GUIDANCE}`,
|
|
36
|
+
exitCode
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function toResult(outcome) {
|
|
40
|
+
if (outcome.exitCode !== null && outcome.exitCode !== 0) {
|
|
41
|
+
return failedResult(outcome, outcome.exitCode);
|
|
42
|
+
}
|
|
43
|
+
if (outcome.exitCode === null && outcome.stderr) {
|
|
44
|
+
return {
|
|
45
|
+
stdout: '',
|
|
46
|
+
stderr: `${outcome.stderr}\n\n${OBSIDIAN_CLI_FAILURE_GUIDANCE}`,
|
|
47
|
+
exitCode: 1
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (outcome.result) {
|
|
51
|
+
return { stdout: outcome.result, stderr: '', exitCode: 0 };
|
|
52
|
+
}
|
|
53
|
+
if (outcome.stderr) {
|
|
54
|
+
return {
|
|
55
|
+
stdout: '',
|
|
56
|
+
stderr: `${outcome.stderr}\n\n${OBSIDIAN_CLI_FAILURE_GUIDANCE}`,
|
|
57
|
+
exitCode: 1
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (outcome.exitCode === 0) {
|
|
61
|
+
return { stdout: '(no output)', stderr: '', exitCode: 0 };
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
stdout: '',
|
|
65
|
+
stderr: 'Obsidian did not respond. Make sure the Obsidian desktop app is open, then try again.\n\n' +
|
|
66
|
+
OBSIDIAN_CLI_FAILURE_GUIDANCE,
|
|
67
|
+
exitCode: 1
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function runOnce(command, runtime, timeoutMs, maxOutputChars, signal) {
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
if (signal?.aborted) {
|
|
73
|
+
resolve({ result: '', stderr: '', exitCode: null });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const env = obsidianPathEnv();
|
|
77
|
+
const child = runtime.spawn(command, {
|
|
78
|
+
shell: true,
|
|
79
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
80
|
+
...(env ? { env } : {})
|
|
81
|
+
});
|
|
82
|
+
const stdout = createCapturedOutput();
|
|
83
|
+
const stderr = createCapturedOutput();
|
|
84
|
+
let settled = false;
|
|
85
|
+
let quietTimer;
|
|
86
|
+
const finish = (exitCode) => {
|
|
87
|
+
if (settled)
|
|
88
|
+
return;
|
|
89
|
+
settled = true;
|
|
90
|
+
globalThis.clearTimeout(hardTimer);
|
|
91
|
+
globalThis.clearTimeout(quietTimer);
|
|
92
|
+
signal?.removeEventListener('abort', onAbort);
|
|
93
|
+
try {
|
|
94
|
+
if (child.pid !== undefined && runtime.killProcess) {
|
|
95
|
+
runtime.killProcess(-child.pid, 'SIGKILL');
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
child.kill('SIGKILL');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
child.kill('SIGKILL');
|
|
103
|
+
}
|
|
104
|
+
resolve({
|
|
105
|
+
result: capOutput(cleanObsidianOutput(stdout.value), maxOutputChars),
|
|
106
|
+
stderr: capOutput(cleanObsidianOutput(stderr.value), maxOutputChars),
|
|
107
|
+
exitCode
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const hardTimer = globalThis.setTimeout(() => finish(null), timeoutMs);
|
|
111
|
+
const onAbort = () => finish(null);
|
|
112
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
113
|
+
const bumpQuiet = () => {
|
|
114
|
+
globalThis.clearTimeout(quietTimer);
|
|
115
|
+
quietTimer = globalThis.setTimeout(() => finish(null), OUTPUT_QUIET_MS);
|
|
116
|
+
};
|
|
117
|
+
child.stdout?.on('data', (chunk) => {
|
|
118
|
+
appendOutput(stdout, chunk, maxOutputChars);
|
|
119
|
+
bumpQuiet();
|
|
120
|
+
});
|
|
121
|
+
child.stderr?.on('data', (chunk) => {
|
|
122
|
+
appendOutput(stderr, chunk, maxOutputChars);
|
|
123
|
+
bumpQuiet();
|
|
124
|
+
});
|
|
125
|
+
child.on('exit', (code) => finish(code));
|
|
126
|
+
child.on('error', () => finish(null));
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
export async function runObsidianCli(command, runtime, options = {}) {
|
|
130
|
+
const signal = options.signal;
|
|
131
|
+
const maxOutputChars = options.maxOutputChars ?? MAX_OUTPUT_CHARS;
|
|
132
|
+
const timeoutMs = options.timeoutMs ?? COMMAND_MS;
|
|
133
|
+
if (!(await isObsidianRunning(runtime.spawn, runtime.killProcess, signal))) {
|
|
134
|
+
if (signal?.aborted) {
|
|
135
|
+
return { stdout: '', stderr: 'Obsidian command aborted.', exitCode: 1 };
|
|
136
|
+
}
|
|
137
|
+
launchObsidianApp(runtime.spawn);
|
|
138
|
+
await delay(READY_WAIT_MS, signal);
|
|
139
|
+
}
|
|
140
|
+
if (signal?.aborted) {
|
|
141
|
+
return { stdout: '', stderr: 'Obsidian command aborted.', exitCode: 1 };
|
|
142
|
+
}
|
|
143
|
+
const outcome = await runOnce(command, runtime, timeoutMs, maxOutputChars, signal);
|
|
144
|
+
if (signal?.aborted) {
|
|
145
|
+
return { stdout: '', stderr: 'Obsidian command aborted.', exitCode: 1 };
|
|
146
|
+
}
|
|
147
|
+
const result = toResult(outcome);
|
|
148
|
+
return {
|
|
149
|
+
stdout: capOutput(result.stdout, maxOutputChars),
|
|
150
|
+
stderr: capOutput(result.stderr, maxOutputChars),
|
|
151
|
+
exitCode: result.exitCode
|
|
152
|
+
};
|
|
153
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { shellArgv } from "../shell-argv.js";
|
|
2
|
+
const OBSIDIAN_BIN = /^obsidian(?:\.exe|\.com)?$/i;
|
|
3
|
+
const OBSIDIAN_PREFIX = /^obsidian(?:\.exe|\.com)?(?:\s|$)/i;
|
|
4
|
+
export function parseObsidianCommand(command) {
|
|
5
|
+
const trimmed = command.trim();
|
|
6
|
+
if (!OBSIDIAN_PREFIX.test(trimmed))
|
|
7
|
+
return null;
|
|
8
|
+
const tokens = shellArgv(trimmed);
|
|
9
|
+
if (tokens.length === 0 || !OBSIDIAN_BIN.test(tokens[0] ?? ''))
|
|
10
|
+
return null;
|
|
11
|
+
if (tokens.length === 1)
|
|
12
|
+
return { action: '', args: [] };
|
|
13
|
+
const [, action, ...args] = tokens;
|
|
14
|
+
return { action: action ?? '', args };
|
|
15
|
+
}
|
|
16
|
+
export function normalizeObsidianCommand(command) {
|
|
17
|
+
return command.replace(/^(obsidian(?:\.exe|\.com)?)(\s+vault)\s+info(?=\s|$)/i, '$1$2');
|
|
18
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const OBSIDIAN_NO_SHELL_FALLBACK: string;
|
|
2
|
+
export declare const OBSIDIAN_CLI_FAILURE_GUIDANCE = "Do not use `ls`, `cat`, `find`, `grep`, or filesystem paths to inspect the vault or Obsidian config \u2014 that bypasses Obsidian and is wrong. Correct the obsidian command or ask the user to open Obsidian / register the CLI.";
|
|
3
|
+
export declare const OBSIDIAN_DESKTOP_AGENT_REQUIRED: string;
|
|
4
|
+
export declare const OBSIDIAN_VAULT_SETUP_REQUIRED: string;
|
|
5
|
+
export declare const OBSIDIAN_VAULT_MODE_NOTE: string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const OBSIDIAN_NO_SHELL_FALLBACK = 'Do not use `ls`, `cat`, `find`, `grep`, or filesystem paths to inspect the vault ' +
|
|
2
|
+
'or Obsidian config — that bypasses Obsidian and is wrong.';
|
|
3
|
+
export const OBSIDIAN_CLI_FAILURE_GUIDANCE = `${OBSIDIAN_NO_SHELL_FALLBACK} Correct the obsidian command or ask the user to open Obsidian / register the CLI.`;
|
|
4
|
+
export const OBSIDIAN_DESKTOP_AGENT_REQUIRED = 'Obsidian cannot run on this device. Switch the chat to the desktop agent that ' +
|
|
5
|
+
'has Obsidian connected (Skills → Obsidian on that desktop), then ask again. ' +
|
|
6
|
+
`${OBSIDIAN_NO_SHELL_FALLBACK} Do not retry the same command here.`;
|
|
7
|
+
export const OBSIDIAN_VAULT_SETUP_REQUIRED = 'Obsidian vault file mode is not set up. Under Snap/Flatpak the Obsidian CLI ' +
|
|
8
|
+
'cannot reach the desktop app, so this skill needs a vault folder: ask the user ' +
|
|
9
|
+
'to open Skills > Obsidian > Select vault folder, then retry the same `obsidian` ' +
|
|
10
|
+
`command. ${OBSIDIAN_NO_SHELL_FALLBACK} This is a one-time setup step, not a reason ` +
|
|
11
|
+
'to switch tools.';
|
|
12
|
+
export const OBSIDIAN_VAULT_MODE_NOTE = [
|
|
13
|
+
'Runtime note — Obsidian vault file mode is active (a vault folder is configured):',
|
|
14
|
+
'- Run vault commands through the `exec` tool, e.g. `obsidian vault info=path`, `obsidian search query="..."`, `obsidian read path="Folder/Note.md"`.',
|
|
15
|
+
'- Start with `obsidian vault info=path` to confirm the configured vault.',
|
|
16
|
+
'- `obsidian vaults` returns only the configured vault folder, not every vault in the Obsidian app.',
|
|
17
|
+
'- App-only actions (open in app, plugin/sync/theme commands) are unavailable in this mode; they require the official Obsidian CLI connected to the running app.'
|
|
18
|
+
].join('\n');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function markdownFileName(name: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cleanObsidianOutput(raw: string): string;
|