@qvac/harness 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/harness.bundle +8 -59
- package/dist/prebuilds-manifest.json +0 -8
- package/dist-lib/index.d.ts +240 -0
- package/dist-lib/index.js +1063 -0
- package/dist-lib/lib/audio-transcode-bare.d.ts +2 -0
- package/dist-lib/lib/audio-transcode-bare.js +145 -0
- package/dist-lib/lib/audio-transcode-node.d.ts +2 -0
- package/dist-lib/lib/audio-transcode-node.js +6 -0
- package/dist-lib/lib/capabilities/audio-resample.d.ts +14 -0
- package/dist-lib/lib/capabilities/audio-resample.js +72 -0
- package/dist-lib/lib/capabilities/completion.d.ts +288 -0
- package/dist-lib/lib/capabilities/completion.js +1077 -0
- package/dist-lib/lib/capabilities/download.d.ts +46 -0
- package/dist-lib/lib/capabilities/download.js +124 -0
- package/dist-lib/lib/capabilities/embed.d.ts +20 -0
- package/dist-lib/lib/capabilities/embed.js +13 -0
- package/dist-lib/lib/capabilities/kv-cache.d.ts +13 -0
- package/dist-lib/lib/capabilities/kv-cache.js +21 -0
- package/dist-lib/lib/capabilities/prompt-prefix.d.ts +6 -0
- package/dist-lib/lib/capabilities/prompt-prefix.js +10 -0
- package/dist-lib/lib/capabilities/speech-lexicon.d.ts +5 -0
- package/dist-lib/lib/capabilities/speech-lexicon.js +32 -0
- package/dist-lib/lib/capabilities/speech-text.d.ts +6 -0
- package/dist-lib/lib/capabilities/speech-text.js +79 -0
- package/dist-lib/lib/capabilities/tool-names.d.ts +3 -0
- package/dist-lib/lib/capabilities/tool-names.js +3 -0
- package/dist-lib/lib/capabilities/tool-selection.d.ts +43 -0
- package/dist-lib/lib/capabilities/tool-selection.js +60 -0
- package/dist-lib/lib/capabilities/tool-turns.d.ts +9 -0
- package/dist-lib/lib/capabilities/tool-turns.js +101 -0
- package/dist-lib/lib/capabilities/usage-breakdown.d.ts +27 -0
- package/dist-lib/lib/capabilities/usage-breakdown.js +44 -0
- package/dist-lib/lib/capabilities/vision-history.d.ts +3 -0
- package/dist-lib/lib/capabilities/vision-history.js +21 -0
- package/dist-lib/lib/capabilities/voice.d.ts +78 -0
- package/dist-lib/lib/capabilities/voice.js +189 -0
- package/dist-lib/lib/connect.d.ts +76 -0
- package/dist-lib/lib/connect.js +789 -0
- package/dist-lib/lib/context-window.d.ts +7 -0
- package/dist-lib/lib/context-window.js +90 -0
- package/dist-lib/lib/contract-types.d.ts +210 -0
- package/dist-lib/lib/contract-types.js +1 -0
- package/dist-lib/lib/diagram-repair.d.ts +21 -0
- package/dist-lib/lib/diagram-repair.js +58 -0
- package/dist-lib/lib/dns-lookup.d.ts +1 -0
- package/dist-lib/lib/dns-lookup.js +13 -0
- package/dist-lib/lib/error-fields.d.ts +2 -0
- package/dist-lib/lib/error-fields.js +8 -0
- package/dist-lib/lib/fetch-node.d.ts +1 -0
- package/dist-lib/lib/fetch-node.js +1 -0
- package/dist-lib/lib/hardware/capability-probe.d.ts +9 -0
- package/dist-lib/lib/hardware/capability-probe.js +99 -0
- package/dist-lib/lib/hardware/gpu-classify.d.ts +2 -0
- package/dist-lib/lib/hardware/gpu-classify.js +32 -0
- package/dist-lib/lib/hardware/gpu-probe-addon.d.ts +2 -0
- package/dist-lib/lib/hardware/gpu-probe-addon.js +42 -0
- package/dist-lib/lib/hardware/gpu-stats.bare.d.ts +1 -0
- package/dist-lib/lib/hardware/gpu-stats.bare.js +24 -0
- package/dist-lib/lib/hardware/gpu-stats.stub.d.ts +1 -0
- package/dist-lib/lib/hardware/gpu-stats.stub.js +3 -0
- package/dist-lib/lib/hardware/memory-budget.d.ts +8 -0
- package/dist-lib/lib/hardware/memory-budget.js +1 -0
- package/dist-lib/lib/hardware/parsers.d.ts +7 -0
- package/dist-lib/lib/hardware/parsers.js +41 -0
- package/dist-lib/lib/headers-bare.d.ts +1 -0
- package/dist-lib/lib/headers-bare.js +1 -0
- package/dist-lib/lib/headers-node.d.ts +4 -0
- package/dist-lib/lib/headers-node.js +1 -0
- package/dist-lib/lib/helpers/buffer-burst.d.ts +1 -0
- package/dist-lib/lib/helpers/buffer-burst.js +20 -0
- package/dist-lib/lib/helpers/control-tokens.d.ts +7 -0
- package/dist-lib/lib/helpers/control-tokens.js +32 -0
- package/dist-lib/lib/helpers/join-guard.d.ts +6 -0
- package/dist-lib/lib/helpers/join-guard.js +46 -0
- package/dist-lib/lib/helpers/markup-stream-filter.d.ts +5 -0
- package/dist-lib/lib/helpers/markup-stream-filter.js +75 -0
- package/dist-lib/lib/helpers/race-abort.d.ts +5 -0
- package/dist-lib/lib/helpers/race-abort.js +18 -0
- package/dist-lib/lib/helpers/retry-memo.d.ts +5 -0
- package/dist-lib/lib/helpers/retry-memo.js +12 -0
- package/dist-lib/lib/helpers/run-outcome.d.ts +33 -0
- package/dist-lib/lib/helpers/run-outcome.js +204 -0
- package/dist-lib/lib/helpers/spawn-path.d.ts +5 -0
- package/dist-lib/lib/helpers/spawn-path.js +57 -0
- package/dist-lib/lib/helpers/text-coalescer.d.ts +15 -0
- package/dist-lib/lib/helpers/text-coalescer.js +34 -0
- package/dist-lib/lib/helpers/thinking.d.ts +8 -0
- package/dist-lib/lib/helpers/thinking.js +95 -0
- package/dist-lib/lib/helpers/tool-call-markup.d.ts +20 -0
- package/dist-lib/lib/helpers/tool-call-markup.js +201 -0
- package/dist-lib/lib/helpers/tool-intent.d.ts +7 -0
- package/dist-lib/lib/helpers/tool-intent.js +21 -0
- package/dist-lib/lib/helpers/tool-label.d.ts +8 -0
- package/dist-lib/lib/helpers/tool-label.js +131 -0
- package/dist-lib/lib/hooks/built-in/arg-repair.d.ts +5 -0
- package/dist-lib/lib/hooks/built-in/arg-repair.js +88 -0
- package/dist-lib/lib/hooks/built-in/egress.d.ts +5 -0
- package/dist-lib/lib/hooks/built-in/egress.js +29 -0
- package/dist-lib/lib/hooks/built-in/index.d.ts +3 -0
- package/dist-lib/lib/hooks/built-in/index.js +3 -0
- package/dist-lib/lib/hooks/built-in/skill-catalog.d.ts +10 -0
- package/dist-lib/lib/hooks/built-in/skill-catalog.js +17 -0
- package/dist-lib/lib/hooks/pipeline.d.ts +20 -0
- package/dist-lib/lib/hooks/pipeline.js +49 -0
- package/dist-lib/lib/hooks/registry.d.ts +2 -0
- package/dist-lib/lib/hooks/registry.js +6 -0
- package/dist-lib/lib/hooks/run.d.ts +5 -0
- package/dist-lib/lib/hooks/run.js +83 -0
- package/dist-lib/lib/hooks/types.d.ts +57 -0
- package/dist-lib/lib/hooks/types.js +1 -0
- package/dist-lib/lib/log.d.ts +5 -0
- package/dist-lib/lib/log.js +37 -0
- package/dist-lib/lib/model-download-progress.d.ts +22 -0
- package/dist-lib/lib/model-download-progress.js +95 -0
- package/dist-lib/lib/models/context.d.ts +5 -0
- package/dist-lib/lib/models/context.js +12 -0
- package/dist-lib/lib/models/embed-config.d.ts +14 -0
- package/dist-lib/lib/models/embed-config.js +31 -0
- package/dist-lib/lib/models/gpu-selection.d.ts +3 -0
- package/dist-lib/lib/models/gpu-selection.js +26 -0
- package/dist-lib/lib/models/kv-cache.d.ts +4 -0
- package/dist-lib/lib/models/kv-cache.js +6 -0
- package/dist-lib/lib/models/llm-presets.d.ts +10 -0
- package/dist-lib/lib/models/llm-presets.js +58 -0
- package/dist-lib/lib/models/model-catalog-constants.d.ts +29 -0
- package/dist-lib/lib/models/model-catalog-constants.js +103 -0
- package/dist-lib/lib/models/model-catalog.d.ts +125 -0
- package/dist-lib/lib/models/model-catalog.js +371 -0
- package/dist-lib/lib/models/model-delete.d.ts +18 -0
- package/dist-lib/lib/models/model-delete.js +47 -0
- package/dist-lib/lib/models/model-handle.d.ts +18 -0
- package/dist-lib/lib/models/model-handle.js +33 -0
- package/dist-lib/lib/models/model-list.d.ts +42 -0
- package/dist-lib/lib/models/model-list.js +123 -0
- package/dist-lib/lib/models/model-pool.d.ts +116 -0
- package/dist-lib/lib/models/model-pool.js +356 -0
- package/dist-lib/lib/models/model-source.d.ts +6 -0
- package/dist-lib/lib/models/model-source.js +21 -0
- package/dist-lib/lib/models/music-catalog.d.ts +12 -0
- package/dist-lib/lib/models/music-catalog.js +26 -0
- package/dist-lib/lib/models/opencl-cache.d.ts +5 -0
- package/dist-lib/lib/models/opencl-cache.js +50 -0
- package/dist-lib/lib/models/sdk-faults.d.ts +21 -0
- package/dist-lib/lib/models/sdk-faults.js +66 -0
- package/dist-lib/lib/models/tool-dialect.d.ts +2 -0
- package/dist-lib/lib/models/tool-dialect.js +19 -0
- package/dist-lib/lib/models/tts-model-default.d.ts +3 -0
- package/dist-lib/lib/models/tts-model-default.js +13 -0
- package/dist-lib/lib/no-redirect-fetch-bare.d.ts +15 -0
- package/dist-lib/lib/no-redirect-fetch-bare.js +59 -0
- package/dist-lib/lib/no-redirect-fetch-impl.d.ts +39 -0
- package/dist-lib/lib/no-redirect-fetch-impl.js +80 -0
- package/dist-lib/lib/no-redirect-fetch-node.d.ts +4 -0
- package/dist-lib/lib/no-redirect-fetch-node.js +52 -0
- package/dist-lib/lib/prompt.d.ts +22 -0
- package/dist-lib/lib/prompt.js +77 -0
- package/dist-lib/lib/queue.d.ts +9 -0
- package/dist-lib/lib/queue.js +48 -0
- package/dist-lib/lib/resolution-detector.d.ts +5 -0
- package/dist-lib/lib/resolution-detector.js +100 -0
- package/dist-lib/lib/rpc-session.d.ts +8 -0
- package/dist-lib/lib/rpc-session.js +20 -0
- package/dist-lib/lib/sdk-config-loader.node.d.ts +1 -0
- package/dist-lib/lib/sdk-config-loader.node.js +1 -0
- package/dist-lib/lib/sdk-loader.d.ts +30 -0
- package/dist-lib/lib/sdk-loader.js +53 -0
- package/dist-lib/lib/sdk-storage.d.ts +8 -0
- package/dist-lib/lib/sdk-storage.js +24 -0
- package/dist-lib/lib/serve.d.ts +3 -0
- package/dist-lib/lib/serve.js +612 -0
- package/dist-lib/lib/spawn.d.ts +62 -0
- package/dist-lib/lib/spawn.js +71 -0
- package/dist-lib/lib/staging.d.ts +4 -0
- package/dist-lib/lib/staging.js +28 -0
- package/dist-lib/lib/storage.d.ts +18 -0
- package/dist-lib/lib/storage.js +26 -0
- package/dist-lib/lib/tmp-path.d.ts +7 -0
- package/dist-lib/lib/tmp-path.js +17 -0
- package/dist-lib/lib/tool-call-display.d.ts +21 -0
- package/dist-lib/lib/tool-call-display.js +1 -0
- package/dist-lib/lib/tools/catalog.d.ts +13 -0
- package/dist-lib/lib/tools/catalog.js +13 -0
- package/dist-lib/lib/tools/create-documents.d.ts +3 -0
- package/dist-lib/lib/tools/create-documents.js +87 -0
- package/dist-lib/lib/tools/edit-documents.d.ts +3 -0
- package/dist-lib/lib/tools/edit-documents.js +122 -0
- package/dist-lib/lib/tools/edit-image.d.ts +25 -0
- package/dist-lib/lib/tools/edit-image.js +271 -0
- package/dist-lib/lib/tools/exec/adapters/adapter.d.ts +27 -0
- package/dist-lib/lib/tools/exec/adapters/adapter.js +1 -0
- package/dist-lib/lib/tools/exec/adapters/python/attachments.d.ts +26 -0
- package/dist-lib/lib/tools/exec/adapters/python/attachments.js +160 -0
- package/dist-lib/lib/tools/exec/adapters/python/create-effect.d.ts +7 -0
- package/dist-lib/lib/tools/exec/adapters/python/create-effect.js +290 -0
- package/dist-lib/lib/tools/exec/adapters/python/loader.d.ts +11 -0
- package/dist-lib/lib/tools/exec/adapters/python/loader.js +94 -0
- package/dist-lib/lib/tools/exec/adapters/python/memfs.d.ts +47 -0
- package/dist-lib/lib/tools/exec/adapters/python/memfs.js +85 -0
- package/dist-lib/lib/tools/exec/adapters/python/output-policy.d.ts +13 -0
- package/dist-lib/lib/tools/exec/adapters/python/output-policy.js +129 -0
- package/dist-lib/lib/tools/exec/adapters/python/pyodide.d.ts +19 -0
- package/dist-lib/lib/tools/exec/adapters/python/pyodide.js +107 -0
- package/dist-lib/lib/tools/exec/adapters/python/python-adapter.d.ts +75 -0
- package/dist-lib/lib/tools/exec/adapters/python/python-adapter.js +1094 -0
- package/dist-lib/lib/tools/exec/adapters/python/run-session.d.ts +75 -0
- package/dist-lib/lib/tools/exec/adapters/python/run-session.js +273 -0
- package/dist-lib/lib/tools/exec/adapters/python/wheels.d.ts +38 -0
- package/dist-lib/lib/tools/exec/adapters/python/wheels.js +102 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/client.d.ts +7 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/client.js +188 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/entry.d.ts +1 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/entry.js +105 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.d.ts +38 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.js +41 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-bare.d.ts +2 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-bare.js +30 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.d.ts +13 -0
- package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.js +45 -0
- package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.d.ts +12 -0
- package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.js +20 -0
- package/dist-lib/lib/tools/exec/obsidian/cli-process.d.ts +8 -0
- package/dist-lib/lib/tools/exec/obsidian/cli-process.js +74 -0
- package/dist-lib/lib/tools/exec/obsidian/cli.d.ts +18 -0
- package/dist-lib/lib/tools/exec/obsidian/cli.js +153 -0
- package/dist-lib/lib/tools/exec/obsidian/command.d.ts +5 -0
- package/dist-lib/lib/tools/exec/obsidian/command.js +18 -0
- package/dist-lib/lib/tools/exec/obsidian/guidance.d.ts +5 -0
- package/dist-lib/lib/tools/exec/obsidian/guidance.js +18 -0
- package/dist-lib/lib/tools/exec/obsidian/note-name.d.ts +1 -0
- package/dist-lib/lib/tools/exec/obsidian/note-name.js +6 -0
- package/dist-lib/lib/tools/exec/obsidian/output.d.ts +1 -0
- package/dist-lib/lib/tools/exec/obsidian/output.js +31 -0
- package/dist-lib/lib/tools/exec/obsidian/route.d.ts +19 -0
- package/dist-lib/lib/tools/exec/obsidian/route.js +85 -0
- package/dist-lib/lib/tools/exec/obsidian/safe-path.d.ts +3 -0
- package/dist-lib/lib/tools/exec/obsidian/safe-path.js +56 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-create.d.ts +1 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-create.js +40 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-fs.d.ts +3 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-fs.js +57 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-paths.d.ts +20 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-paths.js +171 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-read.d.ts +11 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-read.js +119 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-write.d.ts +7 -0
- package/dist-lib/lib/tools/exec/obsidian/vault-write.js +134 -0
- package/dist-lib/lib/tools/exec/runner.d.ts +62 -0
- package/dist-lib/lib/tools/exec/runner.js +87 -0
- package/dist-lib/lib/tools/exec/scope.d.ts +3 -0
- package/dist-lib/lib/tools/exec/scope.js +97 -0
- package/dist-lib/lib/tools/exec/shell-argv.d.ts +2 -0
- package/dist-lib/lib/tools/exec/shell-argv.js +48 -0
- package/dist-lib/lib/tools/exec.d.ts +29 -0
- package/dist-lib/lib/tools/exec.js +459 -0
- package/dist-lib/lib/tools/file-glob.d.ts +15 -0
- package/dist-lib/lib/tools/file-glob.js +112 -0
- package/dist-lib/lib/tools/fs/drive.d.ts +26 -0
- package/dist-lib/lib/tools/fs/drive.js +1 -0
- package/dist-lib/lib/tools/fs/glob.d.ts +1 -0
- package/dist-lib/lib/tools/fs/glob.js +34 -0
- package/dist-lib/lib/tools/fs/local.d.ts +2 -0
- package/dist-lib/lib/tools/fs/local.js +29 -0
- package/dist-lib/lib/tools/fs/read.d.ts +2 -0
- package/dist-lib/lib/tools/fs/read.js +17 -0
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +40 -0
- package/dist-lib/lib/tools/fs/remote-protocol.js +1 -0
- package/dist-lib/lib/tools/fs/remote.d.ts +17 -0
- package/dist-lib/lib/tools/fs/remote.js +131 -0
- package/dist-lib/lib/tools/fs/scope.d.ts +37 -0
- package/dist-lib/lib/tools/fs/scope.js +130 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +15 -0
- package/dist-lib/lib/tools/fs/walk.js +38 -0
- package/dist-lib/lib/tools/fs/write.d.ts +4 -0
- package/dist-lib/lib/tools/fs/write.js +5 -0
- package/dist-lib/lib/tools/generate-image.d.ts +111 -0
- package/dist-lib/lib/tools/generate-image.js +369 -0
- package/dist-lib/lib/tools/generate-music.d.ts +124 -0
- package/dist-lib/lib/tools/generate-music.js +522 -0
- package/dist-lib/lib/tools/grep.d.ts +5 -0
- package/dist-lib/lib/tools/grep.js +158 -0
- package/dist-lib/lib/tools/http-methods.d.ts +1 -0
- package/dist-lib/lib/tools/http-methods.js +1 -0
- package/dist-lib/lib/tools/http-request/encode-fields.d.ts +2 -0
- package/dist-lib/lib/tools/http-request/encode-fields.js +69 -0
- package/dist-lib/lib/tools/http-request/truncate-response.d.ts +1 -0
- package/dist-lib/lib/tools/http-request/truncate-response.js +83 -0
- package/dist-lib/lib/tools/http-request/utils.d.ts +27 -0
- package/dist-lib/lib/tools/http-request/utils.js +84 -0
- package/dist-lib/lib/tools/http-request.d.ts +20 -0
- package/dist-lib/lib/tools/http-request.js +177 -0
- package/dist-lib/lib/tools/mcp/utils.d.ts +47 -0
- package/dist-lib/lib/tools/mcp/utils.js +172 -0
- package/dist-lib/lib/tools/mcp-call.d.ts +14 -0
- package/dist-lib/lib/tools/mcp-call.js +155 -0
- package/dist-lib/lib/tools/model-args.d.ts +1 -0
- package/dist-lib/lib/tools/model-args.js +4 -0
- package/dist-lib/lib/tools/operations/builders.d.ts +17 -0
- package/dist-lib/lib/tools/operations/builders.js +179 -0
- package/dist-lib/lib/tools/operations/compile.d.ts +7 -0
- package/dist-lib/lib/tools/operations/compile.js +92 -0
- package/dist-lib/lib/tools/operations/gmail-message.d.ts +15 -0
- package/dist-lib/lib/tools/operations/gmail-message.js +62 -0
- package/dist-lib/lib/tools/operations/manifest.d.ts +60 -0
- package/dist-lib/lib/tools/operations/manifest.js +50 -0
- package/dist-lib/lib/tools/outbound-guard.d.ts +10 -0
- package/dist-lib/lib/tools/outbound-guard.js +127 -0
- package/dist-lib/lib/tools/private-ip.d.ts +4 -0
- package/dist-lib/lib/tools/private-ip.js +126 -0
- package/dist-lib/lib/tools/rag-search.d.ts +2 -0
- package/dist-lib/lib/tools/rag-search.js +98 -0
- package/dist-lib/lib/tools/read-files.d.ts +5 -0
- package/dist-lib/lib/tools/read-files.js +153 -0
- package/dist-lib/lib/tools/skill.d.ts +10 -0
- package/dist-lib/lib/tools/skill.js +123 -0
- package/dist-lib/lib/tools/skills/auth-resolver.d.ts +43 -0
- package/dist-lib/lib/tools/skills/auth-resolver.js +121 -0
- package/dist-lib/lib/tools/skills/bin-check.d.ts +9 -0
- package/dist-lib/lib/tools/skills/bin-check.js +56 -0
- package/dist-lib/lib/tools/skills/bundled-dir.d.ts +2 -0
- package/dist-lib/lib/tools/skills/bundled-dir.js +117 -0
- package/dist-lib/lib/tools/skills/bundled-hash.d.ts +4 -0
- package/dist-lib/lib/tools/skills/bundled-hash.js +12 -0
- package/dist-lib/lib/tools/skills/catalog.d.ts +60 -0
- package/dist-lib/lib/tools/skills/catalog.js +203 -0
- package/dist-lib/lib/tools/skills/cli-argv.d.ts +9 -0
- package/dist-lib/lib/tools/skills/cli-argv.js +147 -0
- package/dist-lib/lib/tools/skills/cli-schema-check.d.ts +3 -0
- package/dist-lib/lib/tools/skills/cli-schema-check.js +62 -0
- package/dist-lib/lib/tools/skills/cli-schema-load.d.ts +4 -0
- package/dist-lib/lib/tools/skills/cli-schema-load.js +90 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +30 -0
- package/dist-lib/lib/tools/skills/cli-schema-types.js +1 -0
- package/dist-lib/lib/tools/skills/cli-schema.d.ts +7 -0
- package/dist-lib/lib/tools/skills/cli-schema.js +35 -0
- package/dist-lib/lib/tools/skills/credential-check.d.ts +20 -0
- package/dist-lib/lib/tools/skills/credential-check.js +94 -0
- package/dist-lib/lib/tools/skills/credential-grants.d.ts +9 -0
- package/dist-lib/lib/tools/skills/credential-grants.js +25 -0
- package/dist-lib/lib/tools/skills/credential-health.d.ts +8 -0
- package/dist-lib/lib/tools/skills/credential-health.js +51 -0
- package/dist-lib/lib/tools/skills/credential-slots.d.ts +7 -0
- package/dist-lib/lib/tools/skills/credential-slots.js +8 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +23 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +68 -0
- package/dist-lib/lib/tools/skills/index.d.ts +5 -0
- package/dist-lib/lib/tools/skills/index.js +5 -0
- package/dist-lib/lib/tools/skills/manifest-parse.d.ts +12 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +199 -0
- package/dist-lib/lib/tools/skills/manifest.d.ts +47 -0
- package/dist-lib/lib/tools/skills/manifest.js +1 -0
- package/dist-lib/lib/tools/skills/mention-name.d.ts +1 -0
- package/dist-lib/lib/tools/skills/mention-name.js +4 -0
- package/dist-lib/lib/tools/skills/mention.d.ts +6 -0
- package/dist-lib/lib/tools/skills/mention.js +42 -0
- package/dist-lib/lib/tools/skills/obsidian-readiness.d.ts +16 -0
- package/dist-lib/lib/tools/skills/obsidian-readiness.js +95 -0
- package/dist-lib/lib/tools/skills/overlay-crud.d.ts +18 -0
- package/dist-lib/lib/tools/skills/overlay-crud.js +98 -0
- package/dist-lib/lib/tools/skills/overlay-dir.d.ts +2 -0
- package/dist-lib/lib/tools/skills/overlay-dir.js +22 -0
- package/dist-lib/lib/tools/skills/overlay-watch.d.ts +13 -0
- package/dist-lib/lib/tools/skills/overlay-watch.js +44 -0
- package/dist-lib/lib/tools/skills/scope-key.d.ts +7 -0
- package/dist-lib/lib/tools/skills/scope-key.js +7 -0
- package/dist-lib/lib/tools/skills/setup-routes.d.ts +4 -0
- package/dist-lib/lib/tools/skills/setup-routes.js +14 -0
- package/dist-lib/lib/tools/skills/skill-settings.d.ts +16 -0
- package/dist-lib/lib/tools/skills/skill-settings.js +33 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +12 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.js +14 -0
- package/dist-lib/lib/tools/skills/skill-state.d.ts +40 -0
- package/dist-lib/lib/tools/skills/skill-state.js +117 -0
- package/dist-lib/lib/tools/skills/tool-grants.d.ts +5 -0
- package/dist-lib/lib/tools/skills/tool-grants.js +14 -0
- package/dist-lib/lib/tools/toolsets.d.ts +8 -0
- package/dist-lib/lib/tools/toolsets.js +20 -0
- package/dist-lib/lib/tools/url-guard.d.ts +8 -0
- package/dist-lib/lib/tools/url-guard.js +40 -0
- package/dist-lib/lib/tools/web-fetch.d.ts +8 -0
- package/dist-lib/lib/tools/web-fetch.js +302 -0
- package/dist-lib/lib/tools/web-search.d.ts +6 -0
- package/dist-lib/lib/tools/web-search.js +55 -0
- package/dist-lib/lib/transport.d.ts +12 -0
- package/dist-lib/lib/transport.js +59 -0
- package/dist-lib/lib/user-agent.d.ts +1 -0
- package/dist-lib/lib/user-agent.js +1 -0
- package/dist-lib/lib/validating-lookup.d.ts +17 -0
- package/dist-lib/lib/validating-lookup.js +25 -0
- package/dist-lib/lib/wav-encode.d.ts +5 -0
- package/dist-lib/lib/wav-encode.js +24 -0
- package/dist-lib/lib/web-fetch/embedded-state.d.ts +1 -0
- package/dist-lib/lib/web-fetch/embedded-state.js +131 -0
- package/dist-lib/lib/web-fetch/extract.d.ts +6 -0
- package/dist-lib/lib/web-fetch/extract.js +65 -0
- package/dist-lib/lib/web-fetch/images.d.ts +3 -0
- package/dist-lib/lib/web-fetch/images.js +43 -0
- package/dist-lib/lib/web-fetch/video.d.ts +5 -0
- package/dist-lib/lib/web-fetch/video.js +42 -0
- package/dist-lib/lib/web-search/engine-registry.d.ts +7 -0
- package/dist-lib/lib/web-search/engine-registry.js +17 -0
- package/dist-lib/lib/web-search/engines/aol.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/aol.js +81 -0
- package/dist-lib/lib/web-search/engines/bing.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/bing.js +111 -0
- package/dist-lib/lib/web-search/engines/brave.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/brave.js +59 -0
- package/dist-lib/lib/web-search/engines/duckduckgo.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/duckduckgo.js +112 -0
- package/dist-lib/lib/web-search/engines/google.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/google.js +92 -0
- package/dist-lib/lib/web-search/engines/wikipedia.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/wikipedia.js +37 -0
- package/dist-lib/lib/web-search/engines/yahoo.d.ts +3 -0
- package/dist-lib/lib/web-search/engines/yahoo.js +81 -0
- package/dist-lib/lib/web-search/fetch-html.d.ts +25 -0
- package/dist-lib/lib/web-search/fetch-html.js +97 -0
- package/dist-lib/lib/web-search/format-results.d.ts +3 -0
- package/dist-lib/lib/web-search/format-results.js +14 -0
- package/dist-lib/lib/web-search/html-helpers.d.ts +3 -0
- package/dist-lib/lib/web-search/html-helpers.js +24 -0
- package/dist-lib/lib/web-search/merge-results.d.ts +2 -0
- package/dist-lib/lib/web-search/merge-results.js +53 -0
- package/dist-lib/lib/web-search/orchestrator.d.ts +14 -0
- package/dist-lib/lib/web-search/orchestrator.js +50 -0
- package/dist-lib/lib/web-search/types.d.ts +34 -0
- package/dist-lib/lib/web-search/types.js +1 -0
- package/dist-lib/lib/web-search/url-helpers.d.ts +1 -0
- package/dist-lib/lib/web-search/url-helpers.js +11 -0
- package/dist-lib/lib/web-search/url-normalize.d.ts +1 -0
- package/dist-lib/lib/web-search/url-normalize.js +25 -0
- package/dist-lib/lib/web-search/user-agents.d.ts +3 -0
- package/dist-lib/lib/web-search/user-agents.js +3 -0
- package/dist-lib/lib/wire.d.ts +50 -0
- package/dist-lib/lib/wire.js +145 -0
- package/dist-lib/schema/baseline.d.ts +8 -0
- package/dist-lib/schema/baseline.js +35 -0
- package/dist-lib/schema/build.d.ts +1 -0
- package/dist-lib/schema/build.js +39 -0
- package/dist-lib/schema/generate.d.ts +20 -0
- package/dist-lib/schema/generate.js +149 -0
- package/dist-lib/schema/harness.d.ts +2 -0
- package/dist-lib/schema/harness.js +745 -0
- package/dist-lib/schema/release-tags.d.ts +5 -0
- package/dist-lib/schema/release-tags.js +58 -0
- package/dist-lib/spec/bind.d.ts +2 -0
- package/dist-lib/spec/bind.js +124 -0
- package/dist-lib/spec/calls.d.ts +3 -0
- package/dist-lib/spec/calls.js +41 -0
- package/dist-lib/spec/hrpc/hrpc.json +356 -0
- package/dist-lib/spec/hrpc/index.d.ts +3 -0
- package/dist-lib/spec/hrpc/index.js +463 -0
- package/dist-lib/spec/hrpc/messages.d.ts +4 -0
- package/dist-lib/spec/hrpc/messages.js +3102 -0
- package/dist-lib/spec/hyperschema/index.js +3102 -0
- package/dist-lib/spec/hyperschema/schema.json +2290 -0
- package/dist-lib/spec/hyperschema/types.d.ts +554 -0
- package/dist-lib/spec/index.d.ts +8 -0
- package/dist-lib/spec/index.js +1 -0
- package/package.json +239 -64
- package/.gitattributes +0 -1
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
import { AbortController } from 'bare-abort-controller';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { settleOnClose } from "./rpc-session.js";
|
|
4
|
+
import { pipeline, Readable } from 'streamx';
|
|
5
|
+
import { bindApi } from '../spec/bind.js';
|
|
6
|
+
import HRPC from '../spec/hrpc/index.js';
|
|
7
|
+
import { unsupportedKvCacheDeletion } from "./capabilities/kv-cache.js";
|
|
8
|
+
import { errorMessage } from "./error-fields.js";
|
|
9
|
+
import { hlog } from "./log.js";
|
|
10
|
+
import { pushQueue } from "./queue.js";
|
|
11
|
+
import { TextCoalescer } from "./helpers/text-coalescer.js";
|
|
12
|
+
import { prepareOpenclCache } from "./models/opencl-cache.js";
|
|
13
|
+
import { stageFile, sweepStaging } from "./staging.js";
|
|
14
|
+
import { readSetup } from "./tools/skills/manifest-parse.js";
|
|
15
|
+
import { packVectors, toDownloadWire, toWire } from "./wire.js";
|
|
16
|
+
const MODEL_STATUSES = new Set([
|
|
17
|
+
'loading',
|
|
18
|
+
'downloading',
|
|
19
|
+
'ready',
|
|
20
|
+
'error',
|
|
21
|
+
'unloading',
|
|
22
|
+
'unloaded'
|
|
23
|
+
]);
|
|
24
|
+
const DOWNLOAD_PROGRESS_INTERVAL_MS = 500;
|
|
25
|
+
const WIRE_HIGH_WATER_MARK = 64;
|
|
26
|
+
const TEXT_COALESCE_CAP = 8192;
|
|
27
|
+
const TEXT_COALESCE_MS = 60;
|
|
28
|
+
function noop() { }
|
|
29
|
+
function tick() {
|
|
30
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
31
|
+
}
|
|
32
|
+
export function serveHarness(stream, harness) {
|
|
33
|
+
sweepStaging();
|
|
34
|
+
prepareOpenclCache();
|
|
35
|
+
const rpc = settleOnClose(new HRPC(stream));
|
|
36
|
+
bindApi(rpc, {
|
|
37
|
+
setCredentials: async ({ entries }) => {
|
|
38
|
+
await harness.setCredentials?.(entries ?? []);
|
|
39
|
+
return { ok: true };
|
|
40
|
+
},
|
|
41
|
+
setSkillSettings: async ({ entries }) => {
|
|
42
|
+
await harness.setSkillSettings?.(entries ?? []);
|
|
43
|
+
return { ok: true };
|
|
44
|
+
},
|
|
45
|
+
listManagedSkills: async () => ({
|
|
46
|
+
skills: (await harness.listManagedSkills?.()) ?? []
|
|
47
|
+
}),
|
|
48
|
+
readSkillFile: async ({ name }) => {
|
|
49
|
+
const file = await harness.readSkillFile?.(name);
|
|
50
|
+
return file
|
|
51
|
+
? { found: true, content: file.content, origin: file.origin }
|
|
52
|
+
: { found: false, content: '', origin: '' };
|
|
53
|
+
},
|
|
54
|
+
writeSkillFile: async ({ name, content }) => {
|
|
55
|
+
if (!harness.writeSkillFile)
|
|
56
|
+
return { ok: false };
|
|
57
|
+
return harness.writeSkillFile(name, content);
|
|
58
|
+
},
|
|
59
|
+
copySkillForEdit: async ({ name }) => ({
|
|
60
|
+
copied: (await harness.copyBaseForEdit?.(name))?.copied ?? false
|
|
61
|
+
}),
|
|
62
|
+
deleteOverlaySkill: async ({ name }) => ({
|
|
63
|
+
removed: (await harness.deleteOverlaySkill?.(name))?.removed ?? false
|
|
64
|
+
}),
|
|
65
|
+
setCustomModels: async ({ models }) => {
|
|
66
|
+
await harness.setCustomModels?.((models ?? []).map(({ name, src, projectionSrc }) => ({
|
|
67
|
+
name,
|
|
68
|
+
src,
|
|
69
|
+
projectionSrc: projectionSrc ?? undefined
|
|
70
|
+
})));
|
|
71
|
+
return { ok: true };
|
|
72
|
+
},
|
|
73
|
+
describe: async () => (await harness.describe?.()) ?? {
|
|
74
|
+
toolNames: [],
|
|
75
|
+
skills: [],
|
|
76
|
+
supportsImages: false,
|
|
77
|
+
supportsKvCacheDeletion: false
|
|
78
|
+
},
|
|
79
|
+
diagnostics: async () => harness.diagnostics?.() ?? {
|
|
80
|
+
models: [],
|
|
81
|
+
suspended: false,
|
|
82
|
+
sdkLoaded: false,
|
|
83
|
+
toolNames: [],
|
|
84
|
+
skills: []
|
|
85
|
+
},
|
|
86
|
+
embed: async ({ model, texts }) => {
|
|
87
|
+
if (!harness.embed)
|
|
88
|
+
throw new Error('harness does not support embed');
|
|
89
|
+
return packVectors(await harness.embed({ model, texts: texts ?? [] }));
|
|
90
|
+
},
|
|
91
|
+
transcribe: async ({ model, audio }) => {
|
|
92
|
+
if (!harness.transcribe)
|
|
93
|
+
throw new Error('harness does not support transcribe');
|
|
94
|
+
return {
|
|
95
|
+
text: await harness.transcribe({ model: model ?? '', audio: audio ?? Buffer.alloc(0) })
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
speak: async ({ model, text }) => {
|
|
99
|
+
if (!harness.speak)
|
|
100
|
+
throw new Error('harness does not support speak');
|
|
101
|
+
return harness.speak({ model: model ?? '', text: text ?? '' });
|
|
102
|
+
},
|
|
103
|
+
speakStream: speakStream(harness),
|
|
104
|
+
getEmbeddingDevice: async () => {
|
|
105
|
+
if (!harness.getEmbeddingDevice)
|
|
106
|
+
throw unsupportedEmbeddingDeviceControl();
|
|
107
|
+
return { device: await harness.getEmbeddingDevice() };
|
|
108
|
+
},
|
|
109
|
+
setEmbeddingDevice: async ({ device }) => {
|
|
110
|
+
if (!harness.setEmbeddingDevice)
|
|
111
|
+
throw unsupportedEmbeddingDeviceControl();
|
|
112
|
+
await harness.setEmbeddingDevice(device);
|
|
113
|
+
return { ok: true };
|
|
114
|
+
},
|
|
115
|
+
skills: async (req) => ({
|
|
116
|
+
skills: ((await harness.skills?.(req?.agentId, req?.modelName, {
|
|
117
|
+
refresh: req?.refresh === true,
|
|
118
|
+
skipCredentialProbe: req?.skipCredentialProbe === true
|
|
119
|
+
})) ?? []).map(toWireSkill)
|
|
120
|
+
}),
|
|
121
|
+
tools: async () => ({
|
|
122
|
+
tools: (await harness.tools?.()) ?? []
|
|
123
|
+
}),
|
|
124
|
+
listModels: async (req) => ({
|
|
125
|
+
models: (await harness.list?.({
|
|
126
|
+
type: (req?.type || undefined),
|
|
127
|
+
cachedOnly: req?.cachedOnly ?? undefined,
|
|
128
|
+
fullRegistry: req?.fullRegistry ?? undefined
|
|
129
|
+
})) ?? []
|
|
130
|
+
}),
|
|
131
|
+
deleteModel: async (req) => {
|
|
132
|
+
const name = req?.name ?? '';
|
|
133
|
+
return (await harness.deleteModel?.(name)) ?? { name, removed: 0, freedBytes: 0 };
|
|
134
|
+
},
|
|
135
|
+
clearKvCache: async () => (await harness.clearKvCache?.()) ?? unsupportedKvCacheDeletion(),
|
|
136
|
+
infraModels: async ({ profile }) => ({
|
|
137
|
+
models: (await harness.infraModels?.(profile ?? '')) ?? []
|
|
138
|
+
}),
|
|
139
|
+
capability: async () => {
|
|
140
|
+
if (!harness.capability)
|
|
141
|
+
throw new Error('harness does not support capability');
|
|
142
|
+
return harness.capability();
|
|
143
|
+
},
|
|
144
|
+
warmModel: async ({ model, agent }) => {
|
|
145
|
+
if (!harness.warmModel)
|
|
146
|
+
throw new Error('harness does not support warmModel');
|
|
147
|
+
await harness.warmModel({ model, agent: agent ?? {} });
|
|
148
|
+
return { ok: true };
|
|
149
|
+
},
|
|
150
|
+
modelEvents: () => modelEvents(harness),
|
|
151
|
+
completion: completion(harness)
|
|
152
|
+
});
|
|
153
|
+
rpc.onDownload((out) => {
|
|
154
|
+
const src = downloadStream(harness, out.data);
|
|
155
|
+
pipeline(src, out, noop);
|
|
156
|
+
out.writeStream?.on('close', () => src.destroy());
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function toWireSkill(skill) {
|
|
160
|
+
const setupV2 = readSetup(skill.setup);
|
|
161
|
+
const binaries = (skill.requires?.bins ?? []).map((bin) => ({
|
|
162
|
+
bin,
|
|
163
|
+
minVersion: skill.requires?.binMinVersions?.[bin]?.min,
|
|
164
|
+
command: skill.requires?.binMinVersions?.[bin]?.command
|
|
165
|
+
}));
|
|
166
|
+
return {
|
|
167
|
+
name: skill.name,
|
|
168
|
+
description: skill.description,
|
|
169
|
+
tools: skill.tools,
|
|
170
|
+
credentials: skill.credentials,
|
|
171
|
+
allowList: skill.allowList,
|
|
172
|
+
platforms: skill.platform,
|
|
173
|
+
status: skill.status,
|
|
174
|
+
...(skill.requires
|
|
175
|
+
? {
|
|
176
|
+
requirements: {
|
|
177
|
+
binaries,
|
|
178
|
+
credentials: skill.requires.credentials ?? []
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
: {}),
|
|
182
|
+
...(skill.install ? { install: skill.install } : {}),
|
|
183
|
+
...(skill.setup ? { setup: skill.setup, ...(setupV2 ? { setupV2 } : {}) } : {}),
|
|
184
|
+
...(skill.stub !== undefined ? { stub: skill.stub } : {}),
|
|
185
|
+
...(skill.minCapabilityProfile ? { minCapabilityProfile: skill.minCapabilityProfile } : {}),
|
|
186
|
+
...(skill.emoji ? { emoji: skill.emoji } : {})
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function unsupportedEmbeddingDeviceControl() {
|
|
190
|
+
return new Error('harness does not support embedding device control');
|
|
191
|
+
}
|
|
192
|
+
function modelEvents(harness) {
|
|
193
|
+
let last = '';
|
|
194
|
+
let pendingProgress = null;
|
|
195
|
+
let lastProgressAt = 0;
|
|
196
|
+
const flushProgress = (at) => {
|
|
197
|
+
if (pendingProgress === null)
|
|
198
|
+
return;
|
|
199
|
+
stream.push(pendingProgress);
|
|
200
|
+
pendingProgress = null;
|
|
201
|
+
lastProgressAt = at;
|
|
202
|
+
};
|
|
203
|
+
const onModel = (state) => {
|
|
204
|
+
if (!MODEL_STATUSES.has(state.status))
|
|
205
|
+
return;
|
|
206
|
+
const percentage = Math.floor(state.percentage ?? 0);
|
|
207
|
+
const downloaded = Math.floor(state.downloaded ?? 0);
|
|
208
|
+
const total = Math.floor(state.total ?? 0);
|
|
209
|
+
const loaded = state.loaded ?? [];
|
|
210
|
+
const catalogChanged = state.catalogChanged === true;
|
|
211
|
+
const key = [
|
|
212
|
+
state.status,
|
|
213
|
+
state.model ?? '',
|
|
214
|
+
percentage,
|
|
215
|
+
downloaded,
|
|
216
|
+
total,
|
|
217
|
+
state.message ?? '',
|
|
218
|
+
catalogChanged,
|
|
219
|
+
...loaded.map((entry) => `${entry.model}:${entry.refs}`)
|
|
220
|
+
].join('\0');
|
|
221
|
+
if (key === last)
|
|
222
|
+
return;
|
|
223
|
+
last = key;
|
|
224
|
+
const frame = {
|
|
225
|
+
status: state.status,
|
|
226
|
+
model: state.model,
|
|
227
|
+
percentage,
|
|
228
|
+
downloaded,
|
|
229
|
+
total,
|
|
230
|
+
message: state.message,
|
|
231
|
+
catalogChanged,
|
|
232
|
+
loaded
|
|
233
|
+
};
|
|
234
|
+
const now = Date.now();
|
|
235
|
+
if (state.status === 'downloading') {
|
|
236
|
+
pendingProgress = frame;
|
|
237
|
+
if (lastProgressAt === 0 || now - lastProgressAt >= DOWNLOAD_PROGRESS_INTERVAL_MS) {
|
|
238
|
+
flushProgress(now);
|
|
239
|
+
}
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
flushProgress(now);
|
|
243
|
+
lastProgressAt = 0;
|
|
244
|
+
stream.push(frame);
|
|
245
|
+
};
|
|
246
|
+
const stream = new Readable({
|
|
247
|
+
open(cb) {
|
|
248
|
+
harness.on?.('model', onModel);
|
|
249
|
+
cb(null);
|
|
250
|
+
},
|
|
251
|
+
destroy(cb) {
|
|
252
|
+
harness.off?.('model', onModel);
|
|
253
|
+
cb(null);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
return stream;
|
|
257
|
+
}
|
|
258
|
+
function speakStream(harness) {
|
|
259
|
+
return async function* (duplex) {
|
|
260
|
+
if (!harness.speakStream)
|
|
261
|
+
throw new Error('harness does not support speakStream');
|
|
262
|
+
const text = pushQueue();
|
|
263
|
+
const end = () => text.end();
|
|
264
|
+
duplex.on('close', end);
|
|
265
|
+
duplex.on('end', end);
|
|
266
|
+
duplex.readStream?.on('close', end);
|
|
267
|
+
duplex.on('data', (frame) => {
|
|
268
|
+
if (frame.text)
|
|
269
|
+
text.push(frame.text);
|
|
270
|
+
});
|
|
271
|
+
for await (const chunk of harness.speakStream({ model: '', text })) {
|
|
272
|
+
yield { audio: chunk.audio, sampleRate: chunk.sampleRate };
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function completion(harness) {
|
|
277
|
+
return async function* (duplex) {
|
|
278
|
+
const events = pushQueue({ highWaterMark: WIRE_HIGH_WATER_MARK });
|
|
279
|
+
const pending = new Map();
|
|
280
|
+
const pendingAttach = new Map();
|
|
281
|
+
const pendingFetch = new Map();
|
|
282
|
+
const pendingRag = new Map();
|
|
283
|
+
const pendingQuestion = new Map();
|
|
284
|
+
const pendingDrive = new Map();
|
|
285
|
+
const controller = new AbortController();
|
|
286
|
+
let calls = 0;
|
|
287
|
+
let started = false;
|
|
288
|
+
const gone = () => {
|
|
289
|
+
controller.abort('client gone');
|
|
290
|
+
for (const resolve of pending.values())
|
|
291
|
+
resolve(false);
|
|
292
|
+
pending.clear();
|
|
293
|
+
for (const { reject, staged } of pendingAttach.values()) {
|
|
294
|
+
void fs.promises.unlink(staged).catch(noop);
|
|
295
|
+
reject(new Error('client gone'));
|
|
296
|
+
}
|
|
297
|
+
pendingAttach.clear();
|
|
298
|
+
for (const { reject } of pendingFetch.values())
|
|
299
|
+
reject(new Error('client gone'));
|
|
300
|
+
pendingFetch.clear();
|
|
301
|
+
for (const { reject } of pendingRag.values())
|
|
302
|
+
reject(new Error('client gone'));
|
|
303
|
+
pendingRag.clear();
|
|
304
|
+
for (const { resolve } of pendingQuestion.values())
|
|
305
|
+
resolve(null);
|
|
306
|
+
pendingQuestion.clear();
|
|
307
|
+
for (const { reject, path } of pendingDrive.values()) {
|
|
308
|
+
if (path)
|
|
309
|
+
void fs.promises.unlink(path).catch(noop);
|
|
310
|
+
reject(new Error('client gone'));
|
|
311
|
+
}
|
|
312
|
+
pendingDrive.clear();
|
|
313
|
+
events.end();
|
|
314
|
+
};
|
|
315
|
+
duplex.on('close', gone);
|
|
316
|
+
duplex.on('end', gone);
|
|
317
|
+
duplex.readStream?.on('close', gone);
|
|
318
|
+
duplex.on('data', (frame) => {
|
|
319
|
+
if (frame.type === 'decision') {
|
|
320
|
+
if (typeof frame.callId !== 'string')
|
|
321
|
+
return;
|
|
322
|
+
pending.get(frame.callId)?.(frame.approved === true);
|
|
323
|
+
pending.delete(frame.callId);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (frame.type === 'attach-result') {
|
|
327
|
+
if (typeof frame.callId !== 'string')
|
|
328
|
+
return;
|
|
329
|
+
const waiter = pendingAttach.get(frame.callId);
|
|
330
|
+
pendingAttach.delete(frame.callId);
|
|
331
|
+
if (!waiter)
|
|
332
|
+
return;
|
|
333
|
+
void fs.promises.unlink(waiter.staged).catch(noop);
|
|
334
|
+
if (frame.attachment)
|
|
335
|
+
waiter.resolve(frame.attachment);
|
|
336
|
+
else
|
|
337
|
+
waiter.reject(new Error(frame.message || 'the host failed to store the attachment'));
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (frame.type === 'fetch-result') {
|
|
341
|
+
if (typeof frame.callId !== 'string')
|
|
342
|
+
return;
|
|
343
|
+
const waiter = pendingFetch.get(frame.callId);
|
|
344
|
+
pendingFetch.delete(frame.callId);
|
|
345
|
+
if (!waiter)
|
|
346
|
+
return;
|
|
347
|
+
if (frame.message)
|
|
348
|
+
return waiter.reject(new Error(frame.message));
|
|
349
|
+
const staged = frame.path;
|
|
350
|
+
const { fileName, mimeType, attachmentId, size } = frame;
|
|
351
|
+
if (frame.meta === true) {
|
|
352
|
+
return waiter.resolve({
|
|
353
|
+
id: attachmentId ?? '',
|
|
354
|
+
fileName: fileName ?? '',
|
|
355
|
+
mimeType: mimeType ?? '',
|
|
356
|
+
byteLength: typeof size === 'number' ? size : 0
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
if (!staged)
|
|
360
|
+
return waiter.resolve(null);
|
|
361
|
+
fs.promises.readFile(staged).then((bytes) => waiter.resolve({
|
|
362
|
+
id: attachmentId ?? '',
|
|
363
|
+
fileName: fileName ?? '',
|
|
364
|
+
mimeType: mimeType ?? '',
|
|
365
|
+
byteLength: typeof size === 'number' ? size : bytes.byteLength,
|
|
366
|
+
bytes
|
|
367
|
+
}), (err) => waiter.reject(err));
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (frame.type === 'rag-result') {
|
|
371
|
+
if (typeof frame.callId !== 'string')
|
|
372
|
+
return;
|
|
373
|
+
const waiter = pendingRag.get(frame.callId);
|
|
374
|
+
pendingRag.delete(frame.callId);
|
|
375
|
+
if (!waiter)
|
|
376
|
+
return;
|
|
377
|
+
if (frame.message)
|
|
378
|
+
return waiter.reject(new Error(frame.message));
|
|
379
|
+
waiter.resolve(frame.result ?? { enabled: false, indexEmpty: true, hasKnowledge: false, hits: [] });
|
|
380
|
+
}
|
|
381
|
+
if (frame.type === 'question-result') {
|
|
382
|
+
if (typeof frame.callId !== 'string')
|
|
383
|
+
return;
|
|
384
|
+
const waiter = pendingQuestion.get(frame.callId);
|
|
385
|
+
pendingQuestion.delete(frame.callId);
|
|
386
|
+
if (!waiter)
|
|
387
|
+
return;
|
|
388
|
+
if (frame.message)
|
|
389
|
+
hlog('question failed', { callId: frame.callId, message: frame.message });
|
|
390
|
+
waiter.resolve(frame.answer || null);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if (frame.type === 'drive-result') {
|
|
394
|
+
if (typeof frame.callId !== 'string')
|
|
395
|
+
return;
|
|
396
|
+
const waiter = pendingDrive.get(frame.callId);
|
|
397
|
+
pendingDrive.delete(frame.callId);
|
|
398
|
+
if (!waiter)
|
|
399
|
+
return;
|
|
400
|
+
if (frame.message)
|
|
401
|
+
return waiter.reject(new Error(frame.message));
|
|
402
|
+
waiter.resolve((frame.payload ?? {}));
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (frame.type !== 'start' || started)
|
|
406
|
+
return;
|
|
407
|
+
started = true;
|
|
408
|
+
const context = {
|
|
409
|
+
model: frame.model ?? '',
|
|
410
|
+
agent: frame.agent ?? {},
|
|
411
|
+
cacheKey: frame.cacheKey ?? undefined,
|
|
412
|
+
thinkingDefault: frame.thinkingDefault ?? undefined,
|
|
413
|
+
generationParams: frame.generationParams ?? undefined,
|
|
414
|
+
responseFormat: frame.responseFormat ?? undefined,
|
|
415
|
+
messages: (frame.messages ?? []).map(({ role, content, attachments }) => ({
|
|
416
|
+
role,
|
|
417
|
+
content,
|
|
418
|
+
...(attachments?.length
|
|
419
|
+
? { attachments: attachments.map(({ path: file }) => ({ path: file })) }
|
|
420
|
+
: {})
|
|
421
|
+
})),
|
|
422
|
+
toolConfigs: frame.toolConfigs ?? undefined,
|
|
423
|
+
grantedDirs: frame.grantedDirs ?? undefined,
|
|
424
|
+
grantedDrives: frame.grantedDrives?.length
|
|
425
|
+
? frame.grantedDrives.map((drive) => ({
|
|
426
|
+
key: drive.key,
|
|
427
|
+
writable: drive.writable === true
|
|
428
|
+
}))
|
|
429
|
+
: undefined,
|
|
430
|
+
driveOp: frame.grantedDrives?.length
|
|
431
|
+
? (request) => controller.signal.aborted
|
|
432
|
+
? Promise.reject(new Error('client gone'))
|
|
433
|
+
: new Promise((resolve, reject) => {
|
|
434
|
+
const callId = String(calls++);
|
|
435
|
+
pendingDrive.set(callId, {
|
|
436
|
+
resolve,
|
|
437
|
+
reject,
|
|
438
|
+
...(request.op === 'write' ? { path: request.path } : {})
|
|
439
|
+
});
|
|
440
|
+
events.push({ type: 'drive-ask', callId, op: request.op, payload: request });
|
|
441
|
+
})
|
|
442
|
+
: undefined,
|
|
443
|
+
grantedWriteDirs: frame.grantedWriteDirs ?? undefined,
|
|
444
|
+
signal: controller.signal,
|
|
445
|
+
approve: (call) => new Promise((resolve) => {
|
|
446
|
+
const callId = String(calls++);
|
|
447
|
+
pending.set(callId, resolve);
|
|
448
|
+
events.push({
|
|
449
|
+
type: 'approval-ask',
|
|
450
|
+
callId,
|
|
451
|
+
name: call.name,
|
|
452
|
+
arguments: call.arguments,
|
|
453
|
+
resource: call.resource ?? undefined,
|
|
454
|
+
effect: call.effect,
|
|
455
|
+
intent: call.intent ?? undefined,
|
|
456
|
+
display: call.display ?? undefined
|
|
457
|
+
});
|
|
458
|
+
}),
|
|
459
|
+
attach: async (input) => {
|
|
460
|
+
const staged = await stageFile('attach', input.bytes);
|
|
461
|
+
if (controller.signal.aborted) {
|
|
462
|
+
void fs.promises.unlink(staged).catch(noop);
|
|
463
|
+
throw new Error('client gone');
|
|
464
|
+
}
|
|
465
|
+
return new Promise((resolve, reject) => {
|
|
466
|
+
const callId = String(calls++);
|
|
467
|
+
pendingAttach.set(callId, { resolve, reject, staged });
|
|
468
|
+
events.push({
|
|
469
|
+
type: 'attach-ask',
|
|
470
|
+
callId,
|
|
471
|
+
path: staged,
|
|
472
|
+
fileName: input.fileName,
|
|
473
|
+
mimeType: input.mimeType,
|
|
474
|
+
raw: input.raw ?? false
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
},
|
|
478
|
+
fetchAttachment: ({ attachmentId, meta } = {}) => controller.signal.aborted
|
|
479
|
+
? Promise.reject(new Error('client gone'))
|
|
480
|
+
: new Promise((resolve, reject) => {
|
|
481
|
+
const callId = String(calls++);
|
|
482
|
+
pendingFetch.set(callId, { resolve, reject });
|
|
483
|
+
events.push({
|
|
484
|
+
type: 'fetch-ask',
|
|
485
|
+
callId,
|
|
486
|
+
attachmentId,
|
|
487
|
+
...(meta === true ? { meta: true } : {})
|
|
488
|
+
});
|
|
489
|
+
}),
|
|
490
|
+
ragSearch: ({ query, limit }) => controller.signal.aborted
|
|
491
|
+
? Promise.reject(new Error('client gone'))
|
|
492
|
+
: new Promise((resolve, reject) => {
|
|
493
|
+
const callId = String(calls++);
|
|
494
|
+
pendingRag.set(callId, { resolve, reject });
|
|
495
|
+
events.push({ type: 'rag-ask', callId, query, limit });
|
|
496
|
+
}),
|
|
497
|
+
progress: (update) => {
|
|
498
|
+
events.push(update
|
|
499
|
+
? { type: 'progress', percentage: update.percentage }
|
|
500
|
+
: { type: 'progress', cleared: true });
|
|
501
|
+
},
|
|
502
|
+
askUser: (question) => controller.signal.aborted
|
|
503
|
+
? Promise.resolve(null)
|
|
504
|
+
: new Promise((resolve, reject) => {
|
|
505
|
+
const callId = String(calls++);
|
|
506
|
+
pendingQuestion.set(callId, { resolve, reject });
|
|
507
|
+
events.push({
|
|
508
|
+
type: 'question-ask',
|
|
509
|
+
callId,
|
|
510
|
+
question: question.question,
|
|
511
|
+
options: question.options
|
|
512
|
+
});
|
|
513
|
+
})
|
|
514
|
+
};
|
|
515
|
+
void (async () => {
|
|
516
|
+
let produced = 0;
|
|
517
|
+
let frames = 0;
|
|
518
|
+
const text = new TextCoalescer((type, merged) => {
|
|
519
|
+
frames++;
|
|
520
|
+
return events.push({ type, text: merged });
|
|
521
|
+
}, { cap: TEXT_COALESCE_CAP, holdMs: TEXT_COALESCE_MS });
|
|
522
|
+
try {
|
|
523
|
+
for await (const event of harness.completion(context)) {
|
|
524
|
+
produced++;
|
|
525
|
+
const wire = toWire(event);
|
|
526
|
+
if ((wire.type === 'content' || wire.type === 'thinking') && wire.text) {
|
|
527
|
+
await text.add(wire.type, wire.text);
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
await text.flush();
|
|
531
|
+
frames++;
|
|
532
|
+
await events.push(wire);
|
|
533
|
+
}
|
|
534
|
+
await text.flush();
|
|
535
|
+
}
|
|
536
|
+
catch (err) {
|
|
537
|
+
await text.flush();
|
|
538
|
+
events.push({ type: 'error', message: errorMessage(err) });
|
|
539
|
+
}
|
|
540
|
+
events.push({ type: 'done' });
|
|
541
|
+
hlog('wire end', { produced, frames });
|
|
542
|
+
events.end();
|
|
543
|
+
})();
|
|
544
|
+
});
|
|
545
|
+
for await (const event of events) {
|
|
546
|
+
yield event;
|
|
547
|
+
await tick();
|
|
548
|
+
}
|
|
549
|
+
hlog('wire handed off');
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
function downloadStream(harness, req) {
|
|
553
|
+
const controller = new AbortController();
|
|
554
|
+
const stream = new Readable({
|
|
555
|
+
open(cb) {
|
|
556
|
+
void run();
|
|
557
|
+
cb(null);
|
|
558
|
+
},
|
|
559
|
+
destroy(cb) {
|
|
560
|
+
controller.abort('client gone');
|
|
561
|
+
cb(null);
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
const run = async () => {
|
|
565
|
+
if (!harness.download) {
|
|
566
|
+
stream.push({
|
|
567
|
+
type: 'error',
|
|
568
|
+
message: 'harness does not support download'
|
|
569
|
+
});
|
|
570
|
+
stream.push(null);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
let pendingProgress = null;
|
|
574
|
+
let lastProgressAt = 0;
|
|
575
|
+
const flushProgress = (at = Date.now()) => {
|
|
576
|
+
if (pendingProgress === null)
|
|
577
|
+
return;
|
|
578
|
+
stream.push(pendingProgress);
|
|
579
|
+
pendingProgress = null;
|
|
580
|
+
lastProgressAt = at;
|
|
581
|
+
};
|
|
582
|
+
try {
|
|
583
|
+
for await (const event of harness.download({
|
|
584
|
+
model: req.model,
|
|
585
|
+
addon: req.addon,
|
|
586
|
+
seed: req.seed,
|
|
587
|
+
signal: controller.signal
|
|
588
|
+
})) {
|
|
589
|
+
const wire = toDownloadWire(event);
|
|
590
|
+
if (wire.type === 'progress') {
|
|
591
|
+
const now = Date.now();
|
|
592
|
+
pendingProgress = wire;
|
|
593
|
+
if (lastProgressAt === 0 || now - lastProgressAt >= DOWNLOAD_PROGRESS_INTERVAL_MS) {
|
|
594
|
+
flushProgress(now);
|
|
595
|
+
}
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
flushProgress();
|
|
599
|
+
stream.push(wire);
|
|
600
|
+
}
|
|
601
|
+
flushProgress();
|
|
602
|
+
}
|
|
603
|
+
catch (err) {
|
|
604
|
+
if (!controller.signal.aborted) {
|
|
605
|
+
flushProgress();
|
|
606
|
+
stream.push({ type: 'error', message: errorMessage(err) });
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
stream.push(null);
|
|
610
|
+
};
|
|
611
|
+
return stream;
|
|
612
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { SdkStorage } from './storage.ts';
|
|
2
|
+
import { type StowIpc, type StowRunner } from 'bare-supervisor/stow';
|
|
3
|
+
import type { ChildSpec } from 'bare-supervisor';
|
|
4
|
+
import { type RemoteHarness } from './connect.ts';
|
|
5
|
+
import { type EmbedDevice } from './models/embed-config.ts';
|
|
6
|
+
import type { ImageClamps } from './models/model-catalog.ts';
|
|
7
|
+
import type { ImageModelSet } from './tools/generate-image.ts';
|
|
8
|
+
import type { MusicClamps, MusicModelStages } from './tools/generate-music.ts';
|
|
9
|
+
export type MusicModelArg = string | (MusicModelStages & {
|
|
10
|
+
inferenceSteps?: number;
|
|
11
|
+
useGpu?: boolean;
|
|
12
|
+
});
|
|
13
|
+
export interface Logger {
|
|
14
|
+
info(...args: unknown[]): void;
|
|
15
|
+
warn(...args: unknown[]): void;
|
|
16
|
+
}
|
|
17
|
+
export interface HarnessLlmConfig {
|
|
18
|
+
llmDevice?: 'cpu' | 'gpu';
|
|
19
|
+
llmGpuLayers?: number;
|
|
20
|
+
contextSize?: number;
|
|
21
|
+
kvCacheK?: string;
|
|
22
|
+
kvCacheV?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface HarnessChildOptions {
|
|
25
|
+
runner: StowRunner;
|
|
26
|
+
skillsDir?: string;
|
|
27
|
+
wheelsDir?: string;
|
|
28
|
+
sdkStorage?: SdkStorage;
|
|
29
|
+
embedDevice?: EmbedDevice;
|
|
30
|
+
embedGpuLayers?: number;
|
|
31
|
+
embedBatchSize?: number;
|
|
32
|
+
imageModel?: string | ImageModelSet;
|
|
33
|
+
imageClamps?: ImageClamps;
|
|
34
|
+
musicModel?: MusicModelArg;
|
|
35
|
+
musicClamps?: MusicClamps;
|
|
36
|
+
llm?: HarnessLlmConfig;
|
|
37
|
+
onIpc?: (ipc: StowIpc) => void;
|
|
38
|
+
logger?: Logger | null;
|
|
39
|
+
deps?: string[];
|
|
40
|
+
restart?: 'always' | 'never';
|
|
41
|
+
maxRestarts?: number;
|
|
42
|
+
window?: number;
|
|
43
|
+
backoff?: number;
|
|
44
|
+
maxBackoff?: number;
|
|
45
|
+
}
|
|
46
|
+
export declare function harnessChild(entry: string, opts: HarnessChildOptions): ChildSpec<RemoteHarness>;
|
|
47
|
+
export interface SpawnHarnessOptions {
|
|
48
|
+
entry: string;
|
|
49
|
+
skillsDir?: string;
|
|
50
|
+
wheelsDir?: string;
|
|
51
|
+
sdkStorage: SdkStorage;
|
|
52
|
+
embedDevice?: EmbedDevice;
|
|
53
|
+
embedGpuLayers?: number;
|
|
54
|
+
embedBatchSize?: number;
|
|
55
|
+
imageModel?: string | ImageModelSet;
|
|
56
|
+
imageClamps?: ImageClamps;
|
|
57
|
+
musicModel?: MusicModelArg;
|
|
58
|
+
musicClamps?: MusicClamps;
|
|
59
|
+
llm?: HarnessLlmConfig;
|
|
60
|
+
logger?: Logger | null;
|
|
61
|
+
}
|
|
62
|
+
export declare function spawnHarness(opts: SpawnHarnessOptions): RemoteHarness;
|