@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,204 @@
1
+ /**
2
+ * Official SDK v2 serving adapter, not a second business dispatcher.
3
+ *
4
+ * Upstream main inspected at 9bc40e903fde15534ec06ff4c1347d47000dbe16:
5
+ * https://github.com/modelcontextprotocol/typescript-sdk/blob/9bc40e903fde15534ec06ff4c1347d47000dbe16/docs/serving/http.md
6
+ * That revision's packages/server/package.json is 2.3.1; runtime uses the exact
7
+ * npm release @modelcontextprotocol/server@2.3.1 (not a floating git dependency).
8
+ * Registry provenance: https://registry.npmjs.org/@modelcontextprotocol/server/2.3.1
9
+ * tarball SHA-1 a15440d5c06f3bad67360952fe58e6965b4a4ac7; integrity
10
+ * sha512-e59MfWuSssj6DoQ96JCTqdW1AXT5/XtnTl0WWd6MU1Ka434fFUGGosCLJbGNySDhHGvxQWoRWK137FXYFkYNWw==
11
+ * Protocol revision: 2026-07-28. Legacy handshakes/sessions are deliberately refused.
12
+ */
13
+ import { createMcpHandler, fromJsonSchema, McpServer } from '@modelcontextprotocol/server';
14
+ import { toolErrorResult } from "./protocol.js";
15
+ /**
16
+ * Construct official serving around a caller already verified by the transport.
17
+ * No credentials or grants are accepted from JSON-RPC params. Each factory call
18
+ * reads the LIVE surface and creates a fresh server; business execution and its
19
+ * accounting remain exclusively in host.callTool / createMcpHost.
20
+ */
21
+ export function createSdkV2Handler(host, caller, incoming) {
22
+ return createMcpHandler(({ authInfo }) => {
23
+ if (authInfo?.clientId !== caller.clientId) {
24
+ throw new Error('SDK serving requires the transport-verified caller');
25
+ }
26
+ const server = new McpServer(host.serverInfo, {
27
+ supportedProtocolVersions: ['2026-07-28'],
28
+ // Keep tools/list available for an empty caller-specific catalog; SDK
29
+ // handlers otherwise appear only after the first registerTool call.
30
+ capabilities: { tools: { listChanged: false } },
31
+ });
32
+ for (const tool of [...host.listTools()].sort((a, b) => a.name.localeCompare(b.name))) {
33
+ if (!caller.allowedTools.includes(tool.name) || tool.importedFromMcp)
34
+ continue;
35
+ server.registerTool(tool.name, {
36
+ ...tool.title === undefined ? {} : { title: tool.title },
37
+ description: tool.description,
38
+ inputSchema: fromJsonSchema(tool.inputSchema),
39
+ // A definition with no declared result shape must register no
40
+ // outputSchema: the SDK's output validator converts ANY registered
41
+ // outputSchema plus an undefined structuredContent into a tool error
42
+ // ("has an output schema but no structured content was provided"),
43
+ // while the protocol dispatch serves the same host outcome as a
44
+ // content-only success (server.ts). An empty schema is the
45
+ // schema-less sentinel.
46
+ ...tool.outputSchema === undefined || Object.keys(tool.outputSchema).length === 0
47
+ ? {}
48
+ : { outputSchema: fromJsonSchema(tool.outputSchema) },
49
+ }, async (args, ctx) => {
50
+ const outcome = await host.callTool(tool.name, args, ctx.mcpReq.signal, caller);
51
+ if (outcome.isError === true) {
52
+ // An application failure is a tool-error RESULT (P26-04), clamped
53
+ // exactly like the protocol dispatch clamps it: toolErrorResult
54
+ // bounds the message to 2000 chars + '…' (protocol.ts:358-365).
55
+ // The installed SDK's CallToolResult.content is mutable, so the
56
+ // readonly payload content is copied, as the denied-call path does.
57
+ const failure = toolErrorResult(outcome.text);
58
+ return { isError: failure.isError, content: [...failure.content] };
59
+ }
60
+ // The pinned 2026-07-28 schema types structuredContent as `unknown` —
61
+ // ANY JSON value (object, array, string, number, boolean, null:
62
+ // docs/tool-mode/specs/mcp-2026-07-28/schema.ts CallToolResult). The
63
+ // installed SDK's CallToolResultSchema is z.ZodUnknown and its 2026-era
64
+ // projection is identity, so no runtime guard or cast is needed;
65
+ // undefined means "no structured value" and is omitted.
66
+ return {
67
+ content: [{ type: 'text', text: outcome.text }],
68
+ ...outcome.structured === undefined ? {} : { structuredContent: outcome.structured },
69
+ };
70
+ });
71
+ }
72
+ // Withheld known tools must remain invisible to tools/list, but SEC-03
73
+ // requires policy denials in the tool-error lane. Override only this fresh
74
+ // request's denied-call handler; accepted calls retain McpServer's genuine
75
+ // registration/input/output pipeline. The shared host boundary owns the
76
+ // refusal and its accounting; no unauthorized tool is ever registered.
77
+ if (incoming !== undefined) {
78
+ const deniedName = incoming.params?.name;
79
+ /**
80
+ * A name the host KNOWS but withheld is not an unknown method. The SDK only
81
+ * registers published tools, so it would answer its own "Tool … not found"
82
+ * before the host can explain the publication decision. This request-scoped
83
+ * override returns the recorded reason in the tool-error lane; the tool is
84
+ * still never registered, so it remains invisible to tools/list.
85
+ */
86
+ if (incoming.method === 'tools/call' && typeof deniedName === 'string') {
87
+ const withheldReason = host.withheldReason?.(deniedName);
88
+ if (withheldReason !== undefined) {
89
+ server.server.setRequestHandler('tools/call', async (request, ctx) => {
90
+ if (request.params.name !== deniedName)
91
+ throw new Error('request-specific withheld name changed');
92
+ const outcome = await host.callTool(deniedName, request.params.arguments ?? {}, ctx.mcpReq.signal, caller);
93
+ // callTool answers a known withheld name with isError:true. If a host
94
+ // ever accepted it, the publication decision is inconsistent; do not
95
+ // turn that into a success here.
96
+ if (outcome.isError !== true)
97
+ throw new Error('host accepted a withheld tool');
98
+ return { isError: true, content: [...toolErrorResult(outcome.text).content] };
99
+ });
100
+ }
101
+ }
102
+ if (incoming.method === 'tools/call' && typeof deniedName === 'string'
103
+ && !caller.allowedTools.includes(deniedName)
104
+ && host.listTools().some(tool => tool.name === deniedName && !tool.importedFromMcp)) {
105
+ server.server.setRequestHandler('tools/call', async (request, ctx) => {
106
+ if (request.params.name !== deniedName)
107
+ throw new Error('request-specific denial name changed');
108
+ const outcome = await host.callTool(deniedName, request.params.arguments ?? {}, ctx.mcpReq.signal, caller);
109
+ if (outcome.isError !== true)
110
+ throw new Error('host accepted a tool outside the authenticated grant');
111
+ return { isError: true, content: [...toolErrorResult(outcome.text).content] };
112
+ });
113
+ }
114
+ }
115
+ return server;
116
+ }, {
117
+ legacy: 'reject',
118
+ // NEVER 'json': that mode silently drops mid-call notifications. Auto keeps
119
+ // every message, upgrading the response to SSE if one is emitted.
120
+ responseMode: 'auto',
121
+ });
122
+ }
123
+ /**
124
+ * Live Fetch face. The per-request SDK handler belongs to the response body:
125
+ * close it on drain, cancellation, abort or error, never when fetch returns SSE.
126
+ * Linking a controller also makes a Web reader's cancel abort business execution.
127
+ */
128
+ export async function serveSdkV2Request(host, caller, request, token) {
129
+ const incoming = await request.clone().json();
130
+ const handler = createSdkV2Handler(host, caller, incoming);
131
+ const abort = new AbortController();
132
+ let reader;
133
+ let stopped = false;
134
+ let closing;
135
+ const close = () => {
136
+ if (closing === undefined) {
137
+ stopped = true;
138
+ request.signal.removeEventListener('abort', onAbort);
139
+ closing = handler.close();
140
+ }
141
+ return closing;
142
+ };
143
+ const cancel = async (reason) => {
144
+ abort.abort(reason);
145
+ try {
146
+ await reader?.cancel(reason);
147
+ }
148
+ finally {
149
+ await close();
150
+ }
151
+ };
152
+ const onAbort = () => { void cancel(request.signal.reason).catch(() => { }); };
153
+ request.signal.addEventListener('abort', onAbort, { once: true });
154
+ if (request.signal.aborted)
155
+ onAbort();
156
+ try {
157
+ const response = await handler.fetch(new Request(request, { signal: abort.signal }), {
158
+ authInfo: { token, clientId: caller.clientId, scopes: [] },
159
+ });
160
+ if (response.body === null) {
161
+ await close();
162
+ return response;
163
+ }
164
+ reader = response.body.getReader();
165
+ if (abort.signal.aborted) {
166
+ await cancel(abort.signal.reason);
167
+ throw abort.signal.reason ?? new Error('request aborted');
168
+ }
169
+ const body = new ReadableStream({
170
+ async pull(controller) {
171
+ try {
172
+ const next = await reader.read();
173
+ if (stopped) {
174
+ controller.close();
175
+ return;
176
+ }
177
+ if (next.done) {
178
+ await close();
179
+ reader.releaseLock();
180
+ controller.close();
181
+ }
182
+ else {
183
+ controller.enqueue(next.value);
184
+ }
185
+ }
186
+ catch (error) {
187
+ await close();
188
+ controller.error(error);
189
+ }
190
+ },
191
+ async cancel(reason) { await cancel(reason); },
192
+ }, { highWaterMark: 0 });
193
+ return new Response(body, {
194
+ status: response.status,
195
+ statusText: response.statusText,
196
+ headers: response.headers,
197
+ });
198
+ }
199
+ catch (error) {
200
+ await close();
201
+ throw error;
202
+ }
203
+ }
204
+ //# sourceMappingURL=sdk-v2.js.map
@@ -0,0 +1,149 @@
1
+ /**
2
+ * MCP method dispatch (MCP-05, MCP-06, MCP-08, MCP-09, MCP-13).
3
+ *
4
+ * The server is STATELESS by construction, which is what P26-01 requires: a
5
+ * `tools/list` or `tools/call` must be processable as the first application
6
+ * request. There is no session table here to require one, so the requirement is
7
+ * satisfied by the shape of the code rather than by remembering to skip a check.
8
+ *
9
+ * Dispatch resolves ONE authorized definition and calls it through the host's
10
+ * execution path (MCP-08), rather than reaching into a registry by name — the
11
+ * difference matters because the host's path applies the grant, the receipt and
12
+ * the result policy, while a direct lookup would bypass all three.
13
+ *
14
+ * @module @try-works/dsh-tool-mode/mcp/server
15
+ */
16
+ import { type CatalogCachePolicy, type HeaderInput, type WireRequest } from './protocol.ts';
17
+ import type { SubscriptionRegistry } from './subscriptions.ts';
18
+ import type { ExternalCaller } from './client-grant.ts';
19
+ /** One tool as the MCP surface describes it. */
20
+ export interface McpToolDefinition {
21
+ /** The caller-facing name. */
22
+ readonly name: string;
23
+ /** A short human-readable title, when the contract declares one. */
24
+ readonly title?: string;
25
+ /** What the tool does, written for a model. */
26
+ readonly description: string;
27
+ /** The canonical input schema, JSON Schema 2020-12. */
28
+ readonly inputSchema: Readonly<Record<string, unknown>>;
29
+ /** The canonical OUTPUT schema (MCP-09). */
30
+ readonly outputSchema: Readonly<Record<string, unknown>>;
31
+ /** Whether this tool was imported from another MCP server. */
32
+ readonly importedFromMcp: boolean;
33
+ }
34
+ /** The outcome of invoking one tool. */
35
+ export interface ToolInvocationOutcome {
36
+ /** The finalized, post-policy canonical value. */
37
+ readonly structured: unknown;
38
+ /** A bounded, model-readable rendering. */
39
+ readonly text: string;
40
+ /** Whether the tool itself failed. */
41
+ readonly isError?: boolean;
42
+ }
43
+ /** What dispatch needs from the host. */
44
+ export interface McpHost {
45
+ /** This server's identity, reported in result metadata. */
46
+ readonly serverInfo: {
47
+ readonly name: string;
48
+ readonly version: string;
49
+ };
50
+ /**
51
+ * The catalog caching policy carried on `tools/list` and `server/discover` (P26-14).
52
+ *
53
+ * Absent means the unchanged default `{ cacheScope: 'private', ttlMs: 0 }`. The
54
+ * scope is validated by the host factory; dispatch restates the normalized values on
55
+ * BOTH cacheable result types.
56
+ */
57
+ readonly cachePolicy?: CatalogCachePolicy;
58
+ /**
59
+ * The tools this caller may see, in deterministic order (MCP-06).
60
+ * @returns the authorized definitions.
61
+ */
62
+ listTools(): readonly McpToolDefinition[];
63
+ /**
64
+ * Why a tool the host KNOWS is absent from this caller's catalog.
65
+ *
66
+ * Absent/undefined means genuinely unknown. The dispatcher consults this before
67
+ * reporting invalid params, so a withholding decision reaches the caller as a
68
+ * tool error with its recorded reason rather than as a protocol "not found".
69
+ * @param name - the tool name the caller asked for.
70
+ * @returns the recorded reason, or undefined when the host has no such tool.
71
+ */
72
+ withheldReason?(name: string): string | undefined;
73
+ /**
74
+ * Invoke one authorized tool through the host execution path (MCP-08).
75
+ * @param name - the tool name.
76
+ * @param args - the tool arguments.
77
+ * @param signal - the caller's abort signal.
78
+ * @param caller - the AUTHENTICATED external caller and its derived grant (SEC-04),
79
+ * resolved by the transport; absent for non-HTTP transports that carry no client.
80
+ * @returns the outcome.
81
+ */
82
+ callTool(name: string, args: Readonly<Record<string, unknown>>, signal: AbortSignal, caller?: ExternalCaller): Promise<ToolInvocationOutcome>;
83
+ /**
84
+ * Explicit catalog facts (P26-14): profile/model availability and extension
85
+ * generation. Read per discovery request and attached under a namespaced
86
+ * `_meta` key so it is never a hidden per-connection mutation.
87
+ */
88
+ catalogFacts?(): Record<string, unknown>;
89
+ }
90
+ /** One dispatched response. */
91
+ export interface DispatchResult {
92
+ /** The response envelope to send, or undefined for a notification. */
93
+ readonly response?: Record<string, unknown>;
94
+ /** The HTTP status the transport should use. */
95
+ readonly httpStatus: number;
96
+ /**
97
+ * Notifications the transport must deliver after the response (P26-09).
98
+ *
99
+ * Carried on the result rather than written into the body, because a notification
100
+ * is a separate message: embedding one inside a result would produce a frame that
101
+ * is not a valid result and not a valid notification.
102
+ */
103
+ readonly followUp?: readonly Record<string, unknown>[];
104
+ }
105
+ /**
106
+ * Project a definition into the MCP tool shape.
107
+ *
108
+ * `outputSchema` is taken from the resolved definition rather than from DSH's
109
+ * model-facing `schemas()` projection, which intentionally omits `output`: a
110
+ * schema-only export built from that projection would be missing the very field
111
+ * MCP-09 requires.
112
+ * @param definition - the resolved definition.
113
+ * @returns the MCP tool descriptor.
114
+ */
115
+ export declare function toMcpTool(definition: McpToolDefinition): Record<string, unknown>;
116
+ /**
117
+ * Dispatch one request.
118
+ *
119
+ * Stateless: nothing is retained between calls, so a valid request works as the
120
+ * first one.
121
+ * @param request - the parsed request.
122
+ * @param host - the host surface.
123
+ * @param options - headers and the caller's abort signal.
124
+ * @returns the response and the HTTP status.
125
+ */
126
+ export declare function dispatch(request: WireRequest, host: McpHost, options?: {
127
+ readonly headers?: HeaderInput;
128
+ readonly signal?: AbortSignal;
129
+ /** Whether the transport checks headers at all; stdio has none to check. */
130
+ readonly checkHeaders?: boolean;
131
+ /**
132
+ * The catalog subscription registry (P26-09).
133
+ *
134
+ * Optional so a host that offers no subscriptions does not have to construct one;
135
+ * subscriptions/listen then reports the method as unsupported rather than
136
+ * accepting a subscription it cannot serve.
137
+ */
138
+ readonly subscriptions?: SubscriptionRegistry;
139
+ /** The authenticated client, which a subscription is bound to. */
140
+ readonly clientId?: string;
141
+ /**
142
+ * The authenticated external caller and its derived grant (SEC-04).
143
+ *
144
+ * Resolved by the TRANSPORT after authentication, never read from the request body:
145
+ * a caller cannot supply or forge its own identity or grant (BASE-05).
146
+ */
147
+ readonly caller?: ExternalCaller;
148
+ }): Promise<DispatchResult>;
149
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAaL,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,gDAAgD;AAChD,MAAM,WAAW,iBAAiB;IAChC,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,oEAAoE;IACpE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,uDAAuD;IACvD,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACvD,4CAA4C;IAC5C,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACxD,8DAA8D;IAC9D,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAClC;AAED,wCAAwC;AACxC,MAAM,WAAW,qBAAqB;IACpC,kDAAkD;IAClD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,sCAAsC;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED,yCAAyC;AACzC,MAAM,WAAW,OAAO;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,UAAU,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;IACxE;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAA;IACzC;;;OAGG;IACH,SAAS,IAAI,SAAS,iBAAiB,EAAE,CAAA;IACzC;;;;;;;;OAQG;IACH,cAAc,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACjD;;;;;;;;OAQG;IACH,QAAQ,CACN,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACvC,MAAM,EAAE,WAAW,EACnB,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACjC;;;;OAIG;IACH,YAAY,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACzC;AAED,+BAA+B;AAC/B,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC3C,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACvD;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQhF;AAoBD;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,OAAO,EACb,OAAO,GAAE;IACP,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAA;IAC/B;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,oBAAoB,CAAA;IAC7C,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAA;CAC5B,GACL,OAAO,CAAC,cAAc,CAAC,CAgJzB"}
@@ -0,0 +1,302 @@
1
+ /**
2
+ * MCP method dispatch (MCP-05, MCP-06, MCP-08, MCP-09, MCP-13).
3
+ *
4
+ * The server is STATELESS by construction, which is what P26-01 requires: a
5
+ * `tools/list` or `tools/call` must be processable as the first application
6
+ * request. There is no session table here to require one, so the requirement is
7
+ * satisfied by the shape of the code rather than by remembering to skip a check.
8
+ *
9
+ * Dispatch resolves ONE authorized definition and calls it through the host's
10
+ * execution path (MCP-08), rather than reaching into a registry by name — the
11
+ * difference matters because the host's path applies the grant, the receipt and
12
+ * the result policy, while a direct lookup would bypass all three.
13
+ *
14
+ * @module @try-works/dsh-tool-mode/mcp/server
15
+ */
16
+ import { assertHeadersMatch, cacheableResultFields, implementedCapabilities, SUPPORTED_PROTOCOL_VERSIONS, ERROR_CODES, errorResponse, negotiateVersion, parseRequestMetadata, successResult, toolErrorResult, unsupportedRequiredCapabilities, WireError, } from "./protocol.js";
17
+ /**
18
+ * Project a definition into the MCP tool shape.
19
+ *
20
+ * `outputSchema` is taken from the resolved definition rather than from DSH's
21
+ * model-facing `schemas()` projection, which intentionally omits `output`: a
22
+ * schema-only export built from that projection would be missing the very field
23
+ * MCP-09 requires.
24
+ * @param definition - the resolved definition.
25
+ * @returns the MCP tool descriptor.
26
+ */
27
+ export function toMcpTool(definition) {
28
+ return {
29
+ name: definition.name,
30
+ ...definition.title === undefined ? {} : { title: definition.title },
31
+ description: definition.description,
32
+ inputSchema: definition.inputSchema,
33
+ outputSchema: definition.outputSchema,
34
+ };
35
+ }
36
+ /**
37
+ * Attach the host's explicit catalog facts to a discovery result (P26-14).
38
+ * @param result - the method-specific result.
39
+ * @param host - the host that may expose facts.
40
+ * @returns the result with a namespaced `_meta` entry, or unchanged.
41
+ */
42
+ function withCatalogFacts(result, host) {
43
+ const facts = host.catalogFacts?.();
44
+ if (facts === undefined)
45
+ return result;
46
+ const existing = typeof result._meta === 'object' && result._meta !== null
47
+ ? result._meta
48
+ : {};
49
+ return { ...result, _meta: { ...existing, 'io.try-works/catalog': facts } };
50
+ }
51
+ /**
52
+ * Dispatch one request.
53
+ *
54
+ * Stateless: nothing is retained between calls, so a valid request works as the
55
+ * first one.
56
+ * @param request - the parsed request.
57
+ * @param host - the host surface.
58
+ * @param options - headers and the caller's abort signal.
59
+ * @returns the response and the HTTP status.
60
+ */
61
+ export async function dispatch(request, host, options = {}) {
62
+ const id = request.id ?? null;
63
+ try {
64
+ if (options.checkHeaders === true && options.headers !== undefined) {
65
+ assertHeadersMatch(options.headers, request);
66
+ }
67
+ const metadata = parseRequestMetadata(request.params);
68
+ negotiateVersion(metadata);
69
+ // Capabilities the CLIENT requires. A requirement this server cannot meet is
70
+ // -32021 rather than a silent partial service.
71
+ const wiring = { subscriptions: options.subscriptions !== undefined };
72
+ const required = requiredCapabilities(metadata.clientCapabilities);
73
+ const unsupported = unsupportedRequiredCapabilities(required, wiring);
74
+ if (unsupported.length > 0) {
75
+ throw new WireError(ERROR_CODES.unsupportedClientCapability, `the client requires unsupported capability: ${unsupported.join(', ')}`,
76
+ /**
77
+ * THE PINNED SCHEMA'S OWN FIELD NAME, and this was WRONG.
78
+ *
79
+ * `MissingRequiredClientCapabilityError` REQUIRES `data.requiredCapabilities`. This
80
+ * sent `{ unsupported: [...] }`, which Ajv rejects against the pinned definition:
81
+ *
82
+ * INVALID -> /error/data must have required property 'requiredCapabilities'
83
+ *
84
+ * It went unnoticed because the GENERIC `JSONRPCErrorResponse` accepts ANY `data`,
85
+ * every fixture took that path, and no fixture covered `-32021` at all — so the
86
+ * conformance suite validated a shape the specific error definition forbids.
87
+ * P26-03 requires `-32021` "and the schema-defined data"; this is that shape.
88
+ */
89
+ /**
90
+ * A `ClientCapabilities` OBJECT, not an array of names — and this was STILL wrong.
91
+ *
92
+ * The previous correction fixed the FIELD NAME (`unsupported` -> `requiredCapabilities`)
93
+ * and left the VALUE as an array of strings. The pinned definition is precise:
94
+ *
95
+ * requiredCapabilities -> $ref ClientCapabilities (type: object)
96
+ *
97
+ * so the shape is `{ sampling: {} }`, a capabilities object keyed by capability name.
98
+ * Both defects are the same kind — a plausible shape that no fixture covered — and this
99
+ * one survived the first fix because only a LIVE response validated against the pinned
100
+ * definition could distinguish an array from an object. The fixture probe never saw it,
101
+ * and no test asserted the value's TYPE.
102
+ */
103
+ { requiredCapabilities: Object.fromEntries(unsupported.map(name => [name, {}])) });
104
+ }
105
+ switch (request.method) {
106
+ case 'server/discover':
107
+ return {
108
+ response: {
109
+ jsonrpc: '2.0',
110
+ id,
111
+ result: successResult(withCatalogFacts(discoverResult(wiring, host.cachePolicy), host), host.serverInfo),
112
+ },
113
+ httpStatus: 200,
114
+ };
115
+ case 'tools/list':
116
+ return {
117
+ response: {
118
+ jsonrpc: '2.0',
119
+ id,
120
+ result: successResult(withCatalogFacts({
121
+ // Deterministic ordering (MCP-06): the caller sees a stable list, so
122
+ // a client diffing two listings does not see spurious changes.
123
+ //
124
+ // SEC-04: an AUTHENTICATED external caller sees only its GRANTED
125
+ // tools — the list is the client's authorized set, not the operator's
126
+ // whole surface. The grant stays the AUTHORITY: calling a
127
+ // non-granted tool still yields the grant refusal, this only
128
+ // narrows what a client is shown. The caller-less path (stdio /
129
+ // native) sees the full surface.
130
+ tools: [...host.listTools()]
131
+ .filter(tool => options.caller === undefined || options.caller.allowedTools.includes(tool.name))
132
+ .sort((left, right) => left.name.localeCompare(right.name))
133
+ .map(toMcpTool),
134
+ // Required by the schema's CacheableResult; omitting them makes the
135
+ // result non-conformant even though the tool list is correct. The
136
+ // policy comes from the host (private scope, operator TTL), P26-14.
137
+ ...cacheableResultFields(host.cachePolicy),
138
+ }, host), host.serverInfo),
139
+ },
140
+ httpStatus: 200,
141
+ };
142
+ case 'subscriptions/listen': {
143
+ // P26-09. The acknowledgement is returned WITH the result rather than after
144
+ // it, so the client cannot observe an event before being told what the server
145
+ // agreed to send.
146
+ //
147
+ // A host with no registry reports the method as unsupported rather than
148
+ // accepting a subscription it cannot serve: an acknowledged subscription that
149
+ // never fires is indistinguishable from a broken server.
150
+ if (options.subscriptions === undefined) {
151
+ throw new WireError(ERROR_CODES.methodNotFound, 'this server does not offer catalog subscriptions');
152
+ }
153
+ const subscription = options.subscriptions.listen(request, options.clientId ?? 'unknown');
154
+ return {
155
+ response: { jsonrpc: '2.0', id, result: successResult(subscription.result, host.serverInfo) },
156
+ httpStatus: 200,
157
+ followUp: [subscription.acknowledgement],
158
+ };
159
+ }
160
+ case 'tools/call':
161
+ return await callTool(request, id, host, options.signal ?? new AbortController().signal, options.caller);
162
+ default:
163
+ throw new WireError(ERROR_CODES.methodNotFound, `unknown method ${JSON.stringify(request.method)}`);
164
+ }
165
+ }
166
+ catch (error) {
167
+ const wire = error instanceof WireError
168
+ ? error
169
+ : new WireError(ERROR_CODES.internalError, error instanceof Error ? error.message : String(error));
170
+ // An infrastructure failure must never be turned into a successful domain
171
+ // payload (MCP-10), so it leaves as a JSON-RPC error.
172
+ return {
173
+ response: errorResponse(id, wire),
174
+ /**
175
+ * THE PINNED SCHEMA'S OWN `MUST`, read from the schema rather than inferred.
176
+ *
177
+ * Three error definitions state it in as many words — "For HTTP, the response status
178
+ * code MUST be `400 Bad Request`":
179
+ *
180
+ * HeaderMismatchError -> -32020
181
+ * MissingRequiredClientCapabilityError -> -32021
182
+ * UnsupportedProtocolVersionError -> -32022
183
+ *
184
+ * Only the FIRST and `invalidParams` were mapped to 400, so a client requiring an
185
+ * unsupported capability — or presenting an unsupported protocol version — received an
186
+ * error body under a 200 status. The suite stayed green either way, so the status was
187
+ * untested in BOTH directions.
188
+ *
189
+ * Kept as a named SET so the next transport-level rejection is a one-line addition
190
+ * rather than another condition somebody can forget.
191
+ */
192
+ httpStatus: TRANSPORT_LEVEL_REJECTIONS.has(wire.code) ? 400 : 200,
193
+ };
194
+ }
195
+ }
196
+ /**
197
+ * The JSON-RPC codes the pinned schema requires be answered with HTTP 400 as well.
198
+ *
199
+ * Every one of these definitions says, verbatim: "For HTTP, the response status code MUST
200
+ * be `400 Bad Request`." Kept as a named set so the rule lives in ONE place and the next
201
+ * transport-level rejection is an addition rather than another forgotten condition.
202
+ */
203
+ const TRANSPORT_LEVEL_REJECTIONS = new Set([
204
+ ERROR_CODES.headerMismatch, // -32020
205
+ ERROR_CODES.unsupportedClientCapability, // -32021
206
+ ERROR_CODES.unsupportedProtocolVersion, // -32022
207
+ ERROR_CODES.invalidParams, // -32602, a malformed request shape
208
+ ]);
209
+ /** Handle `tools/call`. */
210
+ async function callTool(request, id, host, signal, caller) {
211
+ const name = request.params?.name;
212
+ if (typeof name !== 'string' || name.length === 0) {
213
+ throw new WireError(ERROR_CODES.invalidParams, 'tools/call requires params.name');
214
+ }
215
+ const args = request.params?.arguments;
216
+ if (args !== undefined && (typeof args !== 'object' || args === null || Array.isArray(args))) {
217
+ throw new WireError(ERROR_CODES.invalidParams, 'tools/call arguments must be an object');
218
+ }
219
+ const definition = host.listTools().find(tool => tool.name === name);
220
+ if (definition === undefined) {
221
+ const withheldReason = host.withheldReason?.(name);
222
+ if (withheldReason !== undefined) {
223
+ // Known but withheld: this is an application outcome with a named reason,
224
+ // not an unknown method. The tool was never invoked, so no domain success
225
+ // is fabricated; the envelope is still a successful protocol exchange.
226
+ return {
227
+ response: {
228
+ jsonrpc: '2.0',
229
+ id,
230
+ result: successResult(toolErrorResult(`tool ${JSON.stringify(name)} is withheld: ${withheldReason}`), host.serverInfo),
231
+ },
232
+ httpStatus: 200,
233
+ };
234
+ }
235
+ // An unknown name is invalid params, not a tool error: nothing was invoked, so
236
+ // reporting a domain failure would be a fabrication.
237
+ throw new WireError(ERROR_CODES.invalidParams, `unknown tool ${JSON.stringify(name)}`);
238
+ }
239
+ // MCP-13: never re-export an imported MCP tool, or a server could delegate back
240
+ // into itself through a loop that no caller can see.
241
+ if (definition.importedFromMcp) {
242
+ throw new WireError(ERROR_CODES.invalidParams, `tool ${JSON.stringify(name)} was imported from MCP and is not re-exported`);
243
+ }
244
+ const outcome = await host.callTool(name, (args ?? {}), signal, caller);
245
+ const result = outcome.isError === true
246
+ // An application failure is a tool-error RESULT (P26-04), so the protocol
247
+ // exchange still succeeded.
248
+ ? toolErrorResult(outcome.text)
249
+ : {
250
+ content: [{ type: 'text', text: outcome.text }],
251
+ // The finalized, post-policy canonical value (MCP-10).
252
+ structuredContent: outcome.structured,
253
+ };
254
+ return {
255
+ response: { jsonrpc: '2.0', id, result: successResult(result, host.serverInfo) },
256
+ httpStatus: 200,
257
+ };
258
+ }
259
+ /** The `server/discover` result, in the shape the pinned schema requires. */
260
+ function discoverResult(wiring = {}, cachePolicy) {
261
+ return {
262
+ // `supportedVersions` is the field the schema defines; there is no
263
+ // `protocolVersion` on a DiscoverResult, which is the mistake pinning the schema
264
+ // caught. A client learns the versions the server speaks, not one it picked.
265
+ supportedVersions: [...SUPPORTED_PROTOCOL_VERSIONS],
266
+ capabilities: serverCapabilities(wiring),
267
+ // P26-14: discovery is cacheable too, and it is authorization-filtered by scope.
268
+ ...cacheableResultFields(cachePolicy),
269
+ };
270
+ }
271
+ /**
272
+ * The capabilities this server advertises.
273
+ *
274
+ * Derived from the feature matrix rather than restated, so the matrix a client
275
+ * reads and the capabilities it is offered cannot disagree. P26-12: a feature is
276
+ * advertised only when it is genuinely implemented.
277
+ * @returns the `ServerCapabilities` object.
278
+ */
279
+ function serverCapabilities(wiring = {}) {
280
+ const implemented = new Set(implementedCapabilities(wiring));
281
+ return {
282
+ ...implemented.has('tools') ? { tools: { listChanged: implemented.has('subscriptions/listen') } } : {},
283
+ ...implemented.has('prompts') ? { prompts: {} } : {},
284
+ ...implemented.has('resources/subscribe') ? { resources: {} } : {},
285
+ ...implemented.has('logging') ? { logging: {} } : {},
286
+ };
287
+ }
288
+ /**
289
+ * Read the capabilities a client declared as REQUIRED.
290
+ *
291
+ * A client may declare capabilities it merely supports; only the required ones can
292
+ * make a request unserviceable.
293
+ * @param capabilities - the parsed capability object.
294
+ * @returns the required capability names.
295
+ */
296
+ function requiredCapabilities(capabilities) {
297
+ const required = capabilities.required;
298
+ if (!Array.isArray(required))
299
+ return [];
300
+ return required.filter((name) => typeof name === 'string');
301
+ }
302
+ //# sourceMappingURL=server.js.map