@try-works/dsh-tool-mode 0.0.0-stage → 0.5.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +299 -2
- package/bin/dsh-tool-mode-credentials.mjs +20 -0
- package/bin/dsh-tool-mode-mcp-stdio.mjs +80 -0
- package/bin/dsh-tool-mode.mjs +211 -0
- package/builtins.lock.json +26 -0
- package/catalog/desert-ant-models.json +693 -0
- package/catalog/playbooks.json +531 -0
- package/client/client.model-tools.js +1910 -0
- package/client/index.js +4039 -0
- package/cordis.patch.yml +39 -0
- package/lib/adapters/index.d.ts +61 -0
- package/lib/adapters/index.d.ts.map +1 -0
- package/lib/adapters/index.js +82 -0
- package/lib/adapters/types.d.ts +106 -0
- package/lib/adapters/types.d.ts.map +1 -0
- package/lib/adapters/types.js +85 -0
- package/lib/approval.d.ts +189 -0
- package/lib/approval.d.ts.map +1 -0
- package/lib/approval.js +510 -0
- package/lib/asset-acquisition.d.ts +149 -0
- package/lib/asset-acquisition.d.ts.map +1 -0
- package/lib/asset-acquisition.js +175 -0
- package/lib/authority.d.ts +185 -0
- package/lib/authority.d.ts.map +1 -0
- package/lib/authority.js +223 -0
- package/lib/bindings.d.ts +144 -0
- package/lib/bindings.d.ts.map +1 -0
- package/lib/bindings.js +314 -0
- package/lib/builtins.d.ts +27 -0
- package/lib/builtins.d.ts.map +1 -0
- package/lib/builtins.js +37 -0
- package/lib/capability.d.ts +58 -0
- package/lib/capability.d.ts.map +1 -0
- package/lib/capability.js +192 -0
- package/lib/capture-path.d.ts +97 -0
- package/lib/capture-path.d.ts.map +1 -0
- package/lib/capture-path.js +152 -0
- package/lib/catalog.d.ts +37 -0
- package/lib/catalog.d.ts.map +1 -0
- package/lib/catalog.js +274 -0
- package/lib/contract-payload.d.ts +39 -0
- package/lib/contract-payload.d.ts.map +1 -0
- package/lib/contract-payload.js +56 -0
- package/lib/custom-tools/compile.d.ts +25 -0
- package/lib/custom-tools/compile.d.ts.map +1 -0
- package/lib/custom-tools/compile.js +61 -0
- package/lib/custom-tools/composite-executor.d.ts +42 -0
- package/lib/custom-tools/composite-executor.d.ts.map +1 -0
- package/lib/custom-tools/composite-executor.js +113 -0
- package/lib/custom-tools/dispatch.d.ts +28 -0
- package/lib/custom-tools/dispatch.d.ts.map +1 -0
- package/lib/custom-tools/dispatch.js +34 -0
- package/lib/custom-tools/http-executor.d.ts +48 -0
- package/lib/custom-tools/http-executor.d.ts.map +1 -0
- package/lib/custom-tools/http-executor.js +241 -0
- package/lib/custom-tools/index.d.ts +12 -0
- package/lib/custom-tools/index.d.ts.map +1 -0
- package/lib/custom-tools/index.js +12 -0
- package/lib/custom-tools/mcp-surface.d.ts +14 -0
- package/lib/custom-tools/mcp-surface.d.ts.map +1 -0
- package/lib/custom-tools/mcp-surface.js +41 -0
- package/lib/custom-tools/prompt-executor.d.ts +39 -0
- package/lib/custom-tools/prompt-executor.d.ts.map +1 -0
- package/lib/custom-tools/prompt-executor.js +59 -0
- package/lib/custom-tools/registry.d.ts +69 -0
- package/lib/custom-tools/registry.d.ts.map +1 -0
- package/lib/custom-tools/registry.js +130 -0
- package/lib/custom-tools/schema.d.ts +26 -0
- package/lib/custom-tools/schema.d.ts.map +1 -0
- package/lib/custom-tools/schema.js +375 -0
- package/lib/custom-tools/service.d.ts +90 -0
- package/lib/custom-tools/service.d.ts.map +1 -0
- package/lib/custom-tools/service.js +203 -0
- package/lib/custom-tools/store.d.ts +61 -0
- package/lib/custom-tools/store.d.ts.map +1 -0
- package/lib/custom-tools/store.js +240 -0
- package/lib/custom-tools/types.d.ts +131 -0
- package/lib/custom-tools/types.d.ts.map +1 -0
- package/lib/custom-tools/types.js +11 -0
- package/lib/decision-combine.d.ts +113 -0
- package/lib/decision-combine.d.ts.map +1 -0
- package/lib/decision-combine.js +156 -0
- package/lib/decision-evaluate.d.ts +185 -0
- package/lib/decision-evaluate.d.ts.map +1 -0
- package/lib/decision-evaluate.js +227 -0
- package/lib/deployment-coordinator.d.ts +213 -0
- package/lib/deployment-coordinator.d.ts.map +1 -0
- package/lib/deployment-coordinator.js +274 -0
- package/lib/diagnostics.d.ts +169 -0
- package/lib/diagnostics.d.ts.map +1 -0
- package/lib/diagnostics.js +136 -0
- package/lib/discovery-contracts.d.ts +14 -0
- package/lib/discovery-contracts.d.ts.map +1 -0
- package/lib/discovery-contracts.js +90 -0
- package/lib/discovery-describe.d.ts +35 -0
- package/lib/discovery-describe.d.ts.map +1 -0
- package/lib/discovery-describe.js +99 -0
- package/lib/embedding-index.d.ts +55 -0
- package/lib/embedding-index.d.ts.map +1 -0
- package/lib/embedding-index.js +126 -0
- package/lib/extension-dependencies.d.ts +355 -0
- package/lib/extension-dependencies.d.ts.map +1 -0
- package/lib/extension-dependencies.js +987 -0
- package/lib/extension-dispatch.d.ts +150 -0
- package/lib/extension-dispatch.d.ts.map +1 -0
- package/lib/extension-dispatch.js +178 -0
- package/lib/extension-page-state.d.ts +69 -0
- package/lib/extension-page-state.d.ts.map +1 -0
- package/lib/extension-page-state.js +82 -0
- package/lib/extension-registrar.d.ts +116 -0
- package/lib/extension-registrar.d.ts.map +1 -0
- package/lib/extension-registrar.js +144 -0
- package/lib/extensions-api.d.ts +346 -0
- package/lib/extensions-api.d.ts.map +1 -0
- package/lib/extensions-api.js +17 -0
- package/lib/extensions-remote.d.ts +57 -0
- package/lib/extensions-remote.d.ts.map +1 -0
- package/lib/extensions-remote.js +69 -0
- package/lib/extensions-service.d.ts +568 -0
- package/lib/extensions-service.d.ts.map +1 -0
- package/lib/extensions-service.js +2507 -0
- package/lib/harness-budgets.d.ts +158 -0
- package/lib/harness-budgets.d.ts.map +1 -0
- package/lib/harness-budgets.js +152 -0
- package/lib/harness-llm.d.ts +138 -0
- package/lib/harness-llm.d.ts.map +1 -0
- package/lib/harness-llm.js +218 -0
- package/lib/harness-serving.d.ts +115 -0
- package/lib/harness-serving.d.ts.map +1 -0
- package/lib/harness-serving.js +176 -0
- package/lib/headless.d.ts +97 -0
- package/lib/headless.d.ts.map +1 -0
- package/lib/headless.js +407 -0
- package/lib/http-acquisition.d.ts +27 -0
- package/lib/http-acquisition.d.ts.map +1 -0
- package/lib/http-acquisition.js +140 -0
- package/lib/index.d.ts +546 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5197 -0
- package/lib/invocation-accounting.d.ts +169 -0
- package/lib/invocation-accounting.d.ts.map +1 -0
- package/lib/invocation-accounting.js +148 -0
- package/lib/jev.d.ts +218 -0
- package/lib/jev.d.ts.map +1 -0
- package/lib/jev.js +366 -0
- package/lib/legacy-migration.d.ts +95 -0
- package/lib/legacy-migration.d.ts.map +1 -0
- package/lib/legacy-migration.js +429 -0
- package/lib/license-basis.d.ts +29 -0
- package/lib/license-basis.d.ts.map +1 -0
- package/lib/license-basis.js +58 -0
- package/lib/managed-workers.d.ts +158 -0
- package/lib/managed-workers.d.ts.map +1 -0
- package/lib/managed-workers.js +269 -0
- package/lib/mcp/auth-selection.d.ts +35 -0
- package/lib/mcp/auth-selection.d.ts.map +1 -0
- package/lib/mcp/auth-selection.js +64 -0
- package/lib/mcp/client-grant.d.ts +89 -0
- package/lib/mcp/client-grant.d.ts.map +1 -0
- package/lib/mcp/client-grant.js +63 -0
- package/lib/mcp/credential-cli.d.ts +38 -0
- package/lib/mcp/credential-cli.d.ts.map +1 -0
- package/lib/mcp/credential-cli.js +148 -0
- package/lib/mcp/credential-store.d.ts +143 -0
- package/lib/mcp/credential-store.d.ts.map +1 -0
- package/lib/mcp/credential-store.js +461 -0
- package/lib/mcp/export-policy.d.ts +25 -0
- package/lib/mcp/export-policy.d.ts.map +1 -0
- package/lib/mcp/export-policy.js +31 -0
- package/lib/mcp/host-binding.d.ts +144 -0
- package/lib/mcp/host-binding.d.ts.map +1 -0
- package/lib/mcp/host-binding.js +280 -0
- package/lib/mcp/http.d.ts +180 -0
- package/lib/mcp/http.d.ts.map +1 -0
- package/lib/mcp/http.js +602 -0
- package/lib/mcp/oauth.d.ts +149 -0
- package/lib/mcp/oauth.d.ts.map +1 -0
- package/lib/mcp/oauth.js +396 -0
- package/lib/mcp/protocol.d.ts +329 -0
- package/lib/mcp/protocol.d.ts.map +1 -0
- package/lib/mcp/protocol.js +459 -0
- package/lib/mcp/rate-limit.d.ts +68 -0
- package/lib/mcp/rate-limit.d.ts.map +1 -0
- package/lib/mcp/rate-limit.js +114 -0
- package/lib/mcp/sdk-v2.d.ts +17 -0
- package/lib/mcp/sdk-v2.d.ts.map +1 -0
- package/lib/mcp/sdk-v2.js +204 -0
- package/lib/mcp/server.d.ts +149 -0
- package/lib/mcp/server.d.ts.map +1 -0
- package/lib/mcp/server.js +302 -0
- package/lib/mcp/stdio.d.ts +80 -0
- package/lib/mcp/stdio.d.ts.map +1 -0
- package/lib/mcp/stdio.js +184 -0
- package/lib/mcp/subscriptions.d.ts +177 -0
- package/lib/mcp/subscriptions.d.ts.map +1 -0
- package/lib/mcp/subscriptions.js +288 -0
- package/lib/mcp-status.d.ts +96 -0
- package/lib/mcp-status.d.ts.map +1 -0
- package/lib/mcp-status.js +70 -0
- package/lib/mcp-usage.d.ts +110 -0
- package/lib/mcp-usage.d.ts.map +1 -0
- package/lib/mcp-usage.js +189 -0
- package/lib/model-qualification.d.ts +192 -0
- package/lib/model-qualification.d.ts.map +1 -0
- package/lib/model-qualification.js +178 -0
- package/lib/planning.d.ts +256 -0
- package/lib/planning.d.ts.map +1 -0
- package/lib/planning.js +471 -0
- package/lib/playbook.d.ts +42 -0
- package/lib/playbook.d.ts.map +1 -0
- package/lib/playbook.js +65 -0
- package/lib/prepared-assets.d.ts +269 -0
- package/lib/prepared-assets.d.ts.map +1 -0
- package/lib/prepared-assets.js +471 -0
- package/lib/provider-bridge.d.ts +107 -0
- package/lib/provider-bridge.d.ts.map +1 -0
- package/lib/provider-bridge.js +423 -0
- package/lib/ptc-authority.d.ts +154 -0
- package/lib/ptc-authority.d.ts.map +1 -0
- package/lib/ptc-authority.js +242 -0
- package/lib/ptc-confinement.d.ts +60 -0
- package/lib/ptc-confinement.d.ts.map +1 -0
- package/lib/ptc-confinement.js +212 -0
- package/lib/ptc-runtime.d.ts +166 -0
- package/lib/ptc-runtime.d.ts.map +1 -0
- package/lib/ptc-runtime.js +231 -0
- package/lib/publication.d.ts +161 -0
- package/lib/publication.d.ts.map +1 -0
- package/lib/publication.js +181 -0
- package/lib/receipt-store.d.ts +57 -0
- package/lib/receipt-store.d.ts.map +1 -0
- package/lib/receipt-store.js +143 -0
- package/lib/receipt.d.ts +231 -0
- package/lib/receipt.d.ts.map +1 -0
- package/lib/receipt.js +165 -0
- package/lib/registrar.d.ts +75 -0
- package/lib/registrar.d.ts.map +1 -0
- package/lib/registrar.js +152 -0
- package/lib/resource-governance.d.ts +204 -0
- package/lib/resource-governance.d.ts.map +1 -0
- package/lib/resource-governance.js +213 -0
- package/lib/server-lifecycle.d.ts +175 -0
- package/lib/server-lifecycle.d.ts.map +1 -0
- package/lib/server-lifecycle.js +269 -0
- package/lib/skills.d.ts +31 -0
- package/lib/skills.d.ts.map +1 -0
- package/lib/skills.js +170 -0
- package/lib/speech-bridge.d.ts +74 -0
- package/lib/speech-bridge.d.ts.map +1 -0
- package/lib/speech-bridge.js +115 -0
- package/lib/state.d.ts +100 -0
- package/lib/state.d.ts.map +1 -0
- package/lib/state.js +160 -0
- package/lib/title-proposal.d.ts +194 -0
- package/lib/title-proposal.d.ts.map +1 -0
- package/lib/title-proposal.js +244 -0
- package/lib/tool-inventory.d.ts +90 -0
- package/lib/tool-inventory.d.ts.map +1 -0
- package/lib/tool-inventory.js +102 -0
- package/lib/tool-mode-run.d.ts +310 -0
- package/lib/tool-mode-run.d.ts.map +1 -0
- package/lib/tool-mode-run.js +411 -0
- package/lib/tool-sources.d.ts +80 -0
- package/lib/tool-sources.d.ts.map +1 -0
- package/lib/tool-sources.js +123 -0
- package/lib/tool-usage-projection.d.ts +390 -0
- package/lib/tool-usage-projection.d.ts.map +1 -0
- package/lib/tool-usage-projection.js +1038 -0
- package/lib/tool-usage-report.d.ts +153 -0
- package/lib/tool-usage-report.d.ts.map +1 -0
- package/lib/tool-usage-report.js +274 -0
- package/lib/transport.d.ts +158 -0
- package/lib/transport.d.ts.map +1 -0
- package/lib/transport.js +332 -0
- package/lib/types.d.ts +134 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +8 -0
- package/lib/update-surface.d.ts +79 -0
- package/lib/update-surface.d.ts.map +1 -0
- package/lib/update-surface.js +224 -0
- package/lib/version.d.ts +3 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +27 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts +13 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.js +85 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts +16 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.js +87 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts +38 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.js +445 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts +20 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.js +112 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts +14 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.js +63 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts +14 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.js +76 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts +82 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/dsh.js +274 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts +26 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/index.js +53 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts +133 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/meta.js +64 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts +121 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.js +246 -0
- package/node_modules/@try-works/tool-mode-contracts/package.json +35 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/bin/dsh-tool-mode.mjs +20 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts +80 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.js +533 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts +86 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.js +145 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts +70 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.js +201 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts +57 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.js +83 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts +33 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.js +33 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts +86 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.js +191 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts +137 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.js +349 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts +274 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.js +932 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts +210 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.js +368 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts +63 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.js +149 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts +35 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.js +179 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts +179 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.js +299 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts +395 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.js +839 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts +44 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.js +255 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts +185 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.js +504 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts +17 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.js +80 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts +221 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.js +188 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts +52 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.js +102 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts +171 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.js +271 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts +242 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.js +58 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts +128 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.js +113 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts +41 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.js +52 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts +2 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.js +351 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts +157 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.js +688 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/package.json +54 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/schema/extension-manifest-1.1.0.schema.json +253 -0
- package/node_modules/@try-works/tool-mode-recipes/bin/tool-mode-recipe.mjs +15 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts +460 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/broker.js +647 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts +61 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/cli.js +1106 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts +237 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.js +205 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts +85 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.js +176 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts +119 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/images.js +201 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts +25 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/index.js +25 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts +345 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.js +1465 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts +51 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/templates.js +310 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts +231 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/titles.js +435 -0
- package/node_modules/@try-works/tool-mode-recipes/package.json +56 -0
- package/node_modules/@try-works/tool-mode-recipes/recipes/describe-image.json +38 -0
- package/node_modules/@try-works/tool-mode-recipes/recipes/text-title.json +45 -0
- package/node_modules/@try-works/tool-mode-recipes/schema/harness-model-recipe.schema.json +273 -0
- package/package.json +127 -4
- package/remote/spec.mjs +993 -0
- package/remote/typert.host.mjs +14 -0
- package/remote/typert.remote-client.mjs +16 -0
package/lib/planning.js
ADDED
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host-side `tools_plan` discipline (NDL-02, NDL-03).
|
|
3
|
+
*
|
|
4
|
+
* The Needle extension implements the ENGINE half of the planning contract: one-shot
|
|
5
|
+
* proposals over a caller-supplied tool list, with the list validated by the extension
|
|
6
|
+
* itself. What NDL-02 forbids is the HOST trusting that caller-supplied list. The list is
|
|
7
|
+
* the authorization surface: whatever schemas the planner receives, it may propose calls
|
|
8
|
+
* against, and a caller who could hand over the whole registry — or a list of its own
|
|
9
|
+
* invention — would be using `tools_plan` as a permission oracle. So the host owns four
|
|
10
|
+
* things the extension never sees:
|
|
11
|
+
*
|
|
12
|
+
* 1. **The frozen snapshot.** At first use, the host captures the currently registered
|
|
13
|
+
* tool schemas (name, description, parameters — nothing executable) into a snapshot
|
|
14
|
+
* that is deep-copied and deep-frozen. Later registry changes cannot leak into it, and
|
|
15
|
+
* a holder of the snapshot cannot mutate it. The planner receives ONLY entries from
|
|
16
|
+
* this snapshot; it never receives the caller's declared tool list, an unfiltered
|
|
17
|
+
* registry, or anything callable (NDL-02's "narrow public broker").
|
|
18
|
+
*
|
|
19
|
+
* 2. **The requested-name gate.** The caller asks for names; the host intersects them
|
|
20
|
+
* with the LIVE registry. Unknown names (never registered, or withdrawn), excluded
|
|
21
|
+
* names (management and composition), duplicates, and live-but-unsnapshotted names are
|
|
22
|
+
* all REJECTED — the whole call fails with every rejection named, never a silently
|
|
23
|
+
* smaller offer set (the CODE-03 "reject rather than omit" discipline).
|
|
24
|
+
*
|
|
25
|
+
* 3. **Host-side re-validation.** When the provider returns proposals, the host
|
|
26
|
+
* re-validates every proposal against the SNAPSHOT schema, not the provider's own
|
|
27
|
+
* verdict. A proposal the engine fabricated outside the offered set, or arguments that
|
|
28
|
+
* violate the frozen schema, are moved to `rejected` with the violations named.
|
|
29
|
+
*
|
|
30
|
+
* 4. **Fresh policy checks.** A proposal is DATA; executing it goes through the registry's
|
|
31
|
+
* own admission later (NDL-03). The host still refuses to return a proposal whose tool
|
|
32
|
+
* is no longer registered — deactivated or withdrawn after the snapshot was captured —
|
|
33
|
+
* so a caller never receives a proposal for a tool that is not currently callable.
|
|
34
|
+
*
|
|
35
|
+
* Everything here is a pure function over plain data: the DSH context, the store and the
|
|
36
|
+
* lifecycle stay in the host wiring, so the discipline is testable without mounting a
|
|
37
|
+
* plugin and without the pinned engine artifacts.
|
|
38
|
+
*
|
|
39
|
+
* @module @try-works/dsh-tool-mode/planning
|
|
40
|
+
*/
|
|
41
|
+
import { Ajv } from 'ajv';
|
|
42
|
+
import { EXCLUDED_BINDINGS } from "./ptc-authority.js";
|
|
43
|
+
/**
|
|
44
|
+
* The validator the proposal re-checks compile with.
|
|
45
|
+
*
|
|
46
|
+
* Deliberately NON-STRICT, matching the extension's own `checkArguments` policy: the
|
|
47
|
+
* snapshot entries come from the DSH registry's model-facing projection, which may omit
|
|
48
|
+
* keywords a strict compiler refuses (`additionalProperties` in particular), and a
|
|
49
|
+
* caller-facing tool list must not be rejected because the registry's projection is not
|
|
50
|
+
* strict-authored. The strict compiler stays for DECLARED schemas, which are authored
|
|
51
|
+
* under the contracts package's own discipline.
|
|
52
|
+
*/
|
|
53
|
+
const PROPOSAL_AJV = new Ajv({ allErrors: true, strict: false });
|
|
54
|
+
/** The caller-facing name of the planning contract (NDL-02). */
|
|
55
|
+
export const PLANNING_TOOL_NAME = 'tools_plan';
|
|
56
|
+
/**
|
|
57
|
+
* Tool names the planning surface must never offer or propose (NDL-02 + CODE-07).
|
|
58
|
+
*
|
|
59
|
+
* The program-binding exclusions are reused rather than restated: a proposal targeting
|
|
60
|
+
* `tool_mode_run` (the recursive composition door) or the management surface would hand a
|
|
61
|
+
* caller the same proxy grant CODE-07 withholds from programs. `tools_plan` itself is
|
|
62
|
+
* added so a plan can never propose planning — recursive planning is noise, and the
|
|
63
|
+
* planning tool is not a leaf inference tool.
|
|
64
|
+
*
|
|
65
|
+
* SEALED like {@link EXCLUDED_BINDINGS} — a frozen ARRAY, because freezing a `Set` does
|
|
66
|
+
* not stop `add`/`delete` — so the planning surface and the program-binding surface
|
|
67
|
+
* cannot desynchronize through a runtime mutation.
|
|
68
|
+
*/
|
|
69
|
+
export const PLANNING_EXCLUDED_TOOLS = Object.freeze([...EXCLUDED_BINDINGS, PLANNING_TOOL_NAME]);
|
|
70
|
+
/**
|
|
71
|
+
* Intersect the live registry with the planner's exclusions AND, when present, the
|
|
72
|
+
* external caller's grant (SEC-04/NDL-02). An external caller granted only
|
|
73
|
+
* `tools_plan` must not plan over tools it could not invoke itself.
|
|
74
|
+
* @param names - live registry tool names.
|
|
75
|
+
* @param excluded - tool names the planner never offers.
|
|
76
|
+
* @param callerGrant - the external client's granted names, or undefined for the host.
|
|
77
|
+
* @returns the eligible leaf set.
|
|
78
|
+
*/
|
|
79
|
+
export function filterPlanningLiveTools(names, excluded = PLANNING_EXCLUDED_TOOLS, callerGrant) {
|
|
80
|
+
return new Set(names
|
|
81
|
+
.filter(name => !excluded.includes(name))
|
|
82
|
+
.filter(name => callerGrant === undefined || callerGrant.includes(name)));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Deep-copy a JSON value, guarding against cycles.
|
|
86
|
+
*
|
|
87
|
+
* Hand-rolled rather than `structuredClone` so the module stays independent of which
|
|
88
|
+
* global typings a build resolves, and so a cyclic schema cannot recurse forever.
|
|
89
|
+
* @param value - the value to copy.
|
|
90
|
+
* @param seen - objects already copied, keyed by source.
|
|
91
|
+
* @returns the copy.
|
|
92
|
+
*/
|
|
93
|
+
function deepClone(value, seen) {
|
|
94
|
+
if (value === null || typeof value !== 'object')
|
|
95
|
+
return value;
|
|
96
|
+
const existing = seen.get(value);
|
|
97
|
+
if (existing !== undefined)
|
|
98
|
+
return existing;
|
|
99
|
+
if (Array.isArray(value)) {
|
|
100
|
+
const out = [];
|
|
101
|
+
seen.set(value, out);
|
|
102
|
+
for (const item of value)
|
|
103
|
+
out.push(deepClone(item, seen));
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
const out = {};
|
|
107
|
+
seen.set(value, out);
|
|
108
|
+
for (const [key, child] of Object.entries(value)) {
|
|
109
|
+
out[key] = deepClone(child, seen);
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Freeze a value transitively, guarding against cycles.
|
|
115
|
+
* @param value - the value to freeze.
|
|
116
|
+
* @param seen - objects already visited, so a cyclic schema cannot recurse forever.
|
|
117
|
+
*/
|
|
118
|
+
function deepFreeze(value, seen) {
|
|
119
|
+
if (value === null || typeof value !== 'object')
|
|
120
|
+
return;
|
|
121
|
+
if (seen.has(value))
|
|
122
|
+
return;
|
|
123
|
+
seen.add(value);
|
|
124
|
+
for (const child of Object.values(value))
|
|
125
|
+
deepFreeze(child, seen);
|
|
126
|
+
Object.freeze(value);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Capture the frozen host-approved tool schema snapshot (NDL-02).
|
|
130
|
+
*
|
|
131
|
+
* The capture is a DEEP COPY: mutating the registry afterwards — registering a tool,
|
|
132
|
+
* withdrawing one, changing a description — cannot change the snapshot, and mutating the
|
|
133
|
+
* snapshot is refused by the runtime because every node is frozen. Excluded names are
|
|
134
|
+
* skipped rather than captured-then-filtered, so a management tool's schema never enters
|
|
135
|
+
* the snapshot at all.
|
|
136
|
+
*
|
|
137
|
+
* An empty description is replaced with a stated placeholder rather than captured empty:
|
|
138
|
+
* the planner-side input contract requires a non-empty description, and a capture that
|
|
139
|
+
* guaranteed a later refusal would freeze a call failure into the snapshot.
|
|
140
|
+
* @param schemas - the registry view at capture time.
|
|
141
|
+
* @param options - the generation, and optionally the excluded names (defaults to
|
|
142
|
+
* {@link PLANNING_EXCLUDED_TOOLS}).
|
|
143
|
+
* @returns the frozen snapshot.
|
|
144
|
+
*/
|
|
145
|
+
export function captureToolSchemaSnapshot(schemas, options) {
|
|
146
|
+
const excluded = options.excluded ?? PLANNING_EXCLUDED_TOOLS;
|
|
147
|
+
const tools = new Map();
|
|
148
|
+
for (const schema of schemas) {
|
|
149
|
+
if (excluded.includes(schema.name))
|
|
150
|
+
continue;
|
|
151
|
+
if (typeof schema.parameters !== 'object' || schema.parameters === null || Array.isArray(schema.parameters)) {
|
|
152
|
+
// A tool whose parameters cannot be described as JSON Schema cannot be planned
|
|
153
|
+
// against; capturing it would hand the planner an entry it cannot use.
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const description = typeof schema.description === 'string' && schema.description.trim().length > 0
|
|
157
|
+
? schema.description
|
|
158
|
+
: 'No host description is declared for this tool.';
|
|
159
|
+
const entry = {
|
|
160
|
+
name: schema.name,
|
|
161
|
+
description,
|
|
162
|
+
// deepClone, then freeze: the snapshot must share NO structure with the
|
|
163
|
+
// registry's live objects, or a later registry edit would reach a caller.
|
|
164
|
+
parameters: deepClone(schema.parameters, new Map()),
|
|
165
|
+
};
|
|
166
|
+
deepFreeze(entry.parameters, new Set());
|
|
167
|
+
deepFreeze(entry, new Set());
|
|
168
|
+
tools.set(schema.name, entry);
|
|
169
|
+
}
|
|
170
|
+
// The OUTER record is frozen too: "the snapshot is frozen" must include the
|
|
171
|
+
// container a caller holds, not only the entries inside it (the map is frozen
|
|
172
|
+
// below via the same walk, and the record itself last).
|
|
173
|
+
const snapshot = { generation: options.generation, tools };
|
|
174
|
+
deepFreeze(snapshot, new Set());
|
|
175
|
+
return snapshot;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Intersect the requested names with the live registry and the frozen snapshot (NDL-02).
|
|
179
|
+
*
|
|
180
|
+
* All-or-nothing, mirroring the CODE-03 bindings gate: if ANY requested name is
|
|
181
|
+
* unattainable the whole call is refused with every rejection named, because handing the
|
|
182
|
+
* caller a smaller offer set than it asked for would produce a plan for a different
|
|
183
|
+
* request than the one it stated.
|
|
184
|
+
* @param snapshot - the frozen snapshot, the ONLY source of schemas.
|
|
185
|
+
* @param requested - the names the caller asked to plan over.
|
|
186
|
+
* @param liveLeaf - the leaf tool names currently registered, exclusions already applied.
|
|
187
|
+
* @param excluded - the names refused by policy regardless of registration. Defaults to
|
|
188
|
+
* {@link PLANNING_EXCLUDED_TOOLS}.
|
|
189
|
+
* @returns the offered entries, or every rejection.
|
|
190
|
+
*/
|
|
191
|
+
export function offerToolsFromSnapshot(snapshot, requested, liveLeaf, excluded = PLANNING_EXCLUDED_TOOLS) {
|
|
192
|
+
const rejections = [];
|
|
193
|
+
const offered = [];
|
|
194
|
+
const seen = new Set();
|
|
195
|
+
for (const name of requested) {
|
|
196
|
+
if (seen.has(name)) {
|
|
197
|
+
rejections.push({
|
|
198
|
+
name,
|
|
199
|
+
reason: 'duplicate',
|
|
200
|
+
remedy: 'Request each tool once; a repeated name makes the offered set ambiguous.',
|
|
201
|
+
});
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
seen.add(name);
|
|
205
|
+
if (excluded.includes(name)) {
|
|
206
|
+
rejections.push({
|
|
207
|
+
name,
|
|
208
|
+
reason: 'excluded',
|
|
209
|
+
remedy: `"${name}" is not a leaf tool a plan may target: management and composition bindings are excluded (CODE-07, NDL-02).`,
|
|
210
|
+
});
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (!liveLeaf.has(name)) {
|
|
214
|
+
rejections.push({
|
|
215
|
+
name,
|
|
216
|
+
reason: 'unknown',
|
|
217
|
+
remedy: 'The tool is not currently registered; its owning extension may be deactivated, or the name may never have existed.',
|
|
218
|
+
});
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
const entry = snapshot.tools.get(name);
|
|
222
|
+
if (entry === undefined) {
|
|
223
|
+
rejections.push({
|
|
224
|
+
name,
|
|
225
|
+
reason: 'not-in-snapshot',
|
|
226
|
+
remedy: 'The tool is registered but was added after the frozen snapshot was captured, so no authorized schema exists for it.',
|
|
227
|
+
});
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
offered.push(entry);
|
|
231
|
+
}
|
|
232
|
+
if (rejections.length > 0)
|
|
233
|
+
return { ok: false, rejections };
|
|
234
|
+
return { ok: true, offered };
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Describe a refused request for a caller (NDL-02).
|
|
238
|
+
* @param rejections - the refusals.
|
|
239
|
+
* @returns a readable summary naming every rejection and why.
|
|
240
|
+
*/
|
|
241
|
+
export function describePlanningRejections(rejections) {
|
|
242
|
+
const lines = rejections.map(entry => ` ${entry.name}: ${entry.reason} — ${entry.remedy}`);
|
|
243
|
+
return `tools_plan cannot offer the requested tools:\n${lines.join('\n')}`;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Raised when a provider returns a proposal record that is not proposal-shaped.
|
|
247
|
+
*
|
|
248
|
+
* The provider's declared output contract types every field and closes the record, so a
|
|
249
|
+
* malformed entry is a PROVIDER DEFECT — and it is surfaced as one rather than silently
|
|
250
|
+
* coerced. Coercing a non-object `arguments` into `{}` would present a record the
|
|
251
|
+
* provider never produced as if the host had validated it, and dropping undeclared
|
|
252
|
+
* fields would hide a contract violation the output validator should refuse.
|
|
253
|
+
*/
|
|
254
|
+
export class ProviderDefectError extends Error {
|
|
255
|
+
name = 'ProviderDefectError';
|
|
256
|
+
}
|
|
257
|
+
/** The keys the declared proposal contract admits. */
|
|
258
|
+
const PROPOSAL_FIELDS = new Set(['name', 'arguments', 'offered', 'valid', 'issues']);
|
|
259
|
+
/**
|
|
260
|
+
* Normalize one proposal record from the provider's payload, STRICTLY.
|
|
261
|
+
*
|
|
262
|
+
* Structural violations throw {@link ProviderDefectError}: a non-object record, a missing
|
|
263
|
+
* or non-string name, non-object arguments, or undeclared fields. The typed fields the
|
|
264
|
+
* declared output schema constrains (`offered`, `valid`, `issues`) are read tolerantly —
|
|
265
|
+
* their types are enforced by the output validator that runs after the re-check.
|
|
266
|
+
* @param raw - the record.
|
|
267
|
+
* @returns the normalized entry.
|
|
268
|
+
* @throws ProviderDefectError when the record is not proposal-shaped.
|
|
269
|
+
*/
|
|
270
|
+
function normalizeEntry(raw) {
|
|
271
|
+
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
272
|
+
throw new ProviderDefectError('a provider returned a proposal record that is not an object');
|
|
273
|
+
}
|
|
274
|
+
const record = raw;
|
|
275
|
+
const extra = Object.keys(record).filter(key => !PROPOSAL_FIELDS.has(key));
|
|
276
|
+
if (extra.length > 0) {
|
|
277
|
+
throw new ProviderDefectError(`a provider returned a proposal record with undeclared field(s) ${extra.map(key => JSON.stringify(key)).join(', ')}`);
|
|
278
|
+
}
|
|
279
|
+
if (typeof record.name !== 'string') {
|
|
280
|
+
throw new ProviderDefectError('a provider returned a proposal record whose name is not a string');
|
|
281
|
+
}
|
|
282
|
+
const rawArguments = record.arguments;
|
|
283
|
+
if (typeof rawArguments !== 'object' || rawArguments === null || Array.isArray(rawArguments)) {
|
|
284
|
+
throw new ProviderDefectError(`a provider returned a proposal record whose arguments are not an object (${JSON.stringify(rawArguments)})`);
|
|
285
|
+
}
|
|
286
|
+
const issues = Array.isArray(record.issues)
|
|
287
|
+
? record.issues.filter((issue) => typeof issue === 'string').slice(0, 32)
|
|
288
|
+
: [];
|
|
289
|
+
return {
|
|
290
|
+
name: record.name,
|
|
291
|
+
arguments: rawArguments,
|
|
292
|
+
offered: record.offered === true,
|
|
293
|
+
valid: record.valid === true,
|
|
294
|
+
issues,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Re-check the provider's proposals against the frozen snapshot, the per-call offered set
|
|
299
|
+
* AND the live authorization state (NDL-02, NDL-03).
|
|
300
|
+
*
|
|
301
|
+
* The provider's own validation is not trusted here: it validated against the list the
|
|
302
|
+
* HOST built, but the host still re-checks every proposal before it reaches a caller,
|
|
303
|
+
* because a proposal is the one thing a caller will treat as authorized. Four checks:
|
|
304
|
+
*
|
|
305
|
+
* - the name must be IN the frozen snapshot (the engine cannot invent a plannable tool);
|
|
306
|
+
* - the arguments must satisfy the SNAPSHOT's schema, compiled fresh per snapshot entry;
|
|
307
|
+
* - the name must be in the OFFERED set for THIS call — a provider proposing a tool the
|
|
308
|
+
* caller never requested must not pass it through as valid, even when it is
|
|
309
|
+
* snapshotted, schema-valid and still registered;
|
|
310
|
+
* - the tool must STILL BE AUTHORIZED right now (NDL-03): a tool deactivated, withdrawn
|
|
311
|
+
* or quarantined after capture fails the fresh policy check, and the proposal is
|
|
312
|
+
* refused rather than returned as if it were executable.
|
|
313
|
+
*
|
|
314
|
+
* A proposal failing any check is MOVED to `rejected` with the issues appended, and one
|
|
315
|
+
* bounded warning per moved proposal is returned for the receipt and the meta envelope.
|
|
316
|
+
* A proposal record that is not proposal-shaped throws {@link ProviderDefectError}: the
|
|
317
|
+
* defect belongs to the provider, and silently repairing it would hide the violation.
|
|
318
|
+
* @param snapshot - the frozen snapshot.
|
|
319
|
+
* @param payload - the provider's result.
|
|
320
|
+
* @param offeredNames - the names the HOST offered for this call.
|
|
321
|
+
* @param isCurrentlyAuthorized - the live authorization predicate, read at re-check time;
|
|
322
|
+
* `true` admits, a string is the refusal reason.
|
|
323
|
+
* @returns the amended payload and the warnings.
|
|
324
|
+
*/
|
|
325
|
+
export function recheckProposals(snapshot, payload, offeredNames, isCurrentlyAuthorized) {
|
|
326
|
+
const warnings = [];
|
|
327
|
+
const compiled = new Map();
|
|
328
|
+
/** Compile a snapshot entry's schema once; an uncompilable schema is an issue, not a crash. */
|
|
329
|
+
const validatorFor = (entry) => {
|
|
330
|
+
const cached = compiled.get(entry.name);
|
|
331
|
+
if (cached !== undefined)
|
|
332
|
+
return cached;
|
|
333
|
+
let validate;
|
|
334
|
+
try {
|
|
335
|
+
validate = PROPOSAL_AJV.compile(entry.parameters);
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
// Kept uncompiled: every proposal for this entry then carries the compile failure
|
|
339
|
+
// as an issue instead of the host throwing mid-call.
|
|
340
|
+
return undefined;
|
|
341
|
+
}
|
|
342
|
+
const validator = value => (validate(value) ? [] : [...(validate.errors ?? [])]
|
|
343
|
+
.map(error => `${error.instancePath === '' ? '(root)' : error.instancePath} ${error.message ?? 'is invalid'}`));
|
|
344
|
+
compiled.set(entry.name, validator);
|
|
345
|
+
return validator;
|
|
346
|
+
};
|
|
347
|
+
const rawProposals = Array.isArray(payload.proposals) ? payload.proposals : [];
|
|
348
|
+
const rawRejected = Array.isArray(payload.rejected) ? payload.rejected : [];
|
|
349
|
+
const kept = [];
|
|
350
|
+
const rejected = [...rawRejected];
|
|
351
|
+
for (const raw of rawProposals) {
|
|
352
|
+
const entry = normalizeEntry(raw);
|
|
353
|
+
const hostIssues = [];
|
|
354
|
+
let offered = entry.offered;
|
|
355
|
+
const snapshotEntry = snapshot.tools.get(entry.name);
|
|
356
|
+
if (snapshotEntry === undefined) {
|
|
357
|
+
// A proposal outside the snapshot was never offered by the HOST, whatever the
|
|
358
|
+
// provider believed: the host's offer set is the snapshot by construction.
|
|
359
|
+
offered = false;
|
|
360
|
+
hostIssues.push(`the tool ${JSON.stringify(entry.name)} is not in the frozen host-approved snapshot`);
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
const validate = validatorFor(snapshotEntry);
|
|
364
|
+
if (validate === undefined) {
|
|
365
|
+
hostIssues.push(`the frozen schema for ${JSON.stringify(entry.name)} does not compile, so no arguments can be validated`);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
hostIssues.push(...validate(entry.arguments));
|
|
369
|
+
}
|
|
370
|
+
if (hostIssues.length === 0 && !offeredNames.has(entry.name)) {
|
|
371
|
+
// F6: the OFFERED set is per-call. A snapshotted, schema-valid, still-registered
|
|
372
|
+
// proposal for a tool the caller never requested is still not a valid plan step:
|
|
373
|
+
// the provider had no business proposing it this turn.
|
|
374
|
+
offered = false;
|
|
375
|
+
hostIssues.push(`the tool ${JSON.stringify(entry.name)} was not offered for this turn`);
|
|
376
|
+
}
|
|
377
|
+
if (hostIssues.length === 0) {
|
|
378
|
+
const authorization = isCurrentlyAuthorized(entry.name);
|
|
379
|
+
if (authorization !== true) {
|
|
380
|
+
// NDL-03: fresh policy checks at execution time. The tool was authorized when the
|
|
381
|
+
// snapshot froze, but it is not callable NOW — withdrawn, deactivated or
|
|
382
|
+
// quarantined — so returning the proposal would present a tool that would fail
|
|
383
|
+
// admission as a valid plan step.
|
|
384
|
+
hostIssues.push(`the tool ${JSON.stringify(entry.name)} is no longer authorized: ${authorization}`);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (hostIssues.length === 0) {
|
|
389
|
+
kept.push(entry);
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
// The bounded report shape: the provider's issues first, then the host's, capped at
|
|
393
|
+
// the shipped schema's own 32-item bound rather than grown without limit.
|
|
394
|
+
rejected.push({
|
|
395
|
+
name: entry.name,
|
|
396
|
+
arguments: entry.arguments,
|
|
397
|
+
offered,
|
|
398
|
+
valid: false,
|
|
399
|
+
issues: [...entry.issues, ...hostIssues].slice(0, 32),
|
|
400
|
+
});
|
|
401
|
+
warnings.push(`the host refused the ${entry.name} proposal: ${hostIssues[0] ?? 'invalid'}`);
|
|
402
|
+
}
|
|
403
|
+
return {
|
|
404
|
+
payload: { ...payload, proposals: kept, rejected },
|
|
405
|
+
warnings,
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* The input the HOST advertises and validates for `tools_plan` (NDL-02).
|
|
410
|
+
*
|
|
411
|
+
* The caller names tools as STRINGS — a requested eligible subset, never a grant and
|
|
412
|
+
* never full declarations. The extension's own shipped input schema (full tool objects)
|
|
413
|
+
* remains its provider contract; the host is the broker that turns requested names into
|
|
414
|
+
* snapshot entries, so a caller never supplies the schemas the planner reasons over.
|
|
415
|
+
* Bounds mirror the shipped extension input, so the advertised surface and the transport
|
|
416
|
+
* surface cannot admit different requests.
|
|
417
|
+
*/
|
|
418
|
+
export const PLANNING_TOOL_INPUT_SCHEMA = {
|
|
419
|
+
type: 'object',
|
|
420
|
+
additionalProperties: false,
|
|
421
|
+
required: ['request', 'tools'],
|
|
422
|
+
properties: {
|
|
423
|
+
request: {
|
|
424
|
+
type: 'string',
|
|
425
|
+
minLength: 1,
|
|
426
|
+
maxLength: 32_768,
|
|
427
|
+
description: 'The user request the plan is derived from, verbatim.',
|
|
428
|
+
},
|
|
429
|
+
tools: {
|
|
430
|
+
type: 'array',
|
|
431
|
+
minItems: 1,
|
|
432
|
+
maxItems: 64,
|
|
433
|
+
description: 'The tool names to plan over. A requested eligible subset, never a grant; unknown or excluded names refuse the call.',
|
|
434
|
+
items: { type: 'string', minLength: 1 },
|
|
435
|
+
},
|
|
436
|
+
system: {
|
|
437
|
+
type: 'string',
|
|
438
|
+
maxLength: 4_096,
|
|
439
|
+
description: 'Session facts the model should assume: the date, the locale, the device.',
|
|
440
|
+
},
|
|
441
|
+
max_new_tokens: {
|
|
442
|
+
type: 'integer',
|
|
443
|
+
minimum: 16,
|
|
444
|
+
maximum: 4_096,
|
|
445
|
+
description: 'Response-token budget for the planner.',
|
|
446
|
+
},
|
|
447
|
+
},
|
|
448
|
+
};
|
|
449
|
+
/**
|
|
450
|
+
* Whether a declared input schema has the planning shape (a `tools` array property).
|
|
451
|
+
*
|
|
452
|
+
* The NAME alone is not enough to treat a contribution as the planning contract: a
|
|
453
|
+
* package that named a tool `tools_plan` without the planning input would otherwise be
|
|
454
|
+
* served through the planning pipeline and fail in ways nobody could see. The name plus
|
|
455
|
+
* the shape is the contract; the host refuses the name without the shape.
|
|
456
|
+
* @param schema - the declared input schema.
|
|
457
|
+
* @returns whether the schema declares an array-valued `tools` property.
|
|
458
|
+
*/
|
|
459
|
+
export function hasPlanningInputShape(schema) {
|
|
460
|
+
if (schema === undefined)
|
|
461
|
+
return false;
|
|
462
|
+
const properties = schema.properties;
|
|
463
|
+
if (typeof properties !== 'object' || properties === null || Array.isArray(properties))
|
|
464
|
+
return false;
|
|
465
|
+
const tools = properties.tools;
|
|
466
|
+
if (typeof tools !== 'object' || tools === null || Array.isArray(tools))
|
|
467
|
+
return false;
|
|
468
|
+
const type = tools.type;
|
|
469
|
+
return type === 'array' || (Array.isArray(type) && type.includes('array'));
|
|
470
|
+
}
|
|
471
|
+
//# sourceMappingURL=planning.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playbooks: the per-model knowledge that turns a tool into a usable capability.
|
|
3
|
+
*
|
|
4
|
+
* A catalog entry says what a model *is*; a playbook says what it is *for* — the
|
|
5
|
+
* concrete jobs an agent should reach for it on, the jobs it should not, and how
|
|
6
|
+
* the model composes with its neighbours. Playbooks live in their own document
|
|
7
|
+
* so they can be revised without touching the catalog or the code.
|
|
8
|
+
*
|
|
9
|
+
* @module @try-works/dsh-tool-mode/playbook
|
|
10
|
+
*/
|
|
11
|
+
/** The authored playbook for one model. */
|
|
12
|
+
export interface ModelPlaybook {
|
|
13
|
+
/** Concrete jobs this model is the right tool for. */
|
|
14
|
+
readonly useCases: readonly string[];
|
|
15
|
+
/** Trigger conditions: when the agent should reach for this tool. */
|
|
16
|
+
readonly whenToUse: readonly string[];
|
|
17
|
+
/** Anti-triggers: when this tool is the wrong move. */
|
|
18
|
+
readonly whenNotToUse: readonly string[];
|
|
19
|
+
/** Ordered steps describing how to drive the model well. */
|
|
20
|
+
readonly workflow: readonly string[];
|
|
21
|
+
/** How this model composes with the others, by model id or tool name. */
|
|
22
|
+
readonly pairsWith: readonly string[];
|
|
23
|
+
/** Limits, cost and failure modes worth knowing before calling. */
|
|
24
|
+
readonly caveats: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
/** Absolute path of the playbook document shipped with this package. */
|
|
27
|
+
export declare const DEFAULT_PLAYBOOK_FILE: string;
|
|
28
|
+
/** Raised when the playbook document is present but malformed. */
|
|
29
|
+
export declare class PlaybookError extends Error {
|
|
30
|
+
readonly name = "PlaybookError";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Parse a playbook document into a per-model map.
|
|
34
|
+
*
|
|
35
|
+
* An absent document is not an error: playbooks are editorial content, and the
|
|
36
|
+
* skill renderer falls back to the catalog's own routing description.
|
|
37
|
+
* @param file - absolute path of the playbook document.
|
|
38
|
+
* @returns the playbooks by model id, empty when the document does not exist.
|
|
39
|
+
* @throws PlaybookError when the document exists but is not a valid playbook map.
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadPlaybooks(file?: string): Map<string, ModelPlaybook>;
|
|
42
|
+
//# sourceMappingURL=playbook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playbook.d.ts","sourceRoot":"","sources":["../src/playbook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,qEAAqE;IACrE,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC,uDAAuD;IACvD,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CACpC;AAED,wEAAwE;AACxE,eAAO,MAAM,qBAAqB,QAEjC,CAAA;AAED,kEAAkE;AAClE,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAkB,IAAI,mBAAkB;CACzC;AAID;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE,MAA8B,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAiC9F"}
|
package/lib/playbook.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playbooks: the per-model knowledge that turns a tool into a usable capability.
|
|
3
|
+
*
|
|
4
|
+
* A catalog entry says what a model *is*; a playbook says what it is *for* — the
|
|
5
|
+
* concrete jobs an agent should reach for it on, the jobs it should not, and how
|
|
6
|
+
* the model composes with its neighbours. Playbooks live in their own document
|
|
7
|
+
* so they can be revised without touching the catalog or the code.
|
|
8
|
+
*
|
|
9
|
+
* @module @try-works/dsh-tool-mode/playbook
|
|
10
|
+
*/
|
|
11
|
+
import { readFileSync } from 'node:fs';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
/** Absolute path of the playbook document shipped with this package. */
|
|
14
|
+
export const DEFAULT_PLAYBOOK_FILE = fileURLToPath(new URL('../catalog/playbooks.json', import.meta.url));
|
|
15
|
+
/** Raised when the playbook document is present but malformed. */
|
|
16
|
+
export class PlaybookError extends Error {
|
|
17
|
+
name = 'PlaybookError';
|
|
18
|
+
}
|
|
19
|
+
const STRING_ARRAY_FIELDS = ['useCases', 'whenToUse', 'whenNotToUse', 'workflow', 'pairsWith', 'caveats'];
|
|
20
|
+
/**
|
|
21
|
+
* Parse a playbook document into a per-model map.
|
|
22
|
+
*
|
|
23
|
+
* An absent document is not an error: playbooks are editorial content, and the
|
|
24
|
+
* skill renderer falls back to the catalog's own routing description.
|
|
25
|
+
* @param file - absolute path of the playbook document.
|
|
26
|
+
* @returns the playbooks by model id, empty when the document does not exist.
|
|
27
|
+
* @throws PlaybookError when the document exists but is not a valid playbook map.
|
|
28
|
+
*/
|
|
29
|
+
export function loadPlaybooks(file = DEFAULT_PLAYBOOK_FILE) {
|
|
30
|
+
let text;
|
|
31
|
+
try {
|
|
32
|
+
text = readFileSync(file, 'utf8');
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return new Map();
|
|
36
|
+
}
|
|
37
|
+
let parsed;
|
|
38
|
+
try {
|
|
39
|
+
parsed = JSON.parse(text);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new PlaybookError(`${file} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
43
|
+
}
|
|
44
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
45
|
+
throw new PlaybookError(`${file} must contain a JSON object keyed by model id`);
|
|
46
|
+
}
|
|
47
|
+
const playbooks = new Map();
|
|
48
|
+
for (const [modelId, raw] of Object.entries(parsed)) {
|
|
49
|
+
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
50
|
+
throw new PlaybookError(`${file}: playbook for "${modelId}" must be an object`);
|
|
51
|
+
}
|
|
52
|
+
const record = raw;
|
|
53
|
+
const playbook = {};
|
|
54
|
+
for (const field of STRING_ARRAY_FIELDS) {
|
|
55
|
+
const value = record[field] ?? [];
|
|
56
|
+
if (!Array.isArray(value) || value.some(item => typeof item !== 'string')) {
|
|
57
|
+
throw new PlaybookError(`${file}: playbook "${modelId}" field "${field}" must be an array of strings`);
|
|
58
|
+
}
|
|
59
|
+
playbook[field] = value;
|
|
60
|
+
}
|
|
61
|
+
playbooks.set(modelId, playbook);
|
|
62
|
+
}
|
|
63
|
+
return playbooks;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=playbook.js.map
|