@try-works/dsh-tool-mode 0.0.0-stage → 0.5.45
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/LICENSE +205 -0
- package/README.md +303 -2
- package/bin/dsh-tool-mode-credentials.mjs +20 -0
- package/bin/dsh-tool-mode-mcp-stdio.mjs +80 -0
- package/bin/dsh-tool-mode.mjs +211 -0
- package/builtins.lock.json +26 -0
- package/catalog/desert-ant-models.json +693 -0
- package/catalog/playbooks.json +531 -0
- package/client/client.model-tools.js +1910 -0
- package/client/index.js +4158 -0
- package/cordis.patch.yml +39 -0
- package/lib/adapters/index.d.ts +61 -0
- package/lib/adapters/index.d.ts.map +1 -0
- package/lib/adapters/index.js +82 -0
- package/lib/adapters/types.d.ts +106 -0
- package/lib/adapters/types.d.ts.map +1 -0
- package/lib/adapters/types.js +85 -0
- package/lib/approval.d.ts +189 -0
- package/lib/approval.d.ts.map +1 -0
- package/lib/approval.js +510 -0
- package/lib/asset-acquisition.d.ts +149 -0
- package/lib/asset-acquisition.d.ts.map +1 -0
- package/lib/asset-acquisition.js +175 -0
- package/lib/authority.d.ts +185 -0
- package/lib/authority.d.ts.map +1 -0
- package/lib/authority.js +223 -0
- package/lib/bindings.d.ts +144 -0
- package/lib/bindings.d.ts.map +1 -0
- package/lib/bindings.js +314 -0
- package/lib/builtins.d.ts +27 -0
- package/lib/builtins.d.ts.map +1 -0
- package/lib/builtins.js +37 -0
- package/lib/capability.d.ts +58 -0
- package/lib/capability.d.ts.map +1 -0
- package/lib/capability.js +192 -0
- package/lib/capture-path.d.ts +97 -0
- package/lib/capture-path.d.ts.map +1 -0
- package/lib/capture-path.js +152 -0
- package/lib/catalog.d.ts +37 -0
- package/lib/catalog.d.ts.map +1 -0
- package/lib/catalog.js +274 -0
- package/lib/contract-payload.d.ts +39 -0
- package/lib/contract-payload.d.ts.map +1 -0
- package/lib/contract-payload.js +56 -0
- package/lib/custom-tools/compile.d.ts +25 -0
- package/lib/custom-tools/compile.d.ts.map +1 -0
- package/lib/custom-tools/compile.js +61 -0
- package/lib/custom-tools/composite-executor.d.ts +42 -0
- package/lib/custom-tools/composite-executor.d.ts.map +1 -0
- package/lib/custom-tools/composite-executor.js +113 -0
- package/lib/custom-tools/dispatch.d.ts +28 -0
- package/lib/custom-tools/dispatch.d.ts.map +1 -0
- package/lib/custom-tools/dispatch.js +34 -0
- package/lib/custom-tools/http-executor.d.ts +48 -0
- package/lib/custom-tools/http-executor.d.ts.map +1 -0
- package/lib/custom-tools/http-executor.js +241 -0
- package/lib/custom-tools/index.d.ts +12 -0
- package/lib/custom-tools/index.d.ts.map +1 -0
- package/lib/custom-tools/index.js +12 -0
- package/lib/custom-tools/mcp-surface.d.ts +14 -0
- package/lib/custom-tools/mcp-surface.d.ts.map +1 -0
- package/lib/custom-tools/mcp-surface.js +41 -0
- package/lib/custom-tools/prompt-executor.d.ts +39 -0
- package/lib/custom-tools/prompt-executor.d.ts.map +1 -0
- package/lib/custom-tools/prompt-executor.js +59 -0
- package/lib/custom-tools/registry.d.ts +69 -0
- package/lib/custom-tools/registry.d.ts.map +1 -0
- package/lib/custom-tools/registry.js +130 -0
- package/lib/custom-tools/schema.d.ts +26 -0
- package/lib/custom-tools/schema.d.ts.map +1 -0
- package/lib/custom-tools/schema.js +375 -0
- package/lib/custom-tools/service.d.ts +90 -0
- package/lib/custom-tools/service.d.ts.map +1 -0
- package/lib/custom-tools/service.js +203 -0
- package/lib/custom-tools/store.d.ts +61 -0
- package/lib/custom-tools/store.d.ts.map +1 -0
- package/lib/custom-tools/store.js +240 -0
- package/lib/custom-tools/types.d.ts +131 -0
- package/lib/custom-tools/types.d.ts.map +1 -0
- package/lib/custom-tools/types.js +11 -0
- package/lib/decision-combine.d.ts +113 -0
- package/lib/decision-combine.d.ts.map +1 -0
- package/lib/decision-combine.js +156 -0
- package/lib/decision-evaluate.d.ts +185 -0
- package/lib/decision-evaluate.d.ts.map +1 -0
- package/lib/decision-evaluate.js +227 -0
- package/lib/deployment-coordinator.d.ts +213 -0
- package/lib/deployment-coordinator.d.ts.map +1 -0
- package/lib/deployment-coordinator.js +274 -0
- package/lib/diagnostics.d.ts +169 -0
- package/lib/diagnostics.d.ts.map +1 -0
- package/lib/diagnostics.js +136 -0
- package/lib/discovery-contracts.d.ts +14 -0
- package/lib/discovery-contracts.d.ts.map +1 -0
- package/lib/discovery-contracts.js +90 -0
- package/lib/discovery-describe.d.ts +35 -0
- package/lib/discovery-describe.d.ts.map +1 -0
- package/lib/discovery-describe.js +99 -0
- package/lib/embedding-index.d.ts +55 -0
- package/lib/embedding-index.d.ts.map +1 -0
- package/lib/embedding-index.js +126 -0
- package/lib/extension-dependencies.d.ts +355 -0
- package/lib/extension-dependencies.d.ts.map +1 -0
- package/lib/extension-dependencies.js +987 -0
- package/lib/extension-dispatch.d.ts +150 -0
- package/lib/extension-dispatch.d.ts.map +1 -0
- package/lib/extension-dispatch.js +178 -0
- package/lib/extension-page-state.d.ts +69 -0
- package/lib/extension-page-state.d.ts.map +1 -0
- package/lib/extension-page-state.js +82 -0
- package/lib/extension-registrar.d.ts +116 -0
- package/lib/extension-registrar.d.ts.map +1 -0
- package/lib/extension-registrar.js +144 -0
- package/lib/extensions-api.d.ts +346 -0
- package/lib/extensions-api.d.ts.map +1 -0
- package/lib/extensions-api.js +17 -0
- package/lib/extensions-remote.d.ts +57 -0
- package/lib/extensions-remote.d.ts.map +1 -0
- package/lib/extensions-remote.js +69 -0
- package/lib/extensions-service.d.ts +568 -0
- package/lib/extensions-service.d.ts.map +1 -0
- package/lib/extensions-service.js +2552 -0
- package/lib/harness-budgets.d.ts +158 -0
- package/lib/harness-budgets.d.ts.map +1 -0
- package/lib/harness-budgets.js +152 -0
- package/lib/harness-llm.d.ts +138 -0
- package/lib/harness-llm.d.ts.map +1 -0
- package/lib/harness-llm.js +218 -0
- package/lib/harness-serving.d.ts +115 -0
- package/lib/harness-serving.d.ts.map +1 -0
- package/lib/harness-serving.js +176 -0
- package/lib/headless.d.ts +97 -0
- package/lib/headless.d.ts.map +1 -0
- package/lib/headless.js +407 -0
- package/lib/http-acquisition.d.ts +27 -0
- package/lib/http-acquisition.d.ts.map +1 -0
- package/lib/http-acquisition.js +140 -0
- package/lib/index.d.ts +546 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5273 -0
- package/lib/invocation-accounting.d.ts +169 -0
- package/lib/invocation-accounting.d.ts.map +1 -0
- package/lib/invocation-accounting.js +148 -0
- package/lib/jev.d.ts +218 -0
- package/lib/jev.d.ts.map +1 -0
- package/lib/jev.js +366 -0
- package/lib/legacy-migration.d.ts +95 -0
- package/lib/legacy-migration.d.ts.map +1 -0
- package/lib/legacy-migration.js +429 -0
- package/lib/license-basis.d.ts +29 -0
- package/lib/license-basis.d.ts.map +1 -0
- package/lib/license-basis.js +58 -0
- package/lib/managed-workers.d.ts +158 -0
- package/lib/managed-workers.d.ts.map +1 -0
- package/lib/managed-workers.js +269 -0
- package/lib/mcp/auth-selection.d.ts +35 -0
- package/lib/mcp/auth-selection.d.ts.map +1 -0
- package/lib/mcp/auth-selection.js +64 -0
- package/lib/mcp/client-grant.d.ts +89 -0
- package/lib/mcp/client-grant.d.ts.map +1 -0
- package/lib/mcp/client-grant.js +63 -0
- package/lib/mcp/credential-cli.d.ts +38 -0
- package/lib/mcp/credential-cli.d.ts.map +1 -0
- package/lib/mcp/credential-cli.js +148 -0
- package/lib/mcp/credential-store.d.ts +143 -0
- package/lib/mcp/credential-store.d.ts.map +1 -0
- package/lib/mcp/credential-store.js +461 -0
- package/lib/mcp/export-policy.d.ts +25 -0
- package/lib/mcp/export-policy.d.ts.map +1 -0
- package/lib/mcp/export-policy.js +31 -0
- package/lib/mcp/host-binding.d.ts +144 -0
- package/lib/mcp/host-binding.d.ts.map +1 -0
- package/lib/mcp/host-binding.js +280 -0
- package/lib/mcp/http.d.ts +180 -0
- package/lib/mcp/http.d.ts.map +1 -0
- package/lib/mcp/http.js +602 -0
- package/lib/mcp/oauth.d.ts +149 -0
- package/lib/mcp/oauth.d.ts.map +1 -0
- package/lib/mcp/oauth.js +396 -0
- package/lib/mcp/protocol.d.ts +329 -0
- package/lib/mcp/protocol.d.ts.map +1 -0
- package/lib/mcp/protocol.js +459 -0
- package/lib/mcp/rate-limit.d.ts +68 -0
- package/lib/mcp/rate-limit.d.ts.map +1 -0
- package/lib/mcp/rate-limit.js +114 -0
- package/lib/mcp/sdk-v2.d.ts +17 -0
- package/lib/mcp/sdk-v2.d.ts.map +1 -0
- package/lib/mcp/sdk-v2.js +204 -0
- package/lib/mcp/server.d.ts +149 -0
- package/lib/mcp/server.d.ts.map +1 -0
- package/lib/mcp/server.js +302 -0
- package/lib/mcp/stdio.d.ts +80 -0
- package/lib/mcp/stdio.d.ts.map +1 -0
- package/lib/mcp/stdio.js +184 -0
- package/lib/mcp/subscriptions.d.ts +177 -0
- package/lib/mcp/subscriptions.d.ts.map +1 -0
- package/lib/mcp/subscriptions.js +288 -0
- package/lib/mcp-status.d.ts +96 -0
- package/lib/mcp-status.d.ts.map +1 -0
- package/lib/mcp-status.js +70 -0
- package/lib/mcp-usage.d.ts +110 -0
- package/lib/mcp-usage.d.ts.map +1 -0
- package/lib/mcp-usage.js +189 -0
- package/lib/model-qualification.d.ts +192 -0
- package/lib/model-qualification.d.ts.map +1 -0
- package/lib/model-qualification.js +178 -0
- package/lib/model-runtime-lane.d.ts +69 -0
- package/lib/model-runtime-lane.d.ts.map +1 -0
- package/lib/model-runtime-lane.js +122 -0
- package/lib/model-runtime-recipe.d.ts +132 -0
- package/lib/model-runtime-recipe.d.ts.map +1 -0
- package/lib/model-runtime-recipe.js +291 -0
- package/lib/planning.d.ts +256 -0
- package/lib/planning.d.ts.map +1 -0
- package/lib/planning.js +471 -0
- package/lib/playbook.d.ts +42 -0
- package/lib/playbook.d.ts.map +1 -0
- package/lib/playbook.js +65 -0
- package/lib/prepared-assets.d.ts +269 -0
- package/lib/prepared-assets.d.ts.map +1 -0
- package/lib/prepared-assets.js +471 -0
- package/lib/provider-bridge.d.ts +107 -0
- package/lib/provider-bridge.d.ts.map +1 -0
- package/lib/provider-bridge.js +423 -0
- package/lib/ptc-authority.d.ts +154 -0
- package/lib/ptc-authority.d.ts.map +1 -0
- package/lib/ptc-authority.js +242 -0
- package/lib/ptc-confinement.d.ts +60 -0
- package/lib/ptc-confinement.d.ts.map +1 -0
- package/lib/ptc-confinement.js +212 -0
- package/lib/ptc-runtime.d.ts +166 -0
- package/lib/ptc-runtime.d.ts.map +1 -0
- package/lib/ptc-runtime.js +231 -0
- package/lib/publication.d.ts +161 -0
- package/lib/publication.d.ts.map +1 -0
- package/lib/publication.js +181 -0
- package/lib/receipt-store.d.ts +57 -0
- package/lib/receipt-store.d.ts.map +1 -0
- package/lib/receipt-store.js +143 -0
- package/lib/receipt.d.ts +231 -0
- package/lib/receipt.d.ts.map +1 -0
- package/lib/receipt.js +165 -0
- package/lib/registrar.d.ts +75 -0
- package/lib/registrar.d.ts.map +1 -0
- package/lib/registrar.js +152 -0
- package/lib/resource-governance.d.ts +204 -0
- package/lib/resource-governance.d.ts.map +1 -0
- package/lib/resource-governance.js +213 -0
- package/lib/server-lifecycle.d.ts +175 -0
- package/lib/server-lifecycle.d.ts.map +1 -0
- package/lib/server-lifecycle.js +269 -0
- package/lib/skills.d.ts +31 -0
- package/lib/skills.d.ts.map +1 -0
- package/lib/skills.js +170 -0
- package/lib/speech-bridge.d.ts +74 -0
- package/lib/speech-bridge.d.ts.map +1 -0
- package/lib/speech-bridge.js +115 -0
- package/lib/state.d.ts +100 -0
- package/lib/state.d.ts.map +1 -0
- package/lib/state.js +160 -0
- package/lib/title-proposal.d.ts +194 -0
- package/lib/title-proposal.d.ts.map +1 -0
- package/lib/title-proposal.js +244 -0
- package/lib/tool-inventory.d.ts +90 -0
- package/lib/tool-inventory.d.ts.map +1 -0
- package/lib/tool-inventory.js +102 -0
- package/lib/tool-mode-run.d.ts +310 -0
- package/lib/tool-mode-run.d.ts.map +1 -0
- package/lib/tool-mode-run.js +411 -0
- package/lib/tool-sources.d.ts +80 -0
- package/lib/tool-sources.d.ts.map +1 -0
- package/lib/tool-sources.js +123 -0
- package/lib/tool-usage-projection.d.ts +390 -0
- package/lib/tool-usage-projection.d.ts.map +1 -0
- package/lib/tool-usage-projection.js +1038 -0
- package/lib/tool-usage-report.d.ts +153 -0
- package/lib/tool-usage-report.d.ts.map +1 -0
- package/lib/tool-usage-report.js +274 -0
- package/lib/transport.d.ts +158 -0
- package/lib/transport.d.ts.map +1 -0
- package/lib/transport.js +332 -0
- package/lib/types.d.ts +134 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +8 -0
- package/lib/update-surface.d.ts +79 -0
- package/lib/update-surface.d.ts.map +1 -0
- package/lib/update-surface.js +224 -0
- package/lib/version.d.ts +3 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +27 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts +13 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.js +85 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts +16 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.js +87 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts +38 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.js +445 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts +20 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.js +112 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts +14 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.js +63 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts +14 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.js +76 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts +82 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/dsh.js +274 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts +26 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/index.js +53 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts +133 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/meta.js +64 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts +121 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.js +246 -0
- package/node_modules/@try-works/tool-mode-contracts/package.json +35 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/bin/dsh-tool-mode.mjs +20 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts +80 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.js +533 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts +86 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.js +145 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts +70 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.js +201 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts +57 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.js +83 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts +33 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.js +33 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts +86 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.js +191 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts +137 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.js +349 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts +274 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.js +932 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts +210 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.js +368 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts +63 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.js +149 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts +35 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.js +179 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts +179 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.js +299 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts +395 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.js +839 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts +44 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.js +255 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts +185 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.js +504 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts +17 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.js +80 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts +221 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.js +188 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts +52 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.js +102 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts +171 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.js +271 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts +242 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.js +58 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts +128 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.js +113 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts +41 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.js +52 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts +2 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.js +351 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts +157 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.js +688 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/package.json +54 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/schema/extension-manifest-1.1.0.schema.json +253 -0
- package/node_modules/@try-works/tool-mode-recipes/bin/tool-mode-recipe.mjs +15 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts +460 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/broker.js +647 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts +61 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/cli.js +1106 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts +237 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.js +205 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts +85 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.js +176 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts +119 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/images.js +201 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts +25 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/index.js +25 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts +345 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.js +1465 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts +51 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/templates.js +310 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts +231 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/titles.js +435 -0
- package/node_modules/@try-works/tool-mode-recipes/package.json +56 -0
- package/node_modules/@try-works/tool-mode-recipes/recipes/describe-image.json +38 -0
- package/node_modules/@try-works/tool-mode-recipes/recipes/text-title.json +45 -0
- package/node_modules/@try-works/tool-mode-recipes/schema/harness-model-recipe.schema.json +273 -0
- package/package.json +127 -4
- package/remote/spec.mjs +993 -0
- package/remote/typert.host.mjs +14 -0
- package/remote/typert.remote-client.mjs +16 -0
package/lib/skills.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill publication: teaches an agent when and how to use each model tool.
|
|
3
|
+
*
|
|
4
|
+
* A tool schema tells the model what it *can* call; a skill tells it when the
|
|
5
|
+
* call is the right move, when it is the wrong one, and how the result should be
|
|
6
|
+
* used downstream. This module renders one skill body per registered model from
|
|
7
|
+
* the catalog plus that model's playbook entry.
|
|
8
|
+
*
|
|
9
|
+
* @module @try-works/dsh-tool-mode/skills
|
|
10
|
+
*/
|
|
11
|
+
import type { ModelCatalogEntry } from './types.ts';
|
|
12
|
+
import type { ModelPlaybook } from './playbook.ts';
|
|
13
|
+
/**
|
|
14
|
+
* Render the instruction body for one model's skill.
|
|
15
|
+
*
|
|
16
|
+
* The body is deliberately procedural: it names the tool, states the trigger
|
|
17
|
+
* conditions, states the anti-triggers, and describes what to do with the
|
|
18
|
+
* result. Sections with no content are omitted rather than rendered empty, so a
|
|
19
|
+
* sparse playbook still produces a clean skill.
|
|
20
|
+
* @param entry - the catalog entry.
|
|
21
|
+
* @param playbook - the model's playbook, when one is authored.
|
|
22
|
+
* @returns the markdown skill body.
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderSkillBody(entry: ModelCatalogEntry, playbook?: ModelPlaybook): string;
|
|
25
|
+
/**
|
|
26
|
+
* A locally useful data-handling statement derived from the catalog route (DECL-05).
|
|
27
|
+
* @param entry - the catalog entry.
|
|
28
|
+
* @returns one sentence about where the input goes.
|
|
29
|
+
*/
|
|
30
|
+
export declare function describeDataHandling(entry: ModelCatalogEntry): string;
|
|
31
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,MAAM,CA2G1F;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAcrE"}
|
package/lib/skills.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill publication: teaches an agent when and how to use each model tool.
|
|
3
|
+
*
|
|
4
|
+
* A tool schema tells the model what it *can* call; a skill tells it when the
|
|
5
|
+
* call is the right move, when it is the wrong one, and how the result should be
|
|
6
|
+
* used downstream. This module renders one skill body per registered model from
|
|
7
|
+
* the catalog plus that model's playbook entry.
|
|
8
|
+
*
|
|
9
|
+
* @module @try-works/dsh-tool-mode/skills
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Render the instruction body for one model's skill.
|
|
13
|
+
*
|
|
14
|
+
* The body is deliberately procedural: it names the tool, states the trigger
|
|
15
|
+
* conditions, states the anti-triggers, and describes what to do with the
|
|
16
|
+
* result. Sections with no content are omitted rather than rendered empty, so a
|
|
17
|
+
* sparse playbook still produces a clean skill.
|
|
18
|
+
* @param entry - the catalog entry.
|
|
19
|
+
* @param playbook - the model's playbook, when one is authored.
|
|
20
|
+
* @returns the markdown skill body.
|
|
21
|
+
*/
|
|
22
|
+
export function renderSkillBody(entry, playbook) {
|
|
23
|
+
const lines = [];
|
|
24
|
+
lines.push(`# ${entry.name}`, '');
|
|
25
|
+
lines.push(entry.summary, '');
|
|
26
|
+
lines.push(`Call the \`${entry.tool.name}\` tool. ${entry.tool.returns}`, '');
|
|
27
|
+
lines.push('## When to use', '');
|
|
28
|
+
if (playbook !== undefined && playbook.whenToUse.length > 0) {
|
|
29
|
+
for (const item of playbook.whenToUse)
|
|
30
|
+
lines.push(`- ${item}`);
|
|
31
|
+
}
|
|
32
|
+
else if (entry.skill.whenToUse !== undefined) {
|
|
33
|
+
lines.push(`- ${entry.skill.whenToUse}`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
lines.push(`- ${entry.summary}`);
|
|
37
|
+
}
|
|
38
|
+
lines.push('');
|
|
39
|
+
if (playbook !== undefined && playbook.whenNotToUse.length > 0) {
|
|
40
|
+
lines.push('## When not to use', '');
|
|
41
|
+
for (const item of playbook.whenNotToUse)
|
|
42
|
+
lines.push(`- ${item}`);
|
|
43
|
+
lines.push('');
|
|
44
|
+
}
|
|
45
|
+
if (playbook !== undefined && playbook.useCases.length > 0) {
|
|
46
|
+
lines.push('## Use cases', '');
|
|
47
|
+
for (const item of playbook.useCases)
|
|
48
|
+
lines.push(`- ${item}`);
|
|
49
|
+
lines.push('');
|
|
50
|
+
}
|
|
51
|
+
lines.push('## Calling it', '');
|
|
52
|
+
lines.push(`- Tool: \`${entry.tool.name}\``);
|
|
53
|
+
lines.push(`- Primary input: ${entry.input}`);
|
|
54
|
+
lines.push(`- Runs: ${describeRoute(entry)}`);
|
|
55
|
+
lines.push('');
|
|
56
|
+
for (const [name, param] of Object.entries(entry.tool.params)) {
|
|
57
|
+
lines.push(`- \`${name}\` (${param.type ?? 'string'}): ${param.description}`);
|
|
58
|
+
}
|
|
59
|
+
lines.push('');
|
|
60
|
+
if (playbook !== undefined && playbook.workflow.length > 0) {
|
|
61
|
+
lines.push('## Workflow', '');
|
|
62
|
+
playbook.workflow.forEach((step, index) => lines.push(`${index + 1}. ${step}`));
|
|
63
|
+
lines.push('');
|
|
64
|
+
}
|
|
65
|
+
if (playbook !== undefined && playbook.pairsWith.length > 0) {
|
|
66
|
+
lines.push('## Pairs with', '');
|
|
67
|
+
for (const item of playbook.pairsWith)
|
|
68
|
+
lines.push(`- ${item}`);
|
|
69
|
+
lines.push('');
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Native AND Code Mode examples, generated from the tool's parameter map so a
|
|
73
|
+
* changed parameter changes the example rather than leaving hand-written prose to
|
|
74
|
+
* drift (DECL-05).
|
|
75
|
+
*/
|
|
76
|
+
lines.push('## Examples', '');
|
|
77
|
+
const example = exampleArguments(entry);
|
|
78
|
+
lines.push('Native call:', '');
|
|
79
|
+
lines.push('```json', JSON.stringify({ tool: entry.tool.name, arguments: example }, null, 2), '```', '');
|
|
80
|
+
lines.push('Code Mode:', '');
|
|
81
|
+
lines.push('```js');
|
|
82
|
+
lines.push(`const result = await tools.${entry.tool.name}(${JSON.stringify(example)});`);
|
|
83
|
+
lines.push('return result;');
|
|
84
|
+
lines.push('```', '');
|
|
85
|
+
lines.push('## Unsupported', '');
|
|
86
|
+
const unsupported = playbook?.whenNotToUse ?? [];
|
|
87
|
+
if (unsupported.length === 0) {
|
|
88
|
+
lines.push('- No additional unsupported cases are declared for this tool.');
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
for (const item of unsupported)
|
|
92
|
+
lines.push(`- ${item}`);
|
|
93
|
+
}
|
|
94
|
+
lines.push('');
|
|
95
|
+
lines.push('## Data handling', '');
|
|
96
|
+
lines.push(`- ${describeDataHandling(entry)}`);
|
|
97
|
+
lines.push('');
|
|
98
|
+
lines.push('## Recovery', '');
|
|
99
|
+
lines.push('- If the tool is unavailable, prepare and enable the model through the operator surface; do not install an '
|
|
100
|
+
+ 'arbitrary package to work around it.');
|
|
101
|
+
lines.push('- If the call reports a validation error, fix the named argument; do not retry the same input unchanged.');
|
|
102
|
+
lines.push('- If the model returns a refusal or a model error, surface it to the caller. Do not silently fall back to a '
|
|
103
|
+
+ 'remote provider or convert the input to another modality.');
|
|
104
|
+
lines.push('');
|
|
105
|
+
if (playbook !== undefined && playbook.caveats.length > 0) {
|
|
106
|
+
lines.push('## Caveats', '');
|
|
107
|
+
for (const item of playbook.caveats)
|
|
108
|
+
lines.push(`- ${item}`);
|
|
109
|
+
lines.push('');
|
|
110
|
+
}
|
|
111
|
+
lines.push('## Licensing', '');
|
|
112
|
+
lines.push(`The ${entry.name} weights are licensed under the Desert Ant Labs Source-Available License `
|
|
113
|
+
+ `(https://license.desertant.com/1.0), not an open-source license. Inference is unlimited and free below `
|
|
114
|
+
+ '100,000 monthly active devices per platform per model; attribution is required and the models may not be '
|
|
115
|
+
+ 'redistributed or re-hosted as a service. Run it locally through this tool rather than proxying it to others.', '');
|
|
116
|
+
return lines.join('\n');
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A locally useful data-handling statement derived from the catalog route (DECL-05).
|
|
120
|
+
* @param entry - the catalog entry.
|
|
121
|
+
* @returns one sentence about where the input goes.
|
|
122
|
+
*/
|
|
123
|
+
export function describeDataHandling(entry) {
|
|
124
|
+
switch (entry.windowsSupport) {
|
|
125
|
+
case 'native-node':
|
|
126
|
+
case 'onnxruntime-node':
|
|
127
|
+
case 'browser-only':
|
|
128
|
+
return `Runs in-process through ${entry.npmPackage}; this tool does not send the input to a remote service.`;
|
|
129
|
+
case 'apple-only':
|
|
130
|
+
return 'Runs on an Apple device through the Swift SDK; this Node process cannot execute it without an explicitly configured bridge.';
|
|
131
|
+
case 'no-sdk':
|
|
132
|
+
return 'No runtime is available here, so the tool cannot receive input at all.';
|
|
133
|
+
/* v8 ignore next -- closed union; a new member must fail compilation here. */
|
|
134
|
+
default:
|
|
135
|
+
return 'The execution route does not declare where input goes; treat that as unknown rather than as local.';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** A schema-shaped example argument object from the catalog parameter map. */
|
|
139
|
+
function exampleArguments(entry) {
|
|
140
|
+
return Object.fromEntries(Object.entries(entry.tool.params).map(([name, param]) => [name, sampleValue(param.type)]));
|
|
141
|
+
}
|
|
142
|
+
/** One representative value per declared JSON type. */
|
|
143
|
+
function sampleValue(type) {
|
|
144
|
+
switch (type) {
|
|
145
|
+
case 'integer':
|
|
146
|
+
case 'number': return 1;
|
|
147
|
+
case 'boolean': return true;
|
|
148
|
+
case 'string[]': return ['example'];
|
|
149
|
+
default: return 'example';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/** A short human description of how this model reaches its runtime. */
|
|
153
|
+
function describeRoute(entry) {
|
|
154
|
+
switch (entry.windowsSupport) {
|
|
155
|
+
case 'native-node':
|
|
156
|
+
return `in-process through ${entry.npmPackage}`;
|
|
157
|
+
case 'onnxruntime-node':
|
|
158
|
+
return `in-process through ${entry.npmPackage} with ${entry.requiresRuntime.join(', ')}`;
|
|
159
|
+
case 'browser-only':
|
|
160
|
+
return `in-process through ${entry.npmPackage}${entry.npmSubpath ?? ''} on linux-x64, linux-arm64 and darwin-arm64`;
|
|
161
|
+
case 'apple-only':
|
|
162
|
+
return 'on Apple platforms only, through the Swift SDK; not available to this process';
|
|
163
|
+
case 'no-sdk':
|
|
164
|
+
return 'nowhere yet: the weights are published but no SDK ships them';
|
|
165
|
+
/* v8 ignore next -- closed union; a new member must fail compilation here. */
|
|
166
|
+
default:
|
|
167
|
+
return 'by an unspecified route';
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ARCH-04 — the local Voz deployment as a shared `speechToText` provider.
|
|
3
|
+
*
|
|
4
|
+
* DSH exposes an experimental `speechToText` registry. This bridge registers a
|
|
5
|
+
* host-local provider whose `transcribe()` dispatches to the SAME `stt_transcribe`
|
|
6
|
+
* tool the native and MCP surfaces already use, so a speech request never starts
|
|
7
|
+
* a second Voz instance merely because another transport connected.
|
|
8
|
+
*
|
|
9
|
+
* The bridge is deliberately structural: the harness speech package is not a
|
|
10
|
+
* hard dependency, and an older DSH without the service simply gets no bridge.
|
|
11
|
+
*/
|
|
12
|
+
/** The provider facts the DSH speech registry reads. */
|
|
13
|
+
export interface SpeechProviderInfoLike {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly location: 'host-local' | 'cloud';
|
|
17
|
+
readonly languages: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
/** One provider the DSH speech registry accepts. */
|
|
20
|
+
export interface SpeechProviderLike {
|
|
21
|
+
readonly info: SpeechProviderInfoLike;
|
|
22
|
+
transcribe(input: {
|
|
23
|
+
readonly audio: Uint8Array;
|
|
24
|
+
readonly language: string;
|
|
25
|
+
}, signal: AbortSignal): Promise<{
|
|
26
|
+
readonly text: string;
|
|
27
|
+
readonly audioSeconds: number;
|
|
28
|
+
readonly inferenceSeconds: number;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
/** The slice of the DSH speech service this bridge uses. */
|
|
32
|
+
export interface SpeechRegistryLike {
|
|
33
|
+
register(provider: SpeechProviderLike): () => Promise<void>;
|
|
34
|
+
/** The live provider roster, when the host exposes it. */
|
|
35
|
+
listProviders?(): readonly {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
}[];
|
|
38
|
+
}
|
|
39
|
+
/** The slice of the host tool runtime this bridge uses. */
|
|
40
|
+
export interface ToolExecutorLike {
|
|
41
|
+
execute(request: {
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly arguments: Readonly<Record<string, unknown>>;
|
|
44
|
+
readonly signal: AbortSignal;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
readonly isError?: boolean;
|
|
47
|
+
readonly value?: unknown;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
/** Options for {@link installVozSpeechProvider}. */
|
|
51
|
+
export interface VozSpeechBridgeOptions {
|
|
52
|
+
/** Directory owned by the host for the short-lived WAV handoff. */
|
|
53
|
+
readonly stateDir: string;
|
|
54
|
+
/** The already-published Voz tool; defaults to `stt_transcribe`. */
|
|
55
|
+
readonly toolName?: string;
|
|
56
|
+
/** Provider id shown to the speech UI. */
|
|
57
|
+
readonly providerId?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Called when the bridge contributes nothing because the provider is already
|
|
60
|
+
* served (either visible through `listProviders()` or refused by `register()`).
|
|
61
|
+
* A skip is not an error: the existing provider remains the one deployment, and
|
|
62
|
+
* the caller can record the reason at the same level it would log one.
|
|
63
|
+
*/
|
|
64
|
+
readonly onSkipped?: (reason: string) => void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Register the Voz-backed speech provider.
|
|
68
|
+
* @param registry - the DSH speech service.
|
|
69
|
+
* @param tools - the host tool runtime that owns the one Voz deployment.
|
|
70
|
+
* @param options - local state directory and names.
|
|
71
|
+
* @returns the idempotent unregister function.
|
|
72
|
+
*/
|
|
73
|
+
export declare function installVozSpeechProvider(registry: SpeechRegistryLike, tools: ToolExecutorLike, options: VozSpeechBridgeOptions): () => Promise<void>;
|
|
74
|
+
//# sourceMappingURL=speech-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speech-bridge.d.ts","sourceRoot":"","sources":["../src/speech-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,wDAAwD;AACxD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAA;IACzC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;CACtC;AAED,oDAAoD;AACpD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;IACrC,UAAU,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC;QACzG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;QACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;QAC7B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;KAClC,CAAC,CAAA;CACH;AAED,4DAA4D;AAC5D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3D,0DAA0D;IAC1D,aAAa,CAAC,IAAI,SAAS;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CACrD;AAED,2DAA2D;AAC3D,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,OAAO,EAAE;QACf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;QACrB,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;QACrD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;KAC7B,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;CACtE;AAED,oDAAoD;AACpD,MAAM,WAAW,sBAAsB;IACrC,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9C;AAiCD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,kBAAkB,EAC5B,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,sBAAsB,GAC9B,MAAM,OAAO,CAAC,IAAI,CAAC,CA+DrB"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ARCH-04 — the local Voz deployment as a shared `speechToText` provider.
|
|
3
|
+
*
|
|
4
|
+
* DSH exposes an experimental `speechToText` registry. This bridge registers a
|
|
5
|
+
* host-local provider whose `transcribe()` dispatches to the SAME `stt_transcribe`
|
|
6
|
+
* tool the native and MCP surfaces already use, so a speech request never starts
|
|
7
|
+
* a second Voz instance merely because another transport connected.
|
|
8
|
+
*
|
|
9
|
+
* The bridge is deliberately structural: the harness speech package is not a
|
|
10
|
+
* hard dependency, and an older DSH without the service simply gets no bridge.
|
|
11
|
+
*/
|
|
12
|
+
import { mkdtempSync, rmSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
/** The registration refusal DSH's speech registry raises for a duplicate id. */
|
|
15
|
+
const DUPLICATE_REGISTRATION_PREFIX = 'Speech provider already registered';
|
|
16
|
+
/**
|
|
17
|
+
* Whether an error is the registry's duplicate-provider refusal for THIS id.
|
|
18
|
+
*
|
|
19
|
+
* Only that one fault is recoverable. A registry that is unavailable, a malformed
|
|
20
|
+
* provider or any other throw is a real failure and must keep propagating: swallowing
|
|
21
|
+
* it would silently disable speech for the whole process.
|
|
22
|
+
* @param error - the thrown value.
|
|
23
|
+
* @param providerId - the id this bridge tried to register.
|
|
24
|
+
* @returns true only for the duplicate refusal naming this provider.
|
|
25
|
+
*/
|
|
26
|
+
function isDuplicateProviderError(error, providerId) {
|
|
27
|
+
return error instanceof Error
|
|
28
|
+
&& error.message.startsWith(DUPLICATE_REGISTRATION_PREFIX)
|
|
29
|
+
&& error.message.includes(providerId);
|
|
30
|
+
}
|
|
31
|
+
/** The one-line reason recorded when the bridge yields to an existing provider. */
|
|
32
|
+
function skipReason(providerId) {
|
|
33
|
+
return `speech provider "${providerId}" is already registered; keeping the existing provider `
|
|
34
|
+
+ '(the Voz tool bridge contributes nothing and is not needed)';
|
|
35
|
+
}
|
|
36
|
+
/** Languages the local Voz model accepts as hints; `auto` is the model's own mode. */
|
|
37
|
+
const VOZ_LANGUAGES = [
|
|
38
|
+
'auto', 'en', 'de', 'fr', 'es', 'it', 'pt', 'nl', 'pl', 'ru', 'uk', 'tr',
|
|
39
|
+
'zh', 'ja', 'ko', 'ar', 'hi', 'vi', 'th', 'id',
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* Register the Voz-backed speech provider.
|
|
43
|
+
* @param registry - the DSH speech service.
|
|
44
|
+
* @param tools - the host tool runtime that owns the one Voz deployment.
|
|
45
|
+
* @param options - local state directory and names.
|
|
46
|
+
* @returns the idempotent unregister function.
|
|
47
|
+
*/
|
|
48
|
+
export function installVozSpeechProvider(registry, tools, options) {
|
|
49
|
+
const toolName = options.toolName ?? 'stt_transcribe';
|
|
50
|
+
const providerId = options.providerId ?? 'voz-local';
|
|
51
|
+
/*
|
|
52
|
+
* A profile may also mount the standalone STT plugin, which registers the same
|
|
53
|
+
* `voz-local` id. The speech registry refuses duplicates, and an uncaught throw
|
|
54
|
+
* here aborts the WHOLE model-tools plugin apply (settings, MCP, every tool).
|
|
55
|
+
* If the id is already served, this bridge contributes nothing; the existing
|
|
56
|
+
* provider remains the one headless deployment.
|
|
57
|
+
*/
|
|
58
|
+
if (registry.listProviders?.().some(provider => provider.id === providerId) === true) {
|
|
59
|
+
options.onSkipped?.(skipReason(providerId));
|
|
60
|
+
return async () => { };
|
|
61
|
+
}
|
|
62
|
+
const provider = {
|
|
63
|
+
info: {
|
|
64
|
+
id: providerId,
|
|
65
|
+
name: 'Desert Ant Voz (local)',
|
|
66
|
+
location: 'host-local',
|
|
67
|
+
languages: VOZ_LANGUAGES,
|
|
68
|
+
},
|
|
69
|
+
async transcribe(input, signal) {
|
|
70
|
+
signal.throwIfAborted();
|
|
71
|
+
mkdirSync(options.stateDir, { recursive: true });
|
|
72
|
+
const dir = mkdtempSync(join(options.stateDir, 'voz-speech-'));
|
|
73
|
+
const path = join(dir, 'recording.wav');
|
|
74
|
+
try {
|
|
75
|
+
writeFileSync(path, input.audio);
|
|
76
|
+
const started = Date.now();
|
|
77
|
+
const result = await tools.execute({
|
|
78
|
+
name: toolName,
|
|
79
|
+
arguments: { audio: { path }, language: input.language },
|
|
80
|
+
signal,
|
|
81
|
+
});
|
|
82
|
+
if (result.isError === true) {
|
|
83
|
+
throw new Error(`the local Voz provider refused the recording: ${JSON.stringify(result.value)}`);
|
|
84
|
+
}
|
|
85
|
+
const value = (result.value ?? {});
|
|
86
|
+
const coverage = (value.coverage ?? {});
|
|
87
|
+
const audioSeconds = typeof coverage.transcribedSeconds === 'number' ? coverage.transcribedSeconds : 0;
|
|
88
|
+
return {
|
|
89
|
+
text: typeof value.text === 'string' ? value.text : '',
|
|
90
|
+
audioSeconds,
|
|
91
|
+
inferenceSeconds: (Date.now() - started) / 1000,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
rmSync(dir, { recursive: true, force: true });
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
/*
|
|
100
|
+
* The roster is not authoritative for the outcome: it can lag a provider that
|
|
101
|
+
* registered after the fast-path check (a standalone STT plugin, or a race). The
|
|
102
|
+
* registry then refuses OUR registration with the duplicate message, and that ONE
|
|
103
|
+
* refusal is a skip, not a plugin failure. Every other throw propagates.
|
|
104
|
+
*/
|
|
105
|
+
try {
|
|
106
|
+
return registry.register(provider);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (!isDuplicateProviderError(error, providerId))
|
|
110
|
+
throw error;
|
|
111
|
+
options.onSkipped?.(skipReason(providerId));
|
|
112
|
+
return async () => { };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=speech-bridge.js.map
|
package/lib/state.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable install state: which models the user has enabled or disabled.
|
|
3
|
+
*
|
|
4
|
+
* A plugin's `config` states the *deployment* default — what a profile ships
|
|
5
|
+
* with. This store records the *user's* runtime choices on top of it, so an
|
|
6
|
+
* `enable`/`disable` survives a restart instead of evaporating with the session.
|
|
7
|
+
*
|
|
8
|
+
* The two layers are kept distinct on purpose:
|
|
9
|
+
*
|
|
10
|
+
* - `disabled` always wins, so a user can turn off something the config ships.
|
|
11
|
+
* - `enabled` adds to the config selection, so a user can turn on something the
|
|
12
|
+
* config omitted without editing YAML.
|
|
13
|
+
*
|
|
14
|
+
* Writing to a file rather than back into the profile's `cordis.patch.yml` keeps
|
|
15
|
+
* the plugin out of the user's configuration: a rewrite there would fight the
|
|
16
|
+
* HMR reload and could clobber comments the user wrote.
|
|
17
|
+
*
|
|
18
|
+
* @module @try-works/dsh-tool-mode/state
|
|
19
|
+
*/
|
|
20
|
+
/** The persisted user choices. */
|
|
21
|
+
export interface PersistedState {
|
|
22
|
+
/** Model ids the user turned on beyond the configured selection. */
|
|
23
|
+
readonly enabled: readonly string[];
|
|
24
|
+
/** Model ids the user turned off, overriding the configured selection. */
|
|
25
|
+
readonly disabled: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
/** An empty state. */
|
|
28
|
+
export declare const EMPTY_STATE: PersistedState;
|
|
29
|
+
/** Read and write the durable state. Injectable so tests need no filesystem. */
|
|
30
|
+
export interface StateStore {
|
|
31
|
+
/** Read the current state; an absent or unreadable store is empty, not an error. */
|
|
32
|
+
read(): PersistedState;
|
|
33
|
+
/** Replace the state, durably. */
|
|
34
|
+
write(state: PersistedState): void;
|
|
35
|
+
}
|
|
36
|
+
/** Raised when a state file exists but cannot be understood. */
|
|
37
|
+
export declare class StateError extends Error {
|
|
38
|
+
readonly name = "StateError";
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Normalize a decoded state document.
|
|
42
|
+
*
|
|
43
|
+
* Unknown keys are dropped and non-string entries are rejected rather than
|
|
44
|
+
* silently ignored: a corrupted list is a bug worth surfacing, while a
|
|
45
|
+
* forward-compatible extra key is not.
|
|
46
|
+
* @param raw - the decoded JSON value.
|
|
47
|
+
* @param source - description of the origin, for messages.
|
|
48
|
+
* @returns the normalized state.
|
|
49
|
+
* @throws StateError when the document is not a valid state.
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseState(raw: unknown, source: string): PersistedState;
|
|
52
|
+
/**
|
|
53
|
+
* Derive the default state file from the environment.
|
|
54
|
+
*
|
|
55
|
+
* DSH sets `DSH_HOME`; falling back to `~/.dsh` matches the launcher's own
|
|
56
|
+
* convention for a process started without it.
|
|
57
|
+
* @param env - the environment to read; defaults to the process environment.
|
|
58
|
+
* @returns the absolute path of the state file.
|
|
59
|
+
*/
|
|
60
|
+
export declare function defaultStateFile(env?: NodeJS.ProcessEnv): string;
|
|
61
|
+
/**
|
|
62
|
+
* Build a file-backed store.
|
|
63
|
+
*
|
|
64
|
+
* Writes go through a temporary file and a rename, so a crash mid-write leaves
|
|
65
|
+
* the previous state intact rather than a truncated document that would read as
|
|
66
|
+
* "everything the user configured is gone".
|
|
67
|
+
* @param file - absolute path of the state file.
|
|
68
|
+
* @returns the store.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createFileStateStore(file: string): StateStore;
|
|
71
|
+
/**
|
|
72
|
+
* Build an in-memory store, for tests and for deployments that asked for no
|
|
73
|
+
* persistence.
|
|
74
|
+
* @param initial - the starting state.
|
|
75
|
+
* @returns the store.
|
|
76
|
+
*/
|
|
77
|
+
export declare function createMemoryStateStore(initial?: PersistedState): StateStore;
|
|
78
|
+
/**
|
|
79
|
+
* Apply one enable/disable choice to a state.
|
|
80
|
+
*
|
|
81
|
+
* The two lists are kept mutually exclusive so the merge rule never has to
|
|
82
|
+
* break a tie: enabling a model removes it from `disabled` and vice versa.
|
|
83
|
+
* @param state - the current state.
|
|
84
|
+
* @param modelId - the model the user acted on.
|
|
85
|
+
* @param enabled - true to turn on, false to turn off.
|
|
86
|
+
* @returns the updated state.
|
|
87
|
+
*/
|
|
88
|
+
export declare function withChoice(state: PersistedState, modelId: string, enabled: boolean): PersistedState;
|
|
89
|
+
/**
|
|
90
|
+
* Decide the effective installed set from the configured selection and the
|
|
91
|
+
* user's persisted choices.
|
|
92
|
+
* @param configured - model ids the config selects (already intersected with what can run).
|
|
93
|
+
* @param state - the persisted user choices.
|
|
94
|
+
* @returns the model ids to install, and those the user turned off.
|
|
95
|
+
*/
|
|
96
|
+
export declare function resolveSelection(configured: readonly string[], state: PersistedState): {
|
|
97
|
+
install: Set<string>;
|
|
98
|
+
disabled: Set<string>;
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,kCAAkC;AAClC,MAAM,WAAW,cAAc;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CACrC;AAED,sBAAsB;AACtB,eAAO,MAAM,WAAW,EAAE,cAA8C,CAAA;AAExE,gFAAgF;AAChF,MAAM,WAAW,UAAU;IACzB,oFAAoF;IACpF,IAAI,IAAI,cAAc,CAAA;IACtB,kCAAkC;IAClC,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;CACnC;AAED,gEAAgE;AAChE,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAkB,IAAI,gBAAe;CACtC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAavE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAK7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAkC7D;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,cAA4B,GAAG,UAAU,CAMxF;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,cAAc,CAKnG;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,KAAK,EAAE,cAAc,GACpB;IAAE,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CAMjD"}
|
package/lib/state.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable install state: which models the user has enabled or disabled.
|
|
3
|
+
*
|
|
4
|
+
* A plugin's `config` states the *deployment* default — what a profile ships
|
|
5
|
+
* with. This store records the *user's* runtime choices on top of it, so an
|
|
6
|
+
* `enable`/`disable` survives a restart instead of evaporating with the session.
|
|
7
|
+
*
|
|
8
|
+
* The two layers are kept distinct on purpose:
|
|
9
|
+
*
|
|
10
|
+
* - `disabled` always wins, so a user can turn off something the config ships.
|
|
11
|
+
* - `enabled` adds to the config selection, so a user can turn on something the
|
|
12
|
+
* config omitted without editing YAML.
|
|
13
|
+
*
|
|
14
|
+
* Writing to a file rather than back into the profile's `cordis.patch.yml` keeps
|
|
15
|
+
* the plugin out of the user's configuration: a rewrite there would fight the
|
|
16
|
+
* HMR reload and could clobber comments the user wrote.
|
|
17
|
+
*
|
|
18
|
+
* @module @try-works/dsh-tool-mode/state
|
|
19
|
+
*/
|
|
20
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync, rmSync } from 'node:fs';
|
|
21
|
+
import { homedir } from 'node:os';
|
|
22
|
+
import { dirname, join } from 'node:path';
|
|
23
|
+
/** An empty state. */
|
|
24
|
+
export const EMPTY_STATE = { enabled: [], disabled: [] };
|
|
25
|
+
/** Raised when a state file exists but cannot be understood. */
|
|
26
|
+
export class StateError extends Error {
|
|
27
|
+
name = 'StateError';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Normalize a decoded state document.
|
|
31
|
+
*
|
|
32
|
+
* Unknown keys are dropped and non-string entries are rejected rather than
|
|
33
|
+
* silently ignored: a corrupted list is a bug worth surfacing, while a
|
|
34
|
+
* forward-compatible extra key is not.
|
|
35
|
+
* @param raw - the decoded JSON value.
|
|
36
|
+
* @param source - description of the origin, for messages.
|
|
37
|
+
* @returns the normalized state.
|
|
38
|
+
* @throws StateError when the document is not a valid state.
|
|
39
|
+
*/
|
|
40
|
+
export function parseState(raw, source) {
|
|
41
|
+
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
42
|
+
throw new StateError(`${source} must contain a JSON object`);
|
|
43
|
+
}
|
|
44
|
+
const record = raw;
|
|
45
|
+
const list = (key) => {
|
|
46
|
+
const value = record[key] ?? [];
|
|
47
|
+
if (!Array.isArray(value) || value.some(item => typeof item !== 'string')) {
|
|
48
|
+
throw new StateError(`${source} field "${key}" must be an array of model ids`);
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
};
|
|
52
|
+
return { enabled: list('enabled'), disabled: list('disabled') };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Derive the default state file from the environment.
|
|
56
|
+
*
|
|
57
|
+
* DSH sets `DSH_HOME`; falling back to `~/.dsh` matches the launcher's own
|
|
58
|
+
* convention for a process started without it.
|
|
59
|
+
* @param env - the environment to read; defaults to the process environment.
|
|
60
|
+
* @returns the absolute path of the state file.
|
|
61
|
+
*/
|
|
62
|
+
export function defaultStateFile(env = process.env) {
|
|
63
|
+
const home = env.DSH_HOME !== undefined && env.DSH_HOME.length > 0
|
|
64
|
+
? env.DSH_HOME
|
|
65
|
+
: join(homedir(), '.dsh');
|
|
66
|
+
return join(home, 'model-as-tool', 'state.json');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Build a file-backed store.
|
|
70
|
+
*
|
|
71
|
+
* Writes go through a temporary file and a rename, so a crash mid-write leaves
|
|
72
|
+
* the previous state intact rather than a truncated document that would read as
|
|
73
|
+
* "everything the user configured is gone".
|
|
74
|
+
* @param file - absolute path of the state file.
|
|
75
|
+
* @returns the store.
|
|
76
|
+
*/
|
|
77
|
+
export function createFileStateStore(file) {
|
|
78
|
+
return {
|
|
79
|
+
read() {
|
|
80
|
+
let text;
|
|
81
|
+
try {
|
|
82
|
+
text = readFileSync(file, 'utf8');
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// No file yet is the normal first-run case.
|
|
86
|
+
return EMPTY_STATE;
|
|
87
|
+
}
|
|
88
|
+
let parsed;
|
|
89
|
+
try {
|
|
90
|
+
parsed = JSON.parse(text);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
throw new StateError(`${file} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
94
|
+
}
|
|
95
|
+
return parseState(parsed, file);
|
|
96
|
+
},
|
|
97
|
+
write(state) {
|
|
98
|
+
const normalized = {
|
|
99
|
+
enabled: [...new Set(state.enabled)].sort(),
|
|
100
|
+
disabled: [...new Set(state.disabled)].sort(),
|
|
101
|
+
};
|
|
102
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
103
|
+
const temporary = `${file}.tmp`;
|
|
104
|
+
writeFileSync(temporary, `${JSON.stringify(normalized, null, 2)}\n`, 'utf8');
|
|
105
|
+
try {
|
|
106
|
+
renameSync(temporary, file);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
rmSync(temporary, { force: true });
|
|
110
|
+
throw new StateError(`cannot write ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Build an in-memory store, for tests and for deployments that asked for no
|
|
117
|
+
* persistence.
|
|
118
|
+
* @param initial - the starting state.
|
|
119
|
+
* @returns the store.
|
|
120
|
+
*/
|
|
121
|
+
export function createMemoryStateStore(initial = EMPTY_STATE) {
|
|
122
|
+
let current = initial;
|
|
123
|
+
return {
|
|
124
|
+
read: () => current,
|
|
125
|
+
write: (state) => { current = state; },
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Apply one enable/disable choice to a state.
|
|
130
|
+
*
|
|
131
|
+
* The two lists are kept mutually exclusive so the merge rule never has to
|
|
132
|
+
* break a tie: enabling a model removes it from `disabled` and vice versa.
|
|
133
|
+
* @param state - the current state.
|
|
134
|
+
* @param modelId - the model the user acted on.
|
|
135
|
+
* @param enabled - true to turn on, false to turn off.
|
|
136
|
+
* @returns the updated state.
|
|
137
|
+
*/
|
|
138
|
+
export function withChoice(state, modelId, enabled) {
|
|
139
|
+
const without = (list) => list.filter(id => id !== modelId);
|
|
140
|
+
return enabled
|
|
141
|
+
? { enabled: [...without(state.enabled), modelId], disabled: without(state.disabled) }
|
|
142
|
+
: { enabled: without(state.enabled), disabled: [...without(state.disabled), modelId] };
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Decide the effective installed set from the configured selection and the
|
|
146
|
+
* user's persisted choices.
|
|
147
|
+
* @param configured - model ids the config selects (already intersected with what can run).
|
|
148
|
+
* @param state - the persisted user choices.
|
|
149
|
+
* @returns the model ids to install, and those the user turned off.
|
|
150
|
+
*/
|
|
151
|
+
export function resolveSelection(configured, state) {
|
|
152
|
+
const disabled = new Set(state.disabled);
|
|
153
|
+
const install = new Set(configured);
|
|
154
|
+
for (const id of state.enabled)
|
|
155
|
+
install.add(id);
|
|
156
|
+
for (const id of disabled)
|
|
157
|
+
install.delete(id);
|
|
158
|
+
return { install, disabled };
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=state.js.map
|