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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (425) hide show
  1. package/README.md +299 -2
  2. package/bin/dsh-tool-mode-credentials.mjs +20 -0
  3. package/bin/dsh-tool-mode-mcp-stdio.mjs +80 -0
  4. package/bin/dsh-tool-mode.mjs +211 -0
  5. package/builtins.lock.json +26 -0
  6. package/catalog/desert-ant-models.json +693 -0
  7. package/catalog/playbooks.json +531 -0
  8. package/client/client.model-tools.js +1910 -0
  9. package/client/index.js +4039 -0
  10. package/cordis.patch.yml +39 -0
  11. package/lib/adapters/index.d.ts +61 -0
  12. package/lib/adapters/index.d.ts.map +1 -0
  13. package/lib/adapters/index.js +82 -0
  14. package/lib/adapters/types.d.ts +106 -0
  15. package/lib/adapters/types.d.ts.map +1 -0
  16. package/lib/adapters/types.js +85 -0
  17. package/lib/approval.d.ts +189 -0
  18. package/lib/approval.d.ts.map +1 -0
  19. package/lib/approval.js +510 -0
  20. package/lib/asset-acquisition.d.ts +149 -0
  21. package/lib/asset-acquisition.d.ts.map +1 -0
  22. package/lib/asset-acquisition.js +175 -0
  23. package/lib/authority.d.ts +185 -0
  24. package/lib/authority.d.ts.map +1 -0
  25. package/lib/authority.js +223 -0
  26. package/lib/bindings.d.ts +144 -0
  27. package/lib/bindings.d.ts.map +1 -0
  28. package/lib/bindings.js +314 -0
  29. package/lib/builtins.d.ts +27 -0
  30. package/lib/builtins.d.ts.map +1 -0
  31. package/lib/builtins.js +37 -0
  32. package/lib/capability.d.ts +58 -0
  33. package/lib/capability.d.ts.map +1 -0
  34. package/lib/capability.js +192 -0
  35. package/lib/capture-path.d.ts +97 -0
  36. package/lib/capture-path.d.ts.map +1 -0
  37. package/lib/capture-path.js +152 -0
  38. package/lib/catalog.d.ts +37 -0
  39. package/lib/catalog.d.ts.map +1 -0
  40. package/lib/catalog.js +274 -0
  41. package/lib/contract-payload.d.ts +39 -0
  42. package/lib/contract-payload.d.ts.map +1 -0
  43. package/lib/contract-payload.js +56 -0
  44. package/lib/custom-tools/compile.d.ts +25 -0
  45. package/lib/custom-tools/compile.d.ts.map +1 -0
  46. package/lib/custom-tools/compile.js +61 -0
  47. package/lib/custom-tools/composite-executor.d.ts +42 -0
  48. package/lib/custom-tools/composite-executor.d.ts.map +1 -0
  49. package/lib/custom-tools/composite-executor.js +113 -0
  50. package/lib/custom-tools/dispatch.d.ts +28 -0
  51. package/lib/custom-tools/dispatch.d.ts.map +1 -0
  52. package/lib/custom-tools/dispatch.js +34 -0
  53. package/lib/custom-tools/http-executor.d.ts +48 -0
  54. package/lib/custom-tools/http-executor.d.ts.map +1 -0
  55. package/lib/custom-tools/http-executor.js +241 -0
  56. package/lib/custom-tools/index.d.ts +12 -0
  57. package/lib/custom-tools/index.d.ts.map +1 -0
  58. package/lib/custom-tools/index.js +12 -0
  59. package/lib/custom-tools/mcp-surface.d.ts +14 -0
  60. package/lib/custom-tools/mcp-surface.d.ts.map +1 -0
  61. package/lib/custom-tools/mcp-surface.js +41 -0
  62. package/lib/custom-tools/prompt-executor.d.ts +39 -0
  63. package/lib/custom-tools/prompt-executor.d.ts.map +1 -0
  64. package/lib/custom-tools/prompt-executor.js +59 -0
  65. package/lib/custom-tools/registry.d.ts +69 -0
  66. package/lib/custom-tools/registry.d.ts.map +1 -0
  67. package/lib/custom-tools/registry.js +130 -0
  68. package/lib/custom-tools/schema.d.ts +26 -0
  69. package/lib/custom-tools/schema.d.ts.map +1 -0
  70. package/lib/custom-tools/schema.js +375 -0
  71. package/lib/custom-tools/service.d.ts +90 -0
  72. package/lib/custom-tools/service.d.ts.map +1 -0
  73. package/lib/custom-tools/service.js +203 -0
  74. package/lib/custom-tools/store.d.ts +61 -0
  75. package/lib/custom-tools/store.d.ts.map +1 -0
  76. package/lib/custom-tools/store.js +240 -0
  77. package/lib/custom-tools/types.d.ts +131 -0
  78. package/lib/custom-tools/types.d.ts.map +1 -0
  79. package/lib/custom-tools/types.js +11 -0
  80. package/lib/decision-combine.d.ts +113 -0
  81. package/lib/decision-combine.d.ts.map +1 -0
  82. package/lib/decision-combine.js +156 -0
  83. package/lib/decision-evaluate.d.ts +185 -0
  84. package/lib/decision-evaluate.d.ts.map +1 -0
  85. package/lib/decision-evaluate.js +227 -0
  86. package/lib/deployment-coordinator.d.ts +213 -0
  87. package/lib/deployment-coordinator.d.ts.map +1 -0
  88. package/lib/deployment-coordinator.js +274 -0
  89. package/lib/diagnostics.d.ts +169 -0
  90. package/lib/diagnostics.d.ts.map +1 -0
  91. package/lib/diagnostics.js +136 -0
  92. package/lib/discovery-contracts.d.ts +14 -0
  93. package/lib/discovery-contracts.d.ts.map +1 -0
  94. package/lib/discovery-contracts.js +90 -0
  95. package/lib/discovery-describe.d.ts +35 -0
  96. package/lib/discovery-describe.d.ts.map +1 -0
  97. package/lib/discovery-describe.js +99 -0
  98. package/lib/embedding-index.d.ts +55 -0
  99. package/lib/embedding-index.d.ts.map +1 -0
  100. package/lib/embedding-index.js +126 -0
  101. package/lib/extension-dependencies.d.ts +355 -0
  102. package/lib/extension-dependencies.d.ts.map +1 -0
  103. package/lib/extension-dependencies.js +987 -0
  104. package/lib/extension-dispatch.d.ts +150 -0
  105. package/lib/extension-dispatch.d.ts.map +1 -0
  106. package/lib/extension-dispatch.js +178 -0
  107. package/lib/extension-page-state.d.ts +69 -0
  108. package/lib/extension-page-state.d.ts.map +1 -0
  109. package/lib/extension-page-state.js +82 -0
  110. package/lib/extension-registrar.d.ts +116 -0
  111. package/lib/extension-registrar.d.ts.map +1 -0
  112. package/lib/extension-registrar.js +144 -0
  113. package/lib/extensions-api.d.ts +346 -0
  114. package/lib/extensions-api.d.ts.map +1 -0
  115. package/lib/extensions-api.js +17 -0
  116. package/lib/extensions-remote.d.ts +57 -0
  117. package/lib/extensions-remote.d.ts.map +1 -0
  118. package/lib/extensions-remote.js +69 -0
  119. package/lib/extensions-service.d.ts +568 -0
  120. package/lib/extensions-service.d.ts.map +1 -0
  121. package/lib/extensions-service.js +2507 -0
  122. package/lib/harness-budgets.d.ts +158 -0
  123. package/lib/harness-budgets.d.ts.map +1 -0
  124. package/lib/harness-budgets.js +152 -0
  125. package/lib/harness-llm.d.ts +138 -0
  126. package/lib/harness-llm.d.ts.map +1 -0
  127. package/lib/harness-llm.js +218 -0
  128. package/lib/harness-serving.d.ts +115 -0
  129. package/lib/harness-serving.d.ts.map +1 -0
  130. package/lib/harness-serving.js +176 -0
  131. package/lib/headless.d.ts +97 -0
  132. package/lib/headless.d.ts.map +1 -0
  133. package/lib/headless.js +407 -0
  134. package/lib/http-acquisition.d.ts +27 -0
  135. package/lib/http-acquisition.d.ts.map +1 -0
  136. package/lib/http-acquisition.js +140 -0
  137. package/lib/index.d.ts +546 -0
  138. package/lib/index.d.ts.map +1 -0
  139. package/lib/index.js +5197 -0
  140. package/lib/invocation-accounting.d.ts +169 -0
  141. package/lib/invocation-accounting.d.ts.map +1 -0
  142. package/lib/invocation-accounting.js +148 -0
  143. package/lib/jev.d.ts +218 -0
  144. package/lib/jev.d.ts.map +1 -0
  145. package/lib/jev.js +366 -0
  146. package/lib/legacy-migration.d.ts +95 -0
  147. package/lib/legacy-migration.d.ts.map +1 -0
  148. package/lib/legacy-migration.js +429 -0
  149. package/lib/license-basis.d.ts +29 -0
  150. package/lib/license-basis.d.ts.map +1 -0
  151. package/lib/license-basis.js +58 -0
  152. package/lib/managed-workers.d.ts +158 -0
  153. package/lib/managed-workers.d.ts.map +1 -0
  154. package/lib/managed-workers.js +269 -0
  155. package/lib/mcp/auth-selection.d.ts +35 -0
  156. package/lib/mcp/auth-selection.d.ts.map +1 -0
  157. package/lib/mcp/auth-selection.js +64 -0
  158. package/lib/mcp/client-grant.d.ts +89 -0
  159. package/lib/mcp/client-grant.d.ts.map +1 -0
  160. package/lib/mcp/client-grant.js +63 -0
  161. package/lib/mcp/credential-cli.d.ts +38 -0
  162. package/lib/mcp/credential-cli.d.ts.map +1 -0
  163. package/lib/mcp/credential-cli.js +148 -0
  164. package/lib/mcp/credential-store.d.ts +143 -0
  165. package/lib/mcp/credential-store.d.ts.map +1 -0
  166. package/lib/mcp/credential-store.js +461 -0
  167. package/lib/mcp/export-policy.d.ts +25 -0
  168. package/lib/mcp/export-policy.d.ts.map +1 -0
  169. package/lib/mcp/export-policy.js +31 -0
  170. package/lib/mcp/host-binding.d.ts +144 -0
  171. package/lib/mcp/host-binding.d.ts.map +1 -0
  172. package/lib/mcp/host-binding.js +280 -0
  173. package/lib/mcp/http.d.ts +180 -0
  174. package/lib/mcp/http.d.ts.map +1 -0
  175. package/lib/mcp/http.js +602 -0
  176. package/lib/mcp/oauth.d.ts +149 -0
  177. package/lib/mcp/oauth.d.ts.map +1 -0
  178. package/lib/mcp/oauth.js +396 -0
  179. package/lib/mcp/protocol.d.ts +329 -0
  180. package/lib/mcp/protocol.d.ts.map +1 -0
  181. package/lib/mcp/protocol.js +459 -0
  182. package/lib/mcp/rate-limit.d.ts +68 -0
  183. package/lib/mcp/rate-limit.d.ts.map +1 -0
  184. package/lib/mcp/rate-limit.js +114 -0
  185. package/lib/mcp/sdk-v2.d.ts +17 -0
  186. package/lib/mcp/sdk-v2.d.ts.map +1 -0
  187. package/lib/mcp/sdk-v2.js +204 -0
  188. package/lib/mcp/server.d.ts +149 -0
  189. package/lib/mcp/server.d.ts.map +1 -0
  190. package/lib/mcp/server.js +302 -0
  191. package/lib/mcp/stdio.d.ts +80 -0
  192. package/lib/mcp/stdio.d.ts.map +1 -0
  193. package/lib/mcp/stdio.js +184 -0
  194. package/lib/mcp/subscriptions.d.ts +177 -0
  195. package/lib/mcp/subscriptions.d.ts.map +1 -0
  196. package/lib/mcp/subscriptions.js +288 -0
  197. package/lib/mcp-status.d.ts +96 -0
  198. package/lib/mcp-status.d.ts.map +1 -0
  199. package/lib/mcp-status.js +70 -0
  200. package/lib/mcp-usage.d.ts +110 -0
  201. package/lib/mcp-usage.d.ts.map +1 -0
  202. package/lib/mcp-usage.js +189 -0
  203. package/lib/model-qualification.d.ts +192 -0
  204. package/lib/model-qualification.d.ts.map +1 -0
  205. package/lib/model-qualification.js +178 -0
  206. package/lib/planning.d.ts +256 -0
  207. package/lib/planning.d.ts.map +1 -0
  208. package/lib/planning.js +471 -0
  209. package/lib/playbook.d.ts +42 -0
  210. package/lib/playbook.d.ts.map +1 -0
  211. package/lib/playbook.js +65 -0
  212. package/lib/prepared-assets.d.ts +269 -0
  213. package/lib/prepared-assets.d.ts.map +1 -0
  214. package/lib/prepared-assets.js +471 -0
  215. package/lib/provider-bridge.d.ts +107 -0
  216. package/lib/provider-bridge.d.ts.map +1 -0
  217. package/lib/provider-bridge.js +423 -0
  218. package/lib/ptc-authority.d.ts +154 -0
  219. package/lib/ptc-authority.d.ts.map +1 -0
  220. package/lib/ptc-authority.js +242 -0
  221. package/lib/ptc-confinement.d.ts +60 -0
  222. package/lib/ptc-confinement.d.ts.map +1 -0
  223. package/lib/ptc-confinement.js +212 -0
  224. package/lib/ptc-runtime.d.ts +166 -0
  225. package/lib/ptc-runtime.d.ts.map +1 -0
  226. package/lib/ptc-runtime.js +231 -0
  227. package/lib/publication.d.ts +161 -0
  228. package/lib/publication.d.ts.map +1 -0
  229. package/lib/publication.js +181 -0
  230. package/lib/receipt-store.d.ts +57 -0
  231. package/lib/receipt-store.d.ts.map +1 -0
  232. package/lib/receipt-store.js +143 -0
  233. package/lib/receipt.d.ts +231 -0
  234. package/lib/receipt.d.ts.map +1 -0
  235. package/lib/receipt.js +165 -0
  236. package/lib/registrar.d.ts +75 -0
  237. package/lib/registrar.d.ts.map +1 -0
  238. package/lib/registrar.js +152 -0
  239. package/lib/resource-governance.d.ts +204 -0
  240. package/lib/resource-governance.d.ts.map +1 -0
  241. package/lib/resource-governance.js +213 -0
  242. package/lib/server-lifecycle.d.ts +175 -0
  243. package/lib/server-lifecycle.d.ts.map +1 -0
  244. package/lib/server-lifecycle.js +269 -0
  245. package/lib/skills.d.ts +31 -0
  246. package/lib/skills.d.ts.map +1 -0
  247. package/lib/skills.js +170 -0
  248. package/lib/speech-bridge.d.ts +74 -0
  249. package/lib/speech-bridge.d.ts.map +1 -0
  250. package/lib/speech-bridge.js +115 -0
  251. package/lib/state.d.ts +100 -0
  252. package/lib/state.d.ts.map +1 -0
  253. package/lib/state.js +160 -0
  254. package/lib/title-proposal.d.ts +194 -0
  255. package/lib/title-proposal.d.ts.map +1 -0
  256. package/lib/title-proposal.js +244 -0
  257. package/lib/tool-inventory.d.ts +90 -0
  258. package/lib/tool-inventory.d.ts.map +1 -0
  259. package/lib/tool-inventory.js +102 -0
  260. package/lib/tool-mode-run.d.ts +310 -0
  261. package/lib/tool-mode-run.d.ts.map +1 -0
  262. package/lib/tool-mode-run.js +411 -0
  263. package/lib/tool-sources.d.ts +80 -0
  264. package/lib/tool-sources.d.ts.map +1 -0
  265. package/lib/tool-sources.js +123 -0
  266. package/lib/tool-usage-projection.d.ts +390 -0
  267. package/lib/tool-usage-projection.d.ts.map +1 -0
  268. package/lib/tool-usage-projection.js +1038 -0
  269. package/lib/tool-usage-report.d.ts +153 -0
  270. package/lib/tool-usage-report.d.ts.map +1 -0
  271. package/lib/tool-usage-report.js +274 -0
  272. package/lib/transport.d.ts +158 -0
  273. package/lib/transport.d.ts.map +1 -0
  274. package/lib/transport.js +332 -0
  275. package/lib/types.d.ts +134 -0
  276. package/lib/types.d.ts.map +1 -0
  277. package/lib/types.js +8 -0
  278. package/lib/update-surface.d.ts +79 -0
  279. package/lib/update-surface.d.ts.map +1 -0
  280. package/lib/update-surface.js +224 -0
  281. package/lib/version.d.ts +3 -0
  282. package/lib/version.d.ts.map +1 -0
  283. package/lib/version.js +27 -0
  284. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts +13 -0
  285. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.d.ts.map +1 -0
  286. package/node_modules/@try-works/tool-mode-contracts/lib/contract-metadata.js +85 -0
  287. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts +16 -0
  288. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts.map +1 -0
  289. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.js +87 -0
  290. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts +38 -0
  291. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts.map +1 -0
  292. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.js +445 -0
  293. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts +20 -0
  294. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts.map +1 -0
  295. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.js +112 -0
  296. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts +14 -0
  297. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts.map +1 -0
  298. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.js +63 -0
  299. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts +14 -0
  300. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts.map +1 -0
  301. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.js +76 -0
  302. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts +82 -0
  303. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts.map +1 -0
  304. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.js +274 -0
  305. package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts +26 -0
  306. package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts.map +1 -0
  307. package/node_modules/@try-works/tool-mode-contracts/lib/index.js +53 -0
  308. package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts +133 -0
  309. package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts.map +1 -0
  310. package/node_modules/@try-works/tool-mode-contracts/lib/meta.js +64 -0
  311. package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts +121 -0
  312. package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts.map +1 -0
  313. package/node_modules/@try-works/tool-mode-contracts/lib/registry.js +246 -0
  314. package/node_modules/@try-works/tool-mode-contracts/package.json +35 -0
  315. package/node_modules/@try-works/tool-mode-extension-sdk/bin/dsh-tool-mode.mjs +20 -0
  316. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts +80 -0
  317. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts.map +1 -0
  318. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.js +533 -0
  319. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts +86 -0
  320. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts.map +1 -0
  321. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.js +145 -0
  322. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts +70 -0
  323. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts.map +1 -0
  324. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.js +201 -0
  325. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts +57 -0
  326. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts.map +1 -0
  327. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.js +83 -0
  328. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts +33 -0
  329. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts.map +1 -0
  330. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.js +33 -0
  331. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts +86 -0
  332. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts.map +1 -0
  333. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.js +191 -0
  334. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts +137 -0
  335. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts.map +1 -0
  336. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.js +349 -0
  337. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts +274 -0
  338. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts.map +1 -0
  339. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.js +932 -0
  340. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts +210 -0
  341. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts.map +1 -0
  342. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.js +368 -0
  343. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts +63 -0
  344. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts.map +1 -0
  345. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.js +149 -0
  346. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts +35 -0
  347. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts.map +1 -0
  348. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.js +179 -0
  349. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts +179 -0
  350. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts.map +1 -0
  351. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.js +299 -0
  352. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts +395 -0
  353. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts.map +1 -0
  354. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.js +839 -0
  355. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts +44 -0
  356. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts.map +1 -0
  357. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.js +255 -0
  358. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts +185 -0
  359. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts.map +1 -0
  360. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.js +504 -0
  361. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts +17 -0
  362. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts.map +1 -0
  363. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.js +80 -0
  364. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts +221 -0
  365. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.d.ts.map +1 -0
  366. package/node_modules/@try-works/tool-mode-extension-sdk/lib/licensing.js +188 -0
  367. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts +52 -0
  368. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts.map +1 -0
  369. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.js +102 -0
  370. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts +171 -0
  371. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts.map +1 -0
  372. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.js +271 -0
  373. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts +242 -0
  374. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts.map +1 -0
  375. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.js +58 -0
  376. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts +128 -0
  377. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts.map +1 -0
  378. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.js +113 -0
  379. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts +41 -0
  380. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.d.ts.map +1 -0
  381. package/node_modules/@try-works/tool-mode-extension-sdk/lib/test-host.js +52 -0
  382. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts +2 -0
  383. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts.map +1 -0
  384. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.js +351 -0
  385. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts +157 -0
  386. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts.map +1 -0
  387. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.js +688 -0
  388. package/node_modules/@try-works/tool-mode-extension-sdk/package.json +54 -0
  389. package/node_modules/@try-works/tool-mode-extension-sdk/schema/extension-manifest-1.1.0.schema.json +253 -0
  390. package/node_modules/@try-works/tool-mode-recipes/bin/tool-mode-recipe.mjs +15 -0
  391. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts +460 -0
  392. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts.map +1 -0
  393. package/node_modules/@try-works/tool-mode-recipes/lib/broker.js +647 -0
  394. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts +61 -0
  395. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts.map +1 -0
  396. package/node_modules/@try-works/tool-mode-recipes/lib/cli.js +1106 -0
  397. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts +237 -0
  398. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts.map +1 -0
  399. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.js +205 -0
  400. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts +85 -0
  401. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts.map +1 -0
  402. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.js +176 -0
  403. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts +119 -0
  404. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts.map +1 -0
  405. package/node_modules/@try-works/tool-mode-recipes/lib/images.js +201 -0
  406. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts +25 -0
  407. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts.map +1 -0
  408. package/node_modules/@try-works/tool-mode-recipes/lib/index.js +25 -0
  409. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts +345 -0
  410. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts.map +1 -0
  411. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.js +1465 -0
  412. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts +51 -0
  413. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts.map +1 -0
  414. package/node_modules/@try-works/tool-mode-recipes/lib/templates.js +310 -0
  415. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts +231 -0
  416. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts.map +1 -0
  417. package/node_modules/@try-works/tool-mode-recipes/lib/titles.js +435 -0
  418. package/node_modules/@try-works/tool-mode-recipes/package.json +56 -0
  419. package/node_modules/@try-works/tool-mode-recipes/recipes/describe-image.json +38 -0
  420. package/node_modules/@try-works/tool-mode-recipes/recipes/text-title.json +45 -0
  421. package/node_modules/@try-works/tool-mode-recipes/schema/harness-model-recipe.schema.json +273 -0
  422. package/package.json +127 -4
  423. package/remote/spec.mjs +993 -0
  424. package/remote/typert.host.mjs +14 -0
  425. package/remote/typert.remote-client.mjs +16 -0
@@ -0,0 +1,411 @@
1
+ /**
2
+ * The ONE authorized program-execution pipeline (CODE-02, CODE-03, CODE-08, ARCH-05).
3
+ *
4
+ * THE DEFECT THIS FIXES, found by adversarial review rather than by a test:
5
+ * `ptc-authority.ts` and `ptc-runtime.ts` had **zero callers outside tests**. Everything in
6
+ * them was correct and thoroughly covered — `buildToolBindings`, the guarded mount,
7
+ * `mayExposeToClients()` — and none of it ran in production. `tool_mode_run` did not exist,
8
+ * the mount guard never executed, and the exposure gate guarded nothing because there was
9
+ * no caller to refuse.
10
+ *
11
+ * A security control with no callers is not a control; it is a symbol. This module is the
12
+ * caller.
13
+ *
14
+ * The wiring enforces three things the directive requires and nothing else did:
15
+ *
16
+ * 1. **ONE pipeline.** Native PTC and any external `tool_mode_run` reach tools through the
17
+ * SAME `buildToolBindings` call, so authorization cannot differ between the two doors.
18
+ * 2. **The grant is the grant.** The requested names are intersected with the host's own
19
+ * `allowedTools` and the live registry, and the whole request is refused if anything is
20
+ * unattainable.
21
+ * 3. **The exposure gate has a caller.** `mayExposeToClients()` returning false now
22
+ * actually refuses something, with the reason attached.
23
+ *
24
+ * @module @try-works/dsh-tool-mode/tool-mode-run
25
+ */
26
+ import { admitTimeout, buildToolBindings, exposureWithheldReason, mayExposeToClients, mountPtcRuntimeIfAbsent, PTC_SERVICE, } from "./ptc-runtime.js";
27
+ import { generateProgramTypes } from "./ptc-authority.js";
28
+ import { AsyncLocalStorage } from 'node:async_hooks';
29
+ /** Create the per-call external grant carrier. */
30
+ export function createExternalGrantContext() {
31
+ const store = new AsyncLocalStorage();
32
+ return {
33
+ run(grant, work, profiles = [], remoteDestinations = []) {
34
+ return store.run({ grant, profiles, remoteDestinations }, work);
35
+ },
36
+ current() {
37
+ return store.getStore()?.grant;
38
+ },
39
+ currentProfiles() {
40
+ return store.getStore()?.profiles;
41
+ },
42
+ currentRemoteDestinations() {
43
+ return store.getStore()?.remoteDestinations;
44
+ },
45
+ };
46
+ }
47
+ /** How many sub-calls a trace keeps; the count itself is never truncated. */
48
+ const MAX_TRACE_CALLS = 50;
49
+ /** How much of one argument/result value a trace keeps. */
50
+ const PREVIEW_CHARS = 160;
51
+ /** A bounded, JSON-safe preview of one value. Never throws on a cycle. */
52
+ function preview(value) {
53
+ let text;
54
+ try {
55
+ text = typeof value === 'string' ? value : JSON.stringify(value) ?? String(value);
56
+ }
57
+ catch {
58
+ // A circular argument is still a value the program passed; name what it is rather
59
+ // than failing the run that already happened.
60
+ text = '[unserialisable]';
61
+ }
62
+ return text.length > PREVIEW_CHARS ? `${text.slice(0, PREVIEW_CHARS)}…` : text;
63
+ }
64
+ /** Nested programs allowed in one call chain (AT-10/AT-15). */
65
+ const MAX_PROGRAM_DEPTH = 4;
66
+ /** Identical tool calls allowed before the composition loop detector fires. */
67
+ const MAX_IDENTICAL_TOOL_CALLS = 32;
68
+ /** The depth of the program chain currently executing on this async chain. */
69
+ const programDepth = new AsyncLocalStorage();
70
+ /**
71
+ * Create the runner.
72
+ *
73
+ * @param environment - how to reach tools and the runtime.
74
+ * @returns the runner.
75
+ */
76
+ export function createProgramRunner(environment) {
77
+ let prepared;
78
+ /** Materialized backend, resolved lazily at most once. */
79
+ let backend;
80
+ const materializeBackend = () => {
81
+ backend ??= (async () => {
82
+ // A FUNCTION backend is a lazy resolver; a CLASS is a plugin constructor and
83
+ // must not be invoked here (the mount does the construction). The source
84
+ // prefix distinguishes the two, which is exact for native classes. Wrapped
85
+ // constructors (bound/proxied/transpiled) can slip through as resolvers; the
86
+ // try/catch converts their invocation error into the SAME undefined the
87
+ // designed 'backend-unavailable' refusal reports, so no caller sees an
88
+ // opaque TypeError instead of the documented deployment fact.
89
+ const value = environment.backend;
90
+ const isClass = typeof value === 'function' && /^class\s/.test(Function.prototype.toString.call(value));
91
+ if (typeof value !== 'function' || isClass)
92
+ return value;
93
+ try {
94
+ return await value();
95
+ }
96
+ catch {
97
+ // The failure is reported through prepare()'s 'backend-unavailable'
98
+ // reason, which is the designed channel; the detail does not need a
99
+ // second logger the runner does not own.
100
+ return undefined;
101
+ }
102
+ })();
103
+ return backend;
104
+ };
105
+ return {
106
+ async prepare() {
107
+ // Idempotent: the guard is inside, and re-running it must not double-mount.
108
+ if (prepared !== undefined)
109
+ return prepared;
110
+ prepared = await mountPtcRuntimeIfAbsent(environment.context, await materializeBackend(), {
111
+ timeoutMs: 120_000,
112
+ maxTimeoutMs: 600_000,
113
+ });
114
+ return prepared;
115
+ },
116
+ externalExposurePermitted() {
117
+ return mayExposeToClients(environment.operatorGranted());
118
+ },
119
+ externalExposureReason() {
120
+ return exposureWithheldReason(environment.operatorGranted());
121
+ },
122
+ async run(request) {
123
+ const depth = programDepth.getStore() ?? 0;
124
+ if (depth >= MAX_PROGRAM_DEPTH) {
125
+ return {
126
+ ok: false,
127
+ code: 'failed',
128
+ message: `MODEL_NESTED_DEPTH_EXCEEDED: a program chain may nest at most ${MAX_PROGRAM_DEPTH} composed run(s)`,
129
+ };
130
+ }
131
+ const runtime = environment.runtime();
132
+ if (runtime === undefined) {
133
+ return {
134
+ ok: false,
135
+ code: 'unavailable',
136
+ message: 'no PTC runtime is mounted, so no program can run',
137
+ };
138
+ }
139
+ /**
140
+ * THE AUTHORIZED PIPELINE, and the only place bindings are built.
141
+ *
142
+ * `buildToolBindings` intersects the request with the GRANT and the live registry and
143
+ * refuses the whole thing if any name is unattainable. Both doors — native PTC and any
144
+ * external surface — come through here, which is what makes them the same pipeline
145
+ * rather than two implementations that happen to agree today.
146
+ */
147
+ let toolCalls = 0;
148
+ let harnessModelCalls = 0;
149
+ const calls = [];
150
+ /** Identical call counts for the composition loop detector (AT-10/AT-15). */
151
+ const repeatedCalls = new Map();
152
+ const countedResolve = (name) => {
153
+ const binding = environment.resolve(name);
154
+ if (binding === undefined)
155
+ return undefined;
156
+ // A counter wrapper, not a permission change: the program's binding call is
157
+ // counted so the CODE-02 meta reports real usage rather than a fabricated 0.
158
+ // It also RECORDS a bounded trace, because a count alone cannot say which tools a
159
+ // program combined or in what order.
160
+ return async (args) => {
161
+ // CODE-11: the ROOT budget is charged here, so a nested call cannot reset
162
+ // the counters by invoking another tool.
163
+ const maxToolCalls = environment.budgets?.maxToolCalls;
164
+ if (maxToolCalls !== undefined && toolCalls >= maxToolCalls) {
165
+ throw new Error(`MODEL_BUDGET_EXCEEDED: the program's root tool-call budget of ${maxToolCalls} was exhausted`);
166
+ }
167
+ const harness = environment.budgets?.isHarnessTool?.(name) === true;
168
+ const maxHarnessCalls = environment.budgets?.maxHarnessModelCalls;
169
+ if (harness && maxHarnessCalls !== undefined && harnessModelCalls >= maxHarnessCalls) {
170
+ throw new Error(`MODEL_BUDGET_EXCEEDED: the program's root harness-model-call budget of ${maxHarnessCalls} was exhausted`);
171
+ }
172
+ const loopKey = `${name}\u0000${preview(args)}`;
173
+ const repeated = (repeatedCalls.get(loopKey) ?? 0) + 1;
174
+ if (repeated > MAX_IDENTICAL_TOOL_CALLS) {
175
+ throw new Error(`MODEL_LOOP_DETECTED: ${name} was called ${repeated} times with the same arguments `
176
+ + `(limit ${MAX_IDENTICAL_TOOL_CALLS}); the program is looping without progress`);
177
+ }
178
+ repeatedCalls.set(loopKey, repeated);
179
+ toolCalls += 1;
180
+ if (harness)
181
+ harnessModelCalls += 1;
182
+ const started = Date.now();
183
+ const argumentsPreview = preview(args);
184
+ try {
185
+ const value = await binding(args);
186
+ if (calls.length < MAX_TRACE_CALLS) {
187
+ calls.push({
188
+ name,
189
+ ok: true,
190
+ elapsedMs: Date.now() - started,
191
+ argumentsPreview,
192
+ resultPreview: preview(value),
193
+ });
194
+ }
195
+ return value;
196
+ }
197
+ catch (error) {
198
+ if (calls.length < MAX_TRACE_CALLS) {
199
+ calls.push({
200
+ name,
201
+ ok: false,
202
+ elapsedMs: Date.now() - started,
203
+ argumentsPreview,
204
+ error: error instanceof Error ? error.message : String(error),
205
+ });
206
+ }
207
+ throw error;
208
+ }
209
+ };
210
+ };
211
+ const bindings = buildToolBindings({
212
+ requested: request.requested,
213
+ // THE GRANT IS READ PER RUN: an external client's call composes under the
214
+ // CLIENT's grant (SEC-04), the host path under the host's own.
215
+ authority: {
216
+ granted: environment.grant(),
217
+ visible: environment.visible(),
218
+ confidential: environment.confidential?.() ?? [],
219
+ },
220
+ resolve: countedResolve,
221
+ });
222
+ if (!bindings.ok) {
223
+ return { ok: false, code: 'unauthorized', message: bindings.message };
224
+ }
225
+ try {
226
+ /**
227
+ * CODE-04: program data crosses a JSON binding, never source interpolation.
228
+ * The only source addition is the constant destructuring line below; the
229
+ * value itself never appears in the program text.
230
+ */
231
+ const inputNamespace = request.input === undefined
232
+ ? undefined
233
+ : {
234
+ global: 'inputSource',
235
+ functions: {
236
+ read: async () => request.input,
237
+ },
238
+ };
239
+ const program = inputNamespace === undefined
240
+ ? request.program
241
+ : `const input = await inputSource.read(null);\n${request.program}`;
242
+ const result = await programDepth.run(depth + 1, () => runtime.run(runtime.resolve({
243
+ program,
244
+ bindings: inputNamespace === undefined ? [bindings.namespace] : [bindings.namespace, inputNamespace],
245
+ // The budget is CLAMPED here, not passed through: `null` means "no deadline" in
246
+ // the runtime's vocabulary, which is a request to opt out of budgeting entirely.
247
+ timeoutMs: admitTimeout(request.timeoutMs),
248
+ ...request.cwd === undefined ? {} : { cwd: request.cwd },
249
+ ...request.signal === undefined ? {} : { signal: request.signal },
250
+ })));
251
+ if (result.error !== undefined && result.error !== null) {
252
+ // A cancelled run is NOT a failure, and the distinction reaches the caller rather
253
+ // than being flattened.
254
+ const kind = result.error.kind;
255
+ return {
256
+ ok: false,
257
+ code: kind === 'abort' ? 'cancelled' : 'failed',
258
+ message: result.error.message ?? `the program ended with ${String(kind)}`,
259
+ };
260
+ }
261
+ return { ok: true, value: result.value, logs: result.logs ?? [], toolCalls, calls };
262
+ }
263
+ catch (error) {
264
+ return {
265
+ ok: false,
266
+ code: 'failed',
267
+ message: error instanceof Error ? error.message : String(error),
268
+ };
269
+ }
270
+ },
271
+ };
272
+ }
273
+ /**
274
+ * The refusal an EXTERNAL caller receives (CODE-08).
275
+ *
276
+ * A separate function so the gate has a single enforcement point rather than a condition
277
+ * repeated at each call site — the shape that let the original gate go unused.
278
+ * @param runner - the runner.
279
+ * @returns the refusal, or undefined when exposure is permitted.
280
+ */
281
+ export function externalRefusal(runner) {
282
+ if (runner.externalExposurePermitted())
283
+ return undefined;
284
+ return { message: runner.externalExposureReason() };
285
+ }
286
+ /** The service key the runner depends on, re-exported so a caller need not import both. */
287
+ export { PTC_SERVICE };
288
+ /**
289
+ * The `tool_mode_run` MCP contract, in the ToolContract shape (CODE-02).
290
+ *
291
+ * ONE definition serves the MCP export surface and the conformance test, so the
292
+ * two cannot drift the way an inline object at the export site would: the test
293
+ * validates this shape's MCP projection against the pinned schema before it ever
294
+ * ships on a live tools/list.
295
+ */
296
+ export const TOOL_MODE_RUN_CONTRACT = {
297
+ contract: 'hosted.tool_mode_run',
298
+ version: '1.0.0',
299
+ toolName: 'tool_mode_run',
300
+ description: 'Run a program that calls Tool Mode tools (CODE-02).',
301
+ inputSchema: {
302
+ type: 'object',
303
+ additionalProperties: false,
304
+ // `description` is ADVISORY: `serveProgram` accepts an omitted one (it is never
305
+ // interpolated into source), so advertising it as required made the literal
306
+ // CODE-02 payload `{ code, tools }` fail the advertised schema before execution.
307
+ required: ['code', 'tools'],
308
+ properties: {
309
+ description: { type: 'string' },
310
+ code: { type: 'string' },
311
+ input: {},
312
+ tools: { type: 'array', items: { type: 'string' } },
313
+ timeout_ms: { type: 'integer' },
314
+ },
315
+ },
316
+ outputSchema: {
317
+ type: 'object',
318
+ additionalProperties: false,
319
+ properties: {
320
+ result: {},
321
+ logs: { type: 'array', items: { type: 'string' } },
322
+ /**
323
+ * The meta envelope is declared CLOSED with every field the run reports. The host's
324
+ * output validator treats an object without an explicit `additionalProperties` as
325
+ * closed, so the sub-call trace must be named here or every run fails its own
326
+ * schema with `value.meta.calls is not a declared property`.
327
+ */
328
+ meta: {
329
+ type: 'object',
330
+ additionalProperties: false,
331
+ properties: {
332
+ receiptId: { type: 'string' },
333
+ elapsedMs: { type: 'number' },
334
+ toolCalls: { type: 'number' },
335
+ catalogRevision: { type: 'string' },
336
+ warnings: { type: 'array', items: { type: 'string' } },
337
+ typescript: { type: 'string' },
338
+ calls: { type: 'array', items: { type: 'object', additionalProperties: true } },
339
+ },
340
+ },
341
+ },
342
+ },
343
+ semantics: { deterministic: false, readsInputs: true },
344
+ limits: {},
345
+ unsupported: ['no access to management or installer bindings'],
346
+ };
347
+ /**
348
+ * Serve one CODE-02 request through the authorized pipeline (CODE-02/04).
349
+ *
350
+ * This is the `tool_mode_run` served path: the caller's arguments are validated
351
+ * into the CODE-02 shape, the program runs through the SAME runner native PTC
352
+ * uses, and the report carries the receipt, elapsed time, call count, catalog
353
+ * revision and warnings the interface promises.
354
+ *
355
+ * `input` is refused when the pinned runtime cannot bind it structurally: CODE-04
356
+ * forbids string interpolation into source, and the current PTC runtime has no
357
+ * data-global path, so an input-bearing program gets a precise refusal naming
358
+ * that limitation rather than a silently interpolated program.
359
+ * @param args - the caller's arguments.
360
+ * @param runner - the prepared runner.
361
+ * @param report - the report-shaped facts the host owns (receipt id, revision).
362
+ * @returns the report.
363
+ */
364
+ export async function serveProgram(args, runner, report) {
365
+ const description = typeof args.description === 'string' ? args.description : '';
366
+ const code = typeof args.code === 'string' ? args.code : '';
367
+ if (code.trim().length === 0) {
368
+ throw new Error('`code` must be a non-empty program body');
369
+ }
370
+ void description;
371
+ const requested = Array.isArray(args.tools)
372
+ ? args.tools.filter((name) => typeof name === 'string')
373
+ : [];
374
+ if (requested.length === 0) {
375
+ throw new Error('`tools` must name at least one tool the program will call');
376
+ }
377
+ const prepared = await runner.prepare();
378
+ if (!prepared.mounted && prepared.reason === 'backend-unavailable') {
379
+ throw new Error('the Node PTC backend is unavailable on this deployment, so no program can run');
380
+ }
381
+ const started = Date.now();
382
+ const outcome = await runner.run({
383
+ program: code,
384
+ requested,
385
+ ...args.input === undefined ? {} : { input: args.input },
386
+ ...typeof args.timeout_ms === 'number' ? { timeoutMs: args.timeout_ms } : {},
387
+ });
388
+ if (!outcome.ok) {
389
+ throw new Error(`${outcome.code}: ${outcome.message}`);
390
+ }
391
+ return {
392
+ result: outcome.value ?? null,
393
+ // `logs` is part of the advertised output; `meta` is reserved by the tool
394
+ // runtime and dropped from the canonical value. The accounting line is how an
395
+ // MCP caller sees the host's own sub-call count and trace (AT-76).
396
+ logs: [
397
+ ...outcome.logs,
398
+ `tool_mode_accounting:${JSON.stringify({ toolCalls: outcome.toolCalls, calls: outcome.calls })}`,
399
+ ],
400
+ meta: {
401
+ receiptId: report.receiptId,
402
+ elapsedMs: Date.now() - started,
403
+ toolCalls: outcome.toolCalls,
404
+ calls: outcome.calls,
405
+ catalogRevision: report.catalogRevision,
406
+ warnings: [],
407
+ typescript: generateProgramTypes(requested),
408
+ },
409
+ };
410
+ }
411
+ //# sourceMappingURL=tool-mode-run.js.map
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Tool owner attribution for Tool Insights (plan §3.2).
3
+ *
4
+ * The owner of a tool is resolved from LIVE data first — an active extension that
5
+ * declares the tool name owns it — and only then from deliberately static facts:
6
+ * Tool Mode's own names, the `mcp__<server>__<tool>` grammar the MCP client mounts,
7
+ * and a pinned first-party map. Anything else is `unattributed`: the page must be
8
+ * able to say "we do not know" instead of guessing a package.
9
+ *
10
+ * The projection fold cannot see the extension store (it must be a pure, replayable
11
+ * fold), so it uses {@link staticToolOwner}: pinned map, Tool Mode, MCP grammar, then
12
+ * `unattributed`. Extension-owned calls are re-attributed with the live store by the
13
+ * report/inventory readers.
14
+ *
15
+ * @module @try-works/dsh-tool-mode/tool-sources
16
+ */
17
+ /** The owner label used when no fact attributes a tool. */
18
+ export declare const UNATTRIBUTED_OWNER = "unattributed";
19
+ /** The package that provides Tool Mode itself. */
20
+ export declare const TOOL_MODE_OWNER = "@try-works/dsh-tool-mode";
21
+ /** Tool Mode's own tool names (host-local management plus the composition door). */
22
+ export declare const TOOL_MODE_TOOL_NAMES: readonly string[];
23
+ /**
24
+ * Pinned first-party tool → npm package.
25
+ *
26
+ * Factual pairs verified against the DSH packages that register them
27
+ * (`D:\deepseek-harness\packages\**`). This map exists because a historical call can
28
+ * predate the live registry observation; it is intentionally NOT a guess at the whole
29
+ * catalogue — an unlisted name stays `unattributed`.
30
+ */
31
+ export declare const PINNED_FIRST_PARTY_TOOLS: Readonly<Record<string, string>>;
32
+ /** How a tool came to be registered. */
33
+ export type ToolKind = 'built-in' | 'extension' | 'tool-mode' | 'mcp' | 'custom' | 'unknown';
34
+ /** The grouped origin the inventory renders. */
35
+ export type ToolOrigin = 'dsh-core' | 'extension' | 'tool-mode' | 'mcp' | 'custom' | 'unknown';
36
+ /** One resolved owner fact. */
37
+ export interface ToolOwner {
38
+ /** Package/extension id, `mcp:<server>`, or {@link UNATTRIBUTED_OWNER}. */
39
+ readonly owner: string;
40
+ readonly kind: ToolKind;
41
+ readonly origin: ToolOrigin;
42
+ }
43
+ /** An extension that may own tool names, as the store describes it. */
44
+ export interface ExtensionToolOwner {
45
+ /** The extension package identity. */
46
+ readonly id: string;
47
+ /** Whether the store holds an installed copy. */
48
+ readonly installed: boolean;
49
+ /** Whether the host restored it on this load. */
50
+ readonly active: boolean;
51
+ /** Tool names the manifest declares. */
52
+ readonly tools: readonly string[];
53
+ }
54
+ /**
55
+ * The `mcp__<server>__<tool>` server name, or null when the name is not MCP-shaped.
56
+ * @param name - the tool name.
57
+ * @returns the server name, which is empty-safe.
58
+ */
59
+ export declare function mcpServerOf(name: string): string | null;
60
+ /**
61
+ * Resolve owner facts that need no live registry or store (pure, replayable).
62
+ * @param name - the tool name.
63
+ * @returns the owner fact; unknown names are explicitly `unattributed`.
64
+ */
65
+ export declare function staticToolOwner(name: string): ToolOwner;
66
+ /**
67
+ * Resolve the LIVE owner of a tool: an installed extension's declared tool wins,
68
+ * then the static facts.
69
+ * @param name - the tool name.
70
+ * @param extensions - the store's extensions, as `describe()` reports them.
71
+ * @returns the owner fact.
72
+ */
73
+ export declare function resolveToolOwner(name: string, extensions: readonly ExtensionToolOwner[]): ToolOwner;
74
+ /**
75
+ * Project the store's extensions onto a name → extension owner map.
76
+ * @param extensions - the store's extensions.
77
+ * @returns extension id per declared tool name (installed extensions only).
78
+ */
79
+ export declare function extensionToolOwners(extensions: readonly ExtensionToolOwner[]): ReadonlyMap<string, string>;
80
+ //# sourceMappingURL=tool-sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-sources.d.ts","sourceRoot":"","sources":["../src/tool-sources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,2DAA2D;AAC3D,eAAO,MAAM,kBAAkB,iBAAiB,CAAA;AAEhD,kDAAkD;AAClD,eAAO,MAAM,eAAe,6BAA6B,CAAA;AAEzD,oFAAoF;AACpF,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAAoD,CAAA;AAEtG;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiCpE,CAAA;AAEF,wCAAwC;AACxC,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAA;AAE5F,gDAAgD;AAChD,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAA;AAE9F,+BAA+B;AAC/B,MAAM,WAAW,SAAS;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAC5B;AAED,uEAAuE;AACvE,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAClC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CASvD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,kBAAkB,EAAE,GAAG,SAAS,CAOnG;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,SAAS,kBAAkB,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAO1G"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Tool owner attribution for Tool Insights (plan §3.2).
3
+ *
4
+ * The owner of a tool is resolved from LIVE data first — an active extension that
5
+ * declares the tool name owns it — and only then from deliberately static facts:
6
+ * Tool Mode's own names, the `mcp__<server>__<tool>` grammar the MCP client mounts,
7
+ * and a pinned first-party map. Anything else is `unattributed`: the page must be
8
+ * able to say "we do not know" instead of guessing a package.
9
+ *
10
+ * The projection fold cannot see the extension store (it must be a pure, replayable
11
+ * fold), so it uses {@link staticToolOwner}: pinned map, Tool Mode, MCP grammar, then
12
+ * `unattributed`. Extension-owned calls are re-attributed with the live store by the
13
+ * report/inventory readers.
14
+ *
15
+ * @module @try-works/dsh-tool-mode/tool-sources
16
+ */
17
+ /** The owner label used when no fact attributes a tool. */
18
+ export const UNATTRIBUTED_OWNER = 'unattributed';
19
+ /** The package that provides Tool Mode itself. */
20
+ export const TOOL_MODE_OWNER = '@try-works/dsh-tool-mode';
21
+ /** Tool Mode's own tool names (host-local management plus the composition door). */
22
+ export const TOOL_MODE_TOOL_NAMES = Object.freeze(['model_tools', 'tool_mode_run']);
23
+ /**
24
+ * Pinned first-party tool → npm package.
25
+ *
26
+ * Factual pairs verified against the DSH packages that register them
27
+ * (`D:\deepseek-harness\packages\**`). This map exists because a historical call can
28
+ * predate the live registry observation; it is intentionally NOT a guess at the whole
29
+ * catalogue — an unlisted name stays `unattributed`.
30
+ */
31
+ export const PINNED_FIRST_PARTY_TOOLS = Object.freeze({
32
+ read: '@deepseek-ai/dsh-tool-fs',
33
+ write: '@deepseek-ai/dsh-tool-fs',
34
+ edit: '@deepseek-ai/dsh-tool-fs',
35
+ read_image: '@deepseek-ai/dsh-tool-fs',
36
+ glob: '@deepseek-ai/dsh-tool-fs-search',
37
+ grep: '@deepseek-ai/dsh-tool-fs-search',
38
+ pwsh: '@deepseek-ai/dsh-tool-pwsh',
39
+ bash: '@deepseek-ai/dsh-tool-bash',
40
+ web_search: '@deepseek-ai/dsh-tool-web',
41
+ web_fetch: '@deepseek-ai/dsh-tool-web',
42
+ job_list: '@deepseek-ai/dsh-tool-jobs',
43
+ job_output: '@deepseek-ai/dsh-tool-jobs',
44
+ job_kill: '@deepseek-ai/dsh-tool-jobs',
45
+ todo_write: '@deepseek-ai/dsh-tool-todo',
46
+ skill: '@deepseek-ai/dsh-tool-skill',
47
+ present: '@deepseek-ai/dsh-tool-present',
48
+ ask_user_question: '@deepseek-ai/dsh-tool-ask-user',
49
+ lsp: '@deepseek-ai/dsh-tool-lsp',
50
+ working_directory: '@deepseek-ai/dsh-tool-working-directory',
51
+ schedule_create: '@deepseek-ai/dsh-tool-schedule',
52
+ schedule_delete: '@deepseek-ai/dsh-tool-schedule',
53
+ schedule_list: '@deepseek-ai/dsh-tool-schedule',
54
+ schedule_update: '@deepseek-ai/dsh-tool-schedule',
55
+ create_goal: '@deepseek-ai/dsh-tool-goal',
56
+ get_goal: '@deepseek-ai/dsh-tool-goal',
57
+ update_goal: '@deepseek-ai/dsh-tool-goal',
58
+ list_agents: '@deepseek-ai/dsh-tool-subagent-control',
59
+ send_message: '@deepseek-ai/dsh-tool-subagent-control',
60
+ interrupt_agent: '@deepseek-ai/dsh-tool-subagent-control',
61
+ list_subagent_models: '@deepseek-ai/dsh-tool-subagent',
62
+ subagent: '@deepseek-ai/dsh-tool-subagent',
63
+ workflow: '@deepseek-ai/dsh-tool-workflow',
64
+ });
65
+ /**
66
+ * The `mcp__<server>__<tool>` server name, or null when the name is not MCP-shaped.
67
+ * @param name - the tool name.
68
+ * @returns the server name, which is empty-safe.
69
+ */
70
+ export function mcpServerOf(name) {
71
+ const match = /^mcp__(.+?)__(.+)$/.exec(name);
72
+ return match === null ? null : (match[1] ?? null);
73
+ }
74
+ /**
75
+ * Resolve owner facts that need no live registry or store (pure, replayable).
76
+ * @param name - the tool name.
77
+ * @returns the owner fact; unknown names are explicitly `unattributed`.
78
+ */
79
+ export function staticToolOwner(name) {
80
+ if (TOOL_MODE_TOOL_NAMES.includes(name)) {
81
+ return { owner: TOOL_MODE_OWNER, kind: 'tool-mode', origin: 'tool-mode' };
82
+ }
83
+ const server = mcpServerOf(name);
84
+ if (server !== null)
85
+ return { owner: `mcp:${server}`, kind: 'mcp', origin: 'mcp' };
86
+ const pinned = PINNED_FIRST_PARTY_TOOLS[name];
87
+ if (pinned !== undefined)
88
+ return { owner: pinned, kind: 'built-in', origin: 'dsh-core' };
89
+ return { owner: UNATTRIBUTED_OWNER, kind: 'unknown', origin: 'unknown' };
90
+ }
91
+ /**
92
+ * Resolve the LIVE owner of a tool: an installed extension's declared tool wins,
93
+ * then the static facts.
94
+ * @param name - the tool name.
95
+ * @param extensions - the store's extensions, as `describe()` reports them.
96
+ * @returns the owner fact.
97
+ */
98
+ export function resolveToolOwner(name, extensions) {
99
+ for (const extension of extensions) {
100
+ if (!extension.installed)
101
+ continue;
102
+ if (!extension.tools.includes(name))
103
+ continue;
104
+ return { owner: extension.id, kind: 'extension', origin: 'extension' };
105
+ }
106
+ return staticToolOwner(name);
107
+ }
108
+ /**
109
+ * Project the store's extensions onto a name → extension owner map.
110
+ * @param extensions - the store's extensions.
111
+ * @returns extension id per declared tool name (installed extensions only).
112
+ */
113
+ export function extensionToolOwners(extensions) {
114
+ const owners = new Map();
115
+ for (const extension of extensions) {
116
+ if (!extension.installed)
117
+ continue;
118
+ for (const tool of extension.tools)
119
+ owners.set(tool, extension.id);
120
+ }
121
+ return owners;
122
+ }
123
+ //# sourceMappingURL=tool-sources.js.map