@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,29 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import Localdrive from 'localdrive';
|
|
3
|
+
import { defaultRealpath } from "./scope.js";
|
|
4
|
+
function withSkipList(localdrive) {
|
|
5
|
+
return {
|
|
6
|
+
entry: localdrive.entry.bind(localdrive),
|
|
7
|
+
get: localdrive.get.bind(localdrive),
|
|
8
|
+
list: (folder, opts) => localdrive.list(folder, {
|
|
9
|
+
ignore: (key) => key.split('/').some((segment) => opts?.skip?.has(segment))
|
|
10
|
+
}),
|
|
11
|
+
createReadStream: localdrive.createReadStream.bind(localdrive),
|
|
12
|
+
createWriteStream: localdrive.createWriteStream.bind(localdrive)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export async function createLocalRoots(dirs, realpath = defaultRealpath) {
|
|
16
|
+
const roots = [];
|
|
17
|
+
for (const dir of dirs) {
|
|
18
|
+
let canonical;
|
|
19
|
+
try {
|
|
20
|
+
canonical = await realpath(path.resolve(dir));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const localdrive = new Localdrive(canonical, { atomic: true });
|
|
26
|
+
roots.push({ kind: 'local', root: canonical, drive: withSkipList(localdrive) });
|
|
27
|
+
}
|
|
28
|
+
return roots;
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
2
|
+
const NEWLINE = 0x0a;
|
|
3
|
+
export async function* readLines(drive, key) {
|
|
4
|
+
let carry = null;
|
|
5
|
+
for await (const chunk of drive.createReadStream(key)) {
|
|
6
|
+
const buffer = carry === null ? chunk : b4a.concat([carry, chunk]);
|
|
7
|
+
let start = 0;
|
|
8
|
+
for (let index = 0; index < buffer.length; index++) {
|
|
9
|
+
if (buffer[index] !== NEWLINE)
|
|
10
|
+
continue;
|
|
11
|
+
yield b4a.toString(buffer.subarray(start, index), 'utf8');
|
|
12
|
+
start = index + 1;
|
|
13
|
+
}
|
|
14
|
+
carry = start === buffer.length ? null : buffer.subarray(start);
|
|
15
|
+
}
|
|
16
|
+
yield carry === null ? '' : b4a.toString(carry, 'utf8');
|
|
17
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { DriveEntry } from './drive.ts';
|
|
2
|
+
export type DriveEntryRequest = {
|
|
3
|
+
op: 'entry';
|
|
4
|
+
driveKey: string;
|
|
5
|
+
key: string;
|
|
6
|
+
};
|
|
7
|
+
export type DriveGetRequest = {
|
|
8
|
+
op: 'get';
|
|
9
|
+
driveKey: string;
|
|
10
|
+
key: string;
|
|
11
|
+
};
|
|
12
|
+
export type DriveReadRequest = {
|
|
13
|
+
op: 'read';
|
|
14
|
+
driveKey: string;
|
|
15
|
+
key: string;
|
|
16
|
+
};
|
|
17
|
+
export type DriveListRequest = {
|
|
18
|
+
op: 'list';
|
|
19
|
+
driveKey: string;
|
|
20
|
+
folder: string;
|
|
21
|
+
skip: string[];
|
|
22
|
+
limit: number;
|
|
23
|
+
cursor: string | null;
|
|
24
|
+
};
|
|
25
|
+
export type DriveWriteRequest = {
|
|
26
|
+
op: 'write';
|
|
27
|
+
driveKey: string;
|
|
28
|
+
key: string;
|
|
29
|
+
path: string;
|
|
30
|
+
executable?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export type DriveRequest = DriveEntryRequest | DriveGetRequest | DriveReadRequest | DriveListRequest | DriveWriteRequest;
|
|
33
|
+
export interface DriveResponse {
|
|
34
|
+
error?: string;
|
|
35
|
+
entry?: DriveEntry | null;
|
|
36
|
+
path?: string | null;
|
|
37
|
+
truncated?: boolean;
|
|
38
|
+
entries?: DriveEntry[];
|
|
39
|
+
cursor?: string | null;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DriveRequest, DriveResponse } from './remote-protocol.ts';
|
|
2
|
+
import type { HyperRoot } from './scope.ts';
|
|
3
|
+
export interface GrantedDrive {
|
|
4
|
+
readonly key: string;
|
|
5
|
+
readonly writable: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type DriveOpFn = (request: DriveRequest) => Promise<DriveResponse>;
|
|
8
|
+
export declare const DRIVE_CALL_TIMEOUT_MS = 20000;
|
|
9
|
+
export declare const MAX_DRIVE_BYTES: number;
|
|
10
|
+
export declare const DRIVE_LIST_PAGE = 256;
|
|
11
|
+
export declare class DriveReadTruncatedError extends Error {
|
|
12
|
+
constructor(key: string);
|
|
13
|
+
}
|
|
14
|
+
export declare function isDriveReadTruncated(err: unknown): err is DriveReadTruncatedError;
|
|
15
|
+
export declare function createRemoteRoots(drives: readonly GrantedDrive[], driveOp: DriveOpFn, opts?: {
|
|
16
|
+
readonly timeoutMs?: number;
|
|
17
|
+
}): HyperRoot[];
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { Writable } from 'streamx';
|
|
4
|
+
import { STAGING_DIR } from "../../staging.js";
|
|
5
|
+
export const DRIVE_CALL_TIMEOUT_MS = 20_000;
|
|
6
|
+
export const MAX_DRIVE_BYTES = 8 * 1024 * 1024;
|
|
7
|
+
export const DRIVE_LIST_PAGE = 256;
|
|
8
|
+
const noop = () => { };
|
|
9
|
+
export class DriveReadTruncatedError extends Error {
|
|
10
|
+
constructor(key) {
|
|
11
|
+
super(`read stopped at ${MAX_DRIVE_BYTES} bytes: ${key}`);
|
|
12
|
+
this.name = 'DriveReadTruncatedError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function isDriveReadTruncated(err) {
|
|
16
|
+
return err instanceof DriveReadTruncatedError;
|
|
17
|
+
}
|
|
18
|
+
function withTimeout(promise, ms, op) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const timer = setTimeout(() => reject(new Error(`drive ${op} timed out`)), ms);
|
|
21
|
+
promise.then((value) => {
|
|
22
|
+
clearTimeout(timer);
|
|
23
|
+
resolve(value);
|
|
24
|
+
}, (err) => {
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
reject(err);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async function call(driveOp, request, timeoutMs) {
|
|
31
|
+
const response = await withTimeout(driveOp(request), timeoutMs, request.op);
|
|
32
|
+
if (response.error)
|
|
33
|
+
throw new Error(response.error);
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
async function readStaged(stagedPath) {
|
|
37
|
+
try {
|
|
38
|
+
return await fs.promises.readFile(stagedPath);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
await fs.promises.unlink(stagedPath).catch(noop);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function stagedWritePath() {
|
|
45
|
+
fs.mkdirSync(STAGING_DIR, { recursive: true, mode: 0o700 });
|
|
46
|
+
const unique = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
47
|
+
return path.join(STAGING_DIR, `drive-write-${unique}`);
|
|
48
|
+
}
|
|
49
|
+
function remoteDrive(driveKey, driveOp, timeoutMs) {
|
|
50
|
+
return {
|
|
51
|
+
async entry(entryKey) {
|
|
52
|
+
const response = await call(driveOp, { op: 'entry', driveKey, key: entryKey }, timeoutMs);
|
|
53
|
+
return response.entry ?? null;
|
|
54
|
+
},
|
|
55
|
+
async get(getKey) {
|
|
56
|
+
const response = await call(driveOp, { op: 'get', driveKey, key: getKey }, timeoutMs);
|
|
57
|
+
if (!response.path)
|
|
58
|
+
return null;
|
|
59
|
+
return readStaged(response.path);
|
|
60
|
+
},
|
|
61
|
+
async *list(folder = '/', opts) {
|
|
62
|
+
const skip = [...(opts?.skip ?? [])];
|
|
63
|
+
let cursor = null;
|
|
64
|
+
while (true) {
|
|
65
|
+
const response = await call(driveOp, { op: 'list', driveKey, folder, skip, limit: DRIVE_LIST_PAGE, cursor }, timeoutMs);
|
|
66
|
+
const entries = response.entries ?? [];
|
|
67
|
+
for (const entry of entries)
|
|
68
|
+
yield entry;
|
|
69
|
+
if (!response.cursor || entries.length === 0)
|
|
70
|
+
return;
|
|
71
|
+
cursor = response.cursor;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
async *createReadStream(readKey) {
|
|
75
|
+
const response = await call(driveOp, { op: 'read', driveKey, key: readKey }, timeoutMs);
|
|
76
|
+
if (!response.path)
|
|
77
|
+
return;
|
|
78
|
+
try {
|
|
79
|
+
yield* fs.createReadStream(response.path);
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
await fs.promises.unlink(response.path).catch(noop);
|
|
83
|
+
}
|
|
84
|
+
if (response.truncated)
|
|
85
|
+
throw new DriveReadTruncatedError(readKey);
|
|
86
|
+
},
|
|
87
|
+
createWriteStream(writeKey, writeOpts) {
|
|
88
|
+
const stagedPath = stagedWritePath();
|
|
89
|
+
const sink = fs.createWriteStream(stagedPath, { mode: 0o600 });
|
|
90
|
+
let sinkError = null;
|
|
91
|
+
sink.on('error', (err) => {
|
|
92
|
+
sinkError = err;
|
|
93
|
+
});
|
|
94
|
+
return new Writable({
|
|
95
|
+
write(data, cb) {
|
|
96
|
+
sink.write(data, (err) => cb(err ?? null));
|
|
97
|
+
},
|
|
98
|
+
final(cb) {
|
|
99
|
+
sink.end();
|
|
100
|
+
sink.on('close', () => {
|
|
101
|
+
if (sinkError) {
|
|
102
|
+
fs.promises.unlink(stagedPath).catch(noop);
|
|
103
|
+
cb(sinkError);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
call(driveOp, {
|
|
107
|
+
op: 'write',
|
|
108
|
+
driveKey,
|
|
109
|
+
key: writeKey,
|
|
110
|
+
path: stagedPath,
|
|
111
|
+
...(writeOpts?.executable ? { executable: true } : {})
|
|
112
|
+
}, timeoutMs).then(() => cb(null), (err) => {
|
|
113
|
+
fs.promises.unlink(stagedPath).catch(noop);
|
|
114
|
+
cb(err);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export function createRemoteRoots(drives, driveOp, opts = {}) {
|
|
123
|
+
const timeoutMs = opts.timeoutMs ?? DRIVE_CALL_TIMEOUT_MS;
|
|
124
|
+
return drives.map((drive) => ({
|
|
125
|
+
kind: 'hyper',
|
|
126
|
+
key: drive.key,
|
|
127
|
+
writable: drive.writable,
|
|
128
|
+
prefix: '/',
|
|
129
|
+
drive: remoteDrive(drive.key, driveOp, timeoutMs)
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Drive } from './drive.ts';
|
|
2
|
+
export type Realpath = (p: string) => Promise<string>;
|
|
3
|
+
export declare const defaultRealpath: Realpath;
|
|
4
|
+
export interface LocalRoot {
|
|
5
|
+
readonly kind: 'local';
|
|
6
|
+
readonly root: string;
|
|
7
|
+
readonly drive: Drive;
|
|
8
|
+
}
|
|
9
|
+
export interface HyperRoot {
|
|
10
|
+
readonly kind: 'hyper';
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly writable: boolean;
|
|
13
|
+
readonly prefix: string;
|
|
14
|
+
readonly drive: Drive;
|
|
15
|
+
}
|
|
16
|
+
export type DriveRoot = LocalRoot | HyperRoot;
|
|
17
|
+
export interface FsToolOptions {
|
|
18
|
+
readonly realpath?: Realpath;
|
|
19
|
+
readonly deniedRoots?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
export declare const NO_DIRS_GRANTED = "no directories are granted";
|
|
22
|
+
export declare const NO_STORAGE_ROOT = "cannot fence the app storage root: the SDK home is unknown";
|
|
23
|
+
export declare function deniedRootsFor(sdkHome: string | undefined): readonly string[];
|
|
24
|
+
export declare const PROTECTED_PATH_ERROR = "path is inside a protected app directory";
|
|
25
|
+
export declare function canonicalDenyRoots(deniedRoots: readonly string[] | undefined, realpath: Realpath): Promise<readonly string[]>;
|
|
26
|
+
export declare function isDeniedPath(hostPath: string, canonicalDenyRoots: readonly string[]): boolean;
|
|
27
|
+
export declare function hostPath(root: LocalRoot, key: string): string;
|
|
28
|
+
export declare function displayPath(root: DriveRoot, key: string): string;
|
|
29
|
+
export declare function normalizeDriveKey(prefix: string, input: string): string | null;
|
|
30
|
+
export interface ResolvedKey {
|
|
31
|
+
root: DriveRoot;
|
|
32
|
+
key: string;
|
|
33
|
+
exists: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function resolveKey(p: string, roots: readonly DriveRoot[], realpath: Realpath, deny?: readonly string[]): Promise<ResolvedKey | {
|
|
36
|
+
error: string;
|
|
37
|
+
}>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import process from 'process';
|
|
4
|
+
export const defaultRealpath = (p) => fs.promises.realpath(p);
|
|
5
|
+
export const NO_DIRS_GRANTED = 'no directories are granted';
|
|
6
|
+
const HYPER_PREFIX = 'hyper://';
|
|
7
|
+
function rootLabel(root) {
|
|
8
|
+
return root.kind === 'local' ? root.root : `${HYPER_PREFIX}${root.key}`;
|
|
9
|
+
}
|
|
10
|
+
function outside(roots) {
|
|
11
|
+
return { error: `path must be inside one of: ${roots.map(rootLabel).join(', ')}` };
|
|
12
|
+
}
|
|
13
|
+
export const NO_STORAGE_ROOT = 'cannot fence the app storage root: the SDK home is unknown';
|
|
14
|
+
export function deniedRootsFor(sdkHome) {
|
|
15
|
+
if (!sdkHome)
|
|
16
|
+
throw new Error(NO_STORAGE_ROOT);
|
|
17
|
+
return [path.dirname(sdkHome)];
|
|
18
|
+
}
|
|
19
|
+
export const PROTECTED_PATH_ERROR = 'path is inside a protected app directory';
|
|
20
|
+
function protectedPath() {
|
|
21
|
+
return { error: PROTECTED_PATH_ERROR };
|
|
22
|
+
}
|
|
23
|
+
export async function canonicalDenyRoots(deniedRoots, realpath) {
|
|
24
|
+
if (!deniedRoots?.length)
|
|
25
|
+
return [];
|
|
26
|
+
return Promise.all(deniedRoots.map(async (raw) => {
|
|
27
|
+
try {
|
|
28
|
+
return await realpath(raw);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return path.resolve(raw);
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
export function isDeniedPath(hostPath, canonicalDenyRoots) {
|
|
36
|
+
return canonicalDenyRoots.some((root) => contained(hostPath, root, true));
|
|
37
|
+
}
|
|
38
|
+
const FOLD_CASE = process.platform === 'darwin' || process.platform === 'win32';
|
|
39
|
+
function within(candidate, root) {
|
|
40
|
+
return contained(candidate, root, FOLD_CASE);
|
|
41
|
+
}
|
|
42
|
+
function contained(candidate, root, ignoreCase) {
|
|
43
|
+
const a = ignoreCase ? candidate.toLowerCase() : candidate;
|
|
44
|
+
const b = ignoreCase ? root.toLowerCase() : root;
|
|
45
|
+
return a === b || a.startsWith(b + path.sep);
|
|
46
|
+
}
|
|
47
|
+
function withinPrefix(candidate, prefix) {
|
|
48
|
+
if (prefix === '/')
|
|
49
|
+
return true;
|
|
50
|
+
return candidate === prefix || candidate.startsWith(prefix + '/');
|
|
51
|
+
}
|
|
52
|
+
function toKey(root, canonical) {
|
|
53
|
+
const rel = path.relative(root.root, canonical);
|
|
54
|
+
return rel ? `/${rel.split(path.sep).join('/')}` : '/';
|
|
55
|
+
}
|
|
56
|
+
export function hostPath(root, key) {
|
|
57
|
+
return path.join(root.root, ...key.split('/').filter(Boolean));
|
|
58
|
+
}
|
|
59
|
+
export function displayPath(root, key) {
|
|
60
|
+
return root.kind === 'local' ? hostPath(root, key) : `${HYPER_PREFIX}${root.key}${key}`;
|
|
61
|
+
}
|
|
62
|
+
const CONTROL_OR_NUL = /[\x00-\x1f]/;
|
|
63
|
+
const WINDOWS_DRIVE_LETTER = /^[A-Za-z]:/;
|
|
64
|
+
export function normalizeDriveKey(prefix, input) {
|
|
65
|
+
if (input.includes('\\'))
|
|
66
|
+
return null;
|
|
67
|
+
if (WINDOWS_DRIVE_LETTER.test(input))
|
|
68
|
+
return null;
|
|
69
|
+
if (CONTROL_OR_NUL.test(input))
|
|
70
|
+
return null;
|
|
71
|
+
if (input.includes('://'))
|
|
72
|
+
return null;
|
|
73
|
+
const segments = [];
|
|
74
|
+
for (const segment of input.split('/')) {
|
|
75
|
+
if (segment === '' || segment === '.')
|
|
76
|
+
continue;
|
|
77
|
+
if (segment === '..') {
|
|
78
|
+
if (segments.length === 0)
|
|
79
|
+
return null;
|
|
80
|
+
segments.pop();
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
segments.push(segment);
|
|
84
|
+
}
|
|
85
|
+
const normalized = segments.length ? `/${segments.join('/')}` : '/';
|
|
86
|
+
return withinPrefix(normalized, prefix) ? normalized : null;
|
|
87
|
+
}
|
|
88
|
+
function matchHyperRoot(rest, roots) {
|
|
89
|
+
return roots.find((r) => rest === r.key || rest.startsWith(r.key + '/'));
|
|
90
|
+
}
|
|
91
|
+
export async function resolveKey(p, roots, realpath, deny = []) {
|
|
92
|
+
if (roots.length === 0)
|
|
93
|
+
return { error: NO_DIRS_GRANTED };
|
|
94
|
+
if (p.startsWith(HYPER_PREFIX)) {
|
|
95
|
+
const rest = p.slice(HYPER_PREFIX.length);
|
|
96
|
+
const hyperRoots = roots.filter((r) => r.kind === 'hyper');
|
|
97
|
+
const root = matchHyperRoot(rest, hyperRoots);
|
|
98
|
+
if (!root)
|
|
99
|
+
return outside(roots);
|
|
100
|
+
const tail = rest.slice(root.key.length);
|
|
101
|
+
const key = normalizeDriveKey(root.prefix, tail || '/');
|
|
102
|
+
if (key === null)
|
|
103
|
+
return outside(roots);
|
|
104
|
+
return { root, key, exists: true };
|
|
105
|
+
}
|
|
106
|
+
const localRoots = roots.filter((r) => r.kind === 'local');
|
|
107
|
+
let ancestor = path.resolve(p);
|
|
108
|
+
const tail = [];
|
|
109
|
+
while (true) {
|
|
110
|
+
try {
|
|
111
|
+
const canonical = await realpath(ancestor);
|
|
112
|
+
const target = tail.length ? path.join(canonical, ...tail) : canonical;
|
|
113
|
+
const root = localRoots.find((r) => within(target, r.root));
|
|
114
|
+
if (!root)
|
|
115
|
+
return outside(roots);
|
|
116
|
+
if (isDeniedPath(target, deny)) {
|
|
117
|
+
return protectedPath();
|
|
118
|
+
}
|
|
119
|
+
return { root, key: toKey(root, target), exists: tail.length === 0 };
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
const parent = path.dirname(ancestor);
|
|
123
|
+
if (parent === ancestor)
|
|
124
|
+
break;
|
|
125
|
+
tail.unshift(path.basename(ancestor));
|
|
126
|
+
ancestor = parent;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return outside(roots);
|
|
130
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type DriveRoot } from './scope.ts';
|
|
2
|
+
export declare const WALK_SKIP_DIRS: Set<string>;
|
|
3
|
+
export declare const MAX_WALK_ENTRIES = 10000;
|
|
4
|
+
export declare const MAX_WALK_MS = 30000;
|
|
5
|
+
export interface WalkedFile {
|
|
6
|
+
path: string;
|
|
7
|
+
key: string;
|
|
8
|
+
byteLength: number;
|
|
9
|
+
}
|
|
10
|
+
export interface WalkResult {
|
|
11
|
+
files: WalkedFile[];
|
|
12
|
+
truncated: boolean;
|
|
13
|
+
skippedLinks: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function walkFiles(root: DriveRoot, folder?: string): Promise<WalkResult>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { hlog } from "../../log.js";
|
|
2
|
+
import { displayPath } from "./scope.js";
|
|
3
|
+
export const WALK_SKIP_DIRS = new Set(['.git', 'node_modules']);
|
|
4
|
+
export const MAX_WALK_ENTRIES = 10_000;
|
|
5
|
+
export const MAX_WALK_MS = 30_000;
|
|
6
|
+
export async function walkFiles(root, folder = '/') {
|
|
7
|
+
const files = [];
|
|
8
|
+
let visited = 0;
|
|
9
|
+
let skippedLinks = 0;
|
|
10
|
+
const deadline = Date.now() + MAX_WALK_MS;
|
|
11
|
+
try {
|
|
12
|
+
for await (const entry of root.drive.list(folder, { skip: WALK_SKIP_DIRS })) {
|
|
13
|
+
if (++visited > MAX_WALK_ENTRIES)
|
|
14
|
+
return { files, truncated: true, skippedLinks };
|
|
15
|
+
if (Date.now() > deadline)
|
|
16
|
+
return { files, truncated: true, skippedLinks };
|
|
17
|
+
if (entry.value.linkname !== null) {
|
|
18
|
+
skippedLinks++;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
files.push({
|
|
22
|
+
path: displayPath(root, entry.key),
|
|
23
|
+
key: entry.key,
|
|
24
|
+
byteLength: entry.value.blob?.byteLength ?? 0
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
hlog('warn: walk aborted mid-listing', {
|
|
30
|
+
root: displayPath(root, '/'),
|
|
31
|
+
folder,
|
|
32
|
+
visited,
|
|
33
|
+
err: err.message
|
|
34
|
+
});
|
|
35
|
+
return { files, truncated: true, skippedLinks };
|
|
36
|
+
}
|
|
37
|
+
return { files, truncated: false, skippedLinks };
|
|
38
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
2
|
+
import type { ToolDefinition } from '../capabilities/completion.ts';
|
|
3
|
+
import type { ModelSrc } from '../models/context.ts';
|
|
4
|
+
import { type ImageClamps } from '../models/model-catalog.ts';
|
|
5
|
+
import { type LoadTracker, type TrackedLoad } from '../models/model-pool.ts';
|
|
6
|
+
import { type ModelRegistrySdk } from '../models/model-source.ts';
|
|
7
|
+
export declare const MAX_DIM = 1024;
|
|
8
|
+
export declare const DIM_STEP = 64;
|
|
9
|
+
export declare const MAX_STEPS = 100;
|
|
10
|
+
export interface DiffusionTick {
|
|
11
|
+
step: number;
|
|
12
|
+
totalSteps: number;
|
|
13
|
+
elapsedMs: number;
|
|
14
|
+
}
|
|
15
|
+
interface DiffusionRun {
|
|
16
|
+
progressStream: AsyncGenerator<DiffusionTick>;
|
|
17
|
+
outputs: Promise<Uint8Array[]>;
|
|
18
|
+
stats: Promise<unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface DiffusionParams {
|
|
21
|
+
prompt: string;
|
|
22
|
+
vae_tiling?: boolean;
|
|
23
|
+
width?: number;
|
|
24
|
+
height?: number;
|
|
25
|
+
steps?: number;
|
|
26
|
+
seed?: number;
|
|
27
|
+
negative_prompt?: string;
|
|
28
|
+
init_image?: Uint8Array;
|
|
29
|
+
init_images?: Uint8Array[];
|
|
30
|
+
auto_resize_ref_image?: boolean;
|
|
31
|
+
strength?: number;
|
|
32
|
+
guidance?: number;
|
|
33
|
+
cfg_scale?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface DiffusionModelConfig {
|
|
36
|
+
prediction?: 'flux2_flow';
|
|
37
|
+
llmModelSrc?: ModelSrc;
|
|
38
|
+
vaeModelSrc?: ModelSrc;
|
|
39
|
+
}
|
|
40
|
+
export type DiffusionSdk = ModelRegistrySdk & {
|
|
41
|
+
loadModel(params: {
|
|
42
|
+
modelSrc: ModelSrc;
|
|
43
|
+
modelType: 'diffusion';
|
|
44
|
+
modelConfig?: DiffusionModelConfig;
|
|
45
|
+
onProgress?: (progress: Record<string, unknown>) => void;
|
|
46
|
+
}): TrackedLoad;
|
|
47
|
+
unloadModel(params: {
|
|
48
|
+
modelId: string;
|
|
49
|
+
}): Promise<unknown>;
|
|
50
|
+
diffusion(params: DiffusionParams & {
|
|
51
|
+
modelId: string;
|
|
52
|
+
}): DiffusionRun;
|
|
53
|
+
cancel?(params: {
|
|
54
|
+
operation: 'inference';
|
|
55
|
+
modelId: string;
|
|
56
|
+
} | {
|
|
57
|
+
requestId: string;
|
|
58
|
+
}): Promise<void>;
|
|
59
|
+
};
|
|
60
|
+
export interface ImageModelSet {
|
|
61
|
+
model: string;
|
|
62
|
+
llmModel?: string;
|
|
63
|
+
vaeModel?: string;
|
|
64
|
+
prediction?: 'flux2_flow';
|
|
65
|
+
}
|
|
66
|
+
export declare const IMAGE_LOAD_STALL_MS: number;
|
|
67
|
+
export interface DiffusionRuntimeOptions extends ImageModelSet {
|
|
68
|
+
loadSdk: () => Promise<DiffusionSdk>;
|
|
69
|
+
onProgress?: (model: string, progress: Record<string, unknown>) => void;
|
|
70
|
+
onBeforeLoad?: (signal?: BareAbortSignal) => Promise<void>;
|
|
71
|
+
loads?: LoadTracker;
|
|
72
|
+
stallMs?: number;
|
|
73
|
+
}
|
|
74
|
+
export interface LoadedDiffusionModel {
|
|
75
|
+
modelId: string;
|
|
76
|
+
prediction?: 'flux2_flow';
|
|
77
|
+
}
|
|
78
|
+
export interface DiffusionRuntime {
|
|
79
|
+
loadSdk: () => Promise<DiffusionSdk>;
|
|
80
|
+
ensureLoaded: (sdk: DiffusionSdk, signal?: BareAbortSignal, modelChoice?: string) => Promise<LoadedDiffusionModel>;
|
|
81
|
+
predictionFor(modelChoice?: string): 'flux2_flow' | undefined;
|
|
82
|
+
unload(): Promise<void>;
|
|
83
|
+
unloadIdle(): Promise<void>;
|
|
84
|
+
acquire(): boolean;
|
|
85
|
+
release(): void;
|
|
86
|
+
}
|
|
87
|
+
export declare function generationPercentTick(onPercent: (percentage: number) => void, encodePhases?: number): (tick: DiffusionTick) => void;
|
|
88
|
+
export declare const IMAGE_LOAD_STALL_ERROR = "image model download stalled";
|
|
89
|
+
export declare function createDiffusionRuntime({ loadSdk, onProgress, onBeforeLoad, loads, stallMs, ...base }: DiffusionRuntimeOptions): DiffusionRuntime;
|
|
90
|
+
export declare const BUSY_ERROR = "an image generation is already running; try again when it finishes";
|
|
91
|
+
export declare function runDiffusion(sdk: DiffusionSdk, modelId: string, params: DiffusionParams, signal?: BareAbortSignal, onTick?: (tick: DiffusionTick) => void): Promise<Uint8Array | {
|
|
92
|
+
error: string;
|
|
93
|
+
}>;
|
|
94
|
+
export interface CommonImageArgs {
|
|
95
|
+
prompt: string;
|
|
96
|
+
steps?: number;
|
|
97
|
+
seed?: number;
|
|
98
|
+
negativePrompt?: string;
|
|
99
|
+
}
|
|
100
|
+
export declare function parseCommonArgs(args: Record<string, unknown>, maxSteps?: number): CommonImageArgs | {
|
|
101
|
+
error: string;
|
|
102
|
+
};
|
|
103
|
+
export declare function normalizeClamps(clamps?: ImageClamps): {
|
|
104
|
+
maxDim: number;
|
|
105
|
+
maxSteps: number;
|
|
106
|
+
};
|
|
107
|
+
export declare function settingsDimension(value: number | undefined, maxDim?: number): number | undefined;
|
|
108
|
+
export declare function settingsSteps(value: number | undefined, maxSteps?: number): number | undefined;
|
|
109
|
+
export declare function effectiveSteps(parsedSteps: number | undefined, settingsValue: number | undefined, stepsCap: number | undefined): number | undefined;
|
|
110
|
+
export declare function createGenerateImageTool(runtime: DiffusionRuntime, clamps?: ImageClamps): ToolDefinition;
|
|
111
|
+
export {};
|