@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,423 @@
|
|
|
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 { activateExtension, assertNoReservedMeta, EXTENSION_ENTRY, loadExtensionModule, } from '@try-works/tool-mode-extension-sdk';
|
|
18
|
+
import { createInvocationAuthority } from "./authority.js";
|
|
19
|
+
import { isAbsolute, join } from 'node:path';
|
|
20
|
+
import { pathToFileURL } from 'node:url';
|
|
21
|
+
/** Raised when a model cannot be served through its declared extension. */
|
|
22
|
+
export class ProviderBridgeError extends Error {
|
|
23
|
+
name = 'ProviderBridgeError';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Loads extensions and adapts their providers to the host's adapter interface.
|
|
27
|
+
*
|
|
28
|
+
* One bridge per plugin activation, so an extension is imported and activated
|
|
29
|
+
* once no matter how many tools it serves.
|
|
30
|
+
*/
|
|
31
|
+
export class ProviderBridge {
|
|
32
|
+
#activated = new Map();
|
|
33
|
+
#grant;
|
|
34
|
+
#generation;
|
|
35
|
+
#log;
|
|
36
|
+
/**
|
|
37
|
+
* The managed-worker registry (EXT-20). Present ONLY when the operator opted in
|
|
38
|
+
* (`managedWorkers: true`): every executable route — catalog invocation and
|
|
39
|
+
* inspection — then goes through the worker, and the in-process import/activate
|
|
40
|
+
* path below is never taken for it. There is NO silent in-process fallback: a
|
|
41
|
+
* phase the protocol cannot serve is REFUSED with its reason.
|
|
42
|
+
*/
|
|
43
|
+
#managed;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve an extension ID to its ABSOLUTE installed path when the host knows it.
|
|
46
|
+
*
|
|
47
|
+
* A store install is not on the plugin package's module graph, so resolving it by
|
|
48
|
+
* package NAME throws and every store-only tongue/voz deployment records `failed`.
|
|
49
|
+
* The host supplies the store's verified install path instead; name resolution stays
|
|
50
|
+
* the fallback for packages that really are dependencies.
|
|
51
|
+
*/
|
|
52
|
+
#installedPath;
|
|
53
|
+
constructor(options) {
|
|
54
|
+
this.#grant = options.grant;
|
|
55
|
+
this.#generation = options.activationGeneration;
|
|
56
|
+
this.#managed = options.managed;
|
|
57
|
+
this.#installedPath = options.installedPath;
|
|
58
|
+
this.#log = options.log ?? (() => { });
|
|
59
|
+
}
|
|
60
|
+
/** The extensions currently activated, for diagnostics. */
|
|
61
|
+
get activatedExtensions() {
|
|
62
|
+
return [...this.#activated.keys()];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Inspect one extension-backed catalog entry through its provider.
|
|
66
|
+
*
|
|
67
|
+
* Inspection is the extension's read-only readiness path (EXT-18). It may import
|
|
68
|
+
* and activate the extension, but it does not load model assets or invoke the
|
|
69
|
+
* model; the provider itself must report only approved local state. This is used
|
|
70
|
+
* by publication and discovery so the host does not equate "the package
|
|
71
|
+
* resolves" with "the selected deployment is prepared".
|
|
72
|
+
* @param entry - the catalog entry to inspect.
|
|
73
|
+
* @param signal - cancellation for the read-only inspection.
|
|
74
|
+
* @returns the provider's inspection, or undefined for entries with no provider binding.
|
|
75
|
+
*/
|
|
76
|
+
async inspect(entry, signal) {
|
|
77
|
+
const binding = entry.provider;
|
|
78
|
+
if (binding === undefined)
|
|
79
|
+
return undefined;
|
|
80
|
+
if (this.#managed !== undefined) {
|
|
81
|
+
// EXT-20, managed mode: inspection runs ENTIRELY in the managed process
|
|
82
|
+
// through the verified SDK inspect API — the entry is never imported in-host.
|
|
83
|
+
// A store install is reached through its verified absolute path (see
|
|
84
|
+
// #installedPath); resolving the package name would fail off the plugin graph.
|
|
85
|
+
const resolved = await resolveExtensionPackage(this.#installedPath?.(binding.extension) ?? binding.extension, entry);
|
|
86
|
+
const worker = await this.#managed.adapterFor({
|
|
87
|
+
extensionId: resolved.manifestId,
|
|
88
|
+
entryPath: resolved.entryPath,
|
|
89
|
+
manifestPath: resolved.manifestPath,
|
|
90
|
+
generation: this.#generation,
|
|
91
|
+
});
|
|
92
|
+
return await worker.inspect(binding.modelId, { signal });
|
|
93
|
+
}
|
|
94
|
+
const activated = await this.#activate(binding.extension, entry);
|
|
95
|
+
const provider = await this.#providerFor(activated, binding);
|
|
96
|
+
return provider.inspect(signal);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Inspect one extension INSTALLED IN THE STORE, keyed by its own manifest model id.
|
|
100
|
+
*
|
|
101
|
+
* The catalog-driven {@link inspect} cannot reach an extension that has no catalog
|
|
102
|
+
* row (EmbeddingGemma and Needle ship declared tools but are not catalogued), which
|
|
103
|
+
* left their deployments permanently `needs-preparation`. This route activates the
|
|
104
|
+
* extension through its public entry and inspects the provider the MANIFEST declares,
|
|
105
|
+
* so "prepared" can become a durable fact for store-installed packages too.
|
|
106
|
+
*
|
|
107
|
+
* Inspection remains read-only (EXT-18): no model assets are loaded.
|
|
108
|
+
* @param specifier - the installed extension package name or ABSOLUTE install path.
|
|
109
|
+
* An absolute path runs the exact store copy the caller verified, rather than
|
|
110
|
+
* whatever the package name resolves to in the host's own dependency graph.
|
|
111
|
+
* @param modelId - the model id the extension's manifest declares.
|
|
112
|
+
* @param signal - cancellation for the read-only inspection.
|
|
113
|
+
* @returns the provider's inspection, or undefined when the model is not declared.
|
|
114
|
+
* @throws ProviderBridgeError when the package cannot be resolved or the provider
|
|
115
|
+
* refuses creation for this model id (the model's declaredness is the provider's
|
|
116
|
+
* to assert, so an undeclared id surfaces as a throw rather than undefined).
|
|
117
|
+
*/
|
|
118
|
+
async inspectExtension(specifier, modelId, signal, assets) {
|
|
119
|
+
if (this.#managed !== undefined) {
|
|
120
|
+
// Managed mode: the SAME worker-backed inspection as the catalog path —
|
|
121
|
+
// the entry is imported and created only in the child process.
|
|
122
|
+
const entry = { id: modelId, provider: { extension: specifier, modelId } };
|
|
123
|
+
return await this.inspect(entry, signal);
|
|
124
|
+
}
|
|
125
|
+
const entry = { id: modelId, provider: { extension: specifier, modelId } };
|
|
126
|
+
const activated = await this.#activate(specifier, entry);
|
|
127
|
+
const provider = await this.#providerFor(activated, { extension: specifier, modelId });
|
|
128
|
+
const first = await provider.inspect(signal);
|
|
129
|
+
/**
|
|
130
|
+
* A provider can only see the host's VERIFIED asset map through `load()`, and an
|
|
131
|
+
* extension whose inspect runs without it reports `needs-preparation` even when the
|
|
132
|
+
* bytes are prepared and verified (Needle: inspect resolves env/config/cache, not the
|
|
133
|
+
* host map). When inspect itself says it is unprepared and the host HAS a map for
|
|
134
|
+
* this deployment, hand the map over and re-inspect. This is a recovery path only:
|
|
135
|
+
* a provider that already reports callable readiness is never loaded here (EXT-18).
|
|
136
|
+
*/
|
|
137
|
+
if (first?.readiness === 'needs-preparation' && assets !== undefined) {
|
|
138
|
+
await provider.load({ assets, signal });
|
|
139
|
+
return await provider.inspect(signal);
|
|
140
|
+
}
|
|
141
|
+
return first;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Build an adapter for one catalog entry.
|
|
145
|
+
*
|
|
146
|
+
* Returns undefined when the entry declares no provider binding, which is the
|
|
147
|
+
* correct outcome for a model reached through a command transport instead.
|
|
148
|
+
*
|
|
149
|
+
* The adapter is LAZY: it does not import or activate the extension until the
|
|
150
|
+
* first invocation. Two reasons, and the second is the important one:
|
|
151
|
+
* registering a tool must not run somebody else's package code (EXT-19 requires
|
|
152
|
+
* import and `create()` to stay lightweight), and a package that fails to load
|
|
153
|
+
* must fail the CALL it was needed for rather than the registration of every
|
|
154
|
+
* other tool in the catalog.
|
|
155
|
+
* @param entry - the catalog entry.
|
|
156
|
+
* @returns the adapter, or undefined when no extension implements this model.
|
|
157
|
+
*/
|
|
158
|
+
adapterFor(entry) {
|
|
159
|
+
const binding = entry.provider;
|
|
160
|
+
if (binding === undefined)
|
|
161
|
+
return undefined;
|
|
162
|
+
if (this.#managed !== undefined) {
|
|
163
|
+
/**
|
|
164
|
+
* EXT-20, MANAGED MODE: the catalog invocation runs OUT OF PROCESS. The
|
|
165
|
+
* bridge resolves the entry path by DISCOVERY ONLY (reading the manifest is
|
|
166
|
+
* not importing), binds the worker to the activation generation, and sends
|
|
167
|
+
* the pre-authorized input over the wire — the grant, the caller identity
|
|
168
|
+
* and the host environment never cross, and the HOST resolves the path
|
|
169
|
+
* authority before the wire because the child's resolver DENIES by design.
|
|
170
|
+
*/
|
|
171
|
+
const registry = this.#managed;
|
|
172
|
+
return {
|
|
173
|
+
modelId: entry.id,
|
|
174
|
+
invoke: async (invocation) => {
|
|
175
|
+
const resolved = await resolveExtensionPackage(this.#installedPath?.(binding.extension) ?? binding.extension, entry);
|
|
176
|
+
const authority = invocation.authority ?? createInvocationAuthority(this.#grant, 'interactive');
|
|
177
|
+
const input = {};
|
|
178
|
+
for (const [key, value] of Object.entries(invocation.args)) {
|
|
179
|
+
input[key] = value;
|
|
180
|
+
}
|
|
181
|
+
// SEC-06: the HOST's authority is the child's path broker — the verified
|
|
182
|
+
// SDK protocol asks the host for EVERY path the provider touches, and an
|
|
183
|
+
// unauthorized candidate is refused by the authority inside this callback
|
|
184
|
+
// BEFORE the child ever opens the file. The broker is request-scoped and
|
|
185
|
+
// carries no grant or identity beyond the resolution function.
|
|
186
|
+
const resolvePath = (candidate) => authority.resolvePath(candidate);
|
|
187
|
+
// EXT-20: the worker is keyed by the TRUE MANIFEST ID, never by the path
|
|
188
|
+
// or the package specifier — and the manifest path rides along so the
|
|
189
|
+
// registry can stage an owning-package layout for manifest-less store copies.
|
|
190
|
+
const worker = await registry.adapterFor({
|
|
191
|
+
extensionId: resolved.manifestId,
|
|
192
|
+
entryPath: resolved.entryPath,
|
|
193
|
+
manifestPath: resolved.manifestPath,
|
|
194
|
+
generation: this.#generation,
|
|
195
|
+
});
|
|
196
|
+
// The CHILD's strict protocol maps IMPLEMENTATION ids to model ids through
|
|
197
|
+
// the manifest, so the wire carries the manifest's implementation id for
|
|
198
|
+
// this model — never the model id itself (a strict provider refuses a
|
|
199
|
+
// model id passed as an implementation id).
|
|
200
|
+
const implementationId = resolved.implementations
|
|
201
|
+
.find(implementation => implementation.modelId === binding.modelId)?.id
|
|
202
|
+
?? binding.modelId;
|
|
203
|
+
const payload = await worker.invoke({
|
|
204
|
+
implementationId,
|
|
205
|
+
input,
|
|
206
|
+
signal: invocation.signal,
|
|
207
|
+
resolvePath,
|
|
208
|
+
});
|
|
209
|
+
// The same reserved-root assertion as the in-process path (EXT-17).
|
|
210
|
+
assertNoReservedMeta(payload, binding.modelId);
|
|
211
|
+
return payload;
|
|
212
|
+
},
|
|
213
|
+
dispose: async () => {
|
|
214
|
+
await registry.dispose(binding.extension);
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
modelId: entry.id,
|
|
220
|
+
invoke: async (invocation) => {
|
|
221
|
+
const activated = await this.#activate(binding.extension, entry);
|
|
222
|
+
const provider = await this.#providerFor(activated, binding);
|
|
223
|
+
return this.#invoke(provider, binding, invocation);
|
|
224
|
+
},
|
|
225
|
+
// An arrow function, not a method: a method's `this` would be the adapter
|
|
226
|
+
// object literal rather than the bridge, so `#activated` would not resolve.
|
|
227
|
+
dispose: async () => {
|
|
228
|
+
// Provider-level disposal only when a provider was actually created:
|
|
229
|
+
// disposing a model that was never called must not activate its extension
|
|
230
|
+
// merely in order to shut it down.
|
|
231
|
+
const activated = this.#activated.get(binding.extension);
|
|
232
|
+
if (activated === undefined)
|
|
233
|
+
return;
|
|
234
|
+
const provider = (await activated).providers.get(binding.modelId);
|
|
235
|
+
if (provider !== undefined)
|
|
236
|
+
await (await provider).dispose();
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/** Release every activated extension. */
|
|
241
|
+
async dispose(reason = 'shutdown') {
|
|
242
|
+
const extensions = [...this.#activated.values()];
|
|
243
|
+
this.#activated.clear();
|
|
244
|
+
for (const pending of extensions) {
|
|
245
|
+
try {
|
|
246
|
+
const activated = await pending;
|
|
247
|
+
for (const provider of activated.providers.values()) {
|
|
248
|
+
await (await provider).dispose();
|
|
249
|
+
}
|
|
250
|
+
await activated.instance.dispose(reason);
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
// One extension failing to stop must not prevent the others from being
|
|
254
|
+
// released, or a single bad package would leak every process it shares.
|
|
255
|
+
this.#log('extension disposal failed', { error: String(error) });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/** Activate an extension package once, and reuse it. */
|
|
260
|
+
async #activate(specifier, entry) {
|
|
261
|
+
const existing = this.#activated.get(specifier);
|
|
262
|
+
if (existing !== undefined)
|
|
263
|
+
return existing;
|
|
264
|
+
const pending = (async () => {
|
|
265
|
+
// EVERY route (catalog inspect, extension inspect, tool dispatch) loads the
|
|
266
|
+
// installed copy by PATH when the host knows it: a store install is off this
|
|
267
|
+
// module graph, so a name lookup is what made tongue/voz fail on every boot.
|
|
268
|
+
const loaded = await loadExtensionPackage(this.#installedPath?.(specifier) ?? specifier, entry);
|
|
269
|
+
const instance = await activateExtension(loaded, this.#contextFor(specifier));
|
|
270
|
+
return { instance, providers: new Map() };
|
|
271
|
+
})();
|
|
272
|
+
this.#activated.set(specifier, pending);
|
|
273
|
+
pending.catch(() => {
|
|
274
|
+
if (this.#activated.get(specifier) === pending)
|
|
275
|
+
this.#activated.delete(specifier);
|
|
276
|
+
});
|
|
277
|
+
return pending;
|
|
278
|
+
}
|
|
279
|
+
/** Create or reuse the provider for one model. */
|
|
280
|
+
async #providerFor(activated, binding) {
|
|
281
|
+
const existing = activated.providers.get(binding.modelId);
|
|
282
|
+
if (existing !== undefined)
|
|
283
|
+
return existing;
|
|
284
|
+
const pending = activated.instance.createProvider({
|
|
285
|
+
modelId: binding.modelId,
|
|
286
|
+
configuration: {},
|
|
287
|
+
});
|
|
288
|
+
activated.providers.set(binding.modelId, pending);
|
|
289
|
+
pending.catch(() => {
|
|
290
|
+
if (activated.providers.get(binding.modelId) === pending)
|
|
291
|
+
activated.providers.delete(binding.modelId);
|
|
292
|
+
});
|
|
293
|
+
return pending;
|
|
294
|
+
}
|
|
295
|
+
/** Run one invocation through the provider. */
|
|
296
|
+
async #invoke(provider, binding, invocation) {
|
|
297
|
+
const authority = invocation.authority ?? createInvocationAuthority(this.#grant, 'interactive');
|
|
298
|
+
/**
|
|
299
|
+
* The load is deliberately NOT coordinated here.
|
|
300
|
+
*
|
|
301
|
+
* An earlier version routed `provider.load()` through the DeploymentCoordinator at
|
|
302
|
+
* this point, and the suite caught the consequence: loading then happened BEFORE
|
|
303
|
+
* the implementation authorized its inputs, so a call with a denied path loaded
|
|
304
|
+
* ~349 MB of weights before refusing. SEC-06 wants the denial first, and the
|
|
305
|
+
* extension performs path resolution inside `invoke`, so the coordinator cannot be
|
|
306
|
+
* placed here without inverting that.
|
|
307
|
+
*
|
|
308
|
+
* The coordinator is therefore a tested, standalone component (RES-02/03/05) whose
|
|
309
|
+
* place is INSIDE an implementation's own load path, where it can sit after the
|
|
310
|
+
* checks that must precede a load. Wiring it here would have traded a security
|
|
311
|
+
* property for a resource optimisation.
|
|
312
|
+
*/
|
|
313
|
+
const input = {};
|
|
314
|
+
for (const [key, value] of Object.entries(invocation.args)) {
|
|
315
|
+
input[key] = value;
|
|
316
|
+
}
|
|
317
|
+
const payload = await provider.invoke({
|
|
318
|
+
implementationId: binding.modelId,
|
|
319
|
+
input,
|
|
320
|
+
context: {
|
|
321
|
+
invocationId: `inv_${Date.now().toString(36)}_${Math.floor(Math.random() * 1e6).toString(36)}`,
|
|
322
|
+
signal: invocation.signal,
|
|
323
|
+
limits: authority.limits,
|
|
324
|
+
resolvePath: candidate => authority.resolvePath(candidate),
|
|
325
|
+
},
|
|
326
|
+
});
|
|
327
|
+
// The host authors the reserved root `meta` (EXT-17). An extension supplying one
|
|
328
|
+
// is asserting its own provenance, which it does not get to do.
|
|
329
|
+
assertNoReservedMeta(payload, binding.modelId);
|
|
330
|
+
return payload;
|
|
331
|
+
}
|
|
332
|
+
/** Build the context an extension receives, which carries no host internals. */
|
|
333
|
+
#contextFor(extensionId) {
|
|
334
|
+
const controller = new AbortController();
|
|
335
|
+
return {
|
|
336
|
+
extensionId,
|
|
337
|
+
extensionVersion: '0.0.0',
|
|
338
|
+
activationGeneration: this.#generation,
|
|
339
|
+
storage: {
|
|
340
|
+
// The host grants a directory it owns; the extension never receives a
|
|
341
|
+
// path into the operator's own filesystem.
|
|
342
|
+
directory: '',
|
|
343
|
+
async read() { return undefined; },
|
|
344
|
+
async write() { },
|
|
345
|
+
},
|
|
346
|
+
logger: {
|
|
347
|
+
log: (level, message, fields) => {
|
|
348
|
+
this.#log(`${level}: ${message}`, fields);
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
signal: controller.signal,
|
|
352
|
+
configuration: {},
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Resolve an extension package's entry path, manifest identity and manifest path BY
|
|
358
|
+
* DISCOVERY ONLY (EXT-20).
|
|
359
|
+
*
|
|
360
|
+
* This reads the package's metadata — the package.json and the manifest — and
|
|
361
|
+
* returns the absolute `./tool-mode` entry path, the manifest's TRUE id, and the
|
|
362
|
+
* manifest path WITHOUT importing the entry. Managed mode needs exactly this: the
|
|
363
|
+
* worker child imports the entry in its own process and derives its model mapping
|
|
364
|
+
* from the manifest, so the host must never load the module — and must key the
|
|
365
|
+
* worker by the manifest id, never by a path.
|
|
366
|
+
* @param specifier - the package name or absolute install path.
|
|
367
|
+
* @param entry - the catalog entry, for diagnostics.
|
|
368
|
+
* @returns the entry path, the manifest id and the manifest path.
|
|
369
|
+
* @throws ProviderBridgeError when the package cannot be resolved or has no entry.
|
|
370
|
+
*/
|
|
371
|
+
async function resolveExtensionPackage(specifier, entry) {
|
|
372
|
+
let packageJsonPath;
|
|
373
|
+
try {
|
|
374
|
+
// `import.meta.resolve` is the resolver the runtime itself uses, so the
|
|
375
|
+
// extension is found exactly as Node would find it at call time. An ABSOLUTE
|
|
376
|
+
// path resolves to the exact installed copy.
|
|
377
|
+
if (isAbsolute(specifier)) {
|
|
378
|
+
packageJsonPath = pathToFileURL(join(specifier, 'package.json')).href;
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
packageJsonPath = import.meta.resolve(`${specifier}/package.json`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
const origin = isAbsolute(specifier)
|
|
386
|
+
? 'the installed package'
|
|
387
|
+
: `the dependency "${specifier}"`;
|
|
388
|
+
throw new ProviderBridgeError(`model "${entry.id}" cannot reach ${origin}, which could not be resolved: `
|
|
389
|
+
+ `${error instanceof Error ? error.message : String(error)}. `
|
|
390
|
+
+ (isAbsolute(specifier)
|
|
391
|
+
? 'The store install path is unreadable; reinstall the package and retry.'
|
|
392
|
+
: 'Install it, or correct the catalog binding.'));
|
|
393
|
+
}
|
|
394
|
+
const { discoverExtension } = await import('@try-works/tool-mode-extension-sdk');
|
|
395
|
+
const discovery = discoverExtension(new URL('.', packageJsonPath).pathname.replace(/^\/([A-Za-z]:)/, '$1'));
|
|
396
|
+
if (discovery.entryPath === undefined) {
|
|
397
|
+
throw new ProviderBridgeError(`extension "${specifier}" declares no ${EXTENSION_ENTRY} entry, so it cannot provide model "${entry.id}"`);
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
entryPath: discovery.entryPath,
|
|
401
|
+
manifestId: discovery.manifest.id,
|
|
402
|
+
manifestPath: discovery.manifestPath,
|
|
403
|
+
implementations: discovery.manifest.implementations
|
|
404
|
+
.filter((implementation) => typeof implementation.modelId === 'string')
|
|
405
|
+
.map(implementation => ({ id: implementation.id, modelId: implementation.modelId })),
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Import an extension package's public entry.
|
|
410
|
+
*
|
|
411
|
+
* The specifier is resolved by Node like any other dependency, then the package's
|
|
412
|
+
* own discovery runs so the entry comes from its real `exports` map rather than
|
|
413
|
+
* from a host-side convention.
|
|
414
|
+
* @param specifier - the package name or path.
|
|
415
|
+
* @param entry - the catalog entry, for diagnostics.
|
|
416
|
+
* @returns the validated extension module.
|
|
417
|
+
* @throws ProviderBridgeError when the package cannot be resolved or has no entry.
|
|
418
|
+
*/
|
|
419
|
+
async function loadExtensionPackage(specifier, entry) {
|
|
420
|
+
const { entryPath } = await resolveExtensionPackage(specifier, entry);
|
|
421
|
+
return loadExtensionModule(entryPath);
|
|
422
|
+
}
|
|
423
|
+
//# sourceMappingURL=provider-bridge.js.map
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The authorized tool bindings a PTC program may call (CODE-03, ARCH-01, SEC-03).
|
|
3
|
+
*
|
|
4
|
+
* The directive is specific about this, and about what NOT to do:
|
|
5
|
+
*
|
|
6
|
+
* "ONE authorized-tool-pipeline function feeding both native PTC and external
|
|
7
|
+
* `tool_mode_run` — intersect requested names with the grant and the visible tool set,
|
|
8
|
+
* REJECT unknown/forbidden rather than omit."
|
|
9
|
+
*
|
|
10
|
+
* **Reject rather than omit** is the whole design. A program that asks for a tool it may
|
|
11
|
+
* not have must fail loudly: silently handing it a smaller namespace produces a program
|
|
12
|
+
* that runs, quietly does something other than what it says, and reports success. That is
|
|
13
|
+
* worse than a refusal, because the caller cannot tell the difference.
|
|
14
|
+
*
|
|
15
|
+
* The bindings themselves are built with a **null prototype**, so a program cannot reach
|
|
16
|
+
* `Object.prototype` through a binding name — `toString`, `constructor` and `__proto__`
|
|
17
|
+
* stop being reachable as if they were tools.
|
|
18
|
+
*
|
|
19
|
+
* @module @try-works/dsh-tool-mode/ptc-authority
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* One binding a program may call.
|
|
23
|
+
*
|
|
24
|
+
* The shape is what a PTC runtime expects: a function that takes already-validated
|
|
25
|
+
* arguments and returns the tool's canonical value.
|
|
26
|
+
*/
|
|
27
|
+
export type ToolBinding = (args: Record<string, unknown>) => Promise<unknown>;
|
|
28
|
+
/** What a program asked for. */
|
|
29
|
+
export interface ProgramRequest {
|
|
30
|
+
/** The tool names the generated program declares it will call. */
|
|
31
|
+
readonly requested: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
/** What the caller is permitted to reach. */
|
|
34
|
+
export interface ProgramAuthority {
|
|
35
|
+
/**
|
|
36
|
+
* The tool names the caller's grant admits.
|
|
37
|
+
*
|
|
38
|
+
* This is the AUTHORIZATION half. A tool absent here is forbidden regardless of whether
|
|
39
|
+
* it is registered.
|
|
40
|
+
*/
|
|
41
|
+
readonly granted: readonly string[];
|
|
42
|
+
/**
|
|
43
|
+
* The tool names actually registered right now.
|
|
44
|
+
*
|
|
45
|
+
* This is the AVAILABILITY half, and it is separate: a granted tool whose owning
|
|
46
|
+
* extension is deactivated is not available, while a registered tool the caller has no
|
|
47
|
+
* grant for is not permitted. Only the INTERSECTION is bindable.
|
|
48
|
+
*/
|
|
49
|
+
readonly visible: readonly string[];
|
|
50
|
+
/**
|
|
51
|
+
* Tools whose canonical value is confidential (MCP-11). These are blocked before a
|
|
52
|
+
* binding can return their value, regardless of grant.
|
|
53
|
+
*/
|
|
54
|
+
readonly confidential?: readonly string[];
|
|
55
|
+
}
|
|
56
|
+
/** Why one requested name was refused. */
|
|
57
|
+
export interface BindingRejection {
|
|
58
|
+
readonly name: string;
|
|
59
|
+
readonly reason:
|
|
60
|
+
/** No such tool is registered. */
|
|
61
|
+
'unknown'
|
|
62
|
+
/** Registered, but the caller's grant does not admit it. */
|
|
63
|
+
| 'forbidden'
|
|
64
|
+
/** Requested more than once, which makes the program ambiguous. */
|
|
65
|
+
| 'duplicate'
|
|
66
|
+
/** Not a usable identifier as a binding name. */
|
|
67
|
+
| 'invalid-name'
|
|
68
|
+
/** CODE-07: never bindable inside a program, regardless of grant. */
|
|
69
|
+
| 'excluded'
|
|
70
|
+
/** MCP-11: blocked by the operator confidentiality policy. */
|
|
71
|
+
| 'confidential';
|
|
72
|
+
/** What the caller can do about it, when anything. */
|
|
73
|
+
readonly remedy: string;
|
|
74
|
+
}
|
|
75
|
+
/** The outcome of authorizing a program's requested tools. */
|
|
76
|
+
export type AuthorityDecision = {
|
|
77
|
+
readonly ok: true;
|
|
78
|
+
/** The bindings, with a null prototype. */
|
|
79
|
+
readonly bindings: Record<string, ToolBinding>;
|
|
80
|
+
/** The names that were bound, in request order. */
|
|
81
|
+
readonly bound: readonly string[];
|
|
82
|
+
} | {
|
|
83
|
+
readonly ok: false;
|
|
84
|
+
/**
|
|
85
|
+
* EVERY rejection, not the first.
|
|
86
|
+
*
|
|
87
|
+
* A program asking for three tools it cannot have should learn all three in one
|
|
88
|
+
* round rather than being handed the next one each time.
|
|
89
|
+
*/
|
|
90
|
+
readonly rejections: readonly BindingRejection[];
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Generate TypeScript bindings for EXACTLY the names a program was authorized to call
|
|
94
|
+
* (CODE-03). The generated source is descriptive metadata, not executable code.
|
|
95
|
+
* @param names - the bound names, after the grant/visibility intersection.
|
|
96
|
+
* @returns a TypeScript interface declaration.
|
|
97
|
+
*/
|
|
98
|
+
export declare function generateProgramTypes(names: readonly string[]): string;
|
|
99
|
+
/**
|
|
100
|
+
* Whether a name is usable as a binding.
|
|
101
|
+
*
|
|
102
|
+
* A generated program references bindings as identifiers, so a name that is not a plain
|
|
103
|
+
* identifier cannot be bound — and `__proto__` in particular must never become a key on
|
|
104
|
+
* the map, since assigning it would change the object's prototype rather than add a field.
|
|
105
|
+
* @param name - the candidate name.
|
|
106
|
+
* @returns whether it is usable.
|
|
107
|
+
*/
|
|
108
|
+
export declare function isBindableName(name: string): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Tool names a program binding must NEVER expose, regardless of grant (CODE-07).
|
|
111
|
+
*
|
|
112
|
+
* `tool_mode_run` is the recursive composition door: a program could nest programs, which
|
|
113
|
+
* the requirement forbids in v1. The management surface (`model_tools` and the extension
|
|
114
|
+
* install/activation controls) is operator territory: EXT-32 excludes installer and
|
|
115
|
+
* administration bindings from Code Mode, and SEC-09 keeps installation approval separate
|
|
116
|
+
* from tool-use permission, so a program that could reach them would hold the management
|
|
117
|
+
* grant by proxy.
|
|
118
|
+
*
|
|
119
|
+
* EXPORTED so the planning surface (NDL-02) reuses the SAME names: a `tools_plan`
|
|
120
|
+
* proposal must never target the composition door or the management surface either, and a
|
|
121
|
+
* second, independently maintained copy of this list would drift the first time one of
|
|
122
|
+
* them was edited. One set, two consumers, both refused by name.
|
|
123
|
+
*
|
|
124
|
+
* SEALED AS A FROZEN ARRAY, deliberately not a frozen `Set`: freezing a `Set` does NOT
|
|
125
|
+
* prevent `add`/`delete` (those methods mutate internal slots without consulting
|
|
126
|
+
* extensibility), so a frozen Set would only LOOK immutable. A frozen array throws on
|
|
127
|
+
* every mutation in strict mode, so neither consumer — nor any code holding a
|
|
128
|
+
* reference — can add or remove a name at runtime and silently desynchronize the two
|
|
129
|
+
* surfaces that depend on it.
|
|
130
|
+
*/
|
|
131
|
+
export declare const EXCLUDED_BINDINGS: readonly string[];
|
|
132
|
+
/**
|
|
133
|
+
* Build the bindings a program may call (CODE-03, SEC-03).
|
|
134
|
+
*
|
|
135
|
+
* Intersects the requested names with BOTH the grant and the visible set, and refuses the
|
|
136
|
+
* whole request if anything is unattainable — so a program never runs against a smaller
|
|
137
|
+
* namespace than it declared.
|
|
138
|
+
*
|
|
139
|
+
* @param request - what the program asked for.
|
|
140
|
+
* @param authority - what is granted and what is available.
|
|
141
|
+
* @param resolve - resolves one bound name to its implementation.
|
|
142
|
+
* @returns the bindings, or every rejection.
|
|
143
|
+
*/
|
|
144
|
+
export declare function authorizeProgramTools(request: ProgramRequest, authority: ProgramAuthority, resolve: (name: string) => ToolBinding | undefined): AuthorityDecision;
|
|
145
|
+
/**
|
|
146
|
+
* Describe a refusal for a caller (CODE-03).
|
|
147
|
+
*
|
|
148
|
+
* Names every rejection and why, because a program author who is told only that the
|
|
149
|
+
* request failed cannot fix it.
|
|
150
|
+
* @param rejections - the refusals.
|
|
151
|
+
* @returns a readable summary.
|
|
152
|
+
*/
|
|
153
|
+
export declare function describeRejections(rejections: readonly BindingRejection[]): string;
|
|
154
|
+
//# sourceMappingURL=ptc-authority.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ptc-authority.d.ts","sourceRoot":"","sources":["../src/ptc-authority.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAE7E,gCAAgC;AAChC,MAAM,WAAW,cAAc;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;CACtC;AAED,6CAA6C;AAC7C,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC1C;AAED,0CAA0C;AAC1C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM;IACb,kCAAkC;IAChC,SAAS;IACX,4DAA4D;OAC1D,WAAW;IACb,mEAAmE;OACjE,WAAW;IACb,iDAAiD;OAC/C,cAAc;IAChB,qEAAqE;OACnE,UAAU;IACZ,8DAA8D;OAC5D,cAAc,CAAA;IAClB,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,8DAA8D;AAC9D,MAAM,MAAM,iBAAiB,GACzB;IACA,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;IACjB,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IAC9C,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAClC,GACC;IACA,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAA;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,CAAA;CACjD,CAAA;AAEH;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAUrE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQpD;AAgCD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAA2H,CAAA;AAE1K;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,GACjD,iBAAiB,CAgHnB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,GAAG,MAAM,CAGlF"}
|