@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,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime registration for custom tools.
|
|
3
|
+
*
|
|
4
|
+
* One active registration per custom id. Saving a new version disposes the old
|
|
5
|
+
* definition before registering the new one; disabling/deleting disposes without
|
|
6
|
+
* touching the immutable record. `sync()` is the restart path.
|
|
7
|
+
*
|
|
8
|
+
* @module @try-works/dsh-tool-mode/custom-tools/registry
|
|
9
|
+
*/
|
|
10
|
+
import { compileCustomTool } from "./compile.js";
|
|
11
|
+
import { CustomToolStoreError } from "./store.js";
|
|
12
|
+
/** Owns the live definitions for one profile. */
|
|
13
|
+
export class CustomToolRegistrar {
|
|
14
|
+
store;
|
|
15
|
+
tools;
|
|
16
|
+
execute;
|
|
17
|
+
active = new Map();
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.store = options.store;
|
|
20
|
+
this.tools = options.tools;
|
|
21
|
+
this.execute = options.execute;
|
|
22
|
+
}
|
|
23
|
+
/** The live registration for one id, if any. */
|
|
24
|
+
get(id) {
|
|
25
|
+
return this.active.get(id);
|
|
26
|
+
}
|
|
27
|
+
/** Live registrations, sorted by id. */
|
|
28
|
+
list() {
|
|
29
|
+
return [...this.active.values()].sort((a, b) => a.id.localeCompare(b.id));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Register or refresh one record. The old definition for the same id is
|
|
33
|
+
* disposed first, so a new version is visible without a host restart.
|
|
34
|
+
*/
|
|
35
|
+
register(record) {
|
|
36
|
+
if (!record.enabled)
|
|
37
|
+
throw new Error(`${record.id} is disabled`);
|
|
38
|
+
if (!record.policy.agentExpose)
|
|
39
|
+
throw new Error(`${record.id} is not exposed to agents`);
|
|
40
|
+
const existing = this.active.get(record.id);
|
|
41
|
+
if (existing !== undefined) {
|
|
42
|
+
existing.dispose();
|
|
43
|
+
this.active.delete(record.id);
|
|
44
|
+
}
|
|
45
|
+
const occupant = this.tools.get(record.name);
|
|
46
|
+
if (occupant !== undefined) {
|
|
47
|
+
throw new Error(`custom-tool-name-conflict: ${record.name} is already registered`);
|
|
48
|
+
}
|
|
49
|
+
const definition = compileCustomTool(record, this.execute);
|
|
50
|
+
const dispose = this.tools.register(definition);
|
|
51
|
+
const registration = {
|
|
52
|
+
id: record.id,
|
|
53
|
+
name: record.name,
|
|
54
|
+
version: record.version,
|
|
55
|
+
dispose,
|
|
56
|
+
};
|
|
57
|
+
this.active.set(record.id, registration);
|
|
58
|
+
return registration;
|
|
59
|
+
}
|
|
60
|
+
/** Dispose one id; false when it was not live. */
|
|
61
|
+
dispose(id) {
|
|
62
|
+
const active = this.active.get(id);
|
|
63
|
+
if (active === undefined)
|
|
64
|
+
return false;
|
|
65
|
+
active.dispose();
|
|
66
|
+
this.active.delete(id);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
/** Dispose everything (plugin teardown). */
|
|
70
|
+
disposeAll() {
|
|
71
|
+
for (const registration of this.active.values())
|
|
72
|
+
registration.dispose();
|
|
73
|
+
this.active.clear();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Reconcile the live set with the store. A bad record is reported and does not
|
|
77
|
+
* stop the others; a disabled or agent-hidden record is disposed.
|
|
78
|
+
*/
|
|
79
|
+
sync() {
|
|
80
|
+
const registered = [];
|
|
81
|
+
const skipped = [];
|
|
82
|
+
const errors = [];
|
|
83
|
+
const wanted = new Set();
|
|
84
|
+
for (const id of this.store.listIds()) {
|
|
85
|
+
let record;
|
|
86
|
+
try {
|
|
87
|
+
record = this.store.read(id);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
errors.push({
|
|
91
|
+
id,
|
|
92
|
+
version: null,
|
|
93
|
+
reason: error instanceof CustomToolStoreError ? error.message : String(error),
|
|
94
|
+
});
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (record === undefined)
|
|
98
|
+
continue;
|
|
99
|
+
if (!record.enabled) {
|
|
100
|
+
this.dispose(id);
|
|
101
|
+
skipped.push({ id, version: record.version, reason: 'disabled' });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (!record.policy.agentExpose) {
|
|
105
|
+
this.dispose(id);
|
|
106
|
+
skipped.push({ id, version: record.version, reason: 'not-agent-exposed' });
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
wanted.add(id);
|
|
110
|
+
const live = this.active.get(id);
|
|
111
|
+
if (live?.version === record.version) {
|
|
112
|
+
registered.push({ id, version: record.version, reason: 'already registered' });
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const next = this.register(record);
|
|
117
|
+
registered.push({ id, version: next.version, reason: 'registered' });
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
errors.push({ id, version: record.version, reason: error instanceof Error ? error.message : String(error) });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
for (const id of [...this.active.keys()]) {
|
|
124
|
+
if (!wanted.has(id))
|
|
125
|
+
this.dispose(id);
|
|
126
|
+
}
|
|
127
|
+
return { registered, skipped, errors };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom-tool draft validation.
|
|
3
|
+
*
|
|
4
|
+
* Validation is deliberately split from compilation: a draft may be incomplete
|
|
5
|
+
* and is returned as a list of field issues, while only a validated draft can be
|
|
6
|
+
* compiled or persisted. No network, filesystem or model work happens here.
|
|
7
|
+
*
|
|
8
|
+
* @module @try-works/dsh-tool-mode/custom-tools/schema
|
|
9
|
+
*/
|
|
10
|
+
import type { CustomToolDraft, CustomToolIssue, CustomToolValidation } from './types.ts';
|
|
11
|
+
/** A validated record failure carrying every issue, not just the first. */
|
|
12
|
+
export declare class CustomToolSchemaError extends Error {
|
|
13
|
+
readonly name = "CustomToolSchemaError";
|
|
14
|
+
readonly issues: readonly CustomToolIssue[];
|
|
15
|
+
constructor(issues: readonly CustomToolIssue[]);
|
|
16
|
+
}
|
|
17
|
+
/** Validate and normalize one draft. */
|
|
18
|
+
export declare function validateCustomToolDraft(raw: unknown): CustomToolValidation;
|
|
19
|
+
/**
|
|
20
|
+
* Validate and normalize a draft, throwing one named error with every issue.
|
|
21
|
+
* @param raw - unknown decoded JSON.
|
|
22
|
+
* @returns the normalized draft.
|
|
23
|
+
* @throws CustomToolSchemaError when any field is invalid.
|
|
24
|
+
*/
|
|
25
|
+
export declare function normalizeCustomToolDraft(raw: unknown): CustomToolDraft;
|
|
26
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/custom-tools/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAGV,eAAe,EAGf,eAAe,EAEf,oBAAoB,EAIrB,MAAM,YAAY,CAAA;AAMnB,2EAA2E;AAC3E,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAkB,IAAI,2BAA0B;IAChD,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAA;gBAE/B,MAAM,EAAE,SAAS,eAAe,EAAE;CAI/C;AAgND,wCAAwC;AACxC,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,CAuE1E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CAqCtE"}
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom-tool draft validation.
|
|
3
|
+
*
|
|
4
|
+
* Validation is deliberately split from compilation: a draft may be incomplete
|
|
5
|
+
* and is returned as a list of field issues, while only a validated draft can be
|
|
6
|
+
* compiled or persisted. No network, filesystem or model work happens here.
|
|
7
|
+
*
|
|
8
|
+
* @module @try-works/dsh-tool-mode/custom-tools/schema
|
|
9
|
+
*/
|
|
10
|
+
const ID_PATTERN = /^custom\.[a-z0-9][a-z0-9-]*$/;
|
|
11
|
+
const NAME_PATTERN = /^custom_[a-z0-9][a-z0-9_]*$/;
|
|
12
|
+
const TOOL_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
13
|
+
/** A validated record failure carrying every issue, not just the first. */
|
|
14
|
+
export class CustomToolSchemaError extends Error {
|
|
15
|
+
name = 'CustomToolSchemaError';
|
|
16
|
+
issues;
|
|
17
|
+
constructor(issues) {
|
|
18
|
+
super(issues.map(issue => `${issue.path}: ${issue.message}`).join('; '));
|
|
19
|
+
this.issues = issues;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function isRecord(value) {
|
|
23
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
24
|
+
}
|
|
25
|
+
function nonEmptyString(value) {
|
|
26
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
27
|
+
}
|
|
28
|
+
/** Validate an object-shaped JSON Schema used for tool arguments. */
|
|
29
|
+
function schemaIssues(value, path, issues) {
|
|
30
|
+
if (!isRecord(value)) {
|
|
31
|
+
issues.push({ path, message: 'must be a JSON Schema object' });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (value['type'] !== 'object') {
|
|
35
|
+
issues.push({ path: `${path}.type`, message: 'must be "object" for tool arguments' });
|
|
36
|
+
}
|
|
37
|
+
const properties = value['properties'];
|
|
38
|
+
if (properties !== undefined && !isRecord(properties)) {
|
|
39
|
+
issues.push({ path: `${path}.properties`, message: 'must be an object' });
|
|
40
|
+
}
|
|
41
|
+
const required = value['required'];
|
|
42
|
+
if (required !== undefined) {
|
|
43
|
+
if (!Array.isArray(required) || required.some(item => typeof item !== 'string')) {
|
|
44
|
+
issues.push({ path: `${path}.required`, message: 'must be an array of property names' });
|
|
45
|
+
}
|
|
46
|
+
else if (isRecord(properties)) {
|
|
47
|
+
for (const name of required) {
|
|
48
|
+
if (!(name in properties))
|
|
49
|
+
issues.push({ path: `${path}.required`, message: `unknown property ${JSON.stringify(name)}` });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function validateHttp(value, issues) {
|
|
55
|
+
if (!isRecord(value)) {
|
|
56
|
+
issues.push({ path: 'execution.http', message: 'must be an object' });
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
const method = value['method'];
|
|
60
|
+
if (!['GET', 'POST', 'PUT', 'PATCH', 'DELETE'].includes(String(method))) {
|
|
61
|
+
issues.push({ path: 'execution.http.method', message: 'must be GET, POST, PUT, PATCH or DELETE' });
|
|
62
|
+
}
|
|
63
|
+
const url = value['url'];
|
|
64
|
+
if (!nonEmptyString(url)) {
|
|
65
|
+
issues.push({ path: 'execution.http.url', message: 'must be a non-empty URL template' });
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const literal = url.replace(/\{\{[A-Za-z_][A-Za-z0-9_]*\}\}/g, 'x');
|
|
69
|
+
try {
|
|
70
|
+
const parsed = new URL(literal);
|
|
71
|
+
if (parsed.protocol !== 'https:')
|
|
72
|
+
issues.push({ path: 'execution.http.url', message: 'must use https' });
|
|
73
|
+
if (parsed.username !== '' || parsed.password !== '')
|
|
74
|
+
issues.push({ path: 'execution.http.url', message: 'must not embed credentials' });
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
issues.push({ path: 'execution.http.url', message: 'must be a valid absolute https URL' });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const headers = {};
|
|
81
|
+
if (value['headers'] !== undefined) {
|
|
82
|
+
if (!isRecord(value['headers'])) {
|
|
83
|
+
issues.push({ path: 'execution.http.headers', message: 'must be an object' });
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
for (const [name, header] of Object.entries(value['headers'])) {
|
|
87
|
+
if (typeof header === 'string')
|
|
88
|
+
headers[name] = header;
|
|
89
|
+
else if (isRecord(header) && nonEmptyString(header['secret']))
|
|
90
|
+
headers[name] = { secret: header['secret'] };
|
|
91
|
+
else
|
|
92
|
+
issues.push({ path: `execution.http.headers.${name}`, message: 'must be a string or { secret: "NAME" }' });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
let bodyTemplate;
|
|
97
|
+
if (value['bodyTemplate'] !== undefined) {
|
|
98
|
+
if (typeof value['bodyTemplate'] !== 'string')
|
|
99
|
+
issues.push({ path: 'execution.http.bodyTemplate', message: 'must be a string' });
|
|
100
|
+
else
|
|
101
|
+
bodyTemplate = value['bodyTemplate'];
|
|
102
|
+
}
|
|
103
|
+
let extract;
|
|
104
|
+
if (value['extract'] !== undefined) {
|
|
105
|
+
if (typeof value['extract'] !== 'string')
|
|
106
|
+
issues.push({ path: 'execution.http.extract', message: 'must be a dot path string' });
|
|
107
|
+
else
|
|
108
|
+
extract = value['extract'];
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
method: method,
|
|
112
|
+
url: typeof url === 'string' ? url.trim() : '',
|
|
113
|
+
headers,
|
|
114
|
+
...bodyTemplate === undefined ? {} : { bodyTemplate },
|
|
115
|
+
...extract === undefined ? {} : { extract },
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function validatePrompt(value, issues) {
|
|
119
|
+
if (!isRecord(value)) {
|
|
120
|
+
issues.push({ path: 'execution.prompt', message: 'must be an object' });
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
if (!nonEmptyString(value['template']))
|
|
124
|
+
issues.push({ path: 'execution.prompt.template', message: 'must be a non-empty template' });
|
|
125
|
+
let model;
|
|
126
|
+
if (value['model'] !== undefined) {
|
|
127
|
+
if (!nonEmptyString(value['model']))
|
|
128
|
+
issues.push({ path: 'execution.prompt.model', message: 'must be a non-empty model id' });
|
|
129
|
+
else
|
|
130
|
+
model = value['model'];
|
|
131
|
+
}
|
|
132
|
+
let maxOutputTokens;
|
|
133
|
+
if (value['maxOutputTokens'] !== undefined) {
|
|
134
|
+
if (typeof value['maxOutputTokens'] !== 'number' || !Number.isInteger(value['maxOutputTokens'])
|
|
135
|
+
|| value['maxOutputTokens'] < 1 || value['maxOutputTokens'] > 8192) {
|
|
136
|
+
issues.push({ path: 'execution.prompt.maxOutputTokens', message: 'must be an integer between 1 and 8192' });
|
|
137
|
+
}
|
|
138
|
+
else
|
|
139
|
+
maxOutputTokens = value['maxOutputTokens'];
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
template: typeof value['template'] === 'string' ? value['template'] : '',
|
|
143
|
+
...model === undefined ? {} : { model },
|
|
144
|
+
...maxOutputTokens === undefined ? {} : { maxOutputTokens },
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function validateComposite(value, issues) {
|
|
148
|
+
if (!isRecord(value) || !Array.isArray(value['steps'])) {
|
|
149
|
+
issues.push({ path: 'execution.composite.steps', message: 'must be an array of steps' });
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
if (value['steps'].length === 0)
|
|
153
|
+
issues.push({ path: 'execution.composite.steps', message: 'must contain at least one step' });
|
|
154
|
+
if (value['steps'].length > 10)
|
|
155
|
+
issues.push({ path: 'execution.composite.steps', message: 'may contain at most 10 steps' });
|
|
156
|
+
const steps = [];
|
|
157
|
+
value['steps'].forEach((raw, index) => {
|
|
158
|
+
if (!isRecord(raw)) {
|
|
159
|
+
issues.push({ path: `execution.composite.steps.${index}`, message: 'must be an object' });
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const tool = raw['tool'];
|
|
163
|
+
if (!nonEmptyString(tool) || !TOOL_NAME_PATTERN.test(tool)) {
|
|
164
|
+
issues.push({ path: `execution.composite.steps.${index}.tool`, message: 'must be a valid tool name' });
|
|
165
|
+
}
|
|
166
|
+
const args = {};
|
|
167
|
+
if (raw['args'] !== undefined) {
|
|
168
|
+
if (!isRecord(raw['args']))
|
|
169
|
+
issues.push({ path: `execution.composite.steps.${index}.args`, message: 'must be an object of string templates' });
|
|
170
|
+
else {
|
|
171
|
+
for (const [key, arg] of Object.entries(raw['args'])) {
|
|
172
|
+
if (typeof arg !== 'string')
|
|
173
|
+
issues.push({ path: `execution.composite.steps.${index}.args.${key}`, message: 'must be a string template' });
|
|
174
|
+
else
|
|
175
|
+
args[key] = arg;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const requiresApproval = raw['requiresApproval'];
|
|
180
|
+
if (requiresApproval !== undefined && typeof requiresApproval !== 'boolean') {
|
|
181
|
+
issues.push({ path: `execution.composite.steps.${index}.requiresApproval`, message: 'must be boolean' });
|
|
182
|
+
}
|
|
183
|
+
if (typeof tool === 'string') {
|
|
184
|
+
steps.push({
|
|
185
|
+
tool,
|
|
186
|
+
args,
|
|
187
|
+
...requiresApproval === true ? { requiresApproval: true } : {},
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
let output;
|
|
192
|
+
if (value['output'] !== undefined) {
|
|
193
|
+
if (typeof value['output'] !== 'string')
|
|
194
|
+
issues.push({ path: 'execution.composite.output', message: 'must be a string template' });
|
|
195
|
+
else
|
|
196
|
+
output = value['output'];
|
|
197
|
+
}
|
|
198
|
+
return { steps, ...output === undefined ? {} : { output } };
|
|
199
|
+
}
|
|
200
|
+
function validateExecution(value, issues) {
|
|
201
|
+
if (!isRecord(value)) {
|
|
202
|
+
issues.push({ path: 'execution', message: 'must be an object' });
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
switch (value['kind']) {
|
|
206
|
+
case 'http': {
|
|
207
|
+
const http = validateHttp(value['http'], issues);
|
|
208
|
+
return http === undefined ? undefined : { kind: 'http', http };
|
|
209
|
+
}
|
|
210
|
+
case 'prompt': {
|
|
211
|
+
const prompt = validatePrompt(value['prompt'], issues);
|
|
212
|
+
return prompt === undefined ? undefined : { kind: 'prompt', prompt };
|
|
213
|
+
}
|
|
214
|
+
case 'composite': {
|
|
215
|
+
const composite = validateComposite(value['composite'], issues);
|
|
216
|
+
return composite === undefined ? undefined : { kind: 'composite', composite };
|
|
217
|
+
}
|
|
218
|
+
default:
|
|
219
|
+
issues.push({ path: 'execution.kind', message: 'must be http, prompt or composite' });
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function normalizeOrigins(value, issues) {
|
|
224
|
+
if (value === undefined)
|
|
225
|
+
return [];
|
|
226
|
+
if (!Array.isArray(value)) {
|
|
227
|
+
issues.push({ path: 'policy.networkOrigins', message: 'must be an array of origins' });
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
230
|
+
const origins = [];
|
|
231
|
+
for (const raw of value) {
|
|
232
|
+
if (typeof raw !== 'string') {
|
|
233
|
+
issues.push({ path: 'policy.networkOrigins', message: 'every origin must be a string' });
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
const parsed = new URL(raw);
|
|
238
|
+
if (parsed.protocol !== 'https:' || parsed.origin !== raw.replace(/\/$/, '')) {
|
|
239
|
+
issues.push({ path: 'policy.networkOrigins', message: `${JSON.stringify(raw)} must be an exact https origin` });
|
|
240
|
+
}
|
|
241
|
+
else
|
|
242
|
+
origins.push(parsed.origin);
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
issues.push({ path: 'policy.networkOrigins', message: `${JSON.stringify(raw)} is not an absolute origin` });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return [...new Set(origins)];
|
|
249
|
+
}
|
|
250
|
+
/** Validate and normalize one draft. */
|
|
251
|
+
export function validateCustomToolDraft(raw) {
|
|
252
|
+
const issues = [];
|
|
253
|
+
if (!isRecord(raw))
|
|
254
|
+
return { ok: false, issues: [{ path: '', message: 'draft must be an object' }] };
|
|
255
|
+
const id = raw['id'];
|
|
256
|
+
if (!nonEmptyString(id) || !ID_PATTERN.test(id)) {
|
|
257
|
+
issues.push({ path: 'id', message: 'must look like custom.<lowercase-slug>' });
|
|
258
|
+
}
|
|
259
|
+
const name = raw['name'];
|
|
260
|
+
if (!nonEmptyString(name) || !NAME_PATTERN.test(name)) {
|
|
261
|
+
issues.push({ path: 'name', message: 'must look like custom_<lowercase_slug>' });
|
|
262
|
+
}
|
|
263
|
+
if (typeof id === 'string' && typeof name === 'string') {
|
|
264
|
+
const expected = `custom_${id.slice('custom.'.length).replaceAll('-', '_')}`;
|
|
265
|
+
if (name !== expected)
|
|
266
|
+
issues.push({ path: 'name', message: `must be ${expected}` });
|
|
267
|
+
}
|
|
268
|
+
if (!nonEmptyString(raw['title']))
|
|
269
|
+
issues.push({ path: 'title', message: 'must be a non-empty title' });
|
|
270
|
+
if (!nonEmptyString(raw['description']))
|
|
271
|
+
issues.push({ path: 'description', message: 'must explain when the agent should use the tool' });
|
|
272
|
+
schemaIssues(raw['parameters'], 'parameters', issues);
|
|
273
|
+
if (raw['outputSchema'] !== undefined)
|
|
274
|
+
schemaIssues(raw['outputSchema'], 'outputSchema', issues);
|
|
275
|
+
const execution = validateExecution(raw['execution'], issues);
|
|
276
|
+
if (execution?.kind === 'http' && execution.http.url !== '') {
|
|
277
|
+
// The runtime executor enforces the origin allowlist and DNS checks; the
|
|
278
|
+
// draft only states that the allowlist is present.
|
|
279
|
+
if (!Array.isArray(raw['policy']?.['networkOrigins'])
|
|
280
|
+
|| raw['policy']['networkOrigins'].length === 0) {
|
|
281
|
+
issues.push({ path: 'policy.networkOrigins', message: 'HTTP tools require at least one exact https origin' });
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (!isRecord(raw['policy'])) {
|
|
285
|
+
issues.push({ path: 'policy', message: 'must be an object' });
|
|
286
|
+
}
|
|
287
|
+
const timeout = isRecord(raw['policy']) ? raw['policy']['timeoutMs'] : undefined;
|
|
288
|
+
if (timeout !== undefined && (typeof timeout !== 'number' || !Number.isInteger(timeout) || timeout < 1000 || timeout > 120_000)) {
|
|
289
|
+
issues.push({ path: 'policy.timeoutMs', message: 'must be an integer between 1000 and 120000' });
|
|
290
|
+
}
|
|
291
|
+
if (isRecord(raw['policy'])) {
|
|
292
|
+
for (const key of ['readOnly', 'agentExpose', 'mcpExpose']) {
|
|
293
|
+
const value = raw['policy'][key];
|
|
294
|
+
if (value !== undefined && typeof value !== 'boolean') {
|
|
295
|
+
issues.push({ path: `policy.${key}`, message: 'must be boolean' });
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
normalizeOrigins(raw['policy']['networkOrigins'], issues);
|
|
299
|
+
}
|
|
300
|
+
const examples = [];
|
|
301
|
+
if (raw['examples'] !== undefined) {
|
|
302
|
+
if (!Array.isArray(raw['examples']))
|
|
303
|
+
issues.push({ path: 'examples', message: 'must be an array' });
|
|
304
|
+
else {
|
|
305
|
+
raw['examples'].slice(0, 10).forEach((entry, index) => {
|
|
306
|
+
if (!isRecord(entry)) {
|
|
307
|
+
issues.push({ path: `examples.${index}`, message: 'must be an object' });
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const title = entry['title'];
|
|
311
|
+
const args = entry['arguments'];
|
|
312
|
+
if (!nonEmptyString(title))
|
|
313
|
+
issues.push({ path: `examples.${index}.title`, message: 'must be a non-empty title' });
|
|
314
|
+
if (!isRecord(args))
|
|
315
|
+
issues.push({ path: `examples.${index}.arguments`, message: 'must be an object' });
|
|
316
|
+
else
|
|
317
|
+
examples.push({ title: typeof title === 'string' ? title : '', arguments: args });
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (issues.length > 0 || execution === undefined)
|
|
322
|
+
return { ok: false, issues };
|
|
323
|
+
return {
|
|
324
|
+
ok: true,
|
|
325
|
+
issues: [],
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Validate and normalize a draft, throwing one named error with every issue.
|
|
330
|
+
* @param raw - unknown decoded JSON.
|
|
331
|
+
* @returns the normalized draft.
|
|
332
|
+
* @throws CustomToolSchemaError when any field is invalid.
|
|
333
|
+
*/
|
|
334
|
+
export function normalizeCustomToolDraft(raw) {
|
|
335
|
+
const verdict = validateCustomToolDraft(raw);
|
|
336
|
+
if (!verdict.ok)
|
|
337
|
+
throw new CustomToolSchemaError(verdict.issues);
|
|
338
|
+
// SAFETY: validateCustomToolDraft checked every field this rebuild reads.
|
|
339
|
+
const record = raw;
|
|
340
|
+
const execution = validateExecution(record['execution'], []);
|
|
341
|
+
if (execution === undefined)
|
|
342
|
+
throw new CustomToolSchemaError([{ path: 'execution', message: 'invalid execution' }]);
|
|
343
|
+
const policyRaw = isRecord(record['policy']) ? record['policy'] : {};
|
|
344
|
+
const policy = {
|
|
345
|
+
timeoutMs: typeof policyRaw['timeoutMs'] === 'number' ? policyRaw['timeoutMs'] : 15_000,
|
|
346
|
+
readOnly: policyRaw['readOnly'] === true,
|
|
347
|
+
networkOrigins: normalizeOrigins(policyRaw['networkOrigins'], []),
|
|
348
|
+
agentExpose: policyRaw['agentExpose'] !== false,
|
|
349
|
+
mcpExpose: policyRaw['mcpExpose'] === true,
|
|
350
|
+
};
|
|
351
|
+
const examplesRaw = Array.isArray(record['examples']) ? record['examples'] : [];
|
|
352
|
+
const examples = [];
|
|
353
|
+
for (const entry of examplesRaw.slice(0, 10)) {
|
|
354
|
+
if (!isRecord(entry) || !isRecord(entry['arguments']))
|
|
355
|
+
continue;
|
|
356
|
+
examples.push({
|
|
357
|
+
title: typeof entry['title'] === 'string' ? entry['title'] : '',
|
|
358
|
+
arguments: entry['arguments'],
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
id: String(record['id']),
|
|
363
|
+
name: String(record['name']),
|
|
364
|
+
title: String(record['title']),
|
|
365
|
+
description: String(record['description']),
|
|
366
|
+
parameters: record['parameters'],
|
|
367
|
+
...record['outputSchema'] === undefined
|
|
368
|
+
? {}
|
|
369
|
+
: { outputSchema: record['outputSchema'] },
|
|
370
|
+
execution,
|
|
371
|
+
policy,
|
|
372
|
+
examples,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host service for authoring, testing and registering custom tools.
|
|
3
|
+
*
|
|
4
|
+
* This is the single seam behind the Remote methods and the plugin's startup
|
|
5
|
+
* restore. It owns no UI and no transport; every external dependency (model,
|
|
6
|
+
* credential store, tool dispatcher, fetch) is injected.
|
|
7
|
+
*
|
|
8
|
+
* @module @try-works/dsh-tool-mode/custom-tools/service
|
|
9
|
+
*/
|
|
10
|
+
import { type CustomToolDispatchDeps } from './dispatch.ts';
|
|
11
|
+
import { CustomToolRegistrar } from './registry.ts';
|
|
12
|
+
import { CustomToolStore } from './store.ts';
|
|
13
|
+
import type { CustomToolDraft, CustomToolRecord, CustomToolValidation } from './types.ts';
|
|
14
|
+
/** One row safe for the Create-tool list. */
|
|
15
|
+
export interface CustomToolSummary {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly title: string;
|
|
19
|
+
readonly description: string;
|
|
20
|
+
readonly kind: CustomToolRecord['execution']['kind'];
|
|
21
|
+
readonly version: number;
|
|
22
|
+
readonly enabled: boolean;
|
|
23
|
+
readonly agentExpose: boolean;
|
|
24
|
+
readonly mcpExpose: boolean;
|
|
25
|
+
readonly updatedAt: string;
|
|
26
|
+
}
|
|
27
|
+
/** The Create-tool tab's read model. */
|
|
28
|
+
export interface CustomToolsSnapshot {
|
|
29
|
+
readonly store: string;
|
|
30
|
+
readonly writable: boolean;
|
|
31
|
+
readonly tools: readonly CustomToolSummary[];
|
|
32
|
+
}
|
|
33
|
+
/** The result of a test invocation. */
|
|
34
|
+
export interface CustomToolTestResult {
|
|
35
|
+
readonly ok: boolean;
|
|
36
|
+
readonly value?: unknown;
|
|
37
|
+
readonly error?: {
|
|
38
|
+
readonly code: string;
|
|
39
|
+
readonly message: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** A model-authored draft, never saved by the draft call itself. */
|
|
43
|
+
export interface CustomToolDraftResult {
|
|
44
|
+
readonly ok: boolean;
|
|
45
|
+
readonly draft?: CustomToolDraft;
|
|
46
|
+
readonly error?: {
|
|
47
|
+
readonly code: string;
|
|
48
|
+
readonly message: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Host-level seams. */
|
|
52
|
+
export interface CustomToolsServiceOptions {
|
|
53
|
+
readonly store: CustomToolStore;
|
|
54
|
+
readonly registrar: CustomToolRegistrar;
|
|
55
|
+
readonly dispatch?: CustomToolDispatchDeps;
|
|
56
|
+
/** Resolve a credential reference; used by HTTP tools. */
|
|
57
|
+
readonly resolveCredential?: (name: string) => Promise<string | undefined>;
|
|
58
|
+
/** One host-model call for agent drafts; absent disables drafting. */
|
|
59
|
+
readonly draftModel?: (prompt: string, signal: AbortSignal) => Promise<string>;
|
|
60
|
+
}
|
|
61
|
+
/** The service used by Remote and startup restore. */
|
|
62
|
+
export declare class CustomToolsService {
|
|
63
|
+
readonly store: CustomToolStore;
|
|
64
|
+
readonly registrar: CustomToolRegistrar;
|
|
65
|
+
private readonly dispatch;
|
|
66
|
+
private readonly draftModel;
|
|
67
|
+
constructor(options: CustomToolsServiceOptions);
|
|
68
|
+
/** Read the list model without exposing definitions or secrets. */
|
|
69
|
+
describe(): CustomToolsSnapshot;
|
|
70
|
+
/** Read one full record for editing; header secret values are references only. */
|
|
71
|
+
get(id: string): CustomToolRecord | undefined;
|
|
72
|
+
/** Restore every enabled, agent-exposed tool at startup. */
|
|
73
|
+
sync(): import("./registry.ts").CustomToolSyncResult;
|
|
74
|
+
/** Validate a draft without persisting it. */
|
|
75
|
+
validate(raw: unknown): CustomToolValidation;
|
|
76
|
+
/** Execute a draft once; never persists or registers it. */
|
|
77
|
+
test(raw: unknown, args: Readonly<Record<string, unknown>>): Promise<CustomToolTestResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Ask the host model for a draft from a natural-language description. The
|
|
80
|
+
* result is validated but never saved, registered or executed.
|
|
81
|
+
*/
|
|
82
|
+
draft(description: string): Promise<CustomToolDraftResult>;
|
|
83
|
+
/** Validate, persist a new immutable version and register it when exposed. */
|
|
84
|
+
save(raw: unknown): CustomToolRecord;
|
|
85
|
+
/** Enable/disable one tool and reconcile the live registration. */
|
|
86
|
+
setEnabled(id: string, enabled: boolean): CustomToolRecord;
|
|
87
|
+
/** Delete the active pointer and remove the live tool. */
|
|
88
|
+
delete(id: string): boolean;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/custom-tools/service.ts"],"names":[],"mappings":"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"}
|