@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
package/lib/receipt.js ADDED
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Invocation receipts and lifecycle records (EXT-35).
3
+ *
4
+ * EXT-35 asks for two different things, recorded SEPARATELY, and the separation is
5
+ * the point:
6
+ *
7
+ * - An **invocation receipt** says what ran: the extension, its version and content
8
+ * digest, the model/recipe identity, and the activation generation. It travels
9
+ * with the result.
10
+ * - A **lifecycle record** says who changed the installation: install, activate,
11
+ * deactivate, update and uninstall outcomes together with the approving
12
+ * principal. It does not travel with a result, because it describes an operator
13
+ * action rather than a call.
14
+ *
15
+ * Mixing them would mean a caller reading a receipt learns about operator actions
16
+ * it has no business seeing, and an audit trail becomes indistinguishable from
17
+ * execution metadata.
18
+ *
19
+ * The metadata-only rule is enforced by CONSTRUCTION rather than by remembering to
20
+ * be careful. Nothing here accepts a request body, a token, or a full skill text,
21
+ * and a path is reduced before it can enter a receipt at all — so a future caller
22
+ * cannot leak one by passing it in.
23
+ *
24
+ * @module @try-works/dsh-tool-mode/receipt
25
+ */
26
+ import { createHash } from 'node:crypto';
27
+ import { basename } from 'node:path';
28
+ /** How many invocation receipts are retained (EXT-35), in memory and on disk. */
29
+ export const MAX_RETAINED_RECEIPTS = 200;
30
+ /** Raised when a value cannot be admitted to a receipt. */
31
+ export class ReceiptRedactionError extends Error {
32
+ name = 'ReceiptRedactionError';
33
+ }
34
+ /**
35
+ * Reduce a caller-supplied path to something safe to record.
36
+ *
37
+ * EXT-35 forbids unrestricted file paths in default receipts, and the reason is
38
+ * that a path discloses the operator's layout: directory names, a username, a
39
+ * project name. The basename is enough to correlate a receipt with a call, and a
40
+ * short digest makes two references to the same path comparable without revealing
41
+ * where it is.
42
+ * @param path - the caller-supplied path.
43
+ * @returns the basename plus a short digest, or null.
44
+ */
45
+ export function redactPath(path) {
46
+ if (typeof path !== 'string' || path.length === 0)
47
+ return null;
48
+ const digest = createHash('sha256').update(path).digest('hex').slice(0, 8);
49
+ // `basename` on either separator: a receipt must not leak a Windows path shape
50
+ // merely because the host runs on Windows.
51
+ const leaf = basename(path.replace(/\\/g, '/'));
52
+ return `${leaf}#${digest}`;
53
+ }
54
+ /**
55
+ * Redact anything token-shaped from a free-text note.
56
+ *
57
+ * Notes are authored by the host, but a note that embedded a value read from the
58
+ * environment would leak it. This is a guard against that, not a substitute for
59
+ * not putting secrets in notes.
60
+ * @param text - the note.
61
+ * @returns the note with credential-shaped spans removed.
62
+ */
63
+ export function redactText(text) {
64
+ return text
65
+ .replace(/\b(?:npm_|ghp_|gho_|ghs_|sk-|xox[baprs]-)[A-Za-z0-9_-]{8,}/g, '<redacted>')
66
+ .replace(/\bBearer\s+[A-Za-z0-9._-]{8,}/gi, 'Bearer <redacted>')
67
+ .replace(/\b[A-Fa-f0-9]{40,}\b/g, '<redacted>')
68
+ // SEC-01: a generated secret is exactly 32 base64url bytes (43 characters). A
69
+ // note that ever embedded one is redacted here, even though nothing in the
70
+ // receipt pipeline takes a secret as input. The boundaries are NON-WORD
71
+ // lookarounds, not \b: a base64url secret may begin or end with '-' (or '_'),
72
+ // which are word characters — a \b-bounded pattern misses such a secret when
73
+ // it abuts another word character, and the reviewer demonstrated real
74
+ // crypto-random secrets with a leading '-' surviving redaction.
75
+ .replace(/(?<![A-Za-z0-9_-])[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])/g, '<redacted>')
76
+ .replace(/[A-Za-z]:\\[^\s"']*/g, '<path>')
77
+ .replace(/(?<![\w.])\/(?:[\w.-]+\/)+[\w.-]+/g, '<path>');
78
+ }
79
+ /**
80
+ * Build the invocation receipt for one call.
81
+ *
82
+ * Takes only host-resolved inputs. There is no parameter for a request body, a
83
+ * token or a skill text, so those cannot reach a receipt through this function at
84
+ * all — which is a stronger guarantee than remembering to omit them.
85
+ * @param input - the resolved provenance.
86
+ * @returns the receipt.
87
+ */
88
+ export function buildInvocationReceipt(input) {
89
+ if (input.receiptId.length === 0) {
90
+ throw new ReceiptRedactionError('a receipt needs an identity; an unidentifiable receipt is not an audit trail');
91
+ }
92
+ return {
93
+ receiptId: input.receiptId,
94
+ contract: input.contract,
95
+ contractVersion: input.contractVersion,
96
+ implementationId: input.implementationId,
97
+ extension: input.extension,
98
+ extensionVersion: input.extensionVersion,
99
+ extensionContentDigest: input.extensionContentDigest ?? null,
100
+ dependencyLockDigest: input.dependencyLockDigest ?? null,
101
+ modelIdentity: input.modelIdentity,
102
+ recipeVersion: input.recipeVersion ?? null,
103
+ activationGeneration: input.activationGeneration,
104
+ executionLocation: input.executionLocation,
105
+ // Every note passes through the redactor, so a host-authored note that happened
106
+ // to embed a token or a path cannot leak one.
107
+ warnings: (input.warnings ?? []).map(redactText),
108
+ kind: input.kind ?? 'invocation',
109
+ parentReceiptId: input.parentReceiptId ?? null,
110
+ ...input.outcome === undefined ? {} : { outcome: input.outcome },
111
+ ...input.usage === undefined ? {} : { usage: input.usage },
112
+ ...input.cost === undefined ? {} : { cost: input.cost },
113
+ };
114
+ }
115
+ /**
116
+ * Record one operator action, separately from execution metadata.
117
+ * @param input - the action, its outcome and its approving principal.
118
+ * @returns the lifecycle record.
119
+ */
120
+ export function buildLifecycleRecord(input) {
121
+ if (input.approvedBy.kind === 'operator' && input.approvedBy.identity.length === 0) {
122
+ // An approval with no principal cannot be audited, which defeats the record.
123
+ throw new ReceiptRedactionError('an operator approval needs an identity');
124
+ }
125
+ return {
126
+ operation: input.operation,
127
+ extensionId: input.extensionId,
128
+ version: input.version ?? null,
129
+ contentDigest: input.contentDigest ?? null,
130
+ profile: input.profile ?? null,
131
+ outcome: input.outcome,
132
+ // A failed operation with no reason is the record an operator cannot act on.
133
+ reason: input.reason === undefined || input.reason === null ? null : redactText(input.reason),
134
+ approvedBy: input.approvedBy,
135
+ at: input.at ?? new Date().toISOString(),
136
+ };
137
+ }
138
+ /** The default policy: quiet, metadata-only, and telemetry off unless approved. */
139
+ export const DEFAULT_LOG_POLICY = {
140
+ maxRecords: 500,
141
+ levels: ['warn', 'error'],
142
+ telemetryApproved: false,
143
+ approvedOrigins: [],
144
+ };
145
+ /**
146
+ * Apply a logging policy to one extension record.
147
+ *
148
+ * A dropped record is dropped rather than summarised, because a summarised
149
+ * diagnostic is a diagnostic an operator will misread.
150
+ * @param policy - the policy in force.
151
+ * @param record - the proposed record.
152
+ * @returns whether to retain it.
153
+ */
154
+ export function admitsLogRecord(policy, record) {
155
+ if (!policy.levels.includes(record.level))
156
+ return false;
157
+ if (record.declaredOrigin !== undefined) {
158
+ // An undeclared network origin is refused rather than recorded and forgotten:
159
+ // EXT-35 requires the behaviour to be disclosed and approved, not logged.
160
+ if (!policy.approvedOrigins.includes(record.declaredOrigin))
161
+ return false;
162
+ }
163
+ return true;
164
+ }
165
+ //# sourceMappingURL=receipt.js.map
@@ -0,0 +1,75 @@
1
+ /**
2
+ * The registrar: turns each runnable catalog model into a DSH tool.
3
+ *
4
+ * The registrar owns the translation from the catalog's declarative tool spec
5
+ * into a `defineTool` definition, including the parameter schema, the canonical
6
+ * output contract and the model-facing rendering. Registration goes through
7
+ * `ctx.tools.register`, whose returned disposer is the only unregister API, so
8
+ * the plugin can add or drop a model's tool at runtime as capability changes.
9
+ *
10
+ * @module @try-works/dsh-tool-mode/registrar
11
+ */
12
+ import { type ParameterSchemaSpec } from '@deepseek-ai/dsh-tools';
13
+ import type { ModelCatalogEntry } from './types.ts';
14
+ import type { ModelAdapter } from './adapters/index.ts';
15
+ /** The tool spec a catalog entry declares, resolved into a registration. */
16
+ export interface RegisteredModelTool {
17
+ readonly modelId: string;
18
+ readonly toolName: string;
19
+ readonly dispose: () => void;
20
+ }
21
+ /**
22
+ * Build the parameter schema for one model's tool.
23
+ *
24
+ * Every catalog parameter is advertised as OPTIONAL here: the catalog has no
25
+ * explicit requiredness metadata, and inferring it from parameter order was a
26
+ * model-specific assumption BASE-04 forbids. The adapter validates the model's
27
+ * primary input as a required non-empty value, so an omitted argument is still
28
+ * refused — just by the adapter's rule rather than by an inferred schema flag.
29
+ * Types come from the catalog declaration, so a numeric or list parameter reaches
30
+ * the model as the type it actually is rather than as a string it re-parses.
31
+ * @param entry - the catalog entry.
32
+ * @returns the DSH parameter schema spec.
33
+ */
34
+ export declare function buildParameters(entry: ModelCatalogEntry): ParameterSchemaSpec;
35
+ /**
36
+ * Render the tool result for the model.
37
+ *
38
+ * The canonical value is the source of truth; this projection only chooses how
39
+ * to present it. Tongue's shaped result gets a sentence the model can act on
40
+ * directly, while everything else falls back to stable JSON so no information
41
+ * is lost to a lossy humanization.
42
+ * @param entry - the catalog entry.
43
+ * @param value - the canonical value the adapter returned.
44
+ * @returns the model-facing content blocks.
45
+ */
46
+ /**
47
+ * Render a canonical value as model-facing content blocks.
48
+ *
49
+ * Keyed on the CONTRACT, never on the model id. A model-specific presentation
50
+ * branch is a model-specific postprocessing recipe living in the host, which
51
+ * EXT-01 forbids — and it would also mean a second implementation of the same
52
+ * contract rendered differently, contradicting the point of having a contract.
53
+ * Anything unrecognised falls through to the canonical JSON, so a new contract
54
+ * degrades to readable data rather than to nothing.
55
+ * @param entry - the catalog entry, for its contract binding.
56
+ * @param value - the canonical value the adapter returned.
57
+ * @returns the model-facing content blocks.
58
+ */
59
+ export declare function renderResult(entry: ModelCatalogEntry, value: Record<string, unknown>): {
60
+ type: 'text';
61
+ text: string;
62
+ }[];
63
+ /**
64
+ * Register one model's tool on the calling context.
65
+ * @param ctx - the context whose tool registry receives the definition; its scope decides visibility.
66
+ * @param entry - the catalog entry to expose.
67
+ * @param adapter - the adapter that invokes the model.
68
+ * @returns the model id, the tool name, and the disposer returned by the registry.
69
+ */
70
+ export declare function registerModelTool(ctx: {
71
+ tools: {
72
+ register(definition: unknown): () => void;
73
+ };
74
+ }, entry: ModelCatalogEntry, adapter: ModelAdapter): RegisteredModelTool;
75
+ //# sourceMappingURL=registrar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registrar.d.ts","sourceRoot":"","sources":["../src/registrar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAA0C,KAAK,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACzG,OAAO,KAAK,EAAE,iBAAiB,EAAkB,MAAM,YAAY,CAAA;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,4EAA4E;AAC5E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAC7B;AAwBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,iBAAiB,GAAG,mBAAmB,CAQ7E;AAED;;;;;;;;;;GAUG;AACH;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,iBAAiB,EACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CA8BlC;AAcD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE;IAAE,KAAK,EAAE;QAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,IAAI,CAAA;KAAE,CAAA;CAAE,EAC7D,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,YAAY,GACpB,mBAAmB,CA6BrB"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * The registrar: turns each runnable catalog model into a DSH tool.
3
+ *
4
+ * The registrar owns the translation from the catalog's declarative tool spec
5
+ * into a `defineTool` definition, including the parameter schema, the canonical
6
+ * output contract and the model-facing rendering. Registration goes through
7
+ * `ctx.tools.register`, whose returned disposer is the only unregister API, so
8
+ * the plugin can add or drop a model's tool at runtime as capability changes.
9
+ *
10
+ * @module @try-works/dsh-tool-mode/registrar
11
+ */
12
+ import { defineTool } from '@deepseek-ai/dsh-tools';
13
+ /**
14
+ * Compile one declared parameter into the registry's parameter spec.
15
+ * @param type - the declared JSON-level type.
16
+ * @param description - the model-facing description.
17
+ * @param required - whether the parameter must be supplied.
18
+ * @returns the parameter property spec.
19
+ */
20
+ function parameterSpec(type, description, required) {
21
+ const base = type === 'string[]'
22
+ ? { type: 'array', items: { type: 'string' } }
23
+ : { type };
24
+ return {
25
+ ...base,
26
+ description,
27
+ ...required ? { required: true } : {},
28
+ };
29
+ }
30
+ /**
31
+ * Build the parameter schema for one model's tool.
32
+ *
33
+ * Every catalog parameter is advertised as OPTIONAL here: the catalog has no
34
+ * explicit requiredness metadata, and inferring it from parameter order was a
35
+ * model-specific assumption BASE-04 forbids. The adapter validates the model's
36
+ * primary input as a required non-empty value, so an omitted argument is still
37
+ * refused — just by the adapter's rule rather than by an inferred schema flag.
38
+ * Types come from the catalog declaration, so a numeric or list parameter reaches
39
+ * the model as the type it actually is rather than as a string it re-parses.
40
+ * @param entry - the catalog entry.
41
+ * @returns the DSH parameter schema spec.
42
+ */
43
+ export function buildParameters(entry) {
44
+ const params = entry.tool.params;
45
+ const schema = {};
46
+ for (const [name, param] of Object.entries(params)) {
47
+ if (param === undefined)
48
+ continue;
49
+ schema[name] = parameterSpec(param.type ?? 'string', param.description, false);
50
+ }
51
+ return schema;
52
+ }
53
+ /**
54
+ * Render the tool result for the model.
55
+ *
56
+ * The canonical value is the source of truth; this projection only chooses how
57
+ * to present it. Tongue's shaped result gets a sentence the model can act on
58
+ * directly, while everything else falls back to stable JSON so no information
59
+ * is lost to a lossy humanization.
60
+ * @param entry - the catalog entry.
61
+ * @param value - the canonical value the adapter returned.
62
+ * @returns the model-facing content blocks.
63
+ */
64
+ /**
65
+ * Render a canonical value as model-facing content blocks.
66
+ *
67
+ * Keyed on the CONTRACT, never on the model id. A model-specific presentation
68
+ * branch is a model-specific postprocessing recipe living in the host, which
69
+ * EXT-01 forbids — and it would also mean a second implementation of the same
70
+ * contract rendered differently, contradicting the point of having a contract.
71
+ * Anything unrecognised falls through to the canonical JSON, so a new contract
72
+ * degrades to readable data rather than to nothing.
73
+ * @param entry - the catalog entry, for its contract binding.
74
+ * @param value - the canonical value the adapter returned.
75
+ * @returns the model-facing content blocks.
76
+ */
77
+ export function renderResult(entry, value) {
78
+ if (entry.contract === 'text.language_detect' && typeof value.language === 'string') {
79
+ const candidates = Array.isArray(value.candidates) ? value.candidates : [];
80
+ const detail = candidates
81
+ .filter((candidate) => typeof candidate === 'object' && candidate !== null
82
+ && typeof candidate.language === 'string')
83
+ .map(candidate => `${candidate.language} ${(candidate.probability * 100).toFixed(1)}%`)
84
+ .join(', ');
85
+ // Both spellings are accepted: an implementation reports its own vocabulary and
86
+ // the host translates, so this reads whichever one reached here.
87
+ const tooClose = value.tooCloseToCall === true || value.isTooCloseToCall === true
88
+ ? ' (too close to call)'
89
+ : '';
90
+ return [{
91
+ type: 'text',
92
+ text: `Detected language: ${value.language}${tooClose}`
93
+ + (detail.length > 0 ? `\nCandidates: ${detail}` : ''),
94
+ }];
95
+ }
96
+ if (entry.contract === 'stt.transcribe' && typeof value.text === 'string') {
97
+ const wordCount = typeof value.wordCount === 'number' ? value.wordCount : 0;
98
+ return [{
99
+ type: 'text',
100
+ text: value.text.length > 0
101
+ ? value.text
102
+ : `(no speech recognized; ${wordCount} words)`,
103
+ }];
104
+ }
105
+ return [{ type: 'text', text: JSON.stringify(value, null, 2) }];
106
+ }
107
+ /** The JSON-Schema type of the canonical value a model tool returns. */
108
+ function outputSchemaFor(entry) {
109
+ // One open object schema for every model: the adapters return model-specific
110
+ // fields, and the registry validates the declared shape without forbidding a
111
+ // field a future adapter adds.
112
+ void entry;
113
+ return { type: 'object', additionalProperties: true };
114
+ }
115
+ /**
116
+ * Register one model's tool on the calling context.
117
+ * @param ctx - the context whose tool registry receives the definition; its scope decides visibility.
118
+ * @param entry - the catalog entry to expose.
119
+ * @param adapter - the adapter that invokes the model.
120
+ * @returns the model id, the tool name, and the disposer returned by the registry.
121
+ */
122
+ export function registerModelTool(ctx, entry, adapter) {
123
+ const definition = defineTool({
124
+ name: entry.tool.name,
125
+ description: entry.tool.description,
126
+ parameters: buildParameters(entry),
127
+ output: {
128
+ schema: outputSchemaFor(entry),
129
+ render: (_args, value) => renderResult(entry, value),
130
+ },
131
+ async execute(args, exec) {
132
+ const value = await adapter.invoke({
133
+ args: args,
134
+ signal: exec.signal,
135
+ });
136
+ return value;
137
+ },
138
+ presentCall(args) {
139
+ const primary = Object.values(args)[0];
140
+ const preview = typeof primary === 'string' ? primary : undefined;
141
+ return {
142
+ card: 'generic',
143
+ title: `${entry.name}${entry.input === 'text' ? '' : ` (${entry.input})`}`,
144
+ kind: 'read',
145
+ ...preview !== undefined && entry.input === 'text' ? { rawInput: preview } : {},
146
+ };
147
+ },
148
+ });
149
+ const dispose = ctx.tools.register(definition);
150
+ return { modelId: entry.id, toolName: entry.tool.name, dispose };
151
+ }
152
+ //# sourceMappingURL=registrar.js.map
@@ -0,0 +1,204 @@
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
+ /**
26
+ * The eight readiness/residency states (RES-04).
27
+ *
28
+ * Named `Readiness` rather than `Residency` because it holds both dimensions; the
29
+ * two derived functions below are what separate them.
30
+ */
31
+ export type Readiness =
32
+ /** No compatible implementation exists on this host. */
33
+ 'unavailable'
34
+ /** Compatible, but its assets have not been prepared. */
35
+ | 'needs-preparation'
36
+ /** Preparation is under way. */
37
+ | 'preparing'
38
+ /** Prepared and not loaded: a call will load first. */
39
+ | 'prepared-cold'
40
+ /** Currently loading. */
41
+ | 'loading'
42
+ /** Loaded and idle. */
43
+ | 'ready'
44
+ /** Loaded and serving; further calls queue. */
45
+ | 'busy'
46
+ /** Preparation or loading failed. */
47
+ | 'failed';
48
+ /**
49
+ * Whether a call is possible in this state (RES-04).
50
+ *
51
+ * Determined by compatibility, authorization and PREPARATION — never by residency.
52
+ * @param state - the current state.
53
+ * @returns whether the tool can be called.
54
+ */
55
+ export declare function isCallable(state: Readiness): boolean;
56
+ /**
57
+ * Whether assets are prepared (RES-04).
58
+ * @param state - the current state.
59
+ * @returns whether preparation has completed.
60
+ */
61
+ export declare function isPrepared(state: Readiness): boolean;
62
+ /** How a call is admitted in a given state (RES-04). */
63
+ export type Admission =
64
+ /** Runs now. */
65
+ 'immediate'
66
+ /** Will load first, so it takes longer. */
67
+ | 'loads-first'
68
+ /** Waits for the current call to finish. */
69
+ | 'queued';
70
+ /**
71
+ * How residency affects admission (RES-04).
72
+ *
73
+ * This is the half that residency legitimately controls: not WHETHER a tool exists,
74
+ * but what a call to it costs.
75
+ * @param state - the current state.
76
+ * @returns the admission behaviour, or undefined when no call is possible.
77
+ */
78
+ export declare function admissionOf(state: Readiness): Admission | undefined;
79
+ /**
80
+ * Whether a tool DESCRIPTION may vary with this state (RES-04).
81
+ *
82
+ * Always false. RES-04 forbids changing agent tool descriptions on every warm/cold
83
+ * transition, so this exists to be asserted rather than to be consulted: a caller
84
+ * that branches on residency when building a description has found a bug.
85
+ * @returns always false.
86
+ */
87
+ export declare function descriptionMayVaryWithResidency(): boolean;
88
+ /** A budgeted resource (RES-09). */
89
+ export type BudgetKind = 'sourceBytes' | 'decodedPixels' | 'audioSamples' | 'videoSeconds' | 'videoFrames' | 'processorTokens' | 'batch' | 'outputVectors';
90
+ /** Limits for one input class. `null` means the constraint does not apply. */
91
+ export type Budget = Partial<Record<BudgetKind, number | null>>;
92
+ /**
93
+ * The product defaults the requirement names verbatim (RES-09).
94
+ *
95
+ * These are PRODUCT limits, not guarantees that every input within them fits: the
96
+ * requirement says model context limits may force lower admission, so a successful
97
+ * check here is necessary and not sufficient.
98
+ */
99
+ export declare const DEFAULT_BUDGETS: Readonly<Record<'image' | 'video' | 'audio' | 'text', Budget>>;
100
+ /** A measured input. */
101
+ export type Measurement = Partial<Record<BudgetKind, number>>;
102
+ /** The outcome of admitting an input. */
103
+ export type AdmissionDecision = {
104
+ readonly admitted: true;
105
+ } | {
106
+ readonly admitted: false;
107
+ /** Every exceeded budget, with the actual limit. */
108
+ readonly exceeded: readonly {
109
+ readonly kind: BudgetKind;
110
+ readonly measured: number;
111
+ readonly limit: number;
112
+ }[];
113
+ };
114
+ /**
115
+ * Decide whether an input fits its budget (RES-01, RES-09).
116
+ *
117
+ * Over-budget input is REJECTED with the actual limits. It is never truncated and
118
+ * never sampled down, because the caller cannot otherwise tell that what it supplied
119
+ * is not what was processed.
120
+ * @param measurement - what the input actually is.
121
+ * @param budget - the limits in force.
122
+ * @returns the decision, naming every exceeded budget.
123
+ */
124
+ export declare function admit(measurement: Measurement, budget: Budget): AdmissionDecision;
125
+ /**
126
+ * Render a rejection the caller can act on (RES-01).
127
+ *
128
+ * The requirement says to reject with ACTUAL LIMITS: a caller told only "too large"
129
+ * cannot choose a smaller input.
130
+ * @param decision - a rejection.
131
+ * @returns the message.
132
+ */
133
+ export declare function describeRejection(decision: Extract<AdmissionDecision, {
134
+ admitted: false;
135
+ }>): string;
136
+ /** An explicit sampling instruction (RES-09). */
137
+ export interface SamplingPlan {
138
+ /** What was sampled, in the caller's terms. */
139
+ readonly instruction: string;
140
+ /** The budget that forced sampling, when one did. */
141
+ readonly forcedBy: BudgetKind | null;
142
+ }
143
+ /** What was actually processed, returned so coverage is never implied. */
144
+ export interface Coverage {
145
+ /** Whether every unit of the source was processed. */
146
+ readonly complete: boolean;
147
+ /** Units processed. */
148
+ readonly processed: number;
149
+ /** Units in the source. */
150
+ readonly total: number;
151
+ /** The sampling that was applied, when any was. */
152
+ readonly sampling: SamplingPlan | null;
153
+ /** Why coverage is incomplete. */
154
+ readonly reason: string | null;
155
+ }
156
+ /**
157
+ * Build the coverage report for an input that had to be sampled (RES-09).
158
+ *
159
+ * Sampling is only legitimate when it is EXPLICIT and its coverage is REPORTED. An
160
+ * implementation that quietly processed 32 of 900 frames and reported success has
161
+ * told the caller something false about the input it supplied.
162
+ * @param processed - units processed.
163
+ * @param total - units in the source.
164
+ * @param sampling - the instruction applied, when one was.
165
+ * @returns the coverage report.
166
+ */
167
+ export declare function coverageOf(processed: number, total: number, sampling: SamplingPlan | null): Coverage;
168
+ /** How a cancellation actually ended (RES-06). */
169
+ export type CancellationOutcome =
170
+ /** The work stopped and released its resources. */
171
+ {
172
+ readonly stopped: true;
173
+ }
174
+ /**
175
+ * The work could not be interrupted. It continues to completion, and its result
176
+ * is discarded rather than delivered.
177
+ */
178
+ | {
179
+ readonly stopped: false;
180
+ readonly reason: string;
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 declare function cancellationOutcome(interruptible: boolean, subject: string): CancellationOutcome;
194
+ /**
195
+ * Whether a decompression bomb must be rejected before allocation (RES-09).
196
+ *
197
+ * The check is on the DECLARED expanded size, before any allocation: a check that
198
+ * runs after decompression has already lost.
199
+ * @param declaredBytes - the expansion the container declares.
200
+ * @param limit - the budget for this input class.
201
+ * @returns whether to reject.
202
+ */
203
+ export declare function isExpansionBomb(declaredBytes: number, limit: number): boolean;
204
+ //# sourceMappingURL=resource-governance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-governance.d.ts","sourceRoot":"","sources":["../src/resource-governance.ts"],"names":[],"mappings":"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"}