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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/LICENSE +205 -0
  2. package/README.md +303 -2
  3. package/bin/dsh-tool-mode-credentials.mjs +20 -0
  4. package/bin/dsh-tool-mode-mcp-stdio.mjs +80 -0
  5. package/bin/dsh-tool-mode.mjs +211 -0
  6. package/builtins.lock.json +26 -0
  7. package/catalog/desert-ant-models.json +693 -0
  8. package/catalog/playbooks.json +531 -0
  9. package/client/client.model-tools.js +1910 -0
  10. package/client/index.js +4158 -0
  11. package/cordis.patch.yml +39 -0
  12. package/lib/adapters/index.d.ts +61 -0
  13. package/lib/adapters/index.d.ts.map +1 -0
  14. package/lib/adapters/index.js +82 -0
  15. package/lib/adapters/types.d.ts +106 -0
  16. package/lib/adapters/types.d.ts.map +1 -0
  17. package/lib/adapters/types.js +85 -0
  18. package/lib/approval.d.ts +189 -0
  19. package/lib/approval.d.ts.map +1 -0
  20. package/lib/approval.js +510 -0
  21. package/lib/asset-acquisition.d.ts +149 -0
  22. package/lib/asset-acquisition.d.ts.map +1 -0
  23. package/lib/asset-acquisition.js +175 -0
  24. package/lib/authority.d.ts +185 -0
  25. package/lib/authority.d.ts.map +1 -0
  26. package/lib/authority.js +223 -0
  27. package/lib/bindings.d.ts +144 -0
  28. package/lib/bindings.d.ts.map +1 -0
  29. package/lib/bindings.js +314 -0
  30. package/lib/builtins.d.ts +27 -0
  31. package/lib/builtins.d.ts.map +1 -0
  32. package/lib/builtins.js +37 -0
  33. package/lib/capability.d.ts +58 -0
  34. package/lib/capability.d.ts.map +1 -0
  35. package/lib/capability.js +192 -0
  36. package/lib/capture-path.d.ts +97 -0
  37. package/lib/capture-path.d.ts.map +1 -0
  38. package/lib/capture-path.js +152 -0
  39. package/lib/catalog.d.ts +37 -0
  40. package/lib/catalog.d.ts.map +1 -0
  41. package/lib/catalog.js +274 -0
  42. package/lib/contract-payload.d.ts +39 -0
  43. package/lib/contract-payload.d.ts.map +1 -0
  44. package/lib/contract-payload.js +56 -0
  45. package/lib/custom-tools/compile.d.ts +25 -0
  46. package/lib/custom-tools/compile.d.ts.map +1 -0
  47. package/lib/custom-tools/compile.js +61 -0
  48. package/lib/custom-tools/composite-executor.d.ts +42 -0
  49. package/lib/custom-tools/composite-executor.d.ts.map +1 -0
  50. package/lib/custom-tools/composite-executor.js +113 -0
  51. package/lib/custom-tools/dispatch.d.ts +28 -0
  52. package/lib/custom-tools/dispatch.d.ts.map +1 -0
  53. package/lib/custom-tools/dispatch.js +34 -0
  54. package/lib/custom-tools/http-executor.d.ts +48 -0
  55. package/lib/custom-tools/http-executor.d.ts.map +1 -0
  56. package/lib/custom-tools/http-executor.js +241 -0
  57. package/lib/custom-tools/index.d.ts +12 -0
  58. package/lib/custom-tools/index.d.ts.map +1 -0
  59. package/lib/custom-tools/index.js +12 -0
  60. package/lib/custom-tools/mcp-surface.d.ts +14 -0
  61. package/lib/custom-tools/mcp-surface.d.ts.map +1 -0
  62. package/lib/custom-tools/mcp-surface.js +41 -0
  63. package/lib/custom-tools/prompt-executor.d.ts +39 -0
  64. package/lib/custom-tools/prompt-executor.d.ts.map +1 -0
  65. package/lib/custom-tools/prompt-executor.js +59 -0
  66. package/lib/custom-tools/registry.d.ts +69 -0
  67. package/lib/custom-tools/registry.d.ts.map +1 -0
  68. package/lib/custom-tools/registry.js +130 -0
  69. package/lib/custom-tools/schema.d.ts +26 -0
  70. package/lib/custom-tools/schema.d.ts.map +1 -0
  71. package/lib/custom-tools/schema.js +375 -0
  72. package/lib/custom-tools/service.d.ts +90 -0
  73. package/lib/custom-tools/service.d.ts.map +1 -0
  74. package/lib/custom-tools/service.js +203 -0
  75. package/lib/custom-tools/store.d.ts +61 -0
  76. package/lib/custom-tools/store.d.ts.map +1 -0
  77. package/lib/custom-tools/store.js +240 -0
  78. package/lib/custom-tools/types.d.ts +131 -0
  79. package/lib/custom-tools/types.d.ts.map +1 -0
  80. package/lib/custom-tools/types.js +11 -0
  81. package/lib/decision-combine.d.ts +113 -0
  82. package/lib/decision-combine.d.ts.map +1 -0
  83. package/lib/decision-combine.js +156 -0
  84. package/lib/decision-evaluate.d.ts +185 -0
  85. package/lib/decision-evaluate.d.ts.map +1 -0
  86. package/lib/decision-evaluate.js +227 -0
  87. package/lib/deployment-coordinator.d.ts +213 -0
  88. package/lib/deployment-coordinator.d.ts.map +1 -0
  89. package/lib/deployment-coordinator.js +274 -0
  90. package/lib/diagnostics.d.ts +169 -0
  91. package/lib/diagnostics.d.ts.map +1 -0
  92. package/lib/diagnostics.js +136 -0
  93. package/lib/discovery-contracts.d.ts +14 -0
  94. package/lib/discovery-contracts.d.ts.map +1 -0
  95. package/lib/discovery-contracts.js +90 -0
  96. package/lib/discovery-describe.d.ts +35 -0
  97. package/lib/discovery-describe.d.ts.map +1 -0
  98. package/lib/discovery-describe.js +99 -0
  99. package/lib/embedding-index.d.ts +55 -0
  100. package/lib/embedding-index.d.ts.map +1 -0
  101. package/lib/embedding-index.js +126 -0
  102. package/lib/extension-dependencies.d.ts +355 -0
  103. package/lib/extension-dependencies.d.ts.map +1 -0
  104. package/lib/extension-dependencies.js +987 -0
  105. package/lib/extension-dispatch.d.ts +150 -0
  106. package/lib/extension-dispatch.d.ts.map +1 -0
  107. package/lib/extension-dispatch.js +178 -0
  108. package/lib/extension-page-state.d.ts +69 -0
  109. package/lib/extension-page-state.d.ts.map +1 -0
  110. package/lib/extension-page-state.js +82 -0
  111. package/lib/extension-registrar.d.ts +116 -0
  112. package/lib/extension-registrar.d.ts.map +1 -0
  113. package/lib/extension-registrar.js +144 -0
  114. package/lib/extensions-api.d.ts +346 -0
  115. package/lib/extensions-api.d.ts.map +1 -0
  116. package/lib/extensions-api.js +17 -0
  117. package/lib/extensions-remote.d.ts +57 -0
  118. package/lib/extensions-remote.d.ts.map +1 -0
  119. package/lib/extensions-remote.js +69 -0
  120. package/lib/extensions-service.d.ts +568 -0
  121. package/lib/extensions-service.d.ts.map +1 -0
  122. package/lib/extensions-service.js +2552 -0
  123. package/lib/harness-budgets.d.ts +158 -0
  124. package/lib/harness-budgets.d.ts.map +1 -0
  125. package/lib/harness-budgets.js +152 -0
  126. package/lib/harness-llm.d.ts +138 -0
  127. package/lib/harness-llm.d.ts.map +1 -0
  128. package/lib/harness-llm.js +218 -0
  129. package/lib/harness-serving.d.ts +115 -0
  130. package/lib/harness-serving.d.ts.map +1 -0
  131. package/lib/harness-serving.js +176 -0
  132. package/lib/headless.d.ts +97 -0
  133. package/lib/headless.d.ts.map +1 -0
  134. package/lib/headless.js +407 -0
  135. package/lib/http-acquisition.d.ts +27 -0
  136. package/lib/http-acquisition.d.ts.map +1 -0
  137. package/lib/http-acquisition.js +140 -0
  138. package/lib/index.d.ts +546 -0
  139. package/lib/index.d.ts.map +1 -0
  140. package/lib/index.js +5273 -0
  141. package/lib/invocation-accounting.d.ts +169 -0
  142. package/lib/invocation-accounting.d.ts.map +1 -0
  143. package/lib/invocation-accounting.js +148 -0
  144. package/lib/jev.d.ts +218 -0
  145. package/lib/jev.d.ts.map +1 -0
  146. package/lib/jev.js +366 -0
  147. package/lib/legacy-migration.d.ts +95 -0
  148. package/lib/legacy-migration.d.ts.map +1 -0
  149. package/lib/legacy-migration.js +429 -0
  150. package/lib/license-basis.d.ts +29 -0
  151. package/lib/license-basis.d.ts.map +1 -0
  152. package/lib/license-basis.js +58 -0
  153. package/lib/managed-workers.d.ts +158 -0
  154. package/lib/managed-workers.d.ts.map +1 -0
  155. package/lib/managed-workers.js +269 -0
  156. package/lib/mcp/auth-selection.d.ts +35 -0
  157. package/lib/mcp/auth-selection.d.ts.map +1 -0
  158. package/lib/mcp/auth-selection.js +64 -0
  159. package/lib/mcp/client-grant.d.ts +89 -0
  160. package/lib/mcp/client-grant.d.ts.map +1 -0
  161. package/lib/mcp/client-grant.js +63 -0
  162. package/lib/mcp/credential-cli.d.ts +38 -0
  163. package/lib/mcp/credential-cli.d.ts.map +1 -0
  164. package/lib/mcp/credential-cli.js +148 -0
  165. package/lib/mcp/credential-store.d.ts +143 -0
  166. package/lib/mcp/credential-store.d.ts.map +1 -0
  167. package/lib/mcp/credential-store.js +461 -0
  168. package/lib/mcp/export-policy.d.ts +25 -0
  169. package/lib/mcp/export-policy.d.ts.map +1 -0
  170. package/lib/mcp/export-policy.js +31 -0
  171. package/lib/mcp/host-binding.d.ts +144 -0
  172. package/lib/mcp/host-binding.d.ts.map +1 -0
  173. package/lib/mcp/host-binding.js +280 -0
  174. package/lib/mcp/http.d.ts +180 -0
  175. package/lib/mcp/http.d.ts.map +1 -0
  176. package/lib/mcp/http.js +602 -0
  177. package/lib/mcp/oauth.d.ts +149 -0
  178. package/lib/mcp/oauth.d.ts.map +1 -0
  179. package/lib/mcp/oauth.js +396 -0
  180. package/lib/mcp/protocol.d.ts +329 -0
  181. package/lib/mcp/protocol.d.ts.map +1 -0
  182. package/lib/mcp/protocol.js +459 -0
  183. package/lib/mcp/rate-limit.d.ts +68 -0
  184. package/lib/mcp/rate-limit.d.ts.map +1 -0
  185. package/lib/mcp/rate-limit.js +114 -0
  186. package/lib/mcp/sdk-v2.d.ts +17 -0
  187. package/lib/mcp/sdk-v2.d.ts.map +1 -0
  188. package/lib/mcp/sdk-v2.js +204 -0
  189. package/lib/mcp/server.d.ts +149 -0
  190. package/lib/mcp/server.d.ts.map +1 -0
  191. package/lib/mcp/server.js +302 -0
  192. package/lib/mcp/stdio.d.ts +80 -0
  193. package/lib/mcp/stdio.d.ts.map +1 -0
  194. package/lib/mcp/stdio.js +184 -0
  195. package/lib/mcp/subscriptions.d.ts +177 -0
  196. package/lib/mcp/subscriptions.d.ts.map +1 -0
  197. package/lib/mcp/subscriptions.js +288 -0
  198. package/lib/mcp-status.d.ts +96 -0
  199. package/lib/mcp-status.d.ts.map +1 -0
  200. package/lib/mcp-status.js +70 -0
  201. package/lib/mcp-usage.d.ts +110 -0
  202. package/lib/mcp-usage.d.ts.map +1 -0
  203. package/lib/mcp-usage.js +189 -0
  204. package/lib/model-qualification.d.ts +192 -0
  205. package/lib/model-qualification.d.ts.map +1 -0
  206. package/lib/model-qualification.js +178 -0
  207. package/lib/model-runtime-lane.d.ts +69 -0
  208. package/lib/model-runtime-lane.d.ts.map +1 -0
  209. package/lib/model-runtime-lane.js +122 -0
  210. package/lib/model-runtime-recipe.d.ts +132 -0
  211. package/lib/model-runtime-recipe.d.ts.map +1 -0
  212. package/lib/model-runtime-recipe.js +291 -0
  213. package/lib/planning.d.ts +256 -0
  214. package/lib/planning.d.ts.map +1 -0
  215. package/lib/planning.js +471 -0
  216. package/lib/playbook.d.ts +42 -0
  217. package/lib/playbook.d.ts.map +1 -0
  218. package/lib/playbook.js +65 -0
  219. package/lib/prepared-assets.d.ts +269 -0
  220. package/lib/prepared-assets.d.ts.map +1 -0
  221. package/lib/prepared-assets.js +471 -0
  222. package/lib/provider-bridge.d.ts +107 -0
  223. package/lib/provider-bridge.d.ts.map +1 -0
  224. package/lib/provider-bridge.js +423 -0
  225. package/lib/ptc-authority.d.ts +154 -0
  226. package/lib/ptc-authority.d.ts.map +1 -0
  227. package/lib/ptc-authority.js +242 -0
  228. package/lib/ptc-confinement.d.ts +60 -0
  229. package/lib/ptc-confinement.d.ts.map +1 -0
  230. package/lib/ptc-confinement.js +212 -0
  231. package/lib/ptc-runtime.d.ts +166 -0
  232. package/lib/ptc-runtime.d.ts.map +1 -0
  233. package/lib/ptc-runtime.js +231 -0
  234. package/lib/publication.d.ts +161 -0
  235. package/lib/publication.d.ts.map +1 -0
  236. package/lib/publication.js +181 -0
  237. package/lib/receipt-store.d.ts +57 -0
  238. package/lib/receipt-store.d.ts.map +1 -0
  239. package/lib/receipt-store.js +143 -0
  240. package/lib/receipt.d.ts +231 -0
  241. package/lib/receipt.d.ts.map +1 -0
  242. package/lib/receipt.js +165 -0
  243. package/lib/registrar.d.ts +75 -0
  244. package/lib/registrar.d.ts.map +1 -0
  245. package/lib/registrar.js +152 -0
  246. package/lib/resource-governance.d.ts +204 -0
  247. package/lib/resource-governance.d.ts.map +1 -0
  248. package/lib/resource-governance.js +213 -0
  249. package/lib/server-lifecycle.d.ts +175 -0
  250. package/lib/server-lifecycle.d.ts.map +1 -0
  251. package/lib/server-lifecycle.js +269 -0
  252. package/lib/skills.d.ts +31 -0
  253. package/lib/skills.d.ts.map +1 -0
  254. package/lib/skills.js +170 -0
  255. package/lib/speech-bridge.d.ts +74 -0
  256. package/lib/speech-bridge.d.ts.map +1 -0
  257. package/lib/speech-bridge.js +115 -0
  258. package/lib/state.d.ts +100 -0
  259. package/lib/state.d.ts.map +1 -0
  260. package/lib/state.js +160 -0
  261. package/lib/title-proposal.d.ts +194 -0
  262. package/lib/title-proposal.d.ts.map +1 -0
  263. package/lib/title-proposal.js +244 -0
  264. package/lib/tool-inventory.d.ts +90 -0
  265. package/lib/tool-inventory.d.ts.map +1 -0
  266. package/lib/tool-inventory.js +102 -0
  267. package/lib/tool-mode-run.d.ts +310 -0
  268. package/lib/tool-mode-run.d.ts.map +1 -0
  269. package/lib/tool-mode-run.js +411 -0
  270. package/lib/tool-sources.d.ts +80 -0
  271. package/lib/tool-sources.d.ts.map +1 -0
  272. package/lib/tool-sources.js +123 -0
  273. package/lib/tool-usage-projection.d.ts +390 -0
  274. package/lib/tool-usage-projection.d.ts.map +1 -0
  275. package/lib/tool-usage-projection.js +1038 -0
  276. package/lib/tool-usage-report.d.ts +153 -0
  277. package/lib/tool-usage-report.d.ts.map +1 -0
  278. package/lib/tool-usage-report.js +274 -0
  279. package/lib/transport.d.ts +158 -0
  280. package/lib/transport.d.ts.map +1 -0
  281. package/lib/transport.js +332 -0
  282. package/lib/types.d.ts +134 -0
  283. package/lib/types.d.ts.map +1 -0
  284. package/lib/types.js +8 -0
  285. package/lib/update-surface.d.ts +79 -0
  286. package/lib/update-surface.d.ts.map +1 -0
  287. package/lib/update-surface.js +224 -0
  288. package/lib/version.d.ts +3 -0
  289. package/lib/version.d.ts.map +1 -0
  290. package/lib/version.js +27 -0
  291. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts +13 -0
  292. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts.map +1 -0
  293. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.js +85 -0
  294. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts +16 -0
  295. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts.map +1 -0
  296. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.js +87 -0
  297. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts +38 -0
  298. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts.map +1 -0
  299. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.js +445 -0
  300. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts +20 -0
  301. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts.map +1 -0
  302. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.js +112 -0
  303. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts +14 -0
  304. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts.map +1 -0
  305. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.js +63 -0
  306. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts +14 -0
  307. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts.map +1 -0
  308. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.js +76 -0
  309. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts +82 -0
  310. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts.map +1 -0
  311. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.js +274 -0
  312. package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts +26 -0
  313. package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts.map +1 -0
  314. package/node_modules/@try-works/tool-mode-contracts/lib/index.js +53 -0
  315. package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts +133 -0
  316. package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts.map +1 -0
  317. package/node_modules/@try-works/tool-mode-contracts/lib/meta.js +64 -0
  318. package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts +121 -0
  319. package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts.map +1 -0
  320. package/node_modules/@try-works/tool-mode-contracts/lib/registry.js +246 -0
  321. package/node_modules/@try-works/tool-mode-contracts/package.json +35 -0
  322. package/node_modules/@try-works/tool-mode-extension-sdk/bin/dsh-tool-mode.mjs +20 -0
  323. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts +80 -0
  324. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts.map +1 -0
  325. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.js +533 -0
  326. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts +86 -0
  327. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts.map +1 -0
  328. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.js +145 -0
  329. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts +70 -0
  330. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts.map +1 -0
  331. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.js +201 -0
  332. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts +57 -0
  333. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts.map +1 -0
  334. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.js +83 -0
  335. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts +33 -0
  336. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts.map +1 -0
  337. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.js +33 -0
  338. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts +86 -0
  339. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts.map +1 -0
  340. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.js +191 -0
  341. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts +137 -0
  342. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts.map +1 -0
  343. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.js +349 -0
  344. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts +274 -0
  345. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts.map +1 -0
  346. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.js +932 -0
  347. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts +210 -0
  348. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts.map +1 -0
  349. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.js +368 -0
  350. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts +63 -0
  351. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts.map +1 -0
  352. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.js +149 -0
  353. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts +35 -0
  354. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts.map +1 -0
  355. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.js +179 -0
  356. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts +179 -0
  357. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts.map +1 -0
  358. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.js +299 -0
  359. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts +395 -0
  360. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts.map +1 -0
  361. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.js +839 -0
  362. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts +44 -0
  363. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts.map +1 -0
  364. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.js +255 -0
  365. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts +185 -0
  366. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts.map +1 -0
  367. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.js +504 -0
  368. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts +17 -0
  369. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts.map +1 -0
  370. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.js +80 -0
  371. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts +221 -0
  372. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts.map +1 -0
  373. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.js +188 -0
  374. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts +52 -0
  375. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts.map +1 -0
  376. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.js +102 -0
  377. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts +171 -0
  378. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts.map +1 -0
  379. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.js +271 -0
  380. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts +242 -0
  381. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts.map +1 -0
  382. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.js +58 -0
  383. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts +128 -0
  384. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts.map +1 -0
  385. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.js +113 -0
  386. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts +41 -0
  387. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts.map +1 -0
  388. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.js +52 -0
  389. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts +2 -0
  390. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts.map +1 -0
  391. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.js +351 -0
  392. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts +157 -0
  393. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts.map +1 -0
  394. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.js +688 -0
  395. package/node_modules/@try-works/tool-mode-extension-sdk/package.json +54 -0
  396. package/node_modules/@try-works/tool-mode-extension-sdk/schema/extension-manifest-1.1.0.schema.json +253 -0
  397. package/node_modules/@try-works/tool-mode-recipes/bin/tool-mode-recipe.mjs +15 -0
  398. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts +460 -0
  399. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts.map +1 -0
  400. package/node_modules/@try-works/tool-mode-recipes/lib/broker.js +647 -0
  401. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts +61 -0
  402. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts.map +1 -0
  403. package/node_modules/@try-works/tool-mode-recipes/lib/cli.js +1106 -0
  404. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts +237 -0
  405. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts.map +1 -0
  406. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.js +205 -0
  407. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts +85 -0
  408. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts.map +1 -0
  409. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.js +176 -0
  410. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts +119 -0
  411. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts.map +1 -0
  412. package/node_modules/@try-works/tool-mode-recipes/lib/images.js +201 -0
  413. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts +25 -0
  414. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts.map +1 -0
  415. package/node_modules/@try-works/tool-mode-recipes/lib/index.js +25 -0
  416. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts +345 -0
  417. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts.map +1 -0
  418. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.js +1465 -0
  419. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts +51 -0
  420. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts.map +1 -0
  421. package/node_modules/@try-works/tool-mode-recipes/lib/templates.js +310 -0
  422. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts +231 -0
  423. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts.map +1 -0
  424. package/node_modules/@try-works/tool-mode-recipes/lib/titles.js +435 -0
  425. package/node_modules/@try-works/tool-mode-recipes/package.json +56 -0
  426. package/node_modules/@try-works/tool-mode-recipes/recipes/describe-image.json +38 -0
  427. package/node_modules/@try-works/tool-mode-recipes/recipes/text-title.json +45 -0
  428. package/node_modules/@try-works/tool-mode-recipes/schema/harness-model-recipe.schema.json +273 -0
  429. package/package.json +127 -4
  430. package/remote/spec.mjs +993 -0
  431. package/remote/typert.host.mjs +14 -0
  432. package/remote/typert.remote-client.mjs +16 -0
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Host service for authoring, testing and registering custom tools.
3
+ *
4
+ * This is the single seam behind the Remote methods and the plugin's startup
5
+ * restore. It owns no UI and no transport; every external dependency (model,
6
+ * credential store, tool dispatcher, fetch) is injected.
7
+ *
8
+ * @module @try-works/dsh-tool-mode/custom-tools/service
9
+ */
10
+ import { executeCustomTool } from "./dispatch.js";
11
+ import { normalizeCustomToolDraft } from "./schema.js";
12
+ function summary(record) {
13
+ return {
14
+ id: record.id,
15
+ name: record.name,
16
+ title: record.title,
17
+ description: record.description,
18
+ kind: record.execution.kind,
19
+ version: record.version,
20
+ enabled: record.enabled,
21
+ agentExpose: record.policy.agentExpose,
22
+ mcpExpose: record.policy.mcpExpose,
23
+ updatedAt: record.updatedAt,
24
+ };
25
+ }
26
+ /** The service used by Remote and startup restore. */
27
+ export class CustomToolsService {
28
+ store;
29
+ registrar;
30
+ dispatch;
31
+ draftModel;
32
+ constructor(options) {
33
+ this.store = options.store;
34
+ this.registrar = options.registrar;
35
+ this.draftModel = options.draftModel;
36
+ this.dispatch = {
37
+ ...options.dispatch,
38
+ ...options.resolveCredential === undefined
39
+ ? {}
40
+ : {
41
+ http: {
42
+ ...options.dispatch?.http,
43
+ resolveCredential: options.resolveCredential,
44
+ },
45
+ },
46
+ };
47
+ }
48
+ /** Read the list model without exposing definitions or secrets. */
49
+ describe() {
50
+ const tools = this.store.list().map(summary);
51
+ return { store: this.store.rootDir, writable: true, tools };
52
+ }
53
+ /** Read one full record for editing; header secret values are references only. */
54
+ get(id) {
55
+ return this.store.read(id);
56
+ }
57
+ /** Restore every enabled, agent-exposed tool at startup. */
58
+ sync() {
59
+ return this.registrar.sync();
60
+ }
61
+ /** Validate a draft without persisting it. */
62
+ validate(raw) {
63
+ try {
64
+ normalizeCustomToolDraft(raw);
65
+ return { ok: true, issues: [] };
66
+ }
67
+ catch (error) {
68
+ return {
69
+ ok: false,
70
+ issues: error.issues ?? [{
71
+ path: '',
72
+ message: error instanceof Error ? error.message : String(error),
73
+ }],
74
+ };
75
+ }
76
+ }
77
+ /** Execute a draft once; never persists or registers it. */
78
+ async test(raw, args) {
79
+ let draft;
80
+ try {
81
+ draft = normalizeCustomToolDraft(raw);
82
+ }
83
+ catch (error) {
84
+ return {
85
+ ok: false,
86
+ error: {
87
+ code: 'custom-tool-invalid',
88
+ message: error instanceof Error ? error.message : String(error),
89
+ },
90
+ };
91
+ }
92
+ // A test record has no durable identity/version; use a synthetic record with
93
+ // the draft's shape so the compiler/executor contract is identical.
94
+ const now = new Date().toISOString();
95
+ const record = {
96
+ schemaVersion: 1,
97
+ ...draft,
98
+ version: 0,
99
+ enabled: true,
100
+ createdAt: now,
101
+ updatedAt: now,
102
+ };
103
+ try {
104
+ const value = await executeCustomTool(record, args, {
105
+ signal: new AbortController().signal,
106
+ }, this.dispatch);
107
+ return { ok: true, value };
108
+ }
109
+ catch (error) {
110
+ return {
111
+ ok: false,
112
+ error: {
113
+ code: error.code ?? 'custom-tool-test-failed',
114
+ message: error instanceof Error ? error.message : String(error),
115
+ },
116
+ };
117
+ }
118
+ }
119
+ /**
120
+ * Ask the host model for a draft from a natural-language description. The
121
+ * result is validated but never saved, registered or executed.
122
+ */
123
+ async draft(description) {
124
+ if (this.draftModel === undefined) {
125
+ return { ok: false, error: { code: 'custom-tool-draft-unavailable', message: 'no host model is composed for drafting' } };
126
+ }
127
+ if (description.trim().length === 0) {
128
+ return { ok: false, error: { code: 'custom-tool-draft-invalid', message: 'describe the tool you want before drafting' } };
129
+ }
130
+ const prompt = [
131
+ 'You are drafting one DSH custom tool definition. Return ONLY a JSON object, no markdown.',
132
+ 'The object MUST have these fields: id ("custom.<slug>"), name ("custom_<slug>"), title,',
133
+ 'description, parameters (JSON Schema object), execution, policy, examples.',
134
+ 'execution is one of:',
135
+ '{"kind":"http","http":{"method":"GET","url":"https://...","headers":{}}}',
136
+ '{"kind":"prompt","prompt":{"template":"...","maxOutputTokens":512}}',
137
+ '{"kind":"composite","composite":{"steps":[{"tool":"lang_detect","args":{"text":"{{text}}"}}]}}',
138
+ 'policy MUST contain timeoutMs, readOnly, networkOrigins (exact https origins; [] unless http),',
139
+ 'agentExpose (default true) and mcpExpose (default false).',
140
+ 'Never put a secret value in the object; use {"secret":"ENV_NAME"} in HTTP headers.',
141
+ 'The description field must explain when an agent should call the tool.',
142
+ 'User description:',
143
+ description,
144
+ ].join('\n');
145
+ let text;
146
+ try {
147
+ text = await this.draftModel(prompt, new AbortController().signal);
148
+ }
149
+ catch (error) {
150
+ return {
151
+ ok: false,
152
+ error: { code: 'custom-tool-draft-failed', message: error instanceof Error ? error.message : String(error) },
153
+ };
154
+ }
155
+ const start = text.indexOf('{');
156
+ const end = text.lastIndexOf('}');
157
+ if (start < 0 || end <= start) {
158
+ return { ok: false, error: { code: 'custom-tool-draft-invalid', message: 'the model did not return a JSON object' } };
159
+ }
160
+ try {
161
+ const draft = normalizeCustomToolDraft(JSON.parse(text.slice(start, end + 1)));
162
+ return { ok: true, draft };
163
+ }
164
+ catch (error) {
165
+ return {
166
+ ok: false,
167
+ error: {
168
+ code: 'custom-tool-draft-invalid',
169
+ message: error instanceof Error ? error.message : String(error),
170
+ },
171
+ };
172
+ }
173
+ }
174
+ /** Validate, persist a new immutable version and register it when exposed. */
175
+ save(raw) {
176
+ const draft = normalizeCustomToolDraft(raw);
177
+ const record = this.store.save(draft);
178
+ if (record.enabled && record.policy.agentExpose) {
179
+ this.registrar.register(record);
180
+ }
181
+ else {
182
+ this.registrar.dispose(record.id);
183
+ }
184
+ return record;
185
+ }
186
+ /** Enable/disable one tool and reconcile the live registration. */
187
+ setEnabled(id, enabled) {
188
+ const record = this.store.setEnabled(id, enabled);
189
+ if (enabled && record.policy.agentExpose) {
190
+ this.registrar.register(record);
191
+ }
192
+ else {
193
+ this.registrar.dispose(id);
194
+ }
195
+ return record;
196
+ }
197
+ /** Delete the active pointer and remove the live tool. */
198
+ delete(id) {
199
+ this.registrar.dispose(id);
200
+ return this.store.delete(id);
201
+ }
202
+ }
203
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Profile-scoped durable custom-tool store.
3
+ *
4
+ * The index is the only mutable document; each record version is immutable.
5
+ * Writes use a temp file + rename so a crash cannot leave a half-written active
6
+ * pointer, and an unreadable index fails closed instead of being treated as
7
+ * empty.
8
+ *
9
+ * @module @try-works/dsh-tool-mode/custom-tools/store
10
+ */
11
+ import { CustomToolSchemaError } from './schema.ts';
12
+ import type { CustomToolDraft, CustomToolIndex, CustomToolRecord } from './types.ts';
13
+ /** The current store/index schema. */
14
+ export declare const CUSTOM_TOOLS_SCHEMA_VERSION: 1;
15
+ /** A named refusal from the custom-tool store. */
16
+ export declare class CustomToolStoreError extends Error {
17
+ readonly name = "CustomToolStoreError";
18
+ readonly code: 'custom-tool-store-corrupt' | 'custom-tool-not-found' | 'custom-tool-id-invalid';
19
+ constructor(code: CustomToolStoreError['code'], message: string, options?: ErrorOptions);
20
+ }
21
+ /** Options for the store. */
22
+ export interface CustomToolStoreOptions {
23
+ /** Root directory holding the index and one directory per tool. */
24
+ readonly rootDir: string;
25
+ /** Clock seam for deterministic tests. */
26
+ readonly now?: () => Date;
27
+ }
28
+ /** Durable custom-tool records. */
29
+ export declare class CustomToolStore {
30
+ readonly rootDir: string;
31
+ readonly indexPath: string;
32
+ private readonly now;
33
+ constructor(options: CustomToolStoreOptions);
34
+ /** Read the index; a missing file is the only empty store. */
35
+ readIndex(): CustomToolIndex;
36
+ /** The active record ids, sorted for deterministic UI output. */
37
+ listIds(): readonly string[];
38
+ /** Read one active record; absent means the id is not active. */
39
+ read(id: string): CustomToolRecord | undefined;
40
+ /** Read a specific immutable version. */
41
+ readVersion(id: string, version: number, enabledOverride?: boolean): CustomToolRecord;
42
+ /** All active records, sorted by id. */
43
+ list(): readonly CustomToolRecord[];
44
+ /**
45
+ * Validate and persist a new version. The previous version is never mutated.
46
+ * @param draft - user-authored draft.
47
+ * @returns the persisted record.
48
+ */
49
+ save(draft: CustomToolDraft): CustomToolRecord;
50
+ /** Enable or disable one active tool. */
51
+ setEnabled(id: string, enabled: boolean): CustomToolRecord;
52
+ /** Remove the active pointer; immutable version files remain for audit. */
53
+ delete(id: string): boolean;
54
+ /** Version files present for one id (diagnostics/history). */
55
+ versions(id: string): readonly number[];
56
+ /** The absolute file for one version. */
57
+ versionPath(id: string, version: number): string;
58
+ private assertId;
59
+ }
60
+ export { CustomToolSchemaError };
61
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/custom-tools/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAA4B,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EAEf,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAEnB,sCAAsC;AACtC,eAAO,MAAM,2BAA2B,EAAG,CAAU,CAAA;AAErD,kDAAkD;AAClD,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,SAAkB,IAAI,0BAAyB;IAC/C,QAAQ,CAAC,IAAI,EAAE,2BAA2B,GAAG,uBAAuB,GAAG,wBAAwB,CAAA;gBAEnF,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIxF;AAED,6BAA6B;AAC7B,MAAM,WAAW,sBAAsB;IACrC,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,0CAA0C;IAC1C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;CAC1B;AA6CD,mCAAmC;AACnC,qBAAa,eAAe;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAY;gBAEpB,OAAO,EAAE,sBAAsB;IAM3C,8DAA8D;IAC9D,SAAS,IAAI,eAAe;IAU5B,iEAAiE;IACjE,OAAO,IAAI,SAAS,MAAM,EAAE;IAI5B,iEAAiE;IACjE,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAQ9C,yCAAyC;IACzC,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,OAAO,GAAG,gBAAgB;IA4CrF,wCAAwC;IACxC,IAAI,IAAI,SAAS,gBAAgB,EAAE;IASnC;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB;IAgC9C,yCAAyC;IACzC,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,gBAAgB;IAiB1D,2EAA2E;IAC3E,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAU3B,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE;IAYvC,yCAAyC;IACzC,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAIhD,OAAO,CAAC,QAAQ;CAKjB;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Profile-scoped durable custom-tool store.
3
+ *
4
+ * The index is the only mutable document; each record version is immutable.
5
+ * Writes use a temp file + rename so a crash cannot leave a half-written active
6
+ * pointer, and an unreadable index fails closed instead of being treated as
7
+ * empty.
8
+ *
9
+ * @module @try-works/dsh-tool-mode/custom-tools/store
10
+ */
11
+ import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from 'node:fs';
12
+ import { dirname, join } from 'node:path';
13
+ import { randomBytes } from 'node:crypto';
14
+ import { normalizeCustomToolDraft, CustomToolSchemaError } from "./schema.js";
15
+ /** The current store/index schema. */
16
+ export const CUSTOM_TOOLS_SCHEMA_VERSION = 1;
17
+ /** A named refusal from the custom-tool store. */
18
+ export class CustomToolStoreError extends Error {
19
+ name = 'CustomToolStoreError';
20
+ code;
21
+ constructor(code, message, options) {
22
+ super(message, options);
23
+ this.code = code;
24
+ }
25
+ }
26
+ function isRecord(value) {
27
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
28
+ }
29
+ function emptyIndex() {
30
+ return { schemaVersion: CUSTOM_TOOLS_SCHEMA_VERSION, tools: {} };
31
+ }
32
+ function defaultIndexPath(rootDir) {
33
+ return join(rootDir, 'index.json');
34
+ }
35
+ function idPattern() {
36
+ return /^custom\.[a-z0-9][a-z0-9-]*$/;
37
+ }
38
+ function writeJsonAtomic(file, value) {
39
+ mkdirSync(dirname(file), { recursive: true });
40
+ const temp = `${file}.${process.pid}.${randomBytes(6).toString('hex')}.tmp`;
41
+ writeFileSync(temp, `${JSON.stringify(value, null, 2)}\n`, { encoding: 'utf8', mode: 0o600 });
42
+ renameSync(temp, file);
43
+ }
44
+ function parseIndex(raw, source) {
45
+ if (!isRecord(raw) || raw['schemaVersion'] !== CUSTOM_TOOLS_SCHEMA_VERSION || !isRecord(raw['tools'])) {
46
+ throw new CustomToolStoreError('custom-tool-store-corrupt', `${source} is not a custom-tool index`);
47
+ }
48
+ const tools = {};
49
+ for (const [id, entry] of Object.entries(raw['tools'])) {
50
+ if (!idPattern().test(id) || !isRecord(entry)) {
51
+ throw new CustomToolStoreError('custom-tool-store-corrupt', `${source} has an invalid tool entry ${JSON.stringify(id)}`);
52
+ }
53
+ const activeVersion = entry['activeVersion'];
54
+ const updatedAt = entry['updatedAt'];
55
+ if (typeof activeVersion !== 'number' || !Number.isInteger(activeVersion) || activeVersion < 1
56
+ || typeof updatedAt !== 'string' || typeof entry['enabled'] !== 'boolean') {
57
+ throw new CustomToolStoreError('custom-tool-store-corrupt', `${source} has an invalid index entry for ${id}`);
58
+ }
59
+ tools[id] = { activeVersion, enabled: entry['enabled'], updatedAt };
60
+ }
61
+ return { schemaVersion: CUSTOM_TOOLS_SCHEMA_VERSION, tools };
62
+ }
63
+ /** Durable custom-tool records. */
64
+ export class CustomToolStore {
65
+ rootDir;
66
+ indexPath;
67
+ now;
68
+ constructor(options) {
69
+ this.rootDir = options.rootDir;
70
+ this.indexPath = defaultIndexPath(options.rootDir);
71
+ this.now = options.now ?? (() => new Date());
72
+ }
73
+ /** Read the index; a missing file is the only empty store. */
74
+ readIndex() {
75
+ if (!existsSync(this.indexPath))
76
+ return emptyIndex();
77
+ try {
78
+ return parseIndex(JSON.parse(readFileSync(this.indexPath, 'utf8')), this.indexPath);
79
+ }
80
+ catch (error) {
81
+ if (error instanceof CustomToolStoreError)
82
+ throw error;
83
+ throw new CustomToolStoreError('custom-tool-store-corrupt', `${this.indexPath} could not be read: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
84
+ }
85
+ }
86
+ /** The active record ids, sorted for deterministic UI output. */
87
+ listIds() {
88
+ return Object.keys(this.readIndex().tools).sort();
89
+ }
90
+ /** Read one active record; absent means the id is not active. */
91
+ read(id) {
92
+ this.assertId(id);
93
+ const index = this.readIndex();
94
+ const entry = index.tools[id];
95
+ if (entry === undefined)
96
+ return undefined;
97
+ return this.readVersion(id, entry.activeVersion, entry.enabled);
98
+ }
99
+ /** Read a specific immutable version. */
100
+ readVersion(id, version, enabledOverride) {
101
+ this.assertId(id);
102
+ const file = this.versionPath(id, version);
103
+ if (!existsSync(file)) {
104
+ throw new CustomToolStoreError('custom-tool-store-corrupt', `${id}@${version} is referenced but missing at ${file}`);
105
+ }
106
+ let parsed;
107
+ try {
108
+ parsed = JSON.parse(readFileSync(file, 'utf8'));
109
+ }
110
+ catch (error) {
111
+ throw new CustomToolStoreError('custom-tool-store-corrupt', `${file} could not be read: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
112
+ }
113
+ if (!isRecord(parsed)
114
+ || parsed['schemaVersion'] !== CUSTOM_TOOLS_SCHEMA_VERSION
115
+ || parsed['id'] !== id
116
+ || parsed['version'] !== version
117
+ || typeof parsed['name'] !== 'string'
118
+ || typeof parsed['createdAt'] !== 'string'
119
+ || typeof parsed['updatedAt'] !== 'string') {
120
+ throw new CustomToolStoreError('custom-tool-store-corrupt', `${file} is not a valid ${id}@${version} record`);
121
+ }
122
+ // Validate the persisted draft fields again; a tampered record must not be
123
+ // registered merely because it is syntactically JSON.
124
+ let draft;
125
+ try {
126
+ draft = normalizeCustomToolDraft(parsed);
127
+ }
128
+ catch (error) {
129
+ throw new CustomToolStoreError('custom-tool-store-corrupt', `${file} contains an invalid draft: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
130
+ }
131
+ const enabled = enabledOverride ?? parsed['enabled'] === true;
132
+ return {
133
+ schemaVersion: CUSTOM_TOOLS_SCHEMA_VERSION,
134
+ ...draft,
135
+ version,
136
+ enabled,
137
+ createdAt: parsed['createdAt'],
138
+ updatedAt: parsed['updatedAt'],
139
+ };
140
+ }
141
+ /** All active records, sorted by id. */
142
+ list() {
143
+ const index = this.readIndex();
144
+ return this.listIds().map(id => {
145
+ const entry = index.tools[id];
146
+ if (entry === undefined)
147
+ throw new CustomToolStoreError('custom-tool-store-corrupt', `${id} disappeared from the index`);
148
+ return this.readVersion(id, entry.activeVersion, entry.enabled);
149
+ });
150
+ }
151
+ /**
152
+ * Validate and persist a new version. The previous version is never mutated.
153
+ * @param draft - user-authored draft.
154
+ * @returns the persisted record.
155
+ */
156
+ save(draft) {
157
+ const normalized = normalizeCustomToolDraft(draft);
158
+ this.assertId(normalized.id);
159
+ const index = this.readIndex();
160
+ const existing = index.tools[normalized.id];
161
+ const version = existing === undefined ? 1 : existing.activeVersion + 1;
162
+ const now = this.now().toISOString();
163
+ const record = {
164
+ schemaVersion: CUSTOM_TOOLS_SCHEMA_VERSION,
165
+ ...normalized,
166
+ version,
167
+ enabled: existing?.enabled ?? true,
168
+ createdAt: existing === undefined ? now : this.readVersion(normalized.id, existing.activeVersion).createdAt,
169
+ updatedAt: now,
170
+ };
171
+ const recordFile = this.versionPath(normalized.id, version);
172
+ writeJsonAtomic(recordFile, record);
173
+ const next = {
174
+ schemaVersion: CUSTOM_TOOLS_SCHEMA_VERSION,
175
+ tools: {
176
+ ...index.tools,
177
+ [normalized.id]: {
178
+ activeVersion: version,
179
+ enabled: record.enabled,
180
+ updatedAt: now,
181
+ },
182
+ },
183
+ };
184
+ writeJsonAtomic(this.indexPath, next);
185
+ return record;
186
+ }
187
+ /** Enable or disable one active tool. */
188
+ setEnabled(id, enabled) {
189
+ this.assertId(id);
190
+ const index = this.readIndex();
191
+ const entry = index.tools[id];
192
+ if (entry === undefined)
193
+ throw new CustomToolStoreError('custom-tool-not-found', `${id} is not a custom tool`);
194
+ const now = this.now().toISOString();
195
+ const next = {
196
+ schemaVersion: CUSTOM_TOOLS_SCHEMA_VERSION,
197
+ tools: {
198
+ ...index.tools,
199
+ [id]: { ...entry, enabled, updatedAt: now },
200
+ },
201
+ };
202
+ writeJsonAtomic(this.indexPath, next);
203
+ return this.readVersion(id, entry.activeVersion, enabled);
204
+ }
205
+ /** Remove the active pointer; immutable version files remain for audit. */
206
+ delete(id) {
207
+ this.assertId(id);
208
+ const index = this.readIndex();
209
+ if (index.tools[id] === undefined)
210
+ return false;
211
+ const tools = { ...index.tools };
212
+ delete tools[id];
213
+ writeJsonAtomic(this.indexPath, { schemaVersion: CUSTOM_TOOLS_SCHEMA_VERSION, tools });
214
+ return true;
215
+ }
216
+ /** Version files present for one id (diagnostics/history). */
217
+ versions(id) {
218
+ this.assertId(id);
219
+ const dir = join(this.rootDir, id);
220
+ if (!existsSync(dir))
221
+ return [];
222
+ return readdirSync(dir)
223
+ .map(name => /^(\d+)\.json$/.exec(name)?.[1])
224
+ .filter((value) => value !== undefined)
225
+ .map(Number)
226
+ .filter(version => Number.isInteger(version) && version > 0)
227
+ .sort((a, b) => a - b);
228
+ }
229
+ /** The absolute file for one version. */
230
+ versionPath(id, version) {
231
+ return join(this.rootDir, id, `${version}.json`);
232
+ }
233
+ assertId(id) {
234
+ if (!idPattern().test(id)) {
235
+ throw new CustomToolStoreError('custom-tool-id-invalid', `${JSON.stringify(id)} is not a valid custom tool id`);
236
+ }
237
+ }
238
+ }
239
+ export { CustomToolSchemaError };
240
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Durable custom-tool authoring records.
3
+ *
4
+ * These are NOT runtime tool definitions. A record is validated, versioned and
5
+ * compiled into a `defineTool` definition by the host. Keeping the two separate
6
+ * lets the store reject a bad draft without ever exposing a partial tool.
7
+ *
8
+ * @module @try-works/dsh-tool-mode/custom-tools/types
9
+ */
10
+ /** The safe execution kinds supported in v1. */
11
+ export type CustomToolKind = 'http' | 'prompt' | 'composite';
12
+ /** One literal or credential-reference HTTP header. */
13
+ export type HttpHeaderValue = string | {
14
+ readonly secret: string;
15
+ };
16
+ /** The supported HTTP execution definition. */
17
+ export interface HttpExecution {
18
+ readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
19
+ /** Template URL; only `{{argument}}` leaves are interpolated. */
20
+ readonly url: string;
21
+ readonly headers: Readonly<Record<string, HttpHeaderValue>>;
22
+ /** Optional JSON body template with `{{argument}}` leaves. */
23
+ readonly bodyTemplate?: string;
24
+ /** Dot-path extraction from the JSON response; empty means the whole body. */
25
+ readonly extract?: string;
26
+ }
27
+ /** The supported prompt execution definition. */
28
+ export interface PromptExecution {
29
+ /** Template; only `{{argument}}` leaves are interpolated. */
30
+ readonly template: string;
31
+ /** Optional model id; absent means the deployment default. */
32
+ readonly model?: string;
33
+ readonly maxOutputTokens?: number;
34
+ }
35
+ /** One composite step. `{{steps.N.result}}` addresses a previous result. */
36
+ export interface CompositeStep {
37
+ readonly tool: string;
38
+ readonly args: Readonly<Record<string, string>>;
39
+ readonly requiresApproval?: boolean;
40
+ }
41
+ /** The supported composite execution definition. */
42
+ export interface CompositeExecution {
43
+ readonly steps: readonly CompositeStep[];
44
+ /** Optional selector for the final result; default is the last step. */
45
+ readonly output?: string;
46
+ }
47
+ /** The execution union carried by a record. */
48
+ export type CustomToolExecution = {
49
+ readonly kind: 'http';
50
+ readonly http: HttpExecution;
51
+ } | {
52
+ readonly kind: 'prompt';
53
+ readonly prompt: PromptExecution;
54
+ } | {
55
+ readonly kind: 'composite';
56
+ readonly composite: CompositeExecution;
57
+ };
58
+ /** Governance carried by every custom tool. */
59
+ export interface CustomToolPolicy {
60
+ /** Cooperative execution deadline. */
61
+ readonly timeoutMs: number;
62
+ /** Advisory read-only hint for the agent/UI. */
63
+ readonly readOnly: boolean;
64
+ /** Exact HTTPS origins the HTTP executor may reach. */
65
+ readonly networkOrigins: readonly string[];
66
+ /** Whether the tool is exposed to agents. */
67
+ readonly agentExpose: boolean;
68
+ /** Whether the tool is exposed over MCP. Default false. */
69
+ readonly mcpExpose: boolean;
70
+ }
71
+ /** One example shown in the form and used by the test panel. */
72
+ export interface CustomToolExample {
73
+ readonly title: string;
74
+ readonly arguments: Readonly<Record<string, unknown>>;
75
+ }
76
+ /** A complete, validated authoring record. */
77
+ export interface CustomToolRecord {
78
+ readonly schemaVersion: 1;
79
+ /** Stable id; also the directory name. */
80
+ readonly id: string;
81
+ /** DSH tool name (`custom_...`). */
82
+ readonly name: string;
83
+ readonly title: string;
84
+ readonly description: string;
85
+ /** JSON Schema object for arguments. */
86
+ readonly parameters: Readonly<Record<string, unknown>>;
87
+ /** Optional JSON Schema for the canonical result. */
88
+ readonly outputSchema?: Readonly<Record<string, unknown>>;
89
+ readonly execution: CustomToolExecution;
90
+ readonly policy: CustomToolPolicy;
91
+ readonly examples: readonly CustomToolExample[];
92
+ readonly version: number;
93
+ readonly enabled: boolean;
94
+ readonly createdAt: string;
95
+ readonly updatedAt: string;
96
+ }
97
+ /** A user-editable draft before it has an id/version/timestamps. */
98
+ export interface CustomToolDraft {
99
+ readonly id: string;
100
+ readonly name: string;
101
+ readonly title: string;
102
+ readonly description: string;
103
+ readonly parameters: Readonly<Record<string, unknown>>;
104
+ readonly outputSchema?: Readonly<Record<string, unknown>>;
105
+ readonly execution: CustomToolExecution;
106
+ readonly policy: CustomToolPolicy;
107
+ readonly examples: readonly CustomToolExample[];
108
+ }
109
+ /** The active entry for one custom tool. */
110
+ export interface CustomToolIndexEntry {
111
+ readonly activeVersion: number;
112
+ readonly enabled: boolean;
113
+ readonly updatedAt: string;
114
+ }
115
+ /** The durable index document. */
116
+ export interface CustomToolIndex {
117
+ readonly schemaVersion: 1;
118
+ readonly tools: Readonly<Record<string, CustomToolIndexEntry>>;
119
+ }
120
+ /** One validation issue, safe to render in the form. */
121
+ export interface CustomToolIssue {
122
+ /** Dot path into the draft. */
123
+ readonly path: string;
124
+ readonly message: string;
125
+ }
126
+ /** The validation verdict for a draft. */
127
+ export interface CustomToolValidation {
128
+ readonly ok: boolean;
129
+ readonly issues: readonly CustomToolIssue[];
130
+ }
131
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/custom-tools/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,gDAAgD;AAChD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAA;AAE5D,uDAAuD;AACvD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAElE,+CAA+C;AAC/C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC5D,iEAAiE;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM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,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAA;CAC5C"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Durable custom-tool authoring records.
3
+ *
4
+ * These are NOT runtime tool definitions. A record is validated, versioned and
5
+ * compiled into a `defineTool` definition by the host. Keeping the two separate
6
+ * lets the store reject a bad draft without ever exposing a partial tool.
7
+ *
8
+ * @module @try-works/dsh-tool-mode/custom-tools/types
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=types.js.map