@try-works/dsh-tool-mode 0.0.0-stage → 0.5.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (425) hide show
  1. package/README.md +299 -2
  2. package/bin/dsh-tool-mode-credentials.mjs +20 -0
  3. package/bin/dsh-tool-mode-mcp-stdio.mjs +80 -0
  4. package/bin/dsh-tool-mode.mjs +211 -0
  5. package/builtins.lock.json +26 -0
  6. package/catalog/desert-ant-models.json +693 -0
  7. package/catalog/playbooks.json +531 -0
  8. package/client/client.model-tools.js +1910 -0
  9. package/client/index.js +4039 -0
  10. package/cordis.patch.yml +39 -0
  11. package/lib/adapters/index.d.ts +61 -0
  12. package/lib/adapters/index.d.ts.map +1 -0
  13. package/lib/adapters/index.js +82 -0
  14. package/lib/adapters/types.d.ts +106 -0
  15. package/lib/adapters/types.d.ts.map +1 -0
  16. package/lib/adapters/types.js +85 -0
  17. package/lib/approval.d.ts +189 -0
  18. package/lib/approval.d.ts.map +1 -0
  19. package/lib/approval.js +510 -0
  20. package/lib/asset-acquisition.d.ts +149 -0
  21. package/lib/asset-acquisition.d.ts.map +1 -0
  22. package/lib/asset-acquisition.js +175 -0
  23. package/lib/authority.d.ts +185 -0
  24. package/lib/authority.d.ts.map +1 -0
  25. package/lib/authority.js +223 -0
  26. package/lib/bindings.d.ts +144 -0
  27. package/lib/bindings.d.ts.map +1 -0
  28. package/lib/bindings.js +314 -0
  29. package/lib/builtins.d.ts +27 -0
  30. package/lib/builtins.d.ts.map +1 -0
  31. package/lib/builtins.js +37 -0
  32. package/lib/capability.d.ts +58 -0
  33. package/lib/capability.d.ts.map +1 -0
  34. package/lib/capability.js +192 -0
  35. package/lib/capture-path.d.ts +97 -0
  36. package/lib/capture-path.d.ts.map +1 -0
  37. package/lib/capture-path.js +152 -0
  38. package/lib/catalog.d.ts +37 -0
  39. package/lib/catalog.d.ts.map +1 -0
  40. package/lib/catalog.js +274 -0
  41. package/lib/contract-payload.d.ts +39 -0
  42. package/lib/contract-payload.d.ts.map +1 -0
  43. package/lib/contract-payload.js +56 -0
  44. package/lib/custom-tools/compile.d.ts +25 -0
  45. package/lib/custom-tools/compile.d.ts.map +1 -0
  46. package/lib/custom-tools/compile.js +61 -0
  47. package/lib/custom-tools/composite-executor.d.ts +42 -0
  48. package/lib/custom-tools/composite-executor.d.ts.map +1 -0
  49. package/lib/custom-tools/composite-executor.js +113 -0
  50. package/lib/custom-tools/dispatch.d.ts +28 -0
  51. package/lib/custom-tools/dispatch.d.ts.map +1 -0
  52. package/lib/custom-tools/dispatch.js +34 -0
  53. package/lib/custom-tools/http-executor.d.ts +48 -0
  54. package/lib/custom-tools/http-executor.d.ts.map +1 -0
  55. package/lib/custom-tools/http-executor.js +241 -0
  56. package/lib/custom-tools/index.d.ts +12 -0
  57. package/lib/custom-tools/index.d.ts.map +1 -0
  58. package/lib/custom-tools/index.js +12 -0
  59. package/lib/custom-tools/mcp-surface.d.ts +14 -0
  60. package/lib/custom-tools/mcp-surface.d.ts.map +1 -0
  61. package/lib/custom-tools/mcp-surface.js +41 -0
  62. package/lib/custom-tools/prompt-executor.d.ts +39 -0
  63. package/lib/custom-tools/prompt-executor.d.ts.map +1 -0
  64. package/lib/custom-tools/prompt-executor.js +59 -0
  65. package/lib/custom-tools/registry.d.ts +69 -0
  66. package/lib/custom-tools/registry.d.ts.map +1 -0
  67. package/lib/custom-tools/registry.js +130 -0
  68. package/lib/custom-tools/schema.d.ts +26 -0
  69. package/lib/custom-tools/schema.d.ts.map +1 -0
  70. package/lib/custom-tools/schema.js +375 -0
  71. package/lib/custom-tools/service.d.ts +90 -0
  72. package/lib/custom-tools/service.d.ts.map +1 -0
  73. package/lib/custom-tools/service.js +203 -0
  74. package/lib/custom-tools/store.d.ts +61 -0
  75. package/lib/custom-tools/store.d.ts.map +1 -0
  76. package/lib/custom-tools/store.js +240 -0
  77. package/lib/custom-tools/types.d.ts +131 -0
  78. package/lib/custom-tools/types.d.ts.map +1 -0
  79. package/lib/custom-tools/types.js +11 -0
  80. package/lib/decision-combine.d.ts +113 -0
  81. package/lib/decision-combine.d.ts.map +1 -0
  82. package/lib/decision-combine.js +156 -0
  83. package/lib/decision-evaluate.d.ts +185 -0
  84. package/lib/decision-evaluate.d.ts.map +1 -0
  85. package/lib/decision-evaluate.js +227 -0
  86. package/lib/deployment-coordinator.d.ts +213 -0
  87. package/lib/deployment-coordinator.d.ts.map +1 -0
  88. package/lib/deployment-coordinator.js +274 -0
  89. package/lib/diagnostics.d.ts +169 -0
  90. package/lib/diagnostics.d.ts.map +1 -0
  91. package/lib/diagnostics.js +136 -0
  92. package/lib/discovery-contracts.d.ts +14 -0
  93. package/lib/discovery-contracts.d.ts.map +1 -0
  94. package/lib/discovery-contracts.js +90 -0
  95. package/lib/discovery-describe.d.ts +35 -0
  96. package/lib/discovery-describe.d.ts.map +1 -0
  97. package/lib/discovery-describe.js +99 -0
  98. package/lib/embedding-index.d.ts +55 -0
  99. package/lib/embedding-index.d.ts.map +1 -0
  100. package/lib/embedding-index.js +126 -0
  101. package/lib/extension-dependencies.d.ts +355 -0
  102. package/lib/extension-dependencies.d.ts.map +1 -0
  103. package/lib/extension-dependencies.js +987 -0
  104. package/lib/extension-dispatch.d.ts +150 -0
  105. package/lib/extension-dispatch.d.ts.map +1 -0
  106. package/lib/extension-dispatch.js +178 -0
  107. package/lib/extension-page-state.d.ts +69 -0
  108. package/lib/extension-page-state.d.ts.map +1 -0
  109. package/lib/extension-page-state.js +82 -0
  110. package/lib/extension-registrar.d.ts +116 -0
  111. package/lib/extension-registrar.d.ts.map +1 -0
  112. package/lib/extension-registrar.js +144 -0
  113. package/lib/extensions-api.d.ts +346 -0
  114. package/lib/extensions-api.d.ts.map +1 -0
  115. package/lib/extensions-api.js +17 -0
  116. package/lib/extensions-remote.d.ts +57 -0
  117. package/lib/extensions-remote.d.ts.map +1 -0
  118. package/lib/extensions-remote.js +69 -0
  119. package/lib/extensions-service.d.ts +568 -0
  120. package/lib/extensions-service.d.ts.map +1 -0
  121. package/lib/extensions-service.js +2507 -0
  122. package/lib/harness-budgets.d.ts +158 -0
  123. package/lib/harness-budgets.d.ts.map +1 -0
  124. package/lib/harness-budgets.js +152 -0
  125. package/lib/harness-llm.d.ts +138 -0
  126. package/lib/harness-llm.d.ts.map +1 -0
  127. package/lib/harness-llm.js +218 -0
  128. package/lib/harness-serving.d.ts +115 -0
  129. package/lib/harness-serving.d.ts.map +1 -0
  130. package/lib/harness-serving.js +176 -0
  131. package/lib/headless.d.ts +97 -0
  132. package/lib/headless.d.ts.map +1 -0
  133. package/lib/headless.js +407 -0
  134. package/lib/http-acquisition.d.ts +27 -0
  135. package/lib/http-acquisition.d.ts.map +1 -0
  136. package/lib/http-acquisition.js +140 -0
  137. package/lib/index.d.ts +546 -0
  138. package/lib/index.d.ts.map +1 -0
  139. package/lib/index.js +5197 -0
  140. package/lib/invocation-accounting.d.ts +169 -0
  141. package/lib/invocation-accounting.d.ts.map +1 -0
  142. package/lib/invocation-accounting.js +148 -0
  143. package/lib/jev.d.ts +218 -0
  144. package/lib/jev.d.ts.map +1 -0
  145. package/lib/jev.js +366 -0
  146. package/lib/legacy-migration.d.ts +95 -0
  147. package/lib/legacy-migration.d.ts.map +1 -0
  148. package/lib/legacy-migration.js +429 -0
  149. package/lib/license-basis.d.ts +29 -0
  150. package/lib/license-basis.d.ts.map +1 -0
  151. package/lib/license-basis.js +58 -0
  152. package/lib/managed-workers.d.ts +158 -0
  153. package/lib/managed-workers.d.ts.map +1 -0
  154. package/lib/managed-workers.js +269 -0
  155. package/lib/mcp/auth-selection.d.ts +35 -0
  156. package/lib/mcp/auth-selection.d.ts.map +1 -0
  157. package/lib/mcp/auth-selection.js +64 -0
  158. package/lib/mcp/client-grant.d.ts +89 -0
  159. package/lib/mcp/client-grant.d.ts.map +1 -0
  160. package/lib/mcp/client-grant.js +63 -0
  161. package/lib/mcp/credential-cli.d.ts +38 -0
  162. package/lib/mcp/credential-cli.d.ts.map +1 -0
  163. package/lib/mcp/credential-cli.js +148 -0
  164. package/lib/mcp/credential-store.d.ts +143 -0
  165. package/lib/mcp/credential-store.d.ts.map +1 -0
  166. package/lib/mcp/credential-store.js +461 -0
  167. package/lib/mcp/export-policy.d.ts +25 -0
  168. package/lib/mcp/export-policy.d.ts.map +1 -0
  169. package/lib/mcp/export-policy.js +31 -0
  170. package/lib/mcp/host-binding.d.ts +144 -0
  171. package/lib/mcp/host-binding.d.ts.map +1 -0
  172. package/lib/mcp/host-binding.js +280 -0
  173. package/lib/mcp/http.d.ts +180 -0
  174. package/lib/mcp/http.d.ts.map +1 -0
  175. package/lib/mcp/http.js +602 -0
  176. package/lib/mcp/oauth.d.ts +149 -0
  177. package/lib/mcp/oauth.d.ts.map +1 -0
  178. package/lib/mcp/oauth.js +396 -0
  179. package/lib/mcp/protocol.d.ts +329 -0
  180. package/lib/mcp/protocol.d.ts.map +1 -0
  181. package/lib/mcp/protocol.js +459 -0
  182. package/lib/mcp/rate-limit.d.ts +68 -0
  183. package/lib/mcp/rate-limit.d.ts.map +1 -0
  184. package/lib/mcp/rate-limit.js +114 -0
  185. package/lib/mcp/sdk-v2.d.ts +17 -0
  186. package/lib/mcp/sdk-v2.d.ts.map +1 -0
  187. package/lib/mcp/sdk-v2.js +204 -0
  188. package/lib/mcp/server.d.ts +149 -0
  189. package/lib/mcp/server.d.ts.map +1 -0
  190. package/lib/mcp/server.js +302 -0
  191. package/lib/mcp/stdio.d.ts +80 -0
  192. package/lib/mcp/stdio.d.ts.map +1 -0
  193. package/lib/mcp/stdio.js +184 -0
  194. package/lib/mcp/subscriptions.d.ts +177 -0
  195. package/lib/mcp/subscriptions.d.ts.map +1 -0
  196. package/lib/mcp/subscriptions.js +288 -0
  197. package/lib/mcp-status.d.ts +96 -0
  198. package/lib/mcp-status.d.ts.map +1 -0
  199. package/lib/mcp-status.js +70 -0
  200. package/lib/mcp-usage.d.ts +110 -0
  201. package/lib/mcp-usage.d.ts.map +1 -0
  202. package/lib/mcp-usage.js +189 -0
  203. package/lib/model-qualification.d.ts +192 -0
  204. package/lib/model-qualification.d.ts.map +1 -0
  205. package/lib/model-qualification.js +178 -0
  206. package/lib/planning.d.ts +256 -0
  207. package/lib/planning.d.ts.map +1 -0
  208. package/lib/planning.js +471 -0
  209. package/lib/playbook.d.ts +42 -0
  210. package/lib/playbook.d.ts.map +1 -0
  211. package/lib/playbook.js +65 -0
  212. package/lib/prepared-assets.d.ts +269 -0
  213. package/lib/prepared-assets.d.ts.map +1 -0
  214. package/lib/prepared-assets.js +471 -0
  215. package/lib/provider-bridge.d.ts +107 -0
  216. package/lib/provider-bridge.d.ts.map +1 -0
  217. package/lib/provider-bridge.js +423 -0
  218. package/lib/ptc-authority.d.ts +154 -0
  219. package/lib/ptc-authority.d.ts.map +1 -0
  220. package/lib/ptc-authority.js +242 -0
  221. package/lib/ptc-confinement.d.ts +60 -0
  222. package/lib/ptc-confinement.d.ts.map +1 -0
  223. package/lib/ptc-confinement.js +212 -0
  224. package/lib/ptc-runtime.d.ts +166 -0
  225. package/lib/ptc-runtime.d.ts.map +1 -0
  226. package/lib/ptc-runtime.js +231 -0
  227. package/lib/publication.d.ts +161 -0
  228. package/lib/publication.d.ts.map +1 -0
  229. package/lib/publication.js +181 -0
  230. package/lib/receipt-store.d.ts +57 -0
  231. package/lib/receipt-store.d.ts.map +1 -0
  232. package/lib/receipt-store.js +143 -0
  233. package/lib/receipt.d.ts +231 -0
  234. package/lib/receipt.d.ts.map +1 -0
  235. package/lib/receipt.js +165 -0
  236. package/lib/registrar.d.ts +75 -0
  237. package/lib/registrar.d.ts.map +1 -0
  238. package/lib/registrar.js +152 -0
  239. package/lib/resource-governance.d.ts +204 -0
  240. package/lib/resource-governance.d.ts.map +1 -0
  241. package/lib/resource-governance.js +213 -0
  242. package/lib/server-lifecycle.d.ts +175 -0
  243. package/lib/server-lifecycle.d.ts.map +1 -0
  244. package/lib/server-lifecycle.js +269 -0
  245. package/lib/skills.d.ts +31 -0
  246. package/lib/skills.d.ts.map +1 -0
  247. package/lib/skills.js +170 -0
  248. package/lib/speech-bridge.d.ts +74 -0
  249. package/lib/speech-bridge.d.ts.map +1 -0
  250. package/lib/speech-bridge.js +115 -0
  251. package/lib/state.d.ts +100 -0
  252. package/lib/state.d.ts.map +1 -0
  253. package/lib/state.js +160 -0
  254. package/lib/title-proposal.d.ts +194 -0
  255. package/lib/title-proposal.d.ts.map +1 -0
  256. package/lib/title-proposal.js +244 -0
  257. package/lib/tool-inventory.d.ts +90 -0
  258. package/lib/tool-inventory.d.ts.map +1 -0
  259. package/lib/tool-inventory.js +102 -0
  260. package/lib/tool-mode-run.d.ts +310 -0
  261. package/lib/tool-mode-run.d.ts.map +1 -0
  262. package/lib/tool-mode-run.js +411 -0
  263. package/lib/tool-sources.d.ts +80 -0
  264. package/lib/tool-sources.d.ts.map +1 -0
  265. package/lib/tool-sources.js +123 -0
  266. package/lib/tool-usage-projection.d.ts +390 -0
  267. package/lib/tool-usage-projection.d.ts.map +1 -0
  268. package/lib/tool-usage-projection.js +1038 -0
  269. package/lib/tool-usage-report.d.ts +153 -0
  270. package/lib/tool-usage-report.d.ts.map +1 -0
  271. package/lib/tool-usage-report.js +274 -0
  272. package/lib/transport.d.ts +158 -0
  273. package/lib/transport.d.ts.map +1 -0
  274. package/lib/transport.js +332 -0
  275. package/lib/types.d.ts +134 -0
  276. package/lib/types.d.ts.map +1 -0
  277. package/lib/types.js +8 -0
  278. package/lib/update-surface.d.ts +79 -0
  279. package/lib/update-surface.d.ts.map +1 -0
  280. package/lib/update-surface.js +224 -0
  281. package/lib/version.d.ts +3 -0
  282. package/lib/version.d.ts.map +1 -0
  283. package/lib/version.js +27 -0
  284. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts +13 -0
  285. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts.map +1 -0
  286. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.js +85 -0
  287. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts +16 -0
  288. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts.map +1 -0
  289. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.js +87 -0
  290. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts +38 -0
  291. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts.map +1 -0
  292. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.js +445 -0
  293. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts +20 -0
  294. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts.map +1 -0
  295. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.js +112 -0
  296. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts +14 -0
  297. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts.map +1 -0
  298. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.js +63 -0
  299. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts +14 -0
  300. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts.map +1 -0
  301. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.js +76 -0
  302. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts +82 -0
  303. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts.map +1 -0
  304. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.js +274 -0
  305. package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts +26 -0
  306. package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts.map +1 -0
  307. package/node_modules/@try-works/tool-mode-contracts/lib/index.js +53 -0
  308. package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts +133 -0
  309. package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts.map +1 -0
  310. package/node_modules/@try-works/tool-mode-contracts/lib/meta.js +64 -0
  311. package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts +121 -0
  312. package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts.map +1 -0
  313. package/node_modules/@try-works/tool-mode-contracts/lib/registry.js +246 -0
  314. package/node_modules/@try-works/tool-mode-contracts/package.json +35 -0
  315. package/node_modules/@try-works/tool-mode-extension-sdk/bin/dsh-tool-mode.mjs +20 -0
  316. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts +80 -0
  317. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts.map +1 -0
  318. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.js +533 -0
  319. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts +86 -0
  320. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts.map +1 -0
  321. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.js +145 -0
  322. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts +70 -0
  323. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts.map +1 -0
  324. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.js +201 -0
  325. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts +57 -0
  326. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts.map +1 -0
  327. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.js +83 -0
  328. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts +33 -0
  329. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts.map +1 -0
  330. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.js +33 -0
  331. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts +86 -0
  332. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts.map +1 -0
  333. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.js +191 -0
  334. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts +137 -0
  335. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts.map +1 -0
  336. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.js +349 -0
  337. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts +274 -0
  338. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts.map +1 -0
  339. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.js +932 -0
  340. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts +210 -0
  341. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts.map +1 -0
  342. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.js +368 -0
  343. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts +63 -0
  344. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts.map +1 -0
  345. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.js +149 -0
  346. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts +35 -0
  347. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts.map +1 -0
  348. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.js +179 -0
  349. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts +179 -0
  350. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts.map +1 -0
  351. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.js +299 -0
  352. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts +395 -0
  353. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts.map +1 -0
  354. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.js +839 -0
  355. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts +44 -0
  356. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts.map +1 -0
  357. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.js +255 -0
  358. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts +185 -0
  359. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts.map +1 -0
  360. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.js +504 -0
  361. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts +17 -0
  362. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts.map +1 -0
  363. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.js +80 -0
  364. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts +221 -0
  365. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts.map +1 -0
  366. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.js +188 -0
  367. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts +52 -0
  368. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts.map +1 -0
  369. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.js +102 -0
  370. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts +171 -0
  371. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts.map +1 -0
  372. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.js +271 -0
  373. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts +242 -0
  374. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts.map +1 -0
  375. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.js +58 -0
  376. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts +128 -0
  377. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts.map +1 -0
  378. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.js +113 -0
  379. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts +41 -0
  380. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts.map +1 -0
  381. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.js +52 -0
  382. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts +2 -0
  383. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts.map +1 -0
  384. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.js +351 -0
  385. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts +157 -0
  386. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts.map +1 -0
  387. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.js +688 -0
  388. package/node_modules/@try-works/tool-mode-extension-sdk/package.json +54 -0
  389. package/node_modules/@try-works/tool-mode-extension-sdk/schema/extension-manifest-1.1.0.schema.json +253 -0
  390. package/node_modules/@try-works/tool-mode-recipes/bin/tool-mode-recipe.mjs +15 -0
  391. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts +460 -0
  392. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts.map +1 -0
  393. package/node_modules/@try-works/tool-mode-recipes/lib/broker.js +647 -0
  394. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts +61 -0
  395. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts.map +1 -0
  396. package/node_modules/@try-works/tool-mode-recipes/lib/cli.js +1106 -0
  397. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts +237 -0
  398. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts.map +1 -0
  399. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.js +205 -0
  400. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts +85 -0
  401. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts.map +1 -0
  402. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.js +176 -0
  403. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts +119 -0
  404. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts.map +1 -0
  405. package/node_modules/@try-works/tool-mode-recipes/lib/images.js +201 -0
  406. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts +25 -0
  407. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts.map +1 -0
  408. package/node_modules/@try-works/tool-mode-recipes/lib/index.js +25 -0
  409. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts +345 -0
  410. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts.map +1 -0
  411. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.js +1465 -0
  412. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts +51 -0
  413. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts.map +1 -0
  414. package/node_modules/@try-works/tool-mode-recipes/lib/templates.js +310 -0
  415. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts +231 -0
  416. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts.map +1 -0
  417. package/node_modules/@try-works/tool-mode-recipes/lib/titles.js +435 -0
  418. package/node_modules/@try-works/tool-mode-recipes/package.json +56 -0
  419. package/node_modules/@try-works/tool-mode-recipes/recipes/describe-image.json +38 -0
  420. package/node_modules/@try-works/tool-mode-recipes/recipes/text-title.json +45 -0
  421. package/node_modules/@try-works/tool-mode-recipes/schema/harness-model-recipe.schema.json +273 -0
  422. package/package.json +127 -4
  423. package/remote/spec.mjs +993 -0
  424. package/remote/typert.host.mjs +14 -0
  425. package/remote/typert.remote-client.mjs +16 -0
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Resource governance (RES-01, RES-04, RES-06, RES-09).
3
+ *
4
+ * Three distinctions here are easy to collapse and expensive to get wrong.
5
+ *
6
+ * **Readiness is not residency** (RES-04). The state vocabulary has eight members,
7
+ * and they answer two DIFFERENT questions: `unavailable` and `needs-preparation` say
8
+ * a call is not possible at all, while `prepared-cold`, `loading`, `ready` and `busy`
9
+ * say it is possible and merely describe how the call will be admitted. Treating
10
+ * `prepared-cold` as uncallable withdraws a tool that works, and — worse — makes the
11
+ * tool surface change on every warm/cold transition, which RES-04 explicitly forbids
12
+ * because an agent's view of its tools must not flicker with a cache.
13
+ *
14
+ * **A budget is a rejection, not a truncation** (RES-01, RES-09). Over-budget input
15
+ * is refused WITH THE ACTUAL LIMITS, because a caller that cannot see the limit
16
+ * cannot choose a smaller input. Silently trimming source data is the failure both
17
+ * requirements name.
18
+ *
19
+ * **Cancellation is a claim about behaviour** (RES-06). Where a backend cannot be
20
+ * interrupted, saying "cancelled" while its work continues is worse than admitting
21
+ * the work is still running, so the outcome says which of the two happened.
22
+ *
23
+ * @module @try-works/dsh-tool-mode/resource-governance
24
+ */
25
+ /** The states in which a call is possible at all (RES-04). */
26
+ const CALLABLE = new Set([
27
+ // A cold but PREPARED deployment is callable: preparation, not residency, is what
28
+ // makes a call possible.
29
+ 'prepared-cold',
30
+ 'loading',
31
+ 'ready',
32
+ 'busy',
33
+ ]);
34
+ /** The states that imply assets are on disk (RES-04). */
35
+ const PREPARED = new Set([
36
+ 'prepared-cold',
37
+ 'loading',
38
+ 'ready',
39
+ 'busy',
40
+ ]);
41
+ /**
42
+ * Whether a call is possible in this state (RES-04).
43
+ *
44
+ * Determined by compatibility, authorization and PREPARATION — never by residency.
45
+ * @param state - the current state.
46
+ * @returns whether the tool can be called.
47
+ */
48
+ export function isCallable(state) {
49
+ return CALLABLE.has(state);
50
+ }
51
+ /**
52
+ * Whether assets are prepared (RES-04).
53
+ * @param state - the current state.
54
+ * @returns whether preparation has completed.
55
+ */
56
+ export function isPrepared(state) {
57
+ return PREPARED.has(state);
58
+ }
59
+ /**
60
+ * How residency affects admission (RES-04).
61
+ *
62
+ * This is the half that residency legitimately controls: not WHETHER a tool exists,
63
+ * but what a call to it costs.
64
+ * @param state - the current state.
65
+ * @returns the admission behaviour, or undefined when no call is possible.
66
+ */
67
+ export function admissionOf(state) {
68
+ switch (state) {
69
+ case 'ready': return 'immediate';
70
+ case 'prepared-cold': return 'loads-first';
71
+ // `loading` and `busy` both mean work is in progress, so a new call waits for it
72
+ // rather than starting a second load of the same deployment.
73
+ case 'loading':
74
+ case 'busy': return 'queued';
75
+ default: return undefined;
76
+ }
77
+ }
78
+ /**
79
+ * Whether a tool DESCRIPTION may vary with this state (RES-04).
80
+ *
81
+ * Always false. RES-04 forbids changing agent tool descriptions on every warm/cold
82
+ * transition, so this exists to be asserted rather than to be consulted: a caller
83
+ * that branches on residency when building a description has found a bug.
84
+ * @returns always false.
85
+ */
86
+ export function descriptionMayVaryWithResidency() {
87
+ return false;
88
+ }
89
+ /**
90
+ * The product defaults the requirement names verbatim (RES-09).
91
+ *
92
+ * These are PRODUCT limits, not guarantees that every input within them fits: the
93
+ * requirement says model context limits may force lower admission, so a successful
94
+ * check here is necessary and not sufficient.
95
+ */
96
+ export const DEFAULT_BUDGETS = {
97
+ image: {
98
+ sourceBytes: 8 * 1024 * 1024,
99
+ decodedPixels: 16_000_000,
100
+ },
101
+ video: {
102
+ sourceBytes: 128 * 1024 * 1024,
103
+ videoSeconds: 120,
104
+ videoFrames: 32,
105
+ },
106
+ audio: {
107
+ // 16 kHz mono for an hour, matching the transcription contract's admission.
108
+ audioSamples: 16_000 * 3600,
109
+ },
110
+ text: {
111
+ sourceBytes: 1024 * 1024,
112
+ processorTokens: 8192,
113
+ },
114
+ };
115
+ /**
116
+ * Decide whether an input fits its budget (RES-01, RES-09).
117
+ *
118
+ * Over-budget input is REJECTED with the actual limits. It is never truncated and
119
+ * never sampled down, because the caller cannot otherwise tell that what it supplied
120
+ * is not what was processed.
121
+ * @param measurement - what the input actually is.
122
+ * @param budget - the limits in force.
123
+ * @returns the decision, naming every exceeded budget.
124
+ */
125
+ export function admit(measurement, budget) {
126
+ const exceeded = [];
127
+ for (const [kind, limit] of Object.entries(budget)) {
128
+ if (limit === null || limit === undefined)
129
+ continue;
130
+ const measured = measurement[kind];
131
+ // An unmeasured budget cannot be enforced, and pretending it passed would be a
132
+ // silent acceptance. It is reported as exceeded by zero only if actually over, so
133
+ // an absent measurement is treated as "not applicable" rather than as "fits".
134
+ if (measured === undefined)
135
+ continue;
136
+ if (measured > limit)
137
+ exceeded.push({ kind, measured, limit });
138
+ }
139
+ return exceeded.length === 0 ? { admitted: true } : { admitted: false, exceeded };
140
+ }
141
+ /**
142
+ * Render a rejection the caller can act on (RES-01).
143
+ *
144
+ * The requirement says to reject with ACTUAL LIMITS: a caller told only "too large"
145
+ * cannot choose a smaller input.
146
+ * @param decision - a rejection.
147
+ * @returns the message.
148
+ */
149
+ export function describeRejection(decision) {
150
+ return decision.exceeded
151
+ .map(entry => `${entry.kind} is ${entry.measured}, over the limit of ${entry.limit}`)
152
+ .join('; ');
153
+ }
154
+ /**
155
+ * Build the coverage report for an input that had to be sampled (RES-09).
156
+ *
157
+ * Sampling is only legitimate when it is EXPLICIT and its coverage is REPORTED. An
158
+ * implementation that quietly processed 32 of 900 frames and reported success has
159
+ * told the caller something false about the input it supplied.
160
+ * @param processed - units processed.
161
+ * @param total - units in the source.
162
+ * @param sampling - the instruction applied, when one was.
163
+ * @returns the coverage report.
164
+ */
165
+ export function coverageOf(processed, total, sampling) {
166
+ const complete = processed >= total;
167
+ return {
168
+ complete,
169
+ processed,
170
+ total,
171
+ sampling,
172
+ reason: complete
173
+ ? null
174
+ : sampling === null
175
+ // Incomplete WITHOUT a sampling instruction is a defect, not a policy: the
176
+ // requirement forbids silent sampling, so this case is named rather than
177
+ // dressed up as intentional.
178
+ ? 'the source was not fully processed and no sampling instruction was recorded'
179
+ : `sampled by instruction: ${sampling.instruction}`,
180
+ };
181
+ }
182
+ /**
183
+ * Describe a cancellation honestly (RES-06).
184
+ *
185
+ * RES-06 forbids claiming cancellation while uncontrolled work continues
186
+ * indefinitely. Where a backend cannot be interrupted safely, the honest report is
187
+ * that it is still running and its result will be discarded — which is also why the
188
+ * requirement prefers isolating such a backend in an owned worker.
189
+ * @param interruptible - whether the backend can be interrupted safely.
190
+ * @param subject - what is being cancelled, for the message.
191
+ * @returns the outcome to report.
192
+ */
193
+ export function cancellationOutcome(interruptible, subject) {
194
+ return interruptible
195
+ ? { stopped: true }
196
+ : {
197
+ stopped: false,
198
+ reason: `${subject} cannot be interrupted safely; it will run to completion and its result discarded`,
199
+ };
200
+ }
201
+ /**
202
+ * Whether a decompression bomb must be rejected before allocation (RES-09).
203
+ *
204
+ * The check is on the DECLARED expanded size, before any allocation: a check that
205
+ * runs after decompression has already lost.
206
+ * @param declaredBytes - the expansion the container declares.
207
+ * @param limit - the budget for this input class.
208
+ * @returns whether to reject.
209
+ */
210
+ export function isExpansionBomb(declaredBytes, limit) {
211
+ return declaredBytes > limit;
212
+ }
213
+ //# sourceMappingURL=resource-governance.js.map
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Server and plugin lifecycle (RUN-01, RUN-02, RUN-05, RUN-06, RUN-07).
3
+ *
4
+ * Almost every rule here is about what must NOT happen:
5
+ *
6
+ * - **Do not announce readiness before it is true** (RUN-06). A listener that reports
7
+ * ready before its bind or its initialisation succeeded sends a client to a port
8
+ * that is not answering. Readiness is therefore a STATE derived from both, not a flag
9
+ * set by whoever got there first.
10
+ * - **Do not resolve a port conflict by force or by stealth** (RUN-06). Taking the port
11
+ * from another process, or silently moving to a different one, both break a client
12
+ * that was told where to connect. The conflict is reported.
13
+ * - **Do not let a failed start take the host with it** (RUN-06). The MCP endpoint is
14
+ * one feature of a much larger host; a port clash must leave the rest running.
15
+ * - **Do not kill work you do not own** (RUN-07). A model process serving another
16
+ * still-authorized owner is not this lifecycle's to terminate.
17
+ * - **Do not prepare anything at startup** (RUN-05). Nothing downloads because a plugin
18
+ * loaded or a client listed tools.
19
+ *
20
+ * @module @try-works/dsh-tool-mode/server-lifecycle
21
+ */
22
+ /** Where the server is in its lifecycle. */
23
+ export type ServerState = 'stopped' | 'starting' | 'ready' | 'stopping' | 'failed';
24
+ /** Why a start failed. */
25
+ export interface StartFailure {
26
+ /** A stable code, so a caller can branch without matching a message. */
27
+ readonly code: 'PORT_IN_USE' | 'BIND_FAILED' | 'INIT_FAILED' | 'ALREADY_STARTED';
28
+ readonly message: string;
29
+ /** What to do about it, because a bare failure leaves an operator stuck. */
30
+ readonly remedy: string;
31
+ }
32
+ /** One piece of work the server owns (RUN-07). */
33
+ export interface OwnedWork {
34
+ /** An identity for diagnostics. */
35
+ readonly id: string;
36
+ /**
37
+ * The owner this work serves.
38
+ *
39
+ * Shutdown cancels work THIS lifecycle owns, and the owner is recorded so a model
40
+ * process serving another still-authorized owner is never terminated by mistake.
41
+ */
42
+ readonly owner: string;
43
+ /** Ask the work to stop. */
44
+ cancel(): Promise<void> | void;
45
+ /** Force it to stop after the grace period. */
46
+ terminate?(): void;
47
+ }
48
+ /** What the lifecycle needs from its environment. */
49
+ export interface LifecycleHost {
50
+ /**
51
+ * Bind the listener.
52
+ *
53
+ * Implementations throw with a `code` of `EADDRINUSE` for a port conflict; the
54
+ * lifecycle reports it rather than trying to resolve it.
55
+ */
56
+ bind(): Promise<{
57
+ readonly port: number;
58
+ readonly close: () => Promise<void>;
59
+ }>;
60
+ /** Initialise whatever must be ready before the endpoint serves. */
61
+ initialise(): Promise<void>;
62
+ /** Called once, and only once, when both bind and initialise have succeeded. */
63
+ onReady(port: number): void;
64
+ /** Log a non-fatal diagnostic. */
65
+ log(message: string): void;
66
+ }
67
+ /** The documented grace period for cleanup (RUN-07). */
68
+ export declare const DEFAULT_GRACE_MS = 5000;
69
+ /** How a shutdown ended. */
70
+ export interface ShutdownReport {
71
+ /** Work that stopped within the grace period. */
72
+ readonly cancelled: readonly string[];
73
+ /** Work that had to be terminated after it. */
74
+ readonly terminated: readonly string[];
75
+ /** Work that was NOT touched because this lifecycle does not own it. */
76
+ readonly untouched: readonly string[];
77
+ /** Whether the port was released. */
78
+ readonly portReleased: boolean;
79
+ /** Whether cleanup finished inside the grace period. */
80
+ readonly withinGrace: boolean;
81
+ }
82
+ /**
83
+ * Manages one MCP listener's lifecycle.
84
+ *
85
+ * Deliberately separate from the DSH plugin's own lifecycle: RUN-01 requires disabling
86
+ * the SERVER to stop its listener and owned work without disabling unrelated DSH tools,
87
+ * so the two must be independently stoppable.
88
+ */
89
+ export declare class ServerLifecycle {
90
+ #private;
91
+ constructor(host: LifecycleHost, options?: {
92
+ readonly graceMs?: number;
93
+ });
94
+ /** The current state. */
95
+ get state(): ServerState;
96
+ /** The bound port, once one exists. */
97
+ get port(): number | null;
98
+ /**
99
+ * Whether the endpoint is serving (RUN-06).
100
+ *
101
+ * True only after BOTH bind and initialise succeeded. A caller asking "can I connect"
102
+ * gets one answer, and it is not derived from a flag somebody set early.
103
+ */
104
+ get ready(): boolean;
105
+ /** Work currently owned, for diagnostics. */
106
+ get owned(): readonly OwnedWork[];
107
+ /**
108
+ * Start the listener.
109
+ *
110
+ * @returns nothing on success, or the failure — never a thrown exception, because
111
+ * RUN-06 requires a failed start not to crash the unrelated host.
112
+ */
113
+ start(): Promise<{
114
+ readonly ok: true;
115
+ readonly port: number;
116
+ } | {
117
+ readonly ok: false;
118
+ readonly failure: StartFailure;
119
+ }>;
120
+ /**
121
+ * Register work this lifecycle owns (RUN-07).
122
+ *
123
+ * Refused once shutdown has begun, so a call racing a stop cannot slip into the
124
+ * cleanup window and be left running.
125
+ * @param work - the work to own.
126
+ * @returns whether it was accepted.
127
+ */
128
+ adopt(work: OwnedWork): boolean;
129
+ /** Release work that finished on its own. */
130
+ release(id: string): void;
131
+ /**
132
+ * Stop the listener and everything it owns (RUN-07).
133
+ *
134
+ * The order is the requirement's: refuse new work, cancel owned foreground
135
+ * invocations, wait within the grace period, terminate what remains, close the
136
+ * transport and release the port. Work belonging to another owner is LEFT ALONE.
137
+ * @param options - `ownedBy` selects the owner whose work may be stopped.
138
+ * @returns the report.
139
+ */
140
+ stop(options?: {
141
+ readonly ownedBy?: string;
142
+ }): Promise<ShutdownReport>;
143
+ }
144
+ /** What startup may and may not do (RUN-05). */
145
+ export interface StartupPolicy {
146
+ /**
147
+ * Whether model preparation may run at startup.
148
+ *
149
+ * Always false. The type carries it so the prohibition is visible at the call site
150
+ * rather than only in the requirement.
151
+ */
152
+ readonly preparesModels: false;
153
+ /** Whether package resolution may run at startup. Always false. */
154
+ readonly resolvesPackages: false;
155
+ /** Whether discovery is read-only. Always true. */
156
+ readonly discoveryIsReadOnly: true;
157
+ }
158
+ /** The only startup policy this implementation permits (RUN-05). */
159
+ export declare const READ_ONLY_STARTUP: StartupPolicy;
160
+ /**
161
+ * Whether a startup action is permitted (RUN-05).
162
+ *
163
+ * @param action - what the startup wants to do.
164
+ * @returns whether it may.
165
+ */
166
+ export declare function startupPermits(action: 'restore-active' | 'inspect-assets' | 'read-manifests' | 'prepare-model' | 'resolve-package' | 'download-weights'): boolean;
167
+ /**
168
+ * Whether disabling the MCP server must also disable unrelated DSH tools (RUN-01).
169
+ *
170
+ * It must not. The server and the plugin are independently stoppable, which is why the
171
+ * lifecycle is a separate object from the plugin's own registration state.
172
+ * @returns always false.
173
+ */
174
+ export declare function disablingServerDisablesOtherTools(): boolean;
175
+ //# sourceMappingURL=server-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-lifecycle.d.ts","sourceRoot":"","sources":["../src/server-lifecycle.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,269 @@
1
+ /**
2
+ * Server and plugin lifecycle (RUN-01, RUN-02, RUN-05, RUN-06, RUN-07).
3
+ *
4
+ * Almost every rule here is about what must NOT happen:
5
+ *
6
+ * - **Do not announce readiness before it is true** (RUN-06). A listener that reports
7
+ * ready before its bind or its initialisation succeeded sends a client to a port
8
+ * that is not answering. Readiness is therefore a STATE derived from both, not a flag
9
+ * set by whoever got there first.
10
+ * - **Do not resolve a port conflict by force or by stealth** (RUN-06). Taking the port
11
+ * from another process, or silently moving to a different one, both break a client
12
+ * that was told where to connect. The conflict is reported.
13
+ * - **Do not let a failed start take the host with it** (RUN-06). The MCP endpoint is
14
+ * one feature of a much larger host; a port clash must leave the rest running.
15
+ * - **Do not kill work you do not own** (RUN-07). A model process serving another
16
+ * still-authorized owner is not this lifecycle's to terminate.
17
+ * - **Do not prepare anything at startup** (RUN-05). Nothing downloads because a plugin
18
+ * loaded or a client listed tools.
19
+ *
20
+ * @module @try-works/dsh-tool-mode/server-lifecycle
21
+ */
22
+ /** The documented grace period for cleanup (RUN-07). */
23
+ export const DEFAULT_GRACE_MS = 5000;
24
+ /**
25
+ * Manages one MCP listener's lifecycle.
26
+ *
27
+ * Deliberately separate from the DSH plugin's own lifecycle: RUN-01 requires disabling
28
+ * the SERVER to stop its listener and owned work without disabling unrelated DSH tools,
29
+ * so the two must be independently stoppable.
30
+ */
31
+ export class ServerLifecycle {
32
+ #state = 'stopped';
33
+ #port = null;
34
+ #closeListener = null;
35
+ #work = new Map();
36
+ #host;
37
+ #graceMs;
38
+ /** Set once shutdown begins, so new work is refused from that moment. */
39
+ #acceptingWork = true;
40
+ constructor(host, options = {}) {
41
+ this.#host = host;
42
+ this.#graceMs = options.graceMs ?? DEFAULT_GRACE_MS;
43
+ }
44
+ /** The current state. */
45
+ get state() {
46
+ return this.#state;
47
+ }
48
+ /** The bound port, once one exists. */
49
+ get port() {
50
+ return this.#port;
51
+ }
52
+ /**
53
+ * Whether the endpoint is serving (RUN-06).
54
+ *
55
+ * True only after BOTH bind and initialise succeeded. A caller asking "can I connect"
56
+ * gets one answer, and it is not derived from a flag somebody set early.
57
+ */
58
+ get ready() {
59
+ return this.#state === 'ready';
60
+ }
61
+ /** Work currently owned, for diagnostics. */
62
+ get owned() {
63
+ return [...this.#work.values()];
64
+ }
65
+ /**
66
+ * Start the listener.
67
+ *
68
+ * @returns nothing on success, or the failure — never a thrown exception, because
69
+ * RUN-06 requires a failed start not to crash the unrelated host.
70
+ */
71
+ async start() {
72
+ if (this.#state === 'ready' || this.#state === 'starting') {
73
+ return {
74
+ ok: false,
75
+ failure: {
76
+ code: 'ALREADY_STARTED',
77
+ message: `the server is already ${this.#state}`,
78
+ remedy: 'Call stop() before starting again.',
79
+ },
80
+ };
81
+ }
82
+ this.#state = 'starting';
83
+ try {
84
+ const listener = await this.#host.bind();
85
+ this.#port = listener.port;
86
+ this.#closeListener = listener.close;
87
+ }
88
+ catch (error) {
89
+ const code = error.code;
90
+ this.#state = 'failed';
91
+ if (code === 'EADDRINUSE') {
92
+ // Reported, NOT resolved. Taking the port from another process or silently
93
+ // moving to a different one both break a client told where to connect.
94
+ return {
95
+ ok: false,
96
+ failure: {
97
+ code: 'PORT_IN_USE',
98
+ message: `port ${String(error.message)} is already in use`,
99
+ remedy: 'Choose a different port in the configuration, or stop the process holding it. This server will not take it by force or move silently.',
100
+ },
101
+ };
102
+ }
103
+ return {
104
+ ok: false,
105
+ failure: {
106
+ code: 'BIND_FAILED',
107
+ message: error instanceof Error ? error.message : String(error),
108
+ remedy: 'Check that the bind address is a loopback address and that the port is permitted.',
109
+ },
110
+ };
111
+ }
112
+ try {
113
+ await this.#host.initialise();
114
+ }
115
+ catch (error) {
116
+ this.#state = 'failed';
117
+ // The listener bound but cannot serve, so it is CLOSED rather than left open:
118
+ // an open port that answers nothing is worse than no port.
119
+ await this.#closeListener?.().catch(() => undefined);
120
+ this.#closeListener = null;
121
+ this.#port = null;
122
+ return {
123
+ ok: false,
124
+ failure: {
125
+ code: 'INIT_FAILED',
126
+ message: error instanceof Error ? error.message : String(error),
127
+ remedy: 'Check the server diagnostics; the host itself is unaffected.',
128
+ },
129
+ };
130
+ }
131
+ // Only now. Readiness after BOTH succeed, and never before.
132
+ this.#state = 'ready';
133
+ this.#host.onReady(this.#port);
134
+ return { ok: true, port: this.#port };
135
+ }
136
+ /**
137
+ * Register work this lifecycle owns (RUN-07).
138
+ *
139
+ * Refused once shutdown has begun, so a call racing a stop cannot slip into the
140
+ * cleanup window and be left running.
141
+ * @param work - the work to own.
142
+ * @returns whether it was accepted.
143
+ */
144
+ adopt(work) {
145
+ if (!this.#acceptingWork)
146
+ return false;
147
+ this.#work.set(work.id, work);
148
+ return true;
149
+ }
150
+ /** Release work that finished on its own. */
151
+ release(id) {
152
+ this.#work.delete(id);
153
+ }
154
+ /**
155
+ * Stop the listener and everything it owns (RUN-07).
156
+ *
157
+ * The order is the requirement's: refuse new work, cancel owned foreground
158
+ * invocations, wait within the grace period, terminate what remains, close the
159
+ * transport and release the port. Work belonging to another owner is LEFT ALONE.
160
+ * @param options - `ownedBy` selects the owner whose work may be stopped.
161
+ * @returns the report.
162
+ */
163
+ async stop(options = {}) {
164
+ // 1. Refuse new work FIRST, so nothing is adopted during cleanup.
165
+ this.#acceptingWork = false;
166
+ if (this.#state === 'stopped') {
167
+ return { cancelled: [], terminated: [], untouched: [], portReleased: true, withinGrace: true };
168
+ }
169
+ this.#state = 'stopping';
170
+ const mine = [];
171
+ const untouched = [];
172
+ for (const work of this.#work.values()) {
173
+ // RUN-07: never kill a model process serving another still-authorized owner.
174
+ if (options.ownedBy !== undefined && work.owner !== options.ownedBy) {
175
+ untouched.push(work.id);
176
+ continue;
177
+ }
178
+ mine.push(work);
179
+ }
180
+ // 2. Cancel owned foreground invocations, and wait for them WITHIN the grace
181
+ // period. Racing each cancel against one shared deadline is what makes the grace
182
+ // period mean something: a cancel that never resolves must not hold shutdown open
183
+ // forever, and it must not be reported as stopped either.
184
+ const deadline = Date.now() + this.#graceMs;
185
+ const cancelled = [];
186
+ const terminated = [];
187
+ const outcomes = await Promise.all(mine.map(async (work) => {
188
+ const remaining = Math.max(0, deadline - Date.now());
189
+ const settled = await Promise.race([
190
+ Promise.resolve(work.cancel()).then(() => true).catch(() => false),
191
+ new Promise(resolve => setTimeout(() => resolve(false), remaining)),
192
+ ]);
193
+ return { work, settled };
194
+ }));
195
+ for (const { work, settled } of outcomes) {
196
+ if (settled)
197
+ cancelled.push(work.id);
198
+ }
199
+ const withinGrace = outcomes.every(outcome => outcome.settled);
200
+ // 3. Terminate whatever outlived the grace period.
201
+ for (const { work, settled } of outcomes) {
202
+ if (settled)
203
+ continue;
204
+ try {
205
+ work.terminate?.();
206
+ terminated.push(work.id);
207
+ }
208
+ catch {
209
+ // A terminate that throws is logged rather than fatal: shutdown must complete
210
+ // even when one piece of work refuses to die.
211
+ this.#host.log(`work ${work.id} could not be terminated`);
212
+ }
213
+ }
214
+ this.#work.clear();
215
+ // 4. Close the transport and release the port.
216
+ let portReleased = false;
217
+ try {
218
+ await this.#closeListener?.();
219
+ portReleased = true;
220
+ }
221
+ catch {
222
+ this.#host.log('the listener could not be closed cleanly');
223
+ }
224
+ this.#closeListener = null;
225
+ this.#port = null;
226
+ this.#state = 'stopped';
227
+ this.#acceptingWork = true;
228
+ return { cancelled, terminated, untouched, portReleased, withinGrace };
229
+ }
230
+ }
231
+ /** The only startup policy this implementation permits (RUN-05). */
232
+ export const READ_ONLY_STARTUP = {
233
+ preparesModels: false,
234
+ resolvesPackages: false,
235
+ discoveryIsReadOnly: true,
236
+ };
237
+ /**
238
+ * Whether a startup action is permitted (RUN-05).
239
+ *
240
+ * @param action - what the startup wants to do.
241
+ * @returns whether it may.
242
+ */
243
+ export function startupPermits(action) {
244
+ switch (action) {
245
+ // Restoring an explicitly approved activation and inspecting local state are the
246
+ // two things startup MAY do.
247
+ case 'restore-active':
248
+ case 'inspect-assets':
249
+ case 'read-manifests':
250
+ return true;
251
+ // Preparation and resolution are refused, because RUN-05 is explicit that nothing
252
+ // downloads because a plugin loaded or a client listed tools.
253
+ case 'prepare-model':
254
+ case 'resolve-package':
255
+ case 'download-weights':
256
+ return false;
257
+ }
258
+ }
259
+ /**
260
+ * Whether disabling the MCP server must also disable unrelated DSH tools (RUN-01).
261
+ *
262
+ * It must not. The server and the plugin are independently stoppable, which is why the
263
+ * lifecycle is a separate object from the plugin's own registration state.
264
+ * @returns always false.
265
+ */
266
+ export function disablingServerDisablesOtherTools() {
267
+ return false;
268
+ }
269
+ //# sourceMappingURL=server-lifecycle.js.map