@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
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Staged installation (EXT-07, EXT-08).
|
|
3
|
+
*
|
|
4
|
+
* The ordering is the security property. A package is fetched into quarantine,
|
|
5
|
+
* verified, inspected as DATA, validated, and only then promoted into the store —
|
|
6
|
+
* and promotion is not activation. Nothing in this module imports extension code,
|
|
7
|
+
* runs inference, warms a model, or publishes a tool (EXT-07).
|
|
8
|
+
*
|
|
9
|
+
* The fetch and extract steps are INJECTED rather than implemented here, for two
|
|
10
|
+
* reasons: the SDK must stay free of a network stack and an archive library, and
|
|
11
|
+
* a test must be able to drive every rejection path without a real download or a
|
|
12
|
+
* real filesystem. The host supplies the real implementations.
|
|
13
|
+
*
|
|
14
|
+
* @module @try-works/tool-mode-extension-sdk/install/staged
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
17
|
+
import { createHash } from 'node:crypto';
|
|
18
|
+
import { linkRuntimeSdk, RUNTIME_SDK_NAME } from "./runtime-link.js";
|
|
19
|
+
import { join, resolve, sep } from 'node:path';
|
|
20
|
+
import { ManagementError } from "./../errors.js";
|
|
21
|
+
import { discoverExtension } from "./../discovery.js";
|
|
22
|
+
import { digestInstalledContent, ExtensionStore } from "./store.js";
|
|
23
|
+
import { installDependencyGraph } from "./dependencies.js";
|
|
24
|
+
import { DEFAULT_ARCHIVE_LIMITS, validateArchiveEntries, verifyIntegrity, } from "./archive.js";
|
|
25
|
+
/** SHA-256 hex over bytes or text, for the EXT-12 provenance fields. */
|
|
26
|
+
function sha256(value) {
|
|
27
|
+
return createHash('sha256').update(value).digest('hex');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Remove staging directories left by a CRASHED earlier install (EXT-08).
|
|
31
|
+
*
|
|
32
|
+
* A process that dies mid-install leaves `attempt-<pid>-<time>` behind. The store
|
|
33
|
+
* lock was never written, so the half-extracted bytes are invisible to activation;
|
|
34
|
+
* they are still garbage, and a restart is the right place to reclaim them. A LIVE
|
|
35
|
+
* pid's directory is preserved: it may be another install in progress.
|
|
36
|
+
* @param staging - the store's `.staging` directory.
|
|
37
|
+
*/
|
|
38
|
+
function cleanStaleStaging(staging) {
|
|
39
|
+
for (const name of readdirSync(staging)) {
|
|
40
|
+
const match = /^attempt-(\d+)-/.exec(name);
|
|
41
|
+
if (match === null)
|
|
42
|
+
continue;
|
|
43
|
+
const pid = Number(match[1]);
|
|
44
|
+
if (pid === process.pid)
|
|
45
|
+
continue;
|
|
46
|
+
let alive = true;
|
|
47
|
+
try {
|
|
48
|
+
process.kill(pid, 0);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
// ESRCH is the only proof of death; EPERM means the process exists but is
|
|
52
|
+
// someone else's, and deleting its staging would corrupt a live install.
|
|
53
|
+
alive = error.code !== 'ESRCH';
|
|
54
|
+
}
|
|
55
|
+
if (!alive)
|
|
56
|
+
rmSync(join(staging, name), { recursive: true, force: true });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** Conservative install limits. */
|
|
60
|
+
export const DEFAULT_INSTALL_LIMITS = {
|
|
61
|
+
maxArchiveBytes: 256 * 1024 * 1024,
|
|
62
|
+
fetchTimeoutMs: 120_000,
|
|
63
|
+
archive: DEFAULT_ARCHIVE_LIMITS,
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Install an extension into an operator-owned store, staged (EXT-08).
|
|
67
|
+
*
|
|
68
|
+
* Steps, in order: fetch into quarantine → verify integrity → list entries →
|
|
69
|
+
* validate the entry list → extract → discover → validate compatibility →
|
|
70
|
+
* promote atomically → record the installation. A failure at any step removes the
|
|
71
|
+
* quarantine, so a partial install never becomes visible.
|
|
72
|
+
*
|
|
73
|
+
* The store is RECORDED rather than merely written to: an installation that is not
|
|
74
|
+
* in the lock document cannot be activated later, because nothing would know what
|
|
75
|
+
* bytes were approved.
|
|
76
|
+
*
|
|
77
|
+
* @param options - the source, the store, the injected archive source, and limits.
|
|
78
|
+
* @returns the installed (but inactive) extension.
|
|
79
|
+
* @throws ManagementError for every rejection path.
|
|
80
|
+
*/
|
|
81
|
+
export async function stagedInstall(options) {
|
|
82
|
+
const limits = options.limits ?? DEFAULT_INSTALL_LIMITS;
|
|
83
|
+
const storeDir = resolve(options.storeDir);
|
|
84
|
+
const staging = join(storeDir, '.staging');
|
|
85
|
+
mkdirSync(staging, { recursive: true });
|
|
86
|
+
cleanStaleStaging(staging);
|
|
87
|
+
// A unique per-attempt directory, so two concurrent installs cannot collide and
|
|
88
|
+
// a crashed attempt leaves evidence rather than a half-written package.
|
|
89
|
+
const attempt = join(staging, `attempt-${process.pid}-${Date.now().toString(36)}`);
|
|
90
|
+
mkdirSync(attempt, { recursive: true });
|
|
91
|
+
/** Set when the runtime link could not be made, reported rather than thrown. */
|
|
92
|
+
let runtimeLinkDiagnostic;
|
|
93
|
+
try {
|
|
94
|
+
const bytes = await options.archive.fetch(options.source, {
|
|
95
|
+
maxBytes: limits.maxArchiveBytes,
|
|
96
|
+
timeoutMs: limits.fetchTimeoutMs,
|
|
97
|
+
});
|
|
98
|
+
if (bytes.byteLength > limits.maxArchiveBytes) {
|
|
99
|
+
throw new ManagementError('INVALID_EXTENSION', 'install', `the fetched archive is ${bytes.byteLength} bytes, over the ${limits.maxArchiveBytes} limit`, 'Ask the publisher to reduce the package, or raise the operator limit deliberately.');
|
|
100
|
+
}
|
|
101
|
+
// Integrity first: if the bytes are not the approved ones, nothing downstream
|
|
102
|
+
// is worth doing.
|
|
103
|
+
const archiveDigest = verifyIntegrity(bytes, options.expectedSha512);
|
|
104
|
+
// Entry validation runs on the LIST, before extraction. A traversal entry
|
|
105
|
+
// rejected here never reaches a path join.
|
|
106
|
+
const entries = options.archive.list(bytes);
|
|
107
|
+
validateArchiveEntries(entries, limits.archive);
|
|
108
|
+
const extracted = join(attempt, 'package');
|
|
109
|
+
mkdirSync(extracted, { recursive: true });
|
|
110
|
+
options.archive.extract(bytes, extracted, '');
|
|
111
|
+
// Discovery reads data and imports nothing; a manifest referencing a file the
|
|
112
|
+
// package does not ship is refused before anything is promoted.
|
|
113
|
+
const discovery = discoverExtension(extracted);
|
|
114
|
+
// EXT-09: the extension's runtime dependencies are resolved, verified and
|
|
115
|
+
// materialized into the extension's OWN directory before promotion. A
|
|
116
|
+
// package that declares dependencies without a provided graph installer is
|
|
117
|
+
// REFUSED rather than installed as a guaranteed-broken extension.
|
|
118
|
+
let lockedDependencies = [];
|
|
119
|
+
let declaredDependenciesCount = 0;
|
|
120
|
+
try {
|
|
121
|
+
const packageJson = JSON.parse(readFileSync(join(extracted, 'package.json'), 'utf8'));
|
|
122
|
+
declaredDependenciesCount = Object.keys(packageJson.dependencies ?? {}).length;
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
// The package.json was already read by discovery; this cannot fail.
|
|
126
|
+
}
|
|
127
|
+
if (declaredDependenciesCount > 0) {
|
|
128
|
+
if (options.dependencies === undefined) {
|
|
129
|
+
throw new ManagementError('DEPENDENCY_UNSATISFIED', 'install', `${discovery.packageName} declares ${declaredDependenciesCount} runtime dependenc${declaredDependenciesCount === 1 ? 'y' : 'ies'} but no dependency-graph installer was provided; the extension would be installed broken`, 'Provide the operator-configured registry resolver, or publish the extension with every runtime dependency bundled.');
|
|
130
|
+
}
|
|
131
|
+
lockedDependencies = await installDependencyGraph(extracted, options.dependencies);
|
|
132
|
+
}
|
|
133
|
+
// EXT-08: the operator approval PREVIEW runs BEFORE materialization — the
|
|
134
|
+
// caller sees the permissions/licenses/platform/download implications and
|
|
135
|
+
// may refuse (throw) to abort the install while nothing is promoted.
|
|
136
|
+
if (options.preview !== undefined) {
|
|
137
|
+
const manifest = discovery.manifest;
|
|
138
|
+
await options.preview({
|
|
139
|
+
extensionId: discovery.packageName,
|
|
140
|
+
version: discovery.packageVersion,
|
|
141
|
+
permissions: manifest.permissions,
|
|
142
|
+
models: manifest.models.map(model => ({
|
|
143
|
+
id: model.id,
|
|
144
|
+
assetSet: model.assetSet,
|
|
145
|
+
platforms: model.platforms.map(platform => `${platform.os}-${platform.arch}${platform.accelerator === undefined ? '' : `-${platform.accelerator}`}`),
|
|
146
|
+
})),
|
|
147
|
+
licenses: (manifest.licenses ?? []).map(layer => `${layer.layer}: ${layer.name}`),
|
|
148
|
+
downloadImplications: manifest.models.length === 0
|
|
149
|
+
? 'no model assets declared; nothing is downloaded at install'
|
|
150
|
+
: `${manifest.models.length} model asset set(s) declared; downloads require the separate preparation consent, never the install`,
|
|
151
|
+
requiresApproval: manifest.permissions.nativeCode
|
|
152
|
+
|| manifest.permissions.networkOrigins.length > 0
|
|
153
|
+
|| manifest.permissions.storage !== 'none'
|
|
154
|
+
|| manifest.models.length > 0,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
// Promote by rename, which is atomic within a store. The destination is keyed
|
|
158
|
+
// by identity AND version, so an update installs side by side rather than
|
|
159
|
+
// mutating a live directory (EXT-30).
|
|
160
|
+
const destination = installPathFor(storeDir, discovery.packageName, discovery.packageVersion);
|
|
161
|
+
if (existsSync(destination)) {
|
|
162
|
+
throw new ManagementError('UPGRADE_FAILED', 'install', `${discovery.packageName}@${discovery.packageVersion} is already installed`, 'Install a different version, or uninstall the existing one first.');
|
|
163
|
+
}
|
|
164
|
+
mkdirSync(join(destination, '..'), { recursive: true });
|
|
165
|
+
renameSync(extracted, destination);
|
|
166
|
+
/**
|
|
167
|
+
* Make the RUNTIME SDK resolvable from inside the installed package.
|
|
168
|
+
*
|
|
169
|
+
* Without this the package lands in a directory with no `node_modules`, so an extension
|
|
170
|
+
* that declares the SDK — which the protocol requires it to depend on — dies on its
|
|
171
|
+
* first import with ERR_MODULE_NOT_FOUND. It is discoverable and activatable and cannot
|
|
172
|
+
* RUN, which is the worst of the three states because nothing reports it as broken.
|
|
173
|
+
*
|
|
174
|
+
* A failure here is RECORDED rather than thrown: a package that imports nothing (a
|
|
175
|
+
* declarative or tool-only extension) runs fine without the link, and failing the
|
|
176
|
+
* install would break working packages to fix a problem they do not have.
|
|
177
|
+
*/
|
|
178
|
+
runtimeLinkDiagnostic = linkRuntimeSdk(destination);
|
|
179
|
+
/**
|
|
180
|
+
* A SHADOWED RUNTIME FAILS THE INSTALL.
|
|
181
|
+
*
|
|
182
|
+
* If the package shipped its own copy of the host SDK, the extension would execute
|
|
183
|
+
* against THAT copy while the operator was told the link was merely already present.
|
|
184
|
+
* Installing it is worse than refusing, because the receipt would then describe a
|
|
185
|
+
* containment the installation does not have. This is the one link outcome that is
|
|
186
|
+
* fatal rather than reported.
|
|
187
|
+
*/
|
|
188
|
+
if (runtimeLinkDiagnostic.reason === 'sdk-shadowed') {
|
|
189
|
+
rmSync(destination, { recursive: true, force: true });
|
|
190
|
+
throw new ManagementError('INVALID_EXTENSION', 'install', runtimeLinkDiagnostic.detail ?? 'the package ships its own copy of the host runtime SDK', 'Remove node_modules/' + RUNTIME_SDK_NAME
|
|
191
|
+
+ ' from the package; an extension must run against the host runtime.');
|
|
192
|
+
}
|
|
193
|
+
writeFileSync(join(destination, '.tool-mode-install.json'), `${JSON.stringify({
|
|
194
|
+
extensionId: discovery.packageName,
|
|
195
|
+
version: discovery.packageVersion,
|
|
196
|
+
archiveDigest,
|
|
197
|
+
...runtimeLinkDiagnostic === undefined ? {} : { runtimeLink: runtimeLinkDiagnostic },
|
|
198
|
+
source: { kind: options.source.kind, requested: options.source.requested },
|
|
199
|
+
resolvedSource: `${options.source.kind}:${options.source.requested}#sha512:${archiveDigest}`,
|
|
200
|
+
manifestDigest: sha256(readFileSync(join(destination, 'tool-mode.extension.json'))),
|
|
201
|
+
dependencyLockDigest: sha256(JSON.stringify(lockedDependencies)),
|
|
202
|
+
permissionsDigest: sha256(JSON.stringify(discovery.manifest.permissions)),
|
|
203
|
+
approval: {
|
|
204
|
+
required: discovery.manifest.permissions.nativeCode
|
|
205
|
+
|| discovery.manifest.permissions.inputFiles
|
|
206
|
+
|| discovery.manifest.permissions.secrets.length > 0,
|
|
207
|
+
previewed: options.preview !== undefined,
|
|
208
|
+
},
|
|
209
|
+
licenses: discovery.licenses,
|
|
210
|
+
...lockedDependencies.length === 0 ? {} : { dependencies: lockedDependencies },
|
|
211
|
+
...options.provenance === undefined ? {} : { provenance: options.provenance },
|
|
212
|
+
installedAt: new Date().toISOString(),
|
|
213
|
+
}, null, 2)}\n`);
|
|
214
|
+
// LIC-01: preserve the resolved notices as a packaged file, so attribution is
|
|
215
|
+
// auditable from the installation itself rather than only in memory.
|
|
216
|
+
writeFileSync(join(destination, 'THIRD-PARTY-NOTICES.md'), `# Third-party notices\n\n${discovery.licenses.notices.length === 0
|
|
217
|
+
? 'No layer requires an attribution notice.\n'
|
|
218
|
+
: discovery.licenses.notices.join('\n\n')}\n`, 'utf8');
|
|
219
|
+
// Recorded AFTER the bytes are in place: a lock entry naming a directory that
|
|
220
|
+
// does not exist would be worse than no entry, because verification would then
|
|
221
|
+
// report a missing installation as a changed one.
|
|
222
|
+
if (options.record !== false) {
|
|
223
|
+
const store = new ExtensionStore(storeDir);
|
|
224
|
+
store.recordInstall({
|
|
225
|
+
extensionId: discovery.packageName,
|
|
226
|
+
version: discovery.packageVersion,
|
|
227
|
+
installPath: destination,
|
|
228
|
+
archiveDigest,
|
|
229
|
+
...runtimeLinkDiagnostic === undefined ? {} : { runtimeLink: runtimeLinkDiagnostic },
|
|
230
|
+
// Digest the content as installed, so a later edit is detectable.
|
|
231
|
+
contentDigest: digestInstalledContent(destination),
|
|
232
|
+
source: { kind: options.source.kind, requested: options.source.requested },
|
|
233
|
+
resolvedSource: `${options.source.kind}:${options.source.requested}#sha512:${archiveDigest}`,
|
|
234
|
+
manifestDigest: sha256(readFileSync(join(destination, 'tool-mode.extension.json'))),
|
|
235
|
+
dependencyLockDigest: sha256(JSON.stringify(lockedDependencies)),
|
|
236
|
+
permissionsDigest: sha256(JSON.stringify(discovery.manifest.permissions)),
|
|
237
|
+
approval: {
|
|
238
|
+
required: discovery.manifest.permissions.nativeCode
|
|
239
|
+
|| discovery.manifest.permissions.inputFiles
|
|
240
|
+
|| discovery.manifest.permissions.secrets.length > 0,
|
|
241
|
+
previewed: options.preview !== undefined,
|
|
242
|
+
},
|
|
243
|
+
licenses: discovery.licenses,
|
|
244
|
+
...lockedDependencies.length === 0 ? {} : { dependencies: lockedDependencies },
|
|
245
|
+
...options.provenance === undefined ? {} : { provenance: options.provenance },
|
|
246
|
+
installedAt: new Date().toISOString(),
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
extensionId: discovery.packageName,
|
|
251
|
+
version: discovery.packageVersion,
|
|
252
|
+
installPath: destination,
|
|
253
|
+
activation: 'inactive',
|
|
254
|
+
discovery,
|
|
255
|
+
archiveDigest,
|
|
256
|
+
...runtimeLinkDiagnostic === undefined ? {} : { runtimeLink: runtimeLinkDiagnostic },
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
// Quarantine is removed on EVERY path, success included: the promoted copy is
|
|
261
|
+
// the installation, and leaving a second copy behind would let the two drift.
|
|
262
|
+
rmSync(attempt, { recursive: true, force: true });
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The immutable installation directory for one extension version (EXT-33).
|
|
267
|
+
*
|
|
268
|
+
* The identity is VALIDATED rather than merely escaped. Escaping would turn
|
|
269
|
+
* `../../etc` into a harmless-looking directory name and silently install
|
|
270
|
+
* something under a package name that no registry would accept; refusing says
|
|
271
|
+
* what is actually wrong.
|
|
272
|
+
* @param storeDir - the operator's store root.
|
|
273
|
+
* @param extensionId - the validated extension identity.
|
|
274
|
+
* @param version - the validated version.
|
|
275
|
+
* @returns the absolute installation path.
|
|
276
|
+
* @throws ManagementError when the identity or version is not a legal one.
|
|
277
|
+
*/
|
|
278
|
+
export function installPathFor(storeDir, extensionId, version) {
|
|
279
|
+
// A package name is lower-case, may be scoped, and uses a restricted character
|
|
280
|
+
// set. EXT-14 already requires the manifest id to equal the package name, so an
|
|
281
|
+
// identity outside this grammar did not come from a real package.
|
|
282
|
+
const SEGMENT = '[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?';
|
|
283
|
+
const NAME = new RegExp(`^(?:@${SEGMENT}/)?${SEGMENT}$`);
|
|
284
|
+
if (!NAME.test(extensionId)) {
|
|
285
|
+
throw new ManagementError('INVALID_EXTENSION', 'install', `the extension identity ${JSON.stringify(extensionId)} is not a legal package name`, 'Use a normal npm package name; the manifest id must equal it exactly.');
|
|
286
|
+
}
|
|
287
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {
|
|
288
|
+
throw new ManagementError('INVALID_EXTENSION', 'install', `the version ${JSON.stringify(version)} is not a semantic version`, 'Publish a semantic version.');
|
|
289
|
+
}
|
|
290
|
+
// The separator is the one character a legal name cannot contain, so a
|
|
291
|
+
// validated name needs no further escaping to stay inside the store.
|
|
292
|
+
const path = join(resolve(storeDir), 'extensions', extensionId, version);
|
|
293
|
+
const root = resolve(storeDir);
|
|
294
|
+
if (!path.startsWith(root + sep)) {
|
|
295
|
+
throw new ManagementError('INVALID_EXTENSION', 'install', 'the extension identity would escape the extension store', 'Use a normal package name.');
|
|
296
|
+
}
|
|
297
|
+
return path;
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=staged.js.map
|