@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.
Files changed (432) hide show
  1. package/LICENSE +205 -0
  2. package/README.md +303 -2
  3. package/bin/dsh-tool-mode-credentials.mjs +20 -0
  4. package/bin/dsh-tool-mode-mcp-stdio.mjs +80 -0
  5. package/bin/dsh-tool-mode.mjs +211 -0
  6. package/builtins.lock.json +26 -0
  7. package/catalog/desert-ant-models.json +693 -0
  8. package/catalog/playbooks.json +531 -0
  9. package/client/client.model-tools.js +1910 -0
  10. package/client/index.js +4158 -0
  11. package/cordis.patch.yml +39 -0
  12. package/lib/adapters/index.d.ts +61 -0
  13. package/lib/adapters/index.d.ts.map +1 -0
  14. package/lib/adapters/index.js +82 -0
  15. package/lib/adapters/types.d.ts +106 -0
  16. package/lib/adapters/types.d.ts.map +1 -0
  17. package/lib/adapters/types.js +85 -0
  18. package/lib/approval.d.ts +189 -0
  19. package/lib/approval.d.ts.map +1 -0
  20. package/lib/approval.js +510 -0
  21. package/lib/asset-acquisition.d.ts +149 -0
  22. package/lib/asset-acquisition.d.ts.map +1 -0
  23. package/lib/asset-acquisition.js +175 -0
  24. package/lib/authority.d.ts +185 -0
  25. package/lib/authority.d.ts.map +1 -0
  26. package/lib/authority.js +223 -0
  27. package/lib/bindings.d.ts +144 -0
  28. package/lib/bindings.d.ts.map +1 -0
  29. package/lib/bindings.js +314 -0
  30. package/lib/builtins.d.ts +27 -0
  31. package/lib/builtins.d.ts.map +1 -0
  32. package/lib/builtins.js +37 -0
  33. package/lib/capability.d.ts +58 -0
  34. package/lib/capability.d.ts.map +1 -0
  35. package/lib/capability.js +192 -0
  36. package/lib/capture-path.d.ts +97 -0
  37. package/lib/capture-path.d.ts.map +1 -0
  38. package/lib/capture-path.js +152 -0
  39. package/lib/catalog.d.ts +37 -0
  40. package/lib/catalog.d.ts.map +1 -0
  41. package/lib/catalog.js +274 -0
  42. package/lib/contract-payload.d.ts +39 -0
  43. package/lib/contract-payload.d.ts.map +1 -0
  44. package/lib/contract-payload.js +56 -0
  45. package/lib/custom-tools/compile.d.ts +25 -0
  46. package/lib/custom-tools/compile.d.ts.map +1 -0
  47. package/lib/custom-tools/compile.js +61 -0
  48. package/lib/custom-tools/composite-executor.d.ts +42 -0
  49. package/lib/custom-tools/composite-executor.d.ts.map +1 -0
  50. package/lib/custom-tools/composite-executor.js +113 -0
  51. package/lib/custom-tools/dispatch.d.ts +28 -0
  52. package/lib/custom-tools/dispatch.d.ts.map +1 -0
  53. package/lib/custom-tools/dispatch.js +34 -0
  54. package/lib/custom-tools/http-executor.d.ts +48 -0
  55. package/lib/custom-tools/http-executor.d.ts.map +1 -0
  56. package/lib/custom-tools/http-executor.js +241 -0
  57. package/lib/custom-tools/index.d.ts +12 -0
  58. package/lib/custom-tools/index.d.ts.map +1 -0
  59. package/lib/custom-tools/index.js +12 -0
  60. package/lib/custom-tools/mcp-surface.d.ts +14 -0
  61. package/lib/custom-tools/mcp-surface.d.ts.map +1 -0
  62. package/lib/custom-tools/mcp-surface.js +41 -0
  63. package/lib/custom-tools/prompt-executor.d.ts +39 -0
  64. package/lib/custom-tools/prompt-executor.d.ts.map +1 -0
  65. package/lib/custom-tools/prompt-executor.js +59 -0
  66. package/lib/custom-tools/registry.d.ts +69 -0
  67. package/lib/custom-tools/registry.d.ts.map +1 -0
  68. package/lib/custom-tools/registry.js +130 -0
  69. package/lib/custom-tools/schema.d.ts +26 -0
  70. package/lib/custom-tools/schema.d.ts.map +1 -0
  71. package/lib/custom-tools/schema.js +375 -0
  72. package/lib/custom-tools/service.d.ts +90 -0
  73. package/lib/custom-tools/service.d.ts.map +1 -0
  74. package/lib/custom-tools/service.js +203 -0
  75. package/lib/custom-tools/store.d.ts +61 -0
  76. package/lib/custom-tools/store.d.ts.map +1 -0
  77. package/lib/custom-tools/store.js +240 -0
  78. package/lib/custom-tools/types.d.ts +131 -0
  79. package/lib/custom-tools/types.d.ts.map +1 -0
  80. package/lib/custom-tools/types.js +11 -0
  81. package/lib/decision-combine.d.ts +113 -0
  82. package/lib/decision-combine.d.ts.map +1 -0
  83. package/lib/decision-combine.js +156 -0
  84. package/lib/decision-evaluate.d.ts +185 -0
  85. package/lib/decision-evaluate.d.ts.map +1 -0
  86. package/lib/decision-evaluate.js +227 -0
  87. package/lib/deployment-coordinator.d.ts +213 -0
  88. package/lib/deployment-coordinator.d.ts.map +1 -0
  89. package/lib/deployment-coordinator.js +274 -0
  90. package/lib/diagnostics.d.ts +169 -0
  91. package/lib/diagnostics.d.ts.map +1 -0
  92. package/lib/diagnostics.js +136 -0
  93. package/lib/discovery-contracts.d.ts +14 -0
  94. package/lib/discovery-contracts.d.ts.map +1 -0
  95. package/lib/discovery-contracts.js +90 -0
  96. package/lib/discovery-describe.d.ts +35 -0
  97. package/lib/discovery-describe.d.ts.map +1 -0
  98. package/lib/discovery-describe.js +99 -0
  99. package/lib/embedding-index.d.ts +55 -0
  100. package/lib/embedding-index.d.ts.map +1 -0
  101. package/lib/embedding-index.js +126 -0
  102. package/lib/extension-dependencies.d.ts +355 -0
  103. package/lib/extension-dependencies.d.ts.map +1 -0
  104. package/lib/extension-dependencies.js +987 -0
  105. package/lib/extension-dispatch.d.ts +150 -0
  106. package/lib/extension-dispatch.d.ts.map +1 -0
  107. package/lib/extension-dispatch.js +178 -0
  108. package/lib/extension-page-state.d.ts +69 -0
  109. package/lib/extension-page-state.d.ts.map +1 -0
  110. package/lib/extension-page-state.js +82 -0
  111. package/lib/extension-registrar.d.ts +116 -0
  112. package/lib/extension-registrar.d.ts.map +1 -0
  113. package/lib/extension-registrar.js +144 -0
  114. package/lib/extensions-api.d.ts +346 -0
  115. package/lib/extensions-api.d.ts.map +1 -0
  116. package/lib/extensions-api.js +17 -0
  117. package/lib/extensions-remote.d.ts +57 -0
  118. package/lib/extensions-remote.d.ts.map +1 -0
  119. package/lib/extensions-remote.js +69 -0
  120. package/lib/extensions-service.d.ts +568 -0
  121. package/lib/extensions-service.d.ts.map +1 -0
  122. package/lib/extensions-service.js +2552 -0
  123. package/lib/harness-budgets.d.ts +158 -0
  124. package/lib/harness-budgets.d.ts.map +1 -0
  125. package/lib/harness-budgets.js +152 -0
  126. package/lib/harness-llm.d.ts +138 -0
  127. package/lib/harness-llm.d.ts.map +1 -0
  128. package/lib/harness-llm.js +218 -0
  129. package/lib/harness-serving.d.ts +115 -0
  130. package/lib/harness-serving.d.ts.map +1 -0
  131. package/lib/harness-serving.js +176 -0
  132. package/lib/headless.d.ts +97 -0
  133. package/lib/headless.d.ts.map +1 -0
  134. package/lib/headless.js +407 -0
  135. package/lib/http-acquisition.d.ts +27 -0
  136. package/lib/http-acquisition.d.ts.map +1 -0
  137. package/lib/http-acquisition.js +140 -0
  138. package/lib/index.d.ts +546 -0
  139. package/lib/index.d.ts.map +1 -0
  140. package/lib/index.js +5273 -0
  141. package/lib/invocation-accounting.d.ts +169 -0
  142. package/lib/invocation-accounting.d.ts.map +1 -0
  143. package/lib/invocation-accounting.js +148 -0
  144. package/lib/jev.d.ts +218 -0
  145. package/lib/jev.d.ts.map +1 -0
  146. package/lib/jev.js +366 -0
  147. package/lib/legacy-migration.d.ts +95 -0
  148. package/lib/legacy-migration.d.ts.map +1 -0
  149. package/lib/legacy-migration.js +429 -0
  150. package/lib/license-basis.d.ts +29 -0
  151. package/lib/license-basis.d.ts.map +1 -0
  152. package/lib/license-basis.js +58 -0
  153. package/lib/managed-workers.d.ts +158 -0
  154. package/lib/managed-workers.d.ts.map +1 -0
  155. package/lib/managed-workers.js +269 -0
  156. package/lib/mcp/auth-selection.d.ts +35 -0
  157. package/lib/mcp/auth-selection.d.ts.map +1 -0
  158. package/lib/mcp/auth-selection.js +64 -0
  159. package/lib/mcp/client-grant.d.ts +89 -0
  160. package/lib/mcp/client-grant.d.ts.map +1 -0
  161. package/lib/mcp/client-grant.js +63 -0
  162. package/lib/mcp/credential-cli.d.ts +38 -0
  163. package/lib/mcp/credential-cli.d.ts.map +1 -0
  164. package/lib/mcp/credential-cli.js +148 -0
  165. package/lib/mcp/credential-store.d.ts +143 -0
  166. package/lib/mcp/credential-store.d.ts.map +1 -0
  167. package/lib/mcp/credential-store.js +461 -0
  168. package/lib/mcp/export-policy.d.ts +25 -0
  169. package/lib/mcp/export-policy.d.ts.map +1 -0
  170. package/lib/mcp/export-policy.js +31 -0
  171. package/lib/mcp/host-binding.d.ts +144 -0
  172. package/lib/mcp/host-binding.d.ts.map +1 -0
  173. package/lib/mcp/host-binding.js +280 -0
  174. package/lib/mcp/http.d.ts +180 -0
  175. package/lib/mcp/http.d.ts.map +1 -0
  176. package/lib/mcp/http.js +602 -0
  177. package/lib/mcp/oauth.d.ts +149 -0
  178. package/lib/mcp/oauth.d.ts.map +1 -0
  179. package/lib/mcp/oauth.js +396 -0
  180. package/lib/mcp/protocol.d.ts +329 -0
  181. package/lib/mcp/protocol.d.ts.map +1 -0
  182. package/lib/mcp/protocol.js +459 -0
  183. package/lib/mcp/rate-limit.d.ts +68 -0
  184. package/lib/mcp/rate-limit.d.ts.map +1 -0
  185. package/lib/mcp/rate-limit.js +114 -0
  186. package/lib/mcp/sdk-v2.d.ts +17 -0
  187. package/lib/mcp/sdk-v2.d.ts.map +1 -0
  188. package/lib/mcp/sdk-v2.js +204 -0
  189. package/lib/mcp/server.d.ts +149 -0
  190. package/lib/mcp/server.d.ts.map +1 -0
  191. package/lib/mcp/server.js +302 -0
  192. package/lib/mcp/stdio.d.ts +80 -0
  193. package/lib/mcp/stdio.d.ts.map +1 -0
  194. package/lib/mcp/stdio.js +184 -0
  195. package/lib/mcp/subscriptions.d.ts +177 -0
  196. package/lib/mcp/subscriptions.d.ts.map +1 -0
  197. package/lib/mcp/subscriptions.js +288 -0
  198. package/lib/mcp-status.d.ts +96 -0
  199. package/lib/mcp-status.d.ts.map +1 -0
  200. package/lib/mcp-status.js +70 -0
  201. package/lib/mcp-usage.d.ts +110 -0
  202. package/lib/mcp-usage.d.ts.map +1 -0
  203. package/lib/mcp-usage.js +189 -0
  204. package/lib/model-qualification.d.ts +192 -0
  205. package/lib/model-qualification.d.ts.map +1 -0
  206. package/lib/model-qualification.js +178 -0
  207. package/lib/model-runtime-lane.d.ts +69 -0
  208. package/lib/model-runtime-lane.d.ts.map +1 -0
  209. package/lib/model-runtime-lane.js +122 -0
  210. package/lib/model-runtime-recipe.d.ts +132 -0
  211. package/lib/model-runtime-recipe.d.ts.map +1 -0
  212. package/lib/model-runtime-recipe.js +291 -0
  213. package/lib/planning.d.ts +256 -0
  214. package/lib/planning.d.ts.map +1 -0
  215. package/lib/planning.js +471 -0
  216. package/lib/playbook.d.ts +42 -0
  217. package/lib/playbook.d.ts.map +1 -0
  218. package/lib/playbook.js +65 -0
  219. package/lib/prepared-assets.d.ts +269 -0
  220. package/lib/prepared-assets.d.ts.map +1 -0
  221. package/lib/prepared-assets.js +471 -0
  222. package/lib/provider-bridge.d.ts +107 -0
  223. package/lib/provider-bridge.d.ts.map +1 -0
  224. package/lib/provider-bridge.js +423 -0
  225. package/lib/ptc-authority.d.ts +154 -0
  226. package/lib/ptc-authority.d.ts.map +1 -0
  227. package/lib/ptc-authority.js +242 -0
  228. package/lib/ptc-confinement.d.ts +60 -0
  229. package/lib/ptc-confinement.d.ts.map +1 -0
  230. package/lib/ptc-confinement.js +212 -0
  231. package/lib/ptc-runtime.d.ts +166 -0
  232. package/lib/ptc-runtime.d.ts.map +1 -0
  233. package/lib/ptc-runtime.js +231 -0
  234. package/lib/publication.d.ts +161 -0
  235. package/lib/publication.d.ts.map +1 -0
  236. package/lib/publication.js +181 -0
  237. package/lib/receipt-store.d.ts +57 -0
  238. package/lib/receipt-store.d.ts.map +1 -0
  239. package/lib/receipt-store.js +143 -0
  240. package/lib/receipt.d.ts +231 -0
  241. package/lib/receipt.d.ts.map +1 -0
  242. package/lib/receipt.js +165 -0
  243. package/lib/registrar.d.ts +75 -0
  244. package/lib/registrar.d.ts.map +1 -0
  245. package/lib/registrar.js +152 -0
  246. package/lib/resource-governance.d.ts +204 -0
  247. package/lib/resource-governance.d.ts.map +1 -0
  248. package/lib/resource-governance.js +213 -0
  249. package/lib/server-lifecycle.d.ts +175 -0
  250. package/lib/server-lifecycle.d.ts.map +1 -0
  251. package/lib/server-lifecycle.js +269 -0
  252. package/lib/skills.d.ts +31 -0
  253. package/lib/skills.d.ts.map +1 -0
  254. package/lib/skills.js +170 -0
  255. package/lib/speech-bridge.d.ts +74 -0
  256. package/lib/speech-bridge.d.ts.map +1 -0
  257. package/lib/speech-bridge.js +115 -0
  258. package/lib/state.d.ts +100 -0
  259. package/lib/state.d.ts.map +1 -0
  260. package/lib/state.js +160 -0
  261. package/lib/title-proposal.d.ts +194 -0
  262. package/lib/title-proposal.d.ts.map +1 -0
  263. package/lib/title-proposal.js +244 -0
  264. package/lib/tool-inventory.d.ts +90 -0
  265. package/lib/tool-inventory.d.ts.map +1 -0
  266. package/lib/tool-inventory.js +102 -0
  267. package/lib/tool-mode-run.d.ts +310 -0
  268. package/lib/tool-mode-run.d.ts.map +1 -0
  269. package/lib/tool-mode-run.js +411 -0
  270. package/lib/tool-sources.d.ts +80 -0
  271. package/lib/tool-sources.d.ts.map +1 -0
  272. package/lib/tool-sources.js +123 -0
  273. package/lib/tool-usage-projection.d.ts +390 -0
  274. package/lib/tool-usage-projection.d.ts.map +1 -0
  275. package/lib/tool-usage-projection.js +1038 -0
  276. package/lib/tool-usage-report.d.ts +153 -0
  277. package/lib/tool-usage-report.d.ts.map +1 -0
  278. package/lib/tool-usage-report.js +274 -0
  279. package/lib/transport.d.ts +158 -0
  280. package/lib/transport.d.ts.map +1 -0
  281. package/lib/transport.js +332 -0
  282. package/lib/types.d.ts +134 -0
  283. package/lib/types.d.ts.map +1 -0
  284. package/lib/types.js +8 -0
  285. package/lib/update-surface.d.ts +79 -0
  286. package/lib/update-surface.d.ts.map +1 -0
  287. package/lib/update-surface.js +224 -0
  288. package/lib/version.d.ts +3 -0
  289. package/lib/version.d.ts.map +1 -0
  290. package/lib/version.js +27 -0
  291. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts +13 -0
  292. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts.map +1 -0
  293. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.js +85 -0
  294. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts +16 -0
  295. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts.map +1 -0
  296. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.js +87 -0
  297. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts +38 -0
  298. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts.map +1 -0
  299. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.js +445 -0
  300. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts +20 -0
  301. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts.map +1 -0
  302. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.js +112 -0
  303. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts +14 -0
  304. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts.map +1 -0
  305. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.js +63 -0
  306. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts +14 -0
  307. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts.map +1 -0
  308. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.js +76 -0
  309. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts +82 -0
  310. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts.map +1 -0
  311. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.js +274 -0
  312. package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts +26 -0
  313. package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts.map +1 -0
  314. package/node_modules/@try-works/tool-mode-contracts/lib/index.js +53 -0
  315. package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts +133 -0
  316. package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts.map +1 -0
  317. package/node_modules/@try-works/tool-mode-contracts/lib/meta.js +64 -0
  318. package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts +121 -0
  319. package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts.map +1 -0
  320. package/node_modules/@try-works/tool-mode-contracts/lib/registry.js +246 -0
  321. package/node_modules/@try-works/tool-mode-contracts/package.json +35 -0
  322. package/node_modules/@try-works/tool-mode-extension-sdk/bin/dsh-tool-mode.mjs +20 -0
  323. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts +80 -0
  324. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts.map +1 -0
  325. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.js +533 -0
  326. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts +86 -0
  327. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts.map +1 -0
  328. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.js +145 -0
  329. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts +70 -0
  330. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts.map +1 -0
  331. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.js +201 -0
  332. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts +57 -0
  333. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts.map +1 -0
  334. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.js +83 -0
  335. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts +33 -0
  336. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts.map +1 -0
  337. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.js +33 -0
  338. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts +86 -0
  339. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts.map +1 -0
  340. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.js +191 -0
  341. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts +137 -0
  342. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts.map +1 -0
  343. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.js +349 -0
  344. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts +274 -0
  345. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts.map +1 -0
  346. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.js +932 -0
  347. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts +210 -0
  348. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts.map +1 -0
  349. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.js +368 -0
  350. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts +63 -0
  351. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts.map +1 -0
  352. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.js +149 -0
  353. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts +35 -0
  354. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts.map +1 -0
  355. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.js +179 -0
  356. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts +179 -0
  357. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts.map +1 -0
  358. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.js +299 -0
  359. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts +395 -0
  360. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts.map +1 -0
  361. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.js +839 -0
  362. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts +44 -0
  363. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts.map +1 -0
  364. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.js +255 -0
  365. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts +185 -0
  366. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts.map +1 -0
  367. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.js +504 -0
  368. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts +17 -0
  369. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts.map +1 -0
  370. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.js +80 -0
  371. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts +221 -0
  372. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts.map +1 -0
  373. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.js +188 -0
  374. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts +52 -0
  375. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts.map +1 -0
  376. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.js +102 -0
  377. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts +171 -0
  378. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts.map +1 -0
  379. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.js +271 -0
  380. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts +242 -0
  381. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts.map +1 -0
  382. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.js +58 -0
  383. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts +128 -0
  384. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts.map +1 -0
  385. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.js +113 -0
  386. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts +41 -0
  387. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts.map +1 -0
  388. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.js +52 -0
  389. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts +2 -0
  390. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts.map +1 -0
  391. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.js +351 -0
  392. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts +157 -0
  393. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts.map +1 -0
  394. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.js +688 -0
  395. package/node_modules/@try-works/tool-mode-extension-sdk/package.json +54 -0
  396. package/node_modules/@try-works/tool-mode-extension-sdk/schema/extension-manifest-1.1.0.schema.json +253 -0
  397. package/node_modules/@try-works/tool-mode-recipes/bin/tool-mode-recipe.mjs +15 -0
  398. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts +460 -0
  399. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts.map +1 -0
  400. package/node_modules/@try-works/tool-mode-recipes/lib/broker.js +647 -0
  401. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts +61 -0
  402. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts.map +1 -0
  403. package/node_modules/@try-works/tool-mode-recipes/lib/cli.js +1106 -0
  404. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts +237 -0
  405. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts.map +1 -0
  406. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.js +205 -0
  407. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts +85 -0
  408. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts.map +1 -0
  409. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.js +176 -0
  410. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts +119 -0
  411. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts.map +1 -0
  412. package/node_modules/@try-works/tool-mode-recipes/lib/images.js +201 -0
  413. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts +25 -0
  414. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts.map +1 -0
  415. package/node_modules/@try-works/tool-mode-recipes/lib/index.js +25 -0
  416. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts +345 -0
  417. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts.map +1 -0
  418. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.js +1465 -0
  419. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts +51 -0
  420. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts.map +1 -0
  421. package/node_modules/@try-works/tool-mode-recipes/lib/templates.js +310 -0
  422. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts +231 -0
  423. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts.map +1 -0
  424. package/node_modules/@try-works/tool-mode-recipes/lib/titles.js +435 -0
  425. package/node_modules/@try-works/tool-mode-recipes/package.json +56 -0
  426. package/node_modules/@try-works/tool-mode-recipes/recipes/describe-image.json +38 -0
  427. package/node_modules/@try-works/tool-mode-recipes/recipes/text-title.json +45 -0
  428. package/node_modules/@try-works/tool-mode-recipes/schema/harness-model-recipe.schema.json +273 -0
  429. package/package.json +127 -4
  430. package/remote/spec.mjs +993 -0
  431. package/remote/typert.host.mjs +14 -0
  432. package/remote/typert.remote-client.mjs +16 -0
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The shared result envelope every Tool Mode tool returns (DECL-03).
3
+ *
4
+ * The envelope is what makes a result self-describing: a caller can tell which
5
+ * contract and version produced it, which implementation actually ran, where it
6
+ * ran, and whether the host attached any warnings. The host stamps the
7
+ * authoritative provenance fields; an implementation cannot forge another
8
+ * package's identity.
9
+ *
10
+ * DECL-04 is the reason `warnings` exists but a universal `confidence` does not:
11
+ * a successful call means a valid result was produced, not that it is correct,
12
+ * and a fabricated confidence number would claim more than the model supplied.
13
+ *
14
+ * @module @try-works/tool-mode-contracts/meta
15
+ */
16
+ /** The JSON Schema for {@link ToolMeta}, used to validate every result. */
17
+ export const TOOL_META_SCHEMA = {
18
+ type: 'object',
19
+ additionalProperties: false,
20
+ required: [
21
+ 'contract', 'contractVersion', 'implementationId', 'extension',
22
+ 'extensionVersion', 'activationGeneration', 'executionLocation',
23
+ 'receiptId', 'warnings',
24
+ ],
25
+ properties: {
26
+ contract: { type: 'string', minLength: 1 },
27
+ contractVersion: { type: 'string', pattern: '^\\d+\\.\\d+\\.\\d+$' },
28
+ implementationId: { type: 'string', minLength: 1 },
29
+ extension: { type: 'string', minLength: 1 },
30
+ extensionVersion: { type: 'string', pattern: '^\\d+\\.\\d+\\.\\d+' },
31
+ activationGeneration: { type: 'integer', minimum: 0 },
32
+ executionLocation: { type: 'string', enum: ['host', 'device', 'team-server', 'remote'] },
33
+ receiptId: { type: 'string', minLength: 1 },
34
+ warnings: { type: 'array', items: { type: 'string' } },
35
+ confidence: {
36
+ type: 'object',
37
+ additionalProperties: false,
38
+ required: ['kind', 'source'],
39
+ properties: {
40
+ kind: { type: 'string', enum: ['vendor-reported', 'calibrated', 'ranking-logits', 'unavailable'] },
41
+ source: { type: 'string', minLength: 1 },
42
+ },
43
+ },
44
+ },
45
+ };
46
+ /**
47
+ * Attach a `meta` property to a result schema.
48
+ *
49
+ * Contracts declare their own payload; the envelope is identical everywhere, so
50
+ * it is composed here rather than retyped in each contract — retyping it is how
51
+ * the shapes drift apart.
52
+ * @param payload - the contract's payload schema properties.
53
+ * @param requiredPayload - payload property names that are required.
54
+ * @returns a closed object schema containing the payload plus `meta`.
55
+ */
56
+ export function withMeta(payload, requiredPayload = []) {
57
+ return {
58
+ type: 'object',
59
+ additionalProperties: false,
60
+ required: [...requiredPayload, 'meta'],
61
+ properties: { ...payload, meta: TOOL_META_SCHEMA },
62
+ };
63
+ }
64
+ //# sourceMappingURL=meta.js.map
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Contract definitions and their runtime validation.
3
+ *
4
+ * A contract is the tool's public identity: stable name, version, input and
5
+ * output schema, semantics, limits and policy metadata (DECL-01). It is
6
+ * deliberately model-free — implementations bind to it, it does not know about
7
+ * them — which is what lets two models serve one `stt_transcribe` instead of
8
+ * producing a duplicate tool each (BASE-02).
9
+ *
10
+ * Milestone A is explicit that "a copied schema with no runtime validation is not
11
+ * completion", so this module validates both directions: the contract DEFINITION
12
+ * is checked when registered, and every RESULT is checked against the declared
13
+ * output schema before it reaches a caller.
14
+ *
15
+ * @module @try-works/tool-mode-contracts/registry
16
+ */
17
+ import { TOOL_META_SCHEMA } from './meta.ts';
18
+ /** One tool contract: the authored-once public identity (DECL-01). */
19
+ export interface ToolContract {
20
+ /** Contract identity, e.g. `stt.transcribe`. Never a model name. */
21
+ readonly contract: string;
22
+ /** Semantic version, independent of any host release number. */
23
+ readonly version: string;
24
+ /** The tool name callers see, e.g. `stt_transcribe`. */
25
+ readonly toolName: string;
26
+ /** Concise description, used verbatim for DSH registration. */
27
+ readonly description: string;
28
+ /** Input schema as JSON Schema. The object root is closed. */
29
+ readonly inputSchema: Record<string, unknown>;
30
+ /** Output schema as JSON Schema, including the `meta` envelope. */
31
+ readonly outputSchema: Record<string, unknown>;
32
+ /** Declared semantics a caller must be able to rely on. */
33
+ readonly semantics: Readonly<Record<string, string | number | boolean>>;
34
+ /** Admitted resource limits, in the units the schema declares. */
35
+ readonly limits: Readonly<Record<string, number>>;
36
+ /** Unsupported cases the caller should be told about. */
37
+ readonly unsupported: readonly string[];
38
+ /** Worked examples the author ships with the contract (DECL-01). */
39
+ readonly examples?: readonly ContractExample[];
40
+ /** Policy metadata beyond limits (DECL-01). */
41
+ readonly policy?: ContractPolicy;
42
+ }
43
+ /** One worked example: a representative input and its output payload. */
44
+ export interface ContractExample {
45
+ readonly input: Record<string, unknown>;
46
+ readonly output: Record<string, unknown>;
47
+ }
48
+ /** Explicit policy metadata for a contract (DECL-01). */
49
+ export interface ContractPolicy {
50
+ readonly recording: 'required' | 'optional';
51
+ readonly remote: 'allowed' | 'local-only';
52
+ }
53
+ /** A contract that failed validation, with every reason. */
54
+ export declare class ContractError extends Error {
55
+ readonly name = "ContractError";
56
+ /** The individual violations, in declaration order. */
57
+ readonly violations: readonly string[];
58
+ constructor(subject: string, violations: readonly string[]);
59
+ }
60
+ /** A value that did not satisfy a declared schema. */
61
+ export declare class ContractViolationError extends Error {
62
+ readonly name = "ContractViolationError";
63
+ readonly violations: readonly string[];
64
+ constructor(subject: string, violations: readonly string[]);
65
+ }
66
+ /**
67
+ * Validate a contract definition.
68
+ *
69
+ * This is deliberately strict about the identity fields: a contract whose
70
+ * `toolName` is not a legal tool name, or whose version is not semver, would
71
+ * register a tool that callers cannot address consistently.
72
+ * @param contract - the definition to check.
73
+ * @throws ContractError listing every violation.
74
+ */
75
+ export declare function assertValidContract(contract: ToolContract): void;
76
+ /**
77
+ * Validate caller arguments against the contract's input schema.
78
+ * @param contract - the contract to check against.
79
+ * @param args - the candidate arguments.
80
+ * @throws ContractViolationError listing every violation.
81
+ */
82
+ export declare function assertValidInput(contract: ToolContract, args: unknown): void;
83
+ /**
84
+ * Validate a result against the contract's output schema.
85
+ *
86
+ * This runs before the value reaches a caller, so a violation surfaces as a
87
+ * tool failure rather than as malformed data downstream (AT-11).
88
+ * @param contract - the contract to check against.
89
+ * @param value - the candidate result.
90
+ * @throws ContractViolationError listing every violation.
91
+ */
92
+ export declare function assertValidOutput(contract: ToolContract, value: unknown): void;
93
+ /** The meta envelope's own schema, exported for contract authors. */
94
+ export { TOOL_META_SCHEMA };
95
+ /**
96
+ * Compile an arbitrary JSON Schema once, for a host that serves manifest-declared
97
+ * tool schemas rather than registered contracts.
98
+ *
99
+ * Compiling at REGISTRATION (in the host's try/catch) means a malformed schema
100
+ * fails when the tool is registered, not on the first caller's event-loop tick —
101
+ * and it is never re-compiled per call, which a per-call text-keyed cache could
102
+ * not guarantee.
103
+ * @param schema - the JSON Schema to compile.
104
+ * @throws ContractError when the schema does not compile.
105
+ * @returns a validator whose violations are rendered by {@link assertAgainstSchema}.
106
+ */
107
+ export declare function compileSchema(schema: Readonly<Record<string, unknown>>): (value: unknown) => readonly string[];
108
+ /**
109
+ * Validate an arbitrary value against a compiled declared schema.
110
+ *
111
+ * The full-schema counterpart of {@link assertValidInput}/{@link assertValidOutput}:
112
+ * the projected advertisement the DSH registry validates is deliberately LOOSER
113
+ * (union members become `json`, unsupported keywords are dropped), so without this
114
+ * the dropped keywords are enforced nowhere for manifest-declared tools.
115
+ * @param subject - the tool or schema name used in the violation message.
116
+ * @param validate - the compiled validator, from {@link compileSchema}.
117
+ * @param value - the candidate value.
118
+ * @throws ContractViolationError listing every violation.
119
+ */
120
+ export declare function assertAgainstSchema(subject: string, validate: (value: unknown) => readonly string[], value: unknown): void;
121
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,gEAAgE;IAChE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7C,mEAAmE;IACnE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9C,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAA;IACvE,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACjD,yDAAyD;IACzD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IACvC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,eAAe,EAAE,CAAA;IAC9C,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAA;CACjC;AAED,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACzC;AAED,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,CAAA;IAC3C,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,YAAY,CAAA;CAC1C;AAED,4DAA4D;AAC5D,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAkB,IAAI,mBAAkB;IACxC,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;gBAC1B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE;CAI3D;AAED,sDAAsD;AACtD,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,SAAkB,IAAI,4BAA2B;IACjD,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;gBAC1B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE;CAI3D;AA0ED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAmDhE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAM5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAM9E;AAED,qEAAqE;AACrE,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAE3B;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,MAAM,EAAE,CAQ9G;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,MAAM,EAAE,EAC/C,KAAK,EAAE,OAAO,GACb,IAAI,CAGN"}
@@ -0,0 +1,246 @@
1
+ /**
2
+ * Contract definitions and their runtime validation.
3
+ *
4
+ * A contract is the tool's public identity: stable name, version, input and
5
+ * output schema, semantics, limits and policy metadata (DECL-01). It is
6
+ * deliberately model-free — implementations bind to it, it does not know about
7
+ * them — which is what lets two models serve one `stt_transcribe` instead of
8
+ * producing a duplicate tool each (BASE-02).
9
+ *
10
+ * Milestone A is explicit that "a copied schema with no runtime validation is not
11
+ * completion", so this module validates both directions: the contract DEFINITION
12
+ * is checked when registered, and every RESULT is checked against the declared
13
+ * output schema before it reaches a caller.
14
+ *
15
+ * @module @try-works/tool-mode-contracts/registry
16
+ */
17
+ // The explicit `.js` suffix is REQUIRED for packed installs: plain Node ESM does
18
+ // not apply extension resolution to package subpaths, and the workspace's tsx
19
+ // loader masks that (the round-67 packed-orchestration run caught exactly this
20
+ // failure). extension-needle's validation.ts uses the same spelling.
21
+ import Ajv2020 from 'ajv/dist/2020.js';
22
+ import { TOOL_META_SCHEMA } from "./meta.js";
23
+ /** A contract that failed validation, with every reason. */
24
+ export class ContractError extends Error {
25
+ name = 'ContractError';
26
+ /** The individual violations, in declaration order. */
27
+ violations;
28
+ constructor(subject, violations) {
29
+ super(`${subject} is not a valid contract: ${violations.join('; ')}`);
30
+ this.violations = violations;
31
+ }
32
+ }
33
+ /** A value that did not satisfy a declared schema. */
34
+ export class ContractViolationError extends Error {
35
+ name = 'ContractViolationError';
36
+ violations;
37
+ constructor(subject, violations) {
38
+ super(`value violates the ${subject} schema: ${violations.join('; ')}`);
39
+ this.violations = violations;
40
+ }
41
+ }
42
+ /**
43
+ * The validator, on the 2020-12 dialect.
44
+ *
45
+ * 2020-12 rather than draft-07 because extension-declared schemas ship as
46
+ * 2020-12 documents (`$schema`, `$id`, `$defs` — the extension-needle package's
47
+ * tools-plan/structured-extract schemas are the concrete case): a draft-07
48
+ * compiler cannot resolve `#/$defs/...` references, so those real packages
49
+ * could not be activated in the host. `strict: false` for the same reason as
50
+ * before — contract schemas annotate keywords Ajv's strict mode rejects when
51
+ * they are merely descriptive, and a strict-mode THROW on an annotation would
52
+ * refuse a schema that validates fine. A schema that does not COMPILE (an
53
+ * unresolvable `$ref`, a structurally broken keyword) still throws at
54
+ * registration, so a bad schema refuses loudly rather than being accepted.
55
+ * `allowUnionTypes` admits `type: ["number", "null"]`-style unions, which the
56
+ * shipped needle schemas use for nullable fields. `allErrors` keeps the
57
+ * violation report listing every problem rather than the first.
58
+ */
59
+ function createAjv() {
60
+ return new Ajv2020({ allErrors: true, strict: false, allowUnionTypes: true });
61
+ }
62
+ const ajv = createAjv();
63
+ const outputValidators = new Map();
64
+ const inputValidators = new Map();
65
+ /**
66
+ * Validators for $id-bearing schemas, keyed by the id itself.
67
+ *
68
+ * Ajv registers a compiled schema under its `$id`, and compiling the same id a
69
+ * second time THROWS "already exists" — which would make re-activating an
70
+ * extension (or two tools sharing one declared schema file) fail on the second
71
+ * compile. Identical content re-compiles to the same validator; DIFFERENT
72
+ * content under one id is a refusal, because two schemas sharing an id is
73
+ * exactly the drift a caller must never silently inherit.
74
+ */
75
+ const compiledById = new Map();
76
+ /** Compile a schema, tolerating a repeat compile of identical $id content. */
77
+ function compileTracked(schema) {
78
+ const id = typeof schema.$id === 'string' ? schema.$id : undefined;
79
+ if (id === undefined)
80
+ return ajv.compile(schema);
81
+ const serialized = JSON.stringify(schema);
82
+ const cached = compiledById.get(id);
83
+ if (cached !== undefined) {
84
+ if (cached.serialized !== serialized) {
85
+ throw new ContractError('declared-schema', [`a schema with $id ${JSON.stringify(id)} was already compiled from different content; two different schemas must not share an id`]);
86
+ }
87
+ return cached.validate;
88
+ }
89
+ const validate = ajv.compile(schema);
90
+ compiledById.set(id, { serialized, validate });
91
+ return validate;
92
+ }
93
+ /** Render Ajv errors as stable, deduplicated strings. */
94
+ function renderErrors(errors) {
95
+ const seen = new Set();
96
+ const out = [];
97
+ for (const error of errors ?? []) {
98
+ const path = error.instancePath === '' ? '(root)' : error.instancePath;
99
+ const line = `${path} ${error.message ?? 'is invalid'}`;
100
+ if (!seen.has(line)) {
101
+ seen.add(line);
102
+ out.push(line);
103
+ }
104
+ }
105
+ return out;
106
+ }
107
+ /**
108
+ * Validate a contract definition.
109
+ *
110
+ * This is deliberately strict about the identity fields: a contract whose
111
+ * `toolName` is not a legal tool name, or whose version is not semver, would
112
+ * register a tool that callers cannot address consistently.
113
+ * @param contract - the definition to check.
114
+ * @throws ContractError listing every violation.
115
+ */
116
+ export function assertValidContract(contract) {
117
+ const violations = [];
118
+ if (!/^[a-z][a-z0-9_]*$/.test(contract.toolName)) {
119
+ violations.push(`toolName ${JSON.stringify(contract.toolName)} must be lower snake_case`);
120
+ }
121
+ if (!/^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/.test(contract.contract)) {
122
+ violations.push(`contract ${JSON.stringify(contract.contract)} must be a dotted lower-case identity `
123
+ + '(for example "stt.transcribe" or "text.language_detect")');
124
+ }
125
+ if (!/^\d+\.\d+\.\d+$/.test(contract.version)) {
126
+ violations.push(`version ${JSON.stringify(contract.version)} must be semantic (x.y.z)`);
127
+ }
128
+ if (contract.description.trim().length < 10) {
129
+ violations.push('description must be a real sentence, not a placeholder');
130
+ }
131
+ const input = contract.inputSchema;
132
+ if (input.type !== 'object') {
133
+ violations.push('inputSchema root must be an object (clients require an object argument)');
134
+ }
135
+ const output = contract.outputSchema;
136
+ if (output.type !== 'object') {
137
+ violations.push('outputSchema root must be an object for broad client compatibility (DECL-02)');
138
+ }
139
+ else if (output.properties?.meta === undefined) {
140
+ violations.push('outputSchema must include the shared `meta` envelope (DECL-03)');
141
+ }
142
+ // DECL-02: an unconstrained open object is not an adequate leaf-tool contract.
143
+ if (output.additionalProperties !== false) {
144
+ violations.push('outputSchema must be closed (additionalProperties: false), not a generic open object (DECL-02)');
145
+ }
146
+ if (contract.unsupported.length === 0) {
147
+ violations.push('unsupported must name at least one case; an empty list claims universal support');
148
+ }
149
+ if (violations.length > 0)
150
+ throw new ContractError(contract.contract, violations);
151
+ // Schemas must be compilable, or the contract is unenforceable.
152
+ try {
153
+ inputValidators.set(contract.contract, compileTracked(contract.inputSchema));
154
+ }
155
+ catch (error) {
156
+ throw new ContractError(contract.contract, [`inputSchema does not compile: ${message(error)}`]);
157
+ }
158
+ try {
159
+ outputValidators.set(contract.contract, compileTracked(contract.outputSchema));
160
+ }
161
+ catch (error) {
162
+ throw new ContractError(contract.contract, [`outputSchema does not compile: ${message(error)}`]);
163
+ }
164
+ }
165
+ /**
166
+ * Validate caller arguments against the contract's input schema.
167
+ * @param contract - the contract to check against.
168
+ * @param args - the candidate arguments.
169
+ * @throws ContractViolationError listing every violation.
170
+ */
171
+ export function assertValidInput(contract, args) {
172
+ const validate = inputValidators.get(contract.contract);
173
+ if (validate === undefined) {
174
+ throw new ContractError(contract.contract, ['input was validated before the contract was registered']);
175
+ }
176
+ if (!validate(args))
177
+ throw new ContractViolationError(contract.contract, renderErrors(validate.errors));
178
+ }
179
+ /**
180
+ * Validate a result against the contract's output schema.
181
+ *
182
+ * This runs before the value reaches a caller, so a violation surfaces as a
183
+ * tool failure rather than as malformed data downstream (AT-11).
184
+ * @param contract - the contract to check against.
185
+ * @param value - the candidate result.
186
+ * @throws ContractViolationError listing every violation.
187
+ */
188
+ export function assertValidOutput(contract, value) {
189
+ const validate = outputValidators.get(contract.contract);
190
+ if (validate === undefined) {
191
+ throw new ContractError(contract.contract, ['result was validated before the contract was registered']);
192
+ }
193
+ if (!validate(value))
194
+ throw new ContractViolationError(contract.contract, renderErrors(validate.errors));
195
+ }
196
+ /** The meta envelope's own schema, exported for contract authors. */
197
+ export { TOOL_META_SCHEMA };
198
+ /**
199
+ * Compile an arbitrary JSON Schema once, for a host that serves manifest-declared
200
+ * tool schemas rather than registered contracts.
201
+ *
202
+ * Compiling at REGISTRATION (in the host's try/catch) means a malformed schema
203
+ * fails when the tool is registered, not on the first caller's event-loop tick —
204
+ * and it is never re-compiled per call, which a per-call text-keyed cache could
205
+ * not guarantee.
206
+ * @param schema - the JSON Schema to compile.
207
+ * @throws ContractError when the schema does not compile.
208
+ * @returns a validator whose violations are rendered by {@link assertAgainstSchema}.
209
+ */
210
+ export function compileSchema(schema) {
211
+ let validate;
212
+ try {
213
+ validate = compileTracked(schema);
214
+ }
215
+ catch (error) {
216
+ throw new ContractError('declared-schema', [`schema does not compile: ${message(error)}`]);
217
+ }
218
+ return value => (validate(value) ? [] : renderErrors(validate.errors));
219
+ }
220
+ /**
221
+ * Validate an arbitrary value against a compiled declared schema.
222
+ *
223
+ * The full-schema counterpart of {@link assertValidInput}/{@link assertValidOutput}:
224
+ * the projected advertisement the DSH registry validates is deliberately LOOSER
225
+ * (union members become `json`, unsupported keywords are dropped), so without this
226
+ * the dropped keywords are enforced nowhere for manifest-declared tools.
227
+ * @param subject - the tool or schema name used in the violation message.
228
+ * @param validate - the compiled validator, from {@link compileSchema}.
229
+ * @param value - the candidate value.
230
+ * @throws ContractViolationError listing every violation.
231
+ */
232
+ export function assertAgainstSchema(subject, validate, value) {
233
+ const violations = validate(value);
234
+ if (violations.length > 0)
235
+ throw new ContractViolationError(subject, violations);
236
+ }
237
+ /** Best-effort message from an arbitrary thrown value. */
238
+ function message(error) {
239
+ try {
240
+ return error instanceof Error ? error.message : String(error);
241
+ }
242
+ catch {
243
+ return '<unrenderable>';
244
+ }
245
+ }
246
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@try-works/tool-mode-contracts",
3
+ "version": "0.1.1",
4
+ "description": "Model-free standard tool contracts for Tool Mode: identities, schemas, semantics and runtime validation",
5
+ "license": "Apache-2.0",
6
+ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/try-works/tool-mode.git",
10
+ "directory": "packages/tool-mode-contracts"
11
+ },
12
+ "type": "module",
13
+ "main": "lib/index.js",
14
+ "types": "lib/index.d.ts",
15
+ "exports": {
16
+ ".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": ["lib/**/*.js", "lib/**/*.d.ts", "lib/**/*.d.ts.map", "README.md"],
20
+ "dependencies": {
21
+ "ajv": "^8.20.0"
22
+ },
23
+ "scripts": {
24
+ "build": "tsc -p tsconfig.build.json",
25
+ "typecheck": "tsc --noEmit -p tsconfig.json",
26
+ "test": "tsx --test tests/*.test.ts",
27
+ "prepack": "tsc -p tsconfig.build.json",
28
+ "prepare": "tsc -p tsconfig.build.json"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^24.0.0",
32
+ "typescript": "^5.9.0"
33
+ }
34
+ }
35
+
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The `dsh-tool-mode` executable (EXT-31).
4
+ *
5
+ * A thin shim: it wires real process streams into the tested CLI and translates
6
+ * the returned code into an exit status. All the logic lives in the library, so
7
+ * every path — including the refusals — is exercised by tests rather than only by
8
+ * running the binary by hand.
9
+ */
10
+
11
+ import { runToolModeCli } from '../lib/cli.js'
12
+
13
+ const code = await runToolModeCli(
14
+ process.argv.slice(2),
15
+ {
16
+ out: line => process.stdout.write(`${line}\n`),
17
+ err: line => process.stderr.write(`${line}\n`),
18
+ },
19
+ )
20
+ process.exitCode = code
@@ -0,0 +1,80 @@
1
+ /**
2
+ * The operator command family (EXT-31).
3
+ *
4
+ * EXT-31 is explicit that these are REQUIRED NEW FUNCTIONALITY, not existing npm
5
+ * or DSH commands, and that offline edits must hold exclusive store ownership. So
6
+ * every mutating command takes the store lock, and the CLI refuses rather than
7
+ * racing a running host.
8
+ *
9
+ * The entry point takes argv and an output sink instead of reading `process`
10
+ * directly. A CLI that can only be exercised by spawning a child process is a CLI
11
+ * whose failure paths are tested by hand or not at all, and the failure paths here
12
+ * are the security-relevant ones.
13
+ *
14
+ * The management surface is deliberately NOT the inference surface: EXT-31 forbids
15
+ * exposing the management channel on the MCP tool surface by default, and nothing
16
+ * in this module registers a tool.
17
+ *
18
+ * @module @try-works/tool-mode-extension-sdk/cli
19
+ */
20
+ import { type ContributionRegistrar } from './install/lifecycle.ts';
21
+ /** Where the CLI writes. Injected so a test can capture output. */
22
+ export interface CliIo {
23
+ /** Write one line of normal output. */
24
+ out(line: string): void;
25
+ /** Write one line of error output. */
26
+ err(line: string): void;
27
+ }
28
+ /** Options resolved from argv. */
29
+ export interface CliOptions {
30
+ /** The extension store root. */
31
+ readonly store: string;
32
+ /** The profile to act on. */
33
+ readonly profile: string;
34
+ /** Positional arguments after the command. */
35
+ readonly positional: readonly string[];
36
+ /** `--flag` names and their values. */
37
+ readonly flags: Readonly<Record<string, string | true>>;
38
+ }
39
+ /** What the CLI needs from the environment to act. */
40
+ export interface CliDependencies {
41
+ /** A registrar for activation. Without one, activation is refused rather than faked. */
42
+ readonly registrar?: ContributionRegistrar;
43
+ /** Parse and install from a specifier; injected so the CLI owns no network stack. */
44
+ readonly install?: (spec: string, integrity: string | undefined, store: string) => Promise<string>;
45
+ /**
46
+ * The recipes authoring runner, forwarded to by the `recipes` namespace
47
+ * (RCP-08). When absent, the SDK resolves `@try-works/tool-mode-recipes/cli`
48
+ * lazily at invocation time; when that also fails, the command answers a
49
+ * PRECISE refusal — the SDK never duplicates recipe semantics and never
50
+ * depends on the recipes package at import time.
51
+ */
52
+ readonly recipeCliRunner?: {
53
+ runRecipeCli(argv: readonly string[], io: CliIo): Promise<number>;
54
+ };
55
+ /** Override the lazy resolver (tests); returns the runner or undefined. */
56
+ readonly resolveRecipeCli?: () => Promise<{
57
+ runRecipeCli(argv: readonly string[], io: CliIo): Promise<number>;
58
+ } | undefined>;
59
+ }
60
+ /**
61
+ * Parse argv into options.
62
+ *
63
+ * Anything unrecognised is REFUSED rather than ignored: a mistyped flag that is
64
+ * silently dropped turns `--deactivate` into a command the operator did not ask
65
+ * for, which on `uninstall` is the difference between previewing and removing.
66
+ * @param argv - arguments after the executable name.
67
+ * @returns the parsed options.
68
+ * @throws ManagementError when a flag is unknown or a value is missing.
69
+ */
70
+ export declare function parseArgs(argv: readonly string[]): CliOptions;
71
+ /**
72
+ * Run one command.
73
+ *
74
+ * @param argv - arguments after the executable name.
75
+ * @param io - output sinks.
76
+ * @param dependencies - the registrar and installer to act with.
77
+ * @returns the process exit code.
78
+ */
79
+ export declare function runToolModeCli(argv: readonly string[], io: CliIo, dependencies?: CliDependencies): Promise<number>;
80
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAsB,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAIvF,mEAAmE;AACnE,MAAM,WAAW,KAAK;IACpB,uCAAuC;IACvC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,sCAAsC;IACtC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED,kCAAkC;AAClC,MAAM,WAAW,UAAU;IACzB,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;IACtC,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAA;CACxD;AAED,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC9B,wFAAwF;IACxF,QAAQ,CAAC,SAAS,CAAC,EAAE,qBAAqB,CAAA;IAC1C,qFAAqF;IACrF,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAClG;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE;QAAE,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,CAAA;IAChG,2EAA2E;IAC3E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC;QAAE,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,GAAG,SAAS,CAAC,CAAA;CAC7H;AA4ED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CA4C7D;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,EAAE,KAAK,EACT,YAAY,GAAE,eAAoB,GACjC,OAAO,CAAC,MAAM,CAAC,CA8DjB"}