@try-works/dsh-tool-mode 0.0.0-stage → 0.5.44
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/README.md +299 -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 +4039 -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 +2507 -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 +5197 -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/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
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host's prepared-assets path (RES-02/03/05, the last in-repo slice):
|
|
3
|
+
* lock reading → preparation plan → approval-gated, digest-verified acquisition
|
|
4
|
+
* into an isolated content-addressed cache → the prepared-cold readiness flip →
|
|
5
|
+
* the PreparedAssetMapV1 the provider routes consume.
|
|
6
|
+
*
|
|
7
|
+
* The verified components this module finally gives callers to:
|
|
8
|
+
*
|
|
9
|
+
* - `planPreparation`/`DeploymentIdentity` (deployment-coordinator.ts) — the
|
|
10
|
+
* pre-approval disclosure;
|
|
11
|
+
* - `acquireAsset` (asset-acquisition.ts) — digest+size verified, atomic,
|
|
12
|
+
* resumable acquisition with tamper refusal;
|
|
13
|
+
* - `createHttpSource` (http-acquisition.ts) — the default ranged source.
|
|
14
|
+
*
|
|
15
|
+
* Honesty rules carried through:
|
|
16
|
+
*
|
|
17
|
+
* - a lock with no digests REFUSES (no guessed values);
|
|
18
|
+
* - an executable asset WITHOUT the explicit executable-preparation approval
|
|
19
|
+
* refuses (RES-02);
|
|
20
|
+
* - a tampered final path is refused and never flips readiness;
|
|
21
|
+
* - the cache lives under the host's isolated state dir, never the repo or
|
|
22
|
+
* HOME; a REAL network run is opt-in (the default source), and the suite
|
|
23
|
+
* injects a local file source so it performs no network.
|
|
24
|
+
*
|
|
25
|
+
* @module @try-works/dsh-tool-mode/prepared-assets
|
|
26
|
+
*/
|
|
27
|
+
import { createHash } from 'node:crypto';
|
|
28
|
+
import { existsSync, linkSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, statfsSync, writeFileSync } from 'node:fs';
|
|
29
|
+
import { dirname, join } from 'node:path';
|
|
30
|
+
import { acquireAsset, sameDigest } from "./asset-acquisition.js";
|
|
31
|
+
/**
|
|
32
|
+
* Parse a models.lock.json document.
|
|
33
|
+
*
|
|
34
|
+
* A lock with no digest on any asset REFUSES: a preparation built on guessed
|
|
35
|
+
* bytes would verify nothing (RES-03).
|
|
36
|
+
* @param bytes - the lock document.
|
|
37
|
+
* @returns the parsed lock.
|
|
38
|
+
*/
|
|
39
|
+
export function parseAssetLock(bytes) {
|
|
40
|
+
let document;
|
|
41
|
+
try {
|
|
42
|
+
document = JSON.parse(bytes);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw new Error(`the asset lock is unreadable: ${error instanceof Error ? error.message : String(error)}`);
|
|
46
|
+
}
|
|
47
|
+
if (typeof document !== 'object' || document === null)
|
|
48
|
+
throw new Error('the asset lock is not a document');
|
|
49
|
+
const root = document;
|
|
50
|
+
const assetSets = root['assetSets'];
|
|
51
|
+
if (typeof assetSets !== 'object' || assetSets === null)
|
|
52
|
+
throw new Error('the asset lock declares no assetSets');
|
|
53
|
+
const sets = {};
|
|
54
|
+
for (const [setId, rawSet] of Object.entries(assetSets)) {
|
|
55
|
+
const set = rawSet;
|
|
56
|
+
const revision = typeof set['pinning'] === 'object' && set['pinning'] !== null
|
|
57
|
+
? set['pinning']['revision']
|
|
58
|
+
: undefined;
|
|
59
|
+
const license = typeof set['license'] === 'object' && set['license'] !== null
|
|
60
|
+
? set['license']
|
|
61
|
+
: {};
|
|
62
|
+
const rawGroups = set['groups'];
|
|
63
|
+
if (!Array.isArray(rawGroups))
|
|
64
|
+
throw new Error(`asset set ${setId} declares no groups`);
|
|
65
|
+
const groups = rawGroups.map((rawGroup, groupIndex) => {
|
|
66
|
+
const group = rawGroup;
|
|
67
|
+
const rawAssets = group['assets'];
|
|
68
|
+
if (!Array.isArray(rawAssets))
|
|
69
|
+
throw new Error(`asset set ${setId} group ${groupIndex} declares no assets`);
|
|
70
|
+
const assets = rawAssets.map((rawAsset, assetIndex) => {
|
|
71
|
+
const asset = rawAsset;
|
|
72
|
+
const digest = typeof asset['digest'] === 'string' ? asset['digest'] : '';
|
|
73
|
+
const bytes = typeof asset['bytes'] === 'number' ? asset['bytes'] : NaN;
|
|
74
|
+
const id = typeof asset['id'] === 'string' ? asset['id'] : '';
|
|
75
|
+
const file = typeof asset['file'] === 'string' ? asset['file'] : '';
|
|
76
|
+
const source = typeof asset['source'] === 'string' ? asset['source'] : '';
|
|
77
|
+
if (digest.length === 0 || !Number.isFinite(bytes) || id.length === 0 || file.length === 0) {
|
|
78
|
+
throw new Error(`asset set ${setId} group ${groupIndex} asset ${assetIndex} is incomplete; a lock without pinned digests and sizes refuses (RES-03)`);
|
|
79
|
+
}
|
|
80
|
+
return { id, file, bytes, source, digest, executable: asset['executable'] === true };
|
|
81
|
+
});
|
|
82
|
+
return { id: typeof group['id'] === 'string' ? group['id'] : `group-${groupIndex}`, assets };
|
|
83
|
+
});
|
|
84
|
+
sets[setId] = {
|
|
85
|
+
groups,
|
|
86
|
+
revision: typeof revision === 'string' ? revision : '',
|
|
87
|
+
license: {
|
|
88
|
+
name: typeof license['name'] === 'string' ? license['name'] : 'undeclared',
|
|
89
|
+
url: typeof license['url'] === 'string' ? license['url'] : '',
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const lockRevision = Object.values(sets)[0]?.revision ?? '';
|
|
94
|
+
if (lockRevision.length === 0)
|
|
95
|
+
throw new Error('the asset lock pins no model revision; a preparation cannot be planned');
|
|
96
|
+
return { revision: lockRevision, license: Object.values(sets)[0]?.license ?? { name: 'undeclared', url: '' }, sets };
|
|
97
|
+
}
|
|
98
|
+
/** The identity the lock implies for one model deployment. */
|
|
99
|
+
export function identityFor(extensionId, modelId, lock) {
|
|
100
|
+
return {
|
|
101
|
+
extensionId,
|
|
102
|
+
modelId,
|
|
103
|
+
modelRevision: lock.revision,
|
|
104
|
+
engineVersion: 'onnxruntime-node',
|
|
105
|
+
quantization: 'unquantized-fp32',
|
|
106
|
+
tokenizer: 'gemma',
|
|
107
|
+
preprocessingRecipe: 'pinned',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** The flat PlannedAsset list for one asset set. */
|
|
111
|
+
export function plannedAssets(lock, assetSetId) {
|
|
112
|
+
const set = lock.sets[assetSetId];
|
|
113
|
+
if (set === undefined)
|
|
114
|
+
throw new Error(`the lock declares no asset set "${assetSetId}"`);
|
|
115
|
+
return set.groups.flatMap(group => group.assets.map(asset => ({
|
|
116
|
+
assetId: `${group.id}/${asset.id}`,
|
|
117
|
+
bytes: asset.bytes,
|
|
118
|
+
source: asset.source,
|
|
119
|
+
digest: asset.digest,
|
|
120
|
+
executable: asset.executable,
|
|
121
|
+
})));
|
|
122
|
+
}
|
|
123
|
+
/** The group map for one asset set, keyed by group id. */
|
|
124
|
+
export function lockGroups(lock, assetSetId) {
|
|
125
|
+
const set = lock.sets[assetSetId];
|
|
126
|
+
if (set === undefined)
|
|
127
|
+
throw new Error(`the lock declares no asset set "${assetSetId}"`);
|
|
128
|
+
return set.groups;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Whether one lock `source` is a resolvable http(s) download URL.
|
|
132
|
+
* @param source - the lock's source string.
|
|
133
|
+
* @returns whether a transfer can be planned for it.
|
|
134
|
+
*/
|
|
135
|
+
export function isFetchableAssetSource(source) {
|
|
136
|
+
/**
|
|
137
|
+
* A source is fetchable when it has a URI SCHEME at all: https/http, a `file:`
|
|
138
|
+
* deployment lock, or the injected-source test scheme (`fixture:`). A PROSE
|
|
139
|
+
* description ("the split export of the pinned checkpoint") has no scheme and
|
|
140
|
+
* cannot plan a transfer.
|
|
141
|
+
*/
|
|
142
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(source.trim());
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The operator-facing reason an asset has no transferable location.
|
|
146
|
+
*
|
|
147
|
+
* A prose `source` (e.g. "the split export of the pinned checkpoint") is not a
|
|
148
|
+
* download URL; the bytes must be produced by the documented export and placed in
|
|
149
|
+
* the prepared-assets cache (file name = the pinned digest) before a transfer-free
|
|
150
|
+
* preparation can succeed.
|
|
151
|
+
* @param assetId - the lock asset id.
|
|
152
|
+
* @param source - the prose/non-URL source.
|
|
153
|
+
* @returns the exact refusal reason.
|
|
154
|
+
*/
|
|
155
|
+
export function assetSourceUnavailableReason(assetId, source) {
|
|
156
|
+
return `the asset lock declares no download URL for ${assetId}: its source is ${JSON.stringify(source)}; `
|
|
157
|
+
+ 'the artifacts must be produced by the documented export and placed in the prepared-assets cache';
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The first planned asset with neither an http(s) URL nor bytes already in the cache.
|
|
161
|
+
*
|
|
162
|
+
* A cache hit is a legitimate source: a later acquisition still verifies the blob
|
|
163
|
+
* against the pinned digest, so pre-seeded artifacts are verified rather than trusted.
|
|
164
|
+
* @param assets - the planned assets to check.
|
|
165
|
+
* @param cacheRoot - the content-addressed cache root (blob filename = digest).
|
|
166
|
+
* @returns the first unavailable asset, or undefined when every asset is reachable.
|
|
167
|
+
*/
|
|
168
|
+
export function firstUnavailableAssetSource(assets, cacheRoot) {
|
|
169
|
+
return assets.find(asset => !isFetchableAssetSource(asset.source) && !existsSync(join(cacheRoot, asset.digest)));
|
|
170
|
+
}
|
|
171
|
+
/** The filesystem store acquisition needs, over node:fs. */
|
|
172
|
+
function fsStore() {
|
|
173
|
+
return {
|
|
174
|
+
write(path, bytes) {
|
|
175
|
+
mkdirSync(join(path, '..'), { recursive: true });
|
|
176
|
+
writeFileSync(path, bytes);
|
|
177
|
+
},
|
|
178
|
+
read(path) {
|
|
179
|
+
if (!existsSync(path))
|
|
180
|
+
return undefined;
|
|
181
|
+
return new Uint8Array(readFileSync(path));
|
|
182
|
+
},
|
|
183
|
+
sizeOf(path) {
|
|
184
|
+
if (!existsSync(path))
|
|
185
|
+
return 0;
|
|
186
|
+
return statSyncSize(path);
|
|
187
|
+
},
|
|
188
|
+
rename(from, to) {
|
|
189
|
+
renameSync(from, to);
|
|
190
|
+
},
|
|
191
|
+
remove(path) {
|
|
192
|
+
rmSync(path, { force: true });
|
|
193
|
+
},
|
|
194
|
+
exists(path) {
|
|
195
|
+
return existsSync(path);
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** Synchronous size (the store interface is sync). */
|
|
200
|
+
function statSyncSize(path) {
|
|
201
|
+
try {
|
|
202
|
+
return statSync(path).size;
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The default free-space probe (TASK-131): `statfs` at the nearest existing
|
|
210
|
+
* ancestor of the path, so a cache root that does not exist yet probes the
|
|
211
|
+
* volume it will be created on.
|
|
212
|
+
* @param path - the cache root (which may not exist yet).
|
|
213
|
+
* @returns the available bytes (bavail × bsize), or 0 when unreadable.
|
|
214
|
+
*/
|
|
215
|
+
export function defaultFreeSpaceBytes(path) {
|
|
216
|
+
let current = path;
|
|
217
|
+
for (;;) {
|
|
218
|
+
try {
|
|
219
|
+
const stats = statfsSync(current);
|
|
220
|
+
return stats.bavail * stats.bsize;
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
const parent = dirname(current);
|
|
224
|
+
if (parent === current)
|
|
225
|
+
return 0;
|
|
226
|
+
current = parent;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Create the prepared-assets registry.
|
|
232
|
+
* @param options - the cache root and the default source.
|
|
233
|
+
* @returns the registry.
|
|
234
|
+
*/
|
|
235
|
+
export function createPreparedAssetRegistry(options) {
|
|
236
|
+
const cacheRoot = options.cacheRoot;
|
|
237
|
+
const freeSpaceProbe = options.freeSpaceBytes ?? defaultFreeSpaceBytes;
|
|
238
|
+
const held = new Map();
|
|
239
|
+
const ownersPath = join(cacheRoot, 'owners.json');
|
|
240
|
+
/**
|
|
241
|
+
* Ownership is PERSISTED, not merely computable (RES-03): a restart still knows
|
|
242
|
+
* which extension references which content-addressed digest, so a future purge
|
|
243
|
+
* can refuse to delete a blob another owner still needs.
|
|
244
|
+
*/
|
|
245
|
+
function readOwners() {
|
|
246
|
+
if (!existsSync(ownersPath))
|
|
247
|
+
return {};
|
|
248
|
+
try {
|
|
249
|
+
const parsed = JSON.parse(readFileSync(ownersPath, 'utf8'));
|
|
250
|
+
const owners = {};
|
|
251
|
+
for (const [extensionId, digests] of Object.entries(parsed)) {
|
|
252
|
+
if (!Array.isArray(digests))
|
|
253
|
+
continue;
|
|
254
|
+
owners[extensionId] = digests.filter((digest) => typeof digest === 'string');
|
|
255
|
+
}
|
|
256
|
+
return owners;
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
// A corrupt ownership index is not evidence of zero owners; it is evidence
|
|
260
|
+
// that no safe deletion decision can be made, so it reads as empty and the
|
|
261
|
+
// caller retains blobs (deletion is conservative).
|
|
262
|
+
return {};
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function writeOwners(owners) {
|
|
266
|
+
mkdirSync(cacheRoot, { recursive: true });
|
|
267
|
+
const temporary = `${ownersPath}.${process.pid}.tmp`;
|
|
268
|
+
writeFileSync(temporary, JSON.stringify(owners, null, 2));
|
|
269
|
+
renameSync(temporary, ownersPath);
|
|
270
|
+
}
|
|
271
|
+
function recordOwnership(extensionId, groups) {
|
|
272
|
+
const owners = readOwners();
|
|
273
|
+
owners[extensionId] = [...new Set(groups.flatMap(group => group.files.map(file => file.digest)))];
|
|
274
|
+
writeOwners(owners);
|
|
275
|
+
}
|
|
276
|
+
function forgetOwnership(extensionId) {
|
|
277
|
+
const owners = readOwners();
|
|
278
|
+
if (!(extensionId in owners))
|
|
279
|
+
return;
|
|
280
|
+
delete owners[extensionId];
|
|
281
|
+
writeOwners(owners);
|
|
282
|
+
}
|
|
283
|
+
// The content-addressed blob pool, shared across extensions (RES-03: two
|
|
284
|
+
// owners share one set of bytes).
|
|
285
|
+
return {
|
|
286
|
+
cacheDirectory: cacheRoot,
|
|
287
|
+
plans() {
|
|
288
|
+
return new Map([...held.entries()].map(([extensionId, preparation]) => [extensionId, preparation.plan]));
|
|
289
|
+
},
|
|
290
|
+
assetMapFor(extensionId) {
|
|
291
|
+
const preparation = held.get(extensionId);
|
|
292
|
+
if (preparation === undefined)
|
|
293
|
+
return undefined;
|
|
294
|
+
/**
|
|
295
|
+
* TWO projections over one verified preparation, both truthful:
|
|
296
|
+
*
|
|
297
|
+
* - the GROUP id resolves to the group directory (embeddinggemma's selective
|
|
298
|
+
* loading asks for `text-backbone` and reads `onnx/model.onnx` under it);
|
|
299
|
+
* - each ASSET id resolves to the individual materialized file (needle asks
|
|
300
|
+
* for `needle-engine-win-x64` and needs the executable's path).
|
|
301
|
+
*
|
|
302
|
+
* The SDK documents the map as asset ids to local handles, so the per-asset
|
|
303
|
+
* entries are the canonical projection and the group entry is the directory
|
|
304
|
+
* convenience the first-party group consumers already rely on. An exact
|
|
305
|
+
* asset-id match wins over a group-id match; the ids are namespaced by the
|
|
306
|
+
* lock and a collision is not silently served as the other kind.
|
|
307
|
+
*/
|
|
308
|
+
const groupHandles = new Map();
|
|
309
|
+
const assetHandles = new Map();
|
|
310
|
+
for (const group of preparation.groups) {
|
|
311
|
+
groupHandles.set(group.groupId, { path: group.path, digest: group.digests.join(',') });
|
|
312
|
+
for (const file of group.files) {
|
|
313
|
+
assetHandles.set(file.assetId, { path: file.path, digest: file.digest });
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
assetIds: [...groupHandles.keys(), ...assetHandles.keys()],
|
|
318
|
+
get(assetId) {
|
|
319
|
+
return assetHandles.get(assetId) ?? groupHandles.get(assetId);
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
},
|
|
323
|
+
groupsFor(extensionId) {
|
|
324
|
+
return held.get(extensionId)?.groups ?? [];
|
|
325
|
+
},
|
|
326
|
+
purge(extensionId) {
|
|
327
|
+
const extensionRoot = join(cacheRoot, 'groups', extensionId.replaceAll('/', '__'));
|
|
328
|
+
const removed = existsSync(extensionRoot);
|
|
329
|
+
if (removed)
|
|
330
|
+
rmSync(extensionRoot, { recursive: true, force: true });
|
|
331
|
+
held.delete(extensionId);
|
|
332
|
+
forgetOwnership(extensionId);
|
|
333
|
+
return { removed };
|
|
334
|
+
},
|
|
335
|
+
/**
|
|
336
|
+
* RESTART RESTORE. `prepare` is the only thing that fills the in-process map,
|
|
337
|
+
* and it lives in one process: after a host restart the store still says
|
|
338
|
+
* `prepared-cold`, the extension activates, and every tool call then fails
|
|
339
|
+
* with "the text-backbone asset group was not prepared" because the map is
|
|
340
|
+
* empty. The group directories are on disk from the earlier verified prepare,
|
|
341
|
+
* so rebuilding the handles from them is a stat walk, not a transfer; a file
|
|
342
|
+
* that is absent or no longer the recorded size refuses instead of publishing
|
|
343
|
+
* a handle nobody verified.
|
|
344
|
+
*/
|
|
345
|
+
restore(extensionId, plan, groups) {
|
|
346
|
+
const prepared = [];
|
|
347
|
+
for (const group of groups) {
|
|
348
|
+
const groupDir = join(cacheRoot, 'groups', plan.identity.extensionId.replaceAll('/', '__'), plan.identity.modelId, group.id);
|
|
349
|
+
const digests = [];
|
|
350
|
+
const files = [];
|
|
351
|
+
for (const asset of group.assets) {
|
|
352
|
+
const filePath = join(groupDir, asset.file);
|
|
353
|
+
if (!existsSync(filePath) || statSyncSize(filePath) !== asset.bytes) {
|
|
354
|
+
return {
|
|
355
|
+
ok: false,
|
|
356
|
+
reason: `${group.id}/${asset.id} is not in the prepared cache at its recorded size (${filePath})`,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
digests.push(asset.digest);
|
|
360
|
+
files.push({ assetId: asset.id, file: asset.file, path: filePath, digest: asset.digest });
|
|
361
|
+
}
|
|
362
|
+
prepared.push({ groupId: group.id, path: groupDir, digests, files });
|
|
363
|
+
}
|
|
364
|
+
held.set(extensionId, { plan, groups: prepared });
|
|
365
|
+
recordOwnership(extensionId, prepared);
|
|
366
|
+
return { ok: true, groups: prepared };
|
|
367
|
+
},
|
|
368
|
+
async prepare(extensionId, plan, groups, options) {
|
|
369
|
+
/**
|
|
370
|
+
* A lock whose assets carry PROSE sources (no URL) has no transferable
|
|
371
|
+
* location; refuse BEFORE any acquisition, naming the asset, instead of
|
|
372
|
+
* surfacing a URL-parse error from deep inside the transport. Artifacts
|
|
373
|
+
* already materialized in the content-addressed cache are a legitimate
|
|
374
|
+
* source (a later acquisition still verifies their digest).
|
|
375
|
+
*/
|
|
376
|
+
const unavailable = firstUnavailableAssetSource(groups.flatMap(group => group.assets.map(asset => ({ assetId: `${group.id}/${asset.id}`, source: asset.source, digest: asset.digest }))), cacheRoot);
|
|
377
|
+
if (unavailable !== undefined) {
|
|
378
|
+
return { ok: false, reason: assetSourceUnavailableReason(unavailable.assetId, unavailable.source) };
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* TASK-131 (RC2): the disk-space preflight. Before anything transfers,
|
|
382
|
+
* compare the bytes that are actually MISSING from the content-addressed
|
|
383
|
+
* cache (a digest hit transfers nothing) against the free space at the
|
|
384
|
+
* cache root, and refuse with a named, actionable error quoting the
|
|
385
|
+
* numbers — never let a multi-GB transfer run into a mid-stream ENOSPC
|
|
386
|
+
* that surfaces as a bare transport failure.
|
|
387
|
+
*/
|
|
388
|
+
const missingAssets = groups.flatMap(group => group.assets)
|
|
389
|
+
.filter(asset => !existsSync(join(cacheRoot, asset.digest)));
|
|
390
|
+
const missingBytes = missingAssets.reduce((sum, asset) => sum + asset.bytes, 0);
|
|
391
|
+
if (missingBytes > 0) {
|
|
392
|
+
const free = freeSpaceProbe(cacheRoot);
|
|
393
|
+
if (free < missingBytes) {
|
|
394
|
+
return {
|
|
395
|
+
ok: false,
|
|
396
|
+
reason: `[extension-asset-space-insufficient] the asset cache root ${cacheRoot} needs ${missingBytes} bytes `
|
|
397
|
+
+ `for ${missingAssets.length} missing asset(s) but only ${free} bytes are free. `
|
|
398
|
+
+ 'Configure assetCacheRoot on a volume with at least that much free space, or free space, and retry.',
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (!options.allowExecutable && plan.requiresExecutableApproval) {
|
|
403
|
+
return {
|
|
404
|
+
ok: false,
|
|
405
|
+
reason: 'the plan includes an EXECUTABLE asset, which requires the separate executable-preparation approval (RES-02); this call did not grant it',
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
const store = fsStore();
|
|
409
|
+
mkdirSync(cacheRoot, { recursive: true });
|
|
410
|
+
const prepared = [];
|
|
411
|
+
for (const group of groups) {
|
|
412
|
+
const groupDir = join(cacheRoot, 'groups', plan.identity.extensionId.replaceAll('/', '__'), plan.identity.modelId, group.id);
|
|
413
|
+
const digests = [];
|
|
414
|
+
const files = [];
|
|
415
|
+
for (const asset of group.assets) {
|
|
416
|
+
const planned = {
|
|
417
|
+
assetId: asset.id,
|
|
418
|
+
bytes: asset.bytes,
|
|
419
|
+
source: asset.source,
|
|
420
|
+
digest: asset.digest,
|
|
421
|
+
executable: asset.executable,
|
|
422
|
+
};
|
|
423
|
+
// NO in-memory blob shortcut: acquireAsset re-verifies the on-disk
|
|
424
|
+
// bytes on every call (a cache HIT transfers zero bytes but still
|
|
425
|
+
// checks the digest), so a blob tampered on disk is re-acquired
|
|
426
|
+
// rather than trusted from a stale memory record — and two owners
|
|
427
|
+
// still share the verified bytes.
|
|
428
|
+
const result = await acquireAsset(planned, {
|
|
429
|
+
store,
|
|
430
|
+
source: options.source,
|
|
431
|
+
root: cacheRoot,
|
|
432
|
+
signal: options.signal,
|
|
433
|
+
});
|
|
434
|
+
if (!result.acquired) {
|
|
435
|
+
return { ok: false, reason: `${group.id}/${asset.id}: ${result.reason}` };
|
|
436
|
+
}
|
|
437
|
+
const blob = { digest: result.digest, path: result.path };
|
|
438
|
+
// Materialize the lock's per-asset FILE layout inside the group dir via
|
|
439
|
+
// a hard link: the provider resolves `${groupDir}/onnx/model.onnx` etc.
|
|
440
|
+
// The link shares the verified blob's bytes (same volume); the digest
|
|
441
|
+
// was verified at acquisition and the blob path never changes.
|
|
442
|
+
mkdirSync(join(groupDir, asset.file, '..'), { recursive: true });
|
|
443
|
+
const linkTarget = join(groupDir, asset.file);
|
|
444
|
+
if (!existsSync(linkTarget)) {
|
|
445
|
+
try {
|
|
446
|
+
linkSync(blob.path, linkTarget);
|
|
447
|
+
}
|
|
448
|
+
catch {
|
|
449
|
+
// Hard links can fail across volumes; a copy is the fallback and
|
|
450
|
+
// is equally verified because the blob's digest was checked.
|
|
451
|
+
writeFileSync(linkTarget, readFileSync(blob.path));
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
else if (!sameDigest(createHash('sha256').update(readFileSync(linkTarget)).digest('hex'), asset.digest)) {
|
|
455
|
+
// A tampered FINAL path never poisons readiness: it is removed and
|
|
456
|
+
// the verified blob re-linked.
|
|
457
|
+
rmSync(linkTarget, { force: true });
|
|
458
|
+
linkSync(blob.path, linkTarget);
|
|
459
|
+
}
|
|
460
|
+
digests.push(asset.digest);
|
|
461
|
+
files.push({ assetId: asset.id, file: asset.file, path: linkTarget, digest: asset.digest });
|
|
462
|
+
}
|
|
463
|
+
prepared.push({ groupId: group.id, path: groupDir, digests, files });
|
|
464
|
+
}
|
|
465
|
+
held.set(extensionId, { plan, groups: prepared });
|
|
466
|
+
recordOwnership(extensionId, prepared);
|
|
467
|
+
return { ok: true, groups: prepared };
|
|
468
|
+
},
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
//# sourceMappingURL=prepared-assets.js.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension provider bridge.
|
|
3
|
+
*
|
|
4
|
+
* This is the ONLY route from a catalog entry to model code (BASE-09). The host
|
|
5
|
+
* no longer imports an adapter for any model: it resolves the extension that
|
|
6
|
+
* DECLARES the model, loads that extension through its public `./tool-mode`
|
|
7
|
+
* entry, and asks it for a provider. A first-party package and a third-party
|
|
8
|
+
* package take the same path, so there is no private built-in adapter route that
|
|
9
|
+
* only first-party code can use — which is precisely what BASE-09 forbids.
|
|
10
|
+
*
|
|
11
|
+
* The binding from a catalog model to an extension is DATA, held in the model's
|
|
12
|
+
* own catalog entry, not a switch on the model name. Adding a vendor therefore
|
|
13
|
+
* means publishing a package and adding a catalog row, with no host change.
|
|
14
|
+
*
|
|
15
|
+
* @module @try-works/dsh-tool-mode/provider-bridge
|
|
16
|
+
*/
|
|
17
|
+
import { type PreparedAssetMapV1, type ProviderInspectionV1 } from '@try-works/tool-mode-extension-sdk';
|
|
18
|
+
import { type ToolGrant } from './authority.ts';
|
|
19
|
+
import type { ManagedWorkerRegistry } from './managed-workers.ts';
|
|
20
|
+
import type { ModelCatalogEntry } from './types.ts';
|
|
21
|
+
import type { ModelAdapter } from './adapters/types.ts';
|
|
22
|
+
/** How a model's provider is obtained. */
|
|
23
|
+
export interface ProviderBinding {
|
|
24
|
+
/**
|
|
25
|
+
* The extension package that implements the model, resolved like any other
|
|
26
|
+
* dependency. A relative path is admitted so a first-party package can be used
|
|
27
|
+
* from a checkout before it is published.
|
|
28
|
+
*/
|
|
29
|
+
readonly extension: string;
|
|
30
|
+
/** The `modelId` the extension declares for this model. */
|
|
31
|
+
readonly modelId: string;
|
|
32
|
+
}
|
|
33
|
+
/** Raised when a model cannot be served through its declared extension. */
|
|
34
|
+
export declare class ProviderBridgeError extends Error {
|
|
35
|
+
readonly name = "ProviderBridgeError";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Loads extensions and adapts their providers to the host's adapter interface.
|
|
39
|
+
*
|
|
40
|
+
* One bridge per plugin activation, so an extension is imported and activated
|
|
41
|
+
* once no matter how many tools it serves.
|
|
42
|
+
*/
|
|
43
|
+
export declare class ProviderBridge {
|
|
44
|
+
#private;
|
|
45
|
+
constructor(options: {
|
|
46
|
+
readonly grant: ToolGrant;
|
|
47
|
+
readonly activationGeneration: number;
|
|
48
|
+
readonly installedPath?: (extensionId: string) => string | undefined;
|
|
49
|
+
readonly managed?: ManagedWorkerRegistry;
|
|
50
|
+
readonly log?: (message: string, fields?: Record<string, unknown>) => void;
|
|
51
|
+
});
|
|
52
|
+
/** The extensions currently activated, for diagnostics. */
|
|
53
|
+
get activatedExtensions(): readonly string[];
|
|
54
|
+
/**
|
|
55
|
+
* Inspect one extension-backed catalog entry through its provider.
|
|
56
|
+
*
|
|
57
|
+
* Inspection is the extension's read-only readiness path (EXT-18). It may import
|
|
58
|
+
* and activate the extension, but it does not load model assets or invoke the
|
|
59
|
+
* model; the provider itself must report only approved local state. This is used
|
|
60
|
+
* by publication and discovery so the host does not equate "the package
|
|
61
|
+
* resolves" with "the selected deployment is prepared".
|
|
62
|
+
* @param entry - the catalog entry to inspect.
|
|
63
|
+
* @param signal - cancellation for the read-only inspection.
|
|
64
|
+
* @returns the provider's inspection, or undefined for entries with no provider binding.
|
|
65
|
+
*/
|
|
66
|
+
inspect(entry: ModelCatalogEntry, signal: AbortSignal): Promise<ProviderInspectionV1 | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* Inspect one extension INSTALLED IN THE STORE, keyed by its own manifest model id.
|
|
69
|
+
*
|
|
70
|
+
* The catalog-driven {@link inspect} cannot reach an extension that has no catalog
|
|
71
|
+
* row (EmbeddingGemma and Needle ship declared tools but are not catalogued), which
|
|
72
|
+
* left their deployments permanently `needs-preparation`. This route activates the
|
|
73
|
+
* extension through its public entry and inspects the provider the MANIFEST declares,
|
|
74
|
+
* so "prepared" can become a durable fact for store-installed packages too.
|
|
75
|
+
*
|
|
76
|
+
* Inspection remains read-only (EXT-18): no model assets are loaded.
|
|
77
|
+
* @param specifier - the installed extension package name or ABSOLUTE install path.
|
|
78
|
+
* An absolute path runs the exact store copy the caller verified, rather than
|
|
79
|
+
* whatever the package name resolves to in the host's own dependency graph.
|
|
80
|
+
* @param modelId - the model id the extension's manifest declares.
|
|
81
|
+
* @param signal - cancellation for the read-only inspection.
|
|
82
|
+
* @returns the provider's inspection, or undefined when the model is not declared.
|
|
83
|
+
* @throws ProviderBridgeError when the package cannot be resolved or the provider
|
|
84
|
+
* refuses creation for this model id (the model's declaredness is the provider's
|
|
85
|
+
* to assert, so an undeclared id surfaces as a throw rather than undefined).
|
|
86
|
+
*/
|
|
87
|
+
inspectExtension(specifier: string, modelId: string, signal: AbortSignal, assets?: Readonly<PreparedAssetMapV1>): Promise<ProviderInspectionV1 | undefined>;
|
|
88
|
+
/**
|
|
89
|
+
* Build an adapter for one catalog entry.
|
|
90
|
+
*
|
|
91
|
+
* Returns undefined when the entry declares no provider binding, which is the
|
|
92
|
+
* correct outcome for a model reached through a command transport instead.
|
|
93
|
+
*
|
|
94
|
+
* The adapter is LAZY: it does not import or activate the extension until the
|
|
95
|
+
* first invocation. Two reasons, and the second is the important one:
|
|
96
|
+
* registering a tool must not run somebody else's package code (EXT-19 requires
|
|
97
|
+
* import and `create()` to stay lightweight), and a package that fails to load
|
|
98
|
+
* must fail the CALL it was needed for rather than the registration of every
|
|
99
|
+
* other tool in the catalog.
|
|
100
|
+
* @param entry - the catalog entry.
|
|
101
|
+
* @returns the adapter, or undefined when no extension implements this model.
|
|
102
|
+
*/
|
|
103
|
+
adapterFor(entry: ModelCatalogEntry): ModelAdapter | undefined;
|
|
104
|
+
/** Release every activated extension. */
|
|
105
|
+
dispose(reason?: 'deactivate' | 'upgrade' | 'uninstall' | 'shutdown' | 'fault'): Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=provider-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-bridge.d.ts","sourceRoot":"","sources":["../src/provider-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,oCAAoC,CAAA;AAE3C,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAGjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAgC,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAErF,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAeD,2EAA2E;AAC3E,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,SAAkB,IAAI,yBAAwB;CAC/C;AAED;;;;;GAKG;AACH,qBAAa,cAAc;;gBAuBb,OAAO,EAAE;QACnB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;QACzB,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;QACrC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;QACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAA;QACxC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;KAC3E;IAQD,2DAA2D;IAC3D,IAAI,mBAAmB,IAAI,SAAS,MAAM,EAAE,CAE3C;IAED;;;;;;;;;;;OAWG;IACG,OAAO,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAsBvG;;;;;;;;;;;;;;;;;;;OAmBG;IACG,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,WAAW,EACnB,MAAM,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GACpC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IA0B5C;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,GAAG,SAAS;IAqF9D,yCAAyC;IACnC,OAAO,CAAC,MAAM,GAAE,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,OAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CA6HjH"}
|