@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,166 @@
1
+ /**
2
+ * PTC runtime integration: a guarded mount and the ONE authorized tool pipeline.
3
+ *
4
+ * The directive is explicit that this is repository work, not a missing upstream product:
5
+ *
6
+ * "Use the existing `@deepseek-ai/dsh-ptc-runtime` interface and a compatible
7
+ * `@deepseek-ai/dsh-ptc-runtime-node` backend. Compose its filesystem, subprocess,
8
+ * sandbox, and policy dependencies. **Do not call `ctx.ptcRuntime` without mounting a
9
+ * provider and then report the missing service as an unavailable upstream product.**"
10
+ *
11
+ * "Native DSH PTC and external `tool_mode_run` must use the SAME authorized tool
12
+ * pipeline."
13
+ *
14
+ * Two facts shape the mount, both discovered by reading the DSH source rather than guessed:
15
+ *
16
+ * 1. **The base bundle already mounts a provider.** `packages/bundle/base/cordis.patch.yml`
17
+ * registers `@deepseek-ai/dsh-ptc-runtime-node`, so an UNGUARDED `ctx.plugin(...)`
18
+ * throws `service "ptcRuntime" has been registered at <...>`. The guard is mandatory in
19
+ * both outcomes, so it is not conditional on which host this finds.
20
+ * 2. **The composed services are the inject list**, not something the plugin supplies:
21
+ * `static inject = ['fs','subprocess','sandbox','sandboxPolicy']`. Mounting them here
22
+ * would hit the same duplicate-service throw.
23
+ *
24
+ * Everything that touches Cordis or DSH is INJECTED, so the guard logic and the authorized
25
+ * pipeline are testable without a live runtime.
26
+ *
27
+ * @module @try-works/dsh-tool-mode/ptc-runtime
28
+ */
29
+ import { type ProgramAuthority, type ToolBinding } from './ptc-authority.ts';
30
+ /** The service key the abstract runtime registers itself under. */
31
+ export declare const PTC_SERVICE = "ptcRuntime";
32
+ /** A Cordis-like context, narrowed to what this module needs. */
33
+ export interface PtcHostContext {
34
+ /** Resolve a service, or `undefined` when nothing provides it. */
35
+ get(service: string): unknown;
36
+ /** Mount a plugin. */
37
+ plugin(plugin: unknown, config?: Record<string, unknown>): Promise<unknown> | unknown;
38
+ }
39
+ /** What a mount attempt did. */
40
+ export interface MountOutcome {
41
+ /**
42
+ * Whether this call performed the mount.
43
+ *
44
+ * `false` means the host ALREADY had a provider, which is the expected case inside a
45
+ * full DSH deployment and is a SUCCESS rather than a skip — the distinction is what
46
+ * stops "already present" being reported as "unavailable".
47
+ */
48
+ readonly mounted: boolean;
49
+ /** Why it did not mount, when it did not. */
50
+ readonly reason?: 'already-provided' | 'backend-unavailable';
51
+ /** The service that is now usable, whichever path produced it. */
52
+ readonly service: string;
53
+ }
54
+ /**
55
+ * Mount the Node PTC backend, but only when nothing already provides the service.
56
+ *
57
+ * @param ctx - the host context.
58
+ * @param backend - the backend plugin, or `undefined` when it could not be resolved.
59
+ * @param config - backend configuration.
60
+ * @returns what happened.
61
+ */
62
+ export declare function mountPtcRuntimeIfAbsent(ctx: PtcHostContext, backend: unknown, config?: Record<string, unknown>): Promise<MountOutcome>;
63
+ /** The default budgets, mirroring the backend's own documented defaults. */
64
+ export declare const PTC_DEFAULT_BUDGETS: {
65
+ readonly timeoutMs: 120000;
66
+ readonly maxTimeoutMs: 600000;
67
+ readonly maxOutputBytes: number;
68
+ readonly maxOldGenerationSizeMb: 512;
69
+ };
70
+ /** One authorized binding, ready to expose to a program. */
71
+ export interface BindingNamespace {
72
+ /** The global the program sees, e.g. `tools`. */
73
+ readonly global: string;
74
+ readonly functions: Record<string, ToolBinding>;
75
+ }
76
+ /** A request to build the program-visible bindings. */
77
+ export interface BindingRequest {
78
+ /** The tool names the program declares it will call. */
79
+ readonly requested: readonly string[];
80
+ /** What is granted and what is visible. */
81
+ readonly authority: ProgramAuthority;
82
+ /** The global identifier the program sees. */
83
+ readonly global?: string;
84
+ /**
85
+ * Resolves one tool name to a binding.
86
+ *
87
+ * The CALLER supplies this so that native PTC and external `tool_mode_run` reach tools
88
+ * through the same execution function rather than through two implementations of it.
89
+ */
90
+ readonly resolve: (name: string) => ToolBinding | undefined;
91
+ }
92
+ /** The outcome of building bindings. */
93
+ export type BindingOutcome = {
94
+ readonly ok: true;
95
+ readonly namespace: BindingNamespace;
96
+ } | {
97
+ readonly ok: false;
98
+ readonly message: string;
99
+ };
100
+ /**
101
+ * Build the namespace a program may call (CODE-03, SEC-03).
102
+ *
103
+ * Refuses the WHOLE request when any name is unattainable, so a program never runs against
104
+ * a smaller namespace than it declares.
105
+ *
106
+ * @param request - what to bind.
107
+ * @returns the namespace, or the refusal message.
108
+ */
109
+ export declare function buildToolBindings(request: BindingRequest): BindingOutcome;
110
+ /**
111
+ * The budgets a run is admitted with (RES-10).
112
+ *
113
+ * A requested budget is clamped to the ceiling rather than refused: a caller asking for
114
+ * longer than policy allows gets policy's figure, which is the direction that cannot be
115
+ * widened by asking.
116
+ * @param requestedMs - what the caller asked for, if anything.
117
+ * @returns the admitted budget.
118
+ */
119
+ export declare function admitTimeout(requestedMs: number | null | undefined): number;
120
+ /** Drop the cached artifact reading (tests change the environment between cases). */
121
+ export declare function resetConfinementEvidenceCacheForTest(): void;
122
+ /** The current confinement evidence (CODE-09). */
123
+ export declare function confinementDemonstrated(): boolean;
124
+ /**
125
+ * Why the evidence half of the gate is closed, or undefined when it is open.
126
+ *
127
+ * The row and the refusal text use this so "no evidence configured", "recorded for a
128
+ * different version" and "the recorded run failed" are distinguishable.
129
+ * @returns the reason, or undefined when evidence exists.
130
+ */
131
+ export declare function confinementEvidenceReason(): string | undefined;
132
+ /**
133
+ * Set the confinement evidence (TEST SEAM, CODE-09).
134
+ *
135
+ * The setter is the seam the acceptance test uses. It is inert — throws without
136
+ * moving anything — unless the process carries the explicit environment marker,
137
+ * so the built artifact cannot have the gate opened by code that merely imports
138
+ * it. A production build never sets the marker.
139
+ * @param value - the evidence state to adopt.
140
+ */
141
+ export declare function setConfinementDemonstratedForTest(value: boolean): void;
142
+ /**
143
+ * Whether generated-code execution may be exposed to callers (CODE-08, CODE-10).
144
+ *
145
+ * Exposure is the CONJUNCTION of two independent facts, and neither can stand in
146
+ * for the other:
147
+ *
148
+ * - CODE-09: the specification's confinement tests must have passed. They have
149
+ * not run here, so this half is false — no configuration can open it.
150
+ * - CODE-10: the OPERATOR must have granted hosted code execution, which is a
151
+ * separate consent from ordinary model-tool access. The caller passes the
152
+ * operator's grant in, so the gate has a real input rather than being a literal.
153
+ *
154
+ * A host with the grant flipped but no confinement evidence stays closed; a host
155
+ * with confinement evidence but no operator grant stays closed too.
156
+ * @param operatorGranted - whether the operator granted hosted code execution.
157
+ * @returns whether a caller may be served.
158
+ */
159
+ export declare function mayExposeToClients(operatorGranted: boolean): boolean;
160
+ /**
161
+ * Describe why generated-code execution is withheld, naming WHICH fact is unmet.
162
+ * @param operatorGranted - whether the operator granted hosted code execution.
163
+ * @returns the reason callers are given.
164
+ */
165
+ export declare function exposureWithheldReason(operatorGranted: boolean): string;
166
+ //# sourceMappingURL=ptc-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ptc-runtime.d.ts","sourceRoot":"","sources":["../src/ptc-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAA;AAO3B,mEAAmE;AACnE,eAAO,MAAM,WAAW,eAAe,CAAA;AAEvC,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B,kEAAkE;IAClE,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;IAC7B,sBAAsB;IACtB,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAA;CACtF;AAED,gCAAgC;AAChC,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,qBAAqB,CAAA;IAC5D,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACnC,OAAO,CAAC,YAAY,CAAC,CAkBvB;AAED,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAA;AAEV,4DAA4D;AAC5D,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;CAChD;AAED,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC,2CAA2C;IAC3C,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAA;IACpC,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAA;CAC5D;AAED,wCAAwC;AACxC,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAkBzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAS3E;AAmCD,qFAAqF;AACrF,wBAAgB,oCAAoC,IAAI,IAAI,CAE3D;AAED,kDAAkD;AAClD,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,GAAG,SAAS,CAE9D;AAeD;;;;;;;;GAQG;AACH,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAQtE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,OAAO,GAAG,OAAO,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,OAAO,GAAG,MAAM,CASvE"}
@@ -0,0 +1,231 @@
1
+ /**
2
+ * PTC runtime integration: a guarded mount and the ONE authorized tool pipeline.
3
+ *
4
+ * The directive is explicit that this is repository work, not a missing upstream product:
5
+ *
6
+ * "Use the existing `@deepseek-ai/dsh-ptc-runtime` interface and a compatible
7
+ * `@deepseek-ai/dsh-ptc-runtime-node` backend. Compose its filesystem, subprocess,
8
+ * sandbox, and policy dependencies. **Do not call `ctx.ptcRuntime` without mounting a
9
+ * provider and then report the missing service as an unavailable upstream product.**"
10
+ *
11
+ * "Native DSH PTC and external `tool_mode_run` must use the SAME authorized tool
12
+ * pipeline."
13
+ *
14
+ * Two facts shape the mount, both discovered by reading the DSH source rather than guessed:
15
+ *
16
+ * 1. **The base bundle already mounts a provider.** `packages/bundle/base/cordis.patch.yml`
17
+ * registers `@deepseek-ai/dsh-ptc-runtime-node`, so an UNGUARDED `ctx.plugin(...)`
18
+ * throws `service "ptcRuntime" has been registered at <...>`. The guard is mandatory in
19
+ * both outcomes, so it is not conditional on which host this finds.
20
+ * 2. **The composed services are the inject list**, not something the plugin supplies:
21
+ * `static inject = ['fs','subprocess','sandbox','sandboxPolicy']`. Mounting them here
22
+ * would hit the same duplicate-service throw.
23
+ *
24
+ * Everything that touches Cordis or DSH is INJECTED, so the guard logic and the authorized
25
+ * pipeline are testable without a live runtime.
26
+ *
27
+ * @module @try-works/dsh-tool-mode/ptc-runtime
28
+ */
29
+ import { authorizeProgramTools, describeRejections, } from "./ptc-authority.js";
30
+ import { homedir } from 'node:os';
31
+ import { join } from 'node:path';
32
+ import { checkConfinementEvidence } from "./ptc-confinement.js";
33
+ import { PACKAGE_VERSION } from "./version.js";
34
+ /** The service key the abstract runtime registers itself under. */
35
+ export const PTC_SERVICE = 'ptcRuntime';
36
+ /**
37
+ * Mount the Node PTC backend, but only when nothing already provides the service.
38
+ *
39
+ * @param ctx - the host context.
40
+ * @param backend - the backend plugin, or `undefined` when it could not be resolved.
41
+ * @param config - backend configuration.
42
+ * @returns what happened.
43
+ */
44
+ export async function mountPtcRuntimeIfAbsent(ctx, backend, config = {}) {
45
+ /**
46
+ * THE GUARD. Checked first, because the base bundle mounts a provider and an unguarded
47
+ * `ctx.plugin` throws rather than being idempotent.
48
+ */
49
+ if (ctx.get(PTC_SERVICE) !== undefined) {
50
+ return { mounted: false, reason: 'already-provided', service: PTC_SERVICE };
51
+ }
52
+ if (backend === undefined || backend === null) {
53
+ /**
54
+ * Reported as a REASON, not an exception: a deployment without the backend can still
55
+ * run native tools, and failing the whole plugin load would remove working
56
+ * functionality because an optional one is absent.
57
+ */
58
+ return { mounted: false, reason: 'backend-unavailable', service: PTC_SERVICE };
59
+ }
60
+ await ctx.plugin(backend, config);
61
+ return { mounted: true, service: PTC_SERVICE };
62
+ }
63
+ /** The default budgets, mirroring the backend's own documented defaults. */
64
+ export const PTC_DEFAULT_BUDGETS = {
65
+ timeoutMs: 120_000,
66
+ maxTimeoutMs: 600_000,
67
+ maxOutputBytes: 64 * 1024 * 1024,
68
+ maxOldGenerationSizeMb: 512,
69
+ };
70
+ /**
71
+ * Build the namespace a program may call (CODE-03, SEC-03).
72
+ *
73
+ * Refuses the WHOLE request when any name is unattainable, so a program never runs against
74
+ * a smaller namespace than it declares.
75
+ *
76
+ * @param request - what to bind.
77
+ * @returns the namespace, or the refusal message.
78
+ */
79
+ export function buildToolBindings(request) {
80
+ const decision = authorizeProgramTools({ requested: request.requested }, request.authority, request.resolve);
81
+ if (!decision.ok) {
82
+ return { ok: false, message: describeRejections(decision.rejections) };
83
+ }
84
+ const global = request.global ?? 'tools';
85
+ /**
86
+ * The namespace global obeys the same portability rule the backend enforces, so an
87
+ * invalid one is refused here with a clear reason rather than by the runtime later.
88
+ */
89
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(global)) {
90
+ return {
91
+ ok: false,
92
+ message: `the binding namespace "${global}" is not a language-portable identifier; `
93
+ + 'the same namespace list must work against every backend',
94
+ };
95
+ }
96
+ return { ok: true, namespace: { global, functions: decision.bindings } };
97
+ }
98
+ /**
99
+ * The budgets a run is admitted with (RES-10).
100
+ *
101
+ * A requested budget is clamped to the ceiling rather than refused: a caller asking for
102
+ * longer than policy allows gets policy's figure, which is the direction that cannot be
103
+ * widened by asking.
104
+ * @param requestedMs - what the caller asked for, if anything.
105
+ * @returns the admitted budget.
106
+ */
107
+ export function admitTimeout(requestedMs) {
108
+ if (requestedMs === null) {
109
+ // `null` means "no deadline". That is a request to REMOVE a limit, so it is clamped to
110
+ // the ceiling rather than honoured — otherwise a caller could opt out of budgeting.
111
+ return PTC_DEFAULT_BUDGETS.maxTimeoutMs;
112
+ }
113
+ if (requestedMs === undefined)
114
+ return PTC_DEFAULT_BUDGETS.timeoutMs;
115
+ if (!Number.isFinite(requestedMs) || requestedMs <= 0)
116
+ return PTC_DEFAULT_BUDGETS.timeoutMs;
117
+ return Math.min(requestedMs, PTC_DEFAULT_BUDGETS.maxTimeoutMs);
118
+ }
119
+ /**
120
+ * Whether the confinement acceptance tests have passed on this deployment
121
+ * (CODE-09).
122
+ *
123
+ * Two sources, both deliberate:
124
+ *
125
+ * - the durable EVIDENCE ARTIFACT named by `DSH_PTC_CONFINEMENT_EVIDENCE`, written by
126
+ * `scripts/record-confinement-evidence.mjs` only when the real confinement suite
127
+ * passed on this package version and platform. This is the operator's release path;
128
+ * - the TEST SEAM flag below, which only the acceptance test may move, so the
129
+ * "export appears when the gate opens" case stays executable.
130
+ *
131
+ * A missing, malformed, failed or stale artifact is REFUSED with its reason (see
132
+ * {@link confinementEvidenceReason}); it is never treated as evidence.
133
+ */
134
+ let confinementEvidence = false;
135
+ /** The cached artifact check, so one process reads and validates the file once. */
136
+ let artifactCheck;
137
+ /** Read and cache the evidence artifact for this process. */
138
+ function artifactOutcome() {
139
+ if (artifactCheck !== undefined)
140
+ return artifactCheck;
141
+ const check = checkConfinementEvidence({
142
+ expectedVersion: PACKAGE_VERSION,
143
+ // The recorder writes this standard local artifact, so a host started normally (no
144
+ // wrapper launcher, no environment variable) still has a release path.
145
+ defaultPath: join(homedir(), '.dsh', 'ptc-confinement-evidence.json'),
146
+ });
147
+ artifactCheck = check.ok ? { ok: true, reason: '' } : { ok: false, reason: check.reason };
148
+ return artifactCheck;
149
+ }
150
+ /** Drop the cached artifact reading (tests change the environment between cases). */
151
+ export function resetConfinementEvidenceCacheForTest() {
152
+ artifactCheck = undefined;
153
+ }
154
+ /** The current confinement evidence (CODE-09). */
155
+ export function confinementDemonstrated() {
156
+ return confinementEvidence || artifactOutcome().ok;
157
+ }
158
+ /**
159
+ * Why the evidence half of the gate is closed, or undefined when it is open.
160
+ *
161
+ * The row and the refusal text use this so "no evidence configured", "recorded for a
162
+ * different version" and "the recorded run failed" are distinguishable.
163
+ * @returns the reason, or undefined when evidence exists.
164
+ */
165
+ export function confinementEvidenceReason() {
166
+ return artifactOutcome().ok ? undefined : artifactOutcome().reason;
167
+ }
168
+ /**
169
+ * The environment marker that arms the test seam (CODE-09).
170
+ *
171
+ * The setter below SHIPS in the built artifact (there is no separate test
172
+ * bundle), so it must be inert in every normal process. It therefore refuses to
173
+ * move the gate unless the OPERATOR started this process with an explicit
174
+ * marker — which is itself an operator action, so opening the gate always costs
175
+ * an operator decision and never happens by config, by import or by accident.
176
+ * The acceptance test sets the marker; production never does.
177
+ */
178
+ const CONFINEMENT_SEAM_ENV = 'DSH_PTC_CONFINEMENT_SEAM';
179
+ const CONFINEMENT_SEAM_TOKEN = 'open-for-acceptance-test';
180
+ /**
181
+ * Set the confinement evidence (TEST SEAM, CODE-09).
182
+ *
183
+ * The setter is the seam the acceptance test uses. It is inert — throws without
184
+ * moving anything — unless the process carries the explicit environment marker,
185
+ * so the built artifact cannot have the gate opened by code that merely imports
186
+ * it. A production build never sets the marker.
187
+ * @param value - the evidence state to adopt.
188
+ */
189
+ export function setConfinementDemonstratedForTest(value) {
190
+ if (process.env[CONFINEMENT_SEAM_ENV] !== CONFINEMENT_SEAM_TOKEN) {
191
+ throw new Error('the confinement evidence is a release gate; the acceptance-test seam is '
192
+ + 'closed in this process because the operator marker is absent');
193
+ }
194
+ confinementEvidence = value;
195
+ }
196
+ /**
197
+ * Whether generated-code execution may be exposed to callers (CODE-08, CODE-10).
198
+ *
199
+ * Exposure is the CONJUNCTION of two independent facts, and neither can stand in
200
+ * for the other:
201
+ *
202
+ * - CODE-09: the specification's confinement tests must have passed. They have
203
+ * not run here, so this half is false — no configuration can open it.
204
+ * - CODE-10: the OPERATOR must have granted hosted code execution, which is a
205
+ * separate consent from ordinary model-tool access. The caller passes the
206
+ * operator's grant in, so the gate has a real input rather than being a literal.
207
+ *
208
+ * A host with the grant flipped but no confinement evidence stays closed; a host
209
+ * with confinement evidence but no operator grant stays closed too.
210
+ * @param operatorGranted - whether the operator granted hosted code execution.
211
+ * @returns whether a caller may be served.
212
+ */
213
+ export function mayExposeToClients(operatorGranted) {
214
+ return operatorGranted && confinementDemonstrated();
215
+ }
216
+ /**
217
+ * Describe why generated-code execution is withheld, naming WHICH fact is unmet.
218
+ * @param operatorGranted - whether the operator granted hosted code execution.
219
+ * @returns the reason callers are given.
220
+ */
221
+ export function exposureWithheldReason(operatorGranted) {
222
+ if (!operatorGranted) {
223
+ return 'generated-code execution is disabled: the operator has not granted hosted '
224
+ + 'code execution (CODE-10); it is a separate consent from model-tool access';
225
+ }
226
+ const evidence = confinementEvidenceReason();
227
+ return 'generated-code execution is withheld until the confinement tests pass'
228
+ + (evidence === undefined ? '' : ` (${evidence})`)
229
+ + '; the runtime is mounted and usable in-process, and no production client is served it';
230
+ }
231
+ //# sourceMappingURL=ptc-runtime.js.map
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Coherent publication from one versioned generation (EXT-24).
3
+ *
4
+ * EXT-24 forbids two observable states: an available tool WITHOUT its executable
5
+ * binding, and a new schema served by an old handler. The way to avoid both is to
6
+ * build the whole surface first, check it for internal consistency, and only then
7
+ * make it visible — staging plus a single switch, which is what the requirement
8
+ * asks for rather than an invented transactional registry API.
9
+ *
10
+ * The rules encoded here, each with a reason:
11
+ *
12
+ * - A tool is advertised only when a real implementation binding exists. A schema
13
+ * alone is a promise nothing can keep, and EXT-24 states that no contract is
14
+ * automatically callable merely because its schema is installed.
15
+ * - An ACTIVE package whose model is unprepared publishes readiness information and
16
+ * a preparation skill, but NOT a working inference tool. Advertising a callable
17
+ * tool that will fail on first use is worse than advertising nothing, because the
18
+ * caller has no way to tell the difference until it fails.
19
+ * - A usage skill appears only when every tool it requires is visible. A skill that
20
+ * instructs an agent to call a tool that is not there produces a confident
21
+ * failure.
22
+ * - Every skill carries its owning extension, so it can be withdrawn with that
23
+ * package rather than outliving it.
24
+ *
25
+ * @module @try-works/dsh-tool-mode/publication
26
+ */
27
+ import type { ModelReadiness } from '@try-works/tool-mode-extension-sdk';
28
+ /** Why a candidate contribution did not reach the published surface. */
29
+ export interface WithheldContribution {
30
+ /** Stable reason code. */
31
+ readonly code: 'no-implementation' | 'needs-preparation' | 'unregistered-contribution' | 'model-failed';
32
+ /** Human-readable explanation. */
33
+ readonly message: string;
34
+ /** The tool or skill that was withheld. */
35
+ readonly subject: string;
36
+ /** The extension that owns it. */
37
+ readonly extensionId: string;
38
+ }
39
+ /** One implementation offered for a contract. */
40
+ export interface ImplementationCandidate {
41
+ /** The extension providing it. */
42
+ readonly extensionId: string;
43
+ /** The catalog model backing it. */
44
+ readonly modelId: string;
45
+ /** Whether the model is prepared and callable right now. */
46
+ readonly readiness: ModelReadiness;
47
+ /** Whether the model can run on this host at all. */
48
+ readonly runnable: boolean;
49
+ }
50
+ /** One contract offered for publication. */
51
+ export interface ToolCandidate {
52
+ /** The caller-facing tool name. */
53
+ readonly name: string;
54
+ /** The contract it implements. */
55
+ readonly contractId: string;
56
+ /** The model the operator selected to serve it. */
57
+ readonly selectedModelId: string;
58
+ /** Every implementation that could serve it. */
59
+ readonly implementations: readonly ImplementationCandidate[];
60
+ }
61
+ /** One skill offered for publication. */
62
+ export interface SkillCandidate {
63
+ /** The skill name. */
64
+ readonly name: string;
65
+ /** The extension that owns it. */
66
+ readonly extensionId: string;
67
+ /** Tool NAMES the skill depends on. An absent list means it depends on nothing. */
68
+ readonly requiresTools?: readonly string[];
69
+ /**
70
+ * Whether this skill exists to explain preparation rather than usage.
71
+ *
72
+ * A preparation skill is published even when nothing is callable, because its
73
+ * whole purpose is to tell an operator what to do about that.
74
+ */
75
+ readonly purpose?: 'usage' | 'preparation';
76
+ }
77
+ /** A published tool, which by construction has an executable binding. */
78
+ export interface PublishedTool {
79
+ readonly name: string;
80
+ readonly contractId: string;
81
+ readonly extensionId: string;
82
+ readonly modelId: string;
83
+ readonly readiness: ImplementationCandidate['readiness'];
84
+ /** The other implementations a caller could be switched to. */
85
+ readonly alternatives: readonly string[];
86
+ }
87
+ /** A published skill. */
88
+ export interface PublishedSkill {
89
+ readonly name: string;
90
+ readonly extensionId: string;
91
+ readonly purpose: 'usage' | 'preparation';
92
+ readonly requiresTools: readonly string[];
93
+ }
94
+ /** One model deployment's readiness, published for operator visibility. */
95
+ export interface ReadinessNotice {
96
+ readonly extensionId: string;
97
+ readonly modelId: string;
98
+ readonly readiness: ImplementationCandidate['readiness'];
99
+ readonly callable: boolean;
100
+ readonly reason: string;
101
+ }
102
+ /** A complete, internally consistent surface. */
103
+ export interface CatalogGeneration {
104
+ /** The generation this surface belongs to. */
105
+ readonly generation: number;
106
+ readonly tools: readonly PublishedTool[];
107
+ readonly skills: readonly PublishedSkill[];
108
+ readonly readiness: readonly ReadinessNotice[];
109
+ /** Everything withheld, with the reason. Never silently dropped. */
110
+ readonly withheld: readonly WithheldContribution[];
111
+ }
112
+ /**
113
+ * Build a coherent surface from the candidates available now.
114
+ *
115
+ * Pure: it decides what MAY be published, and the caller makes the result visible.
116
+ * Keeping the decision separate from the switch is what allows a surface to be
117
+ * rejected before anything observes it.
118
+ * @param options - the candidates and the generation they belong to.
119
+ * @returns the complete surface, including what was withheld and why.
120
+ * @throws Error when the candidates are internally inconsistent in a way that
121
+ * cannot be resolved by withholding, such as two tools sharing a name.
122
+ */
123
+ export declare function buildSurface(options: {
124
+ readonly generation: number;
125
+ readonly tools: readonly ToolCandidate[];
126
+ readonly skills: readonly SkillCandidate[];
127
+ }): CatalogGeneration;
128
+ /**
129
+ * The published surface, swapped only as a whole (EXT-24).
130
+ *
131
+ * `publish` refuses a surface that would retire a tool without retiring the skill
132
+ * that teaches it, which is the "new schema with the old handler" failure seen from
133
+ * the other side.
134
+ */
135
+ export declare class PublicationSurface {
136
+ #private;
137
+ constructor(options?: {
138
+ readonly generation?: number;
139
+ readonly onSwap?: (next: CatalogGeneration, previous: CatalogGeneration) => void;
140
+ });
141
+ /** The generation currently visible. */
142
+ get current(): CatalogGeneration;
143
+ /**
144
+ * Replace the visible surface.
145
+ *
146
+ * The callback receives the whole change at once, so a consumer can update its
147
+ * declarations without ever seeing an intermediate state.
148
+ * @param next - the surface to make visible.
149
+ */
150
+ publish(next: CatalogGeneration): void;
151
+ /**
152
+ * Skills that must be withdrawn because their owning extension is gone.
153
+ *
154
+ * EXT-24 requires the host to track skill provenance and remove a skill with the
155
+ * package or tool that owns it, rather than leaving orphaned guidance behind.
156
+ * @param liveExtensionIds - the extensions still installed and active.
157
+ * @returns the skills that should no longer be visible.
158
+ */
159
+ orphanedSkills(liveExtensionIds: readonly string[]): readonly PublishedSkill[];
160
+ }
161
+ //# sourceMappingURL=publication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publication.d.ts","sourceRoot":"","sources":["../src/publication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AASxE,wEAAwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,0BAA0B;IAC1B,QAAQ,CAAC,IAAI,EACT,mBAAmB,GACnB,mBAAmB,GACnB,2BAA2B,GAC3B,cAAc,CAAA;IAClB,kCAAkC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,kCAAkC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED,iDAAiD;AACjD,MAAM,WAAW,uBAAuB;IACtC,kCAAkC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;IAClC,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAC3B;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,kCAAkC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,mDAAmD;IACnD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,gDAAgD;IAChD,QAAQ,CAAC,eAAe,EAAE,SAAS,uBAAuB,EAAE,CAAA;CAC7D;AAED,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,sBAAsB;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,kCAAkC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,mFAAmF;IACnF,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,aAAa,CAAA;CAC3C;AAED,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,EAAE,uBAAuB,CAAC,WAAW,CAAC,CAAA;IACxD,+DAA+D;IAC/D,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;CACzC;AAED,yBAAyB;AACzB,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAAA;IACzC,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAA;CAC1C;AAED,2EAA2E;AAC3E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,EAAE,uBAAuB,CAAC,WAAW,CAAC,CAAA;IACxD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,iDAAiD;AACjD,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAA;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAA;IAC1C,QAAQ,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,CAAA;IAC9C,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,CAAA;CACnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAA;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAA;CAC3C,GAAG,iBAAiB,CAoGpB;AAED;;;;;;GAMG;AACH,qBAAa,kBAAkB;;gBAIjB,OAAO,GAAE;QAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAA;KAAO;IAK5I,wCAAwC;IACxC,IAAI,OAAO,IAAI,iBAAiB,CAE/B;IAED;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI;IAMtC;;;;;;;OAOG;IACH,cAAc,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,cAAc,EAAE;CAI/E"}