@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,471 @@
1
+ /**
2
+ * The host's prepared-assets path (RES-02/03/05, the last in-repo slice):
3
+ * lock reading → preparation plan → approval-gated, digest-verified acquisition
4
+ * into an isolated content-addressed cache → the prepared-cold readiness flip →
5
+ * the PreparedAssetMapV1 the provider routes consume.
6
+ *
7
+ * The verified components this module finally gives callers to:
8
+ *
9
+ * - `planPreparation`/`DeploymentIdentity` (deployment-coordinator.ts) — the
10
+ * pre-approval disclosure;
11
+ * - `acquireAsset` (asset-acquisition.ts) — digest+size verified, atomic,
12
+ * resumable acquisition with tamper refusal;
13
+ * - `createHttpSource` (http-acquisition.ts) — the default ranged source.
14
+ *
15
+ * Honesty rules carried through:
16
+ *
17
+ * - a lock with no digests REFUSES (no guessed values);
18
+ * - an executable asset WITHOUT the explicit executable-preparation approval
19
+ * refuses (RES-02);
20
+ * - a tampered final path is refused and never flips readiness;
21
+ * - the cache lives under the host's isolated state dir, never the repo or
22
+ * HOME; a REAL network run is opt-in (the default source), and the suite
23
+ * injects a local file source so it performs no network.
24
+ *
25
+ * @module @try-works/dsh-tool-mode/prepared-assets
26
+ */
27
+ import { createHash } from 'node:crypto';
28
+ import { existsSync, linkSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, statfsSync, writeFileSync } from 'node:fs';
29
+ import { dirname, join } from 'node:path';
30
+ import { acquireAsset, sameDigest } from "./asset-acquisition.js";
31
+ /**
32
+ * Parse a models.lock.json document.
33
+ *
34
+ * A lock with no digest on any asset REFUSES: a preparation built on guessed
35
+ * bytes would verify nothing (RES-03).
36
+ * @param bytes - the lock document.
37
+ * @returns the parsed lock.
38
+ */
39
+ export function parseAssetLock(bytes) {
40
+ let document;
41
+ try {
42
+ document = JSON.parse(bytes);
43
+ }
44
+ catch (error) {
45
+ throw new Error(`the asset lock is unreadable: ${error instanceof Error ? error.message : String(error)}`);
46
+ }
47
+ if (typeof document !== 'object' || document === null)
48
+ throw new Error('the asset lock is not a document');
49
+ const root = document;
50
+ const assetSets = root['assetSets'];
51
+ if (typeof assetSets !== 'object' || assetSets === null)
52
+ throw new Error('the asset lock declares no assetSets');
53
+ const sets = {};
54
+ for (const [setId, rawSet] of Object.entries(assetSets)) {
55
+ const set = rawSet;
56
+ const revision = typeof set['pinning'] === 'object' && set['pinning'] !== null
57
+ ? set['pinning']['revision']
58
+ : undefined;
59
+ const license = typeof set['license'] === 'object' && set['license'] !== null
60
+ ? set['license']
61
+ : {};
62
+ const rawGroups = set['groups'];
63
+ if (!Array.isArray(rawGroups))
64
+ throw new Error(`asset set ${setId} declares no groups`);
65
+ const groups = rawGroups.map((rawGroup, groupIndex) => {
66
+ const group = rawGroup;
67
+ const rawAssets = group['assets'];
68
+ if (!Array.isArray(rawAssets))
69
+ throw new Error(`asset set ${setId} group ${groupIndex} declares no assets`);
70
+ const assets = rawAssets.map((rawAsset, assetIndex) => {
71
+ const asset = rawAsset;
72
+ const digest = typeof asset['digest'] === 'string' ? asset['digest'] : '';
73
+ const bytes = typeof asset['bytes'] === 'number' ? asset['bytes'] : NaN;
74
+ const id = typeof asset['id'] === 'string' ? asset['id'] : '';
75
+ const file = typeof asset['file'] === 'string' ? asset['file'] : '';
76
+ const source = typeof asset['source'] === 'string' ? asset['source'] : '';
77
+ if (digest.length === 0 || !Number.isFinite(bytes) || id.length === 0 || file.length === 0) {
78
+ throw new Error(`asset set ${setId} group ${groupIndex} asset ${assetIndex} is incomplete; a lock without pinned digests and sizes refuses (RES-03)`);
79
+ }
80
+ return { id, file, bytes, source, digest, executable: asset['executable'] === true };
81
+ });
82
+ return { id: typeof group['id'] === 'string' ? group['id'] : `group-${groupIndex}`, assets };
83
+ });
84
+ sets[setId] = {
85
+ groups,
86
+ revision: typeof revision === 'string' ? revision : '',
87
+ license: {
88
+ name: typeof license['name'] === 'string' ? license['name'] : 'undeclared',
89
+ url: typeof license['url'] === 'string' ? license['url'] : '',
90
+ },
91
+ };
92
+ }
93
+ const lockRevision = Object.values(sets)[0]?.revision ?? '';
94
+ if (lockRevision.length === 0)
95
+ throw new Error('the asset lock pins no model revision; a preparation cannot be planned');
96
+ return { revision: lockRevision, license: Object.values(sets)[0]?.license ?? { name: 'undeclared', url: '' }, sets };
97
+ }
98
+ /** The identity the lock implies for one model deployment. */
99
+ export function identityFor(extensionId, modelId, lock) {
100
+ return {
101
+ extensionId,
102
+ modelId,
103
+ modelRevision: lock.revision,
104
+ engineVersion: 'onnxruntime-node',
105
+ quantization: 'unquantized-fp32',
106
+ tokenizer: 'gemma',
107
+ preprocessingRecipe: 'pinned',
108
+ };
109
+ }
110
+ /** The flat PlannedAsset list for one asset set. */
111
+ export function plannedAssets(lock, assetSetId) {
112
+ const set = lock.sets[assetSetId];
113
+ if (set === undefined)
114
+ throw new Error(`the lock declares no asset set "${assetSetId}"`);
115
+ return set.groups.flatMap(group => group.assets.map(asset => ({
116
+ assetId: `${group.id}/${asset.id}`,
117
+ bytes: asset.bytes,
118
+ source: asset.source,
119
+ digest: asset.digest,
120
+ executable: asset.executable,
121
+ })));
122
+ }
123
+ /** The group map for one asset set, keyed by group id. */
124
+ export function lockGroups(lock, assetSetId) {
125
+ const set = lock.sets[assetSetId];
126
+ if (set === undefined)
127
+ throw new Error(`the lock declares no asset set "${assetSetId}"`);
128
+ return set.groups;
129
+ }
130
+ /**
131
+ * Whether one lock `source` is a resolvable http(s) download URL.
132
+ * @param source - the lock's source string.
133
+ * @returns whether a transfer can be planned for it.
134
+ */
135
+ export function isFetchableAssetSource(source) {
136
+ /**
137
+ * A source is fetchable when it has a URI SCHEME at all: https/http, a `file:`
138
+ * deployment lock, or the injected-source test scheme (`fixture:`). A PROSE
139
+ * description ("the split export of the pinned checkpoint") has no scheme and
140
+ * cannot plan a transfer.
141
+ */
142
+ return /^[a-z][a-z0-9+.-]*:/i.test(source.trim());
143
+ }
144
+ /**
145
+ * The operator-facing reason an asset has no transferable location.
146
+ *
147
+ * A prose `source` (e.g. "the split export of the pinned checkpoint") is not a
148
+ * download URL; the bytes must be produced by the documented export and placed in
149
+ * the prepared-assets cache (file name = the pinned digest) before a transfer-free
150
+ * preparation can succeed.
151
+ * @param assetId - the lock asset id.
152
+ * @param source - the prose/non-URL source.
153
+ * @returns the exact refusal reason.
154
+ */
155
+ export function assetSourceUnavailableReason(assetId, source) {
156
+ return `the asset lock declares no download URL for ${assetId}: its source is ${JSON.stringify(source)}; `
157
+ + 'the artifacts must be produced by the documented export and placed in the prepared-assets cache';
158
+ }
159
+ /**
160
+ * The first planned asset with neither an http(s) URL nor bytes already in the cache.
161
+ *
162
+ * A cache hit is a legitimate source: a later acquisition still verifies the blob
163
+ * against the pinned digest, so pre-seeded artifacts are verified rather than trusted.
164
+ * @param assets - the planned assets to check.
165
+ * @param cacheRoot - the content-addressed cache root (blob filename = digest).
166
+ * @returns the first unavailable asset, or undefined when every asset is reachable.
167
+ */
168
+ export function firstUnavailableAssetSource(assets, cacheRoot) {
169
+ return assets.find(asset => !isFetchableAssetSource(asset.source) && !existsSync(join(cacheRoot, asset.digest)));
170
+ }
171
+ /** The filesystem store acquisition needs, over node:fs. */
172
+ function fsStore() {
173
+ return {
174
+ write(path, bytes) {
175
+ mkdirSync(join(path, '..'), { recursive: true });
176
+ writeFileSync(path, bytes);
177
+ },
178
+ read(path) {
179
+ if (!existsSync(path))
180
+ return undefined;
181
+ return new Uint8Array(readFileSync(path));
182
+ },
183
+ sizeOf(path) {
184
+ if (!existsSync(path))
185
+ return 0;
186
+ return statSyncSize(path);
187
+ },
188
+ rename(from, to) {
189
+ renameSync(from, to);
190
+ },
191
+ remove(path) {
192
+ rmSync(path, { force: true });
193
+ },
194
+ exists(path) {
195
+ return existsSync(path);
196
+ },
197
+ };
198
+ }
199
+ /** Synchronous size (the store interface is sync). */
200
+ function statSyncSize(path) {
201
+ try {
202
+ return statSync(path).size;
203
+ }
204
+ catch {
205
+ return 0;
206
+ }
207
+ }
208
+ /**
209
+ * The default free-space probe (TASK-131): `statfs` at the nearest existing
210
+ * ancestor of the path, so a cache root that does not exist yet probes the
211
+ * volume it will be created on.
212
+ * @param path - the cache root (which may not exist yet).
213
+ * @returns the available bytes (bavail × bsize), or 0 when unreadable.
214
+ */
215
+ export function defaultFreeSpaceBytes(path) {
216
+ let current = path;
217
+ for (;;) {
218
+ try {
219
+ const stats = statfsSync(current);
220
+ return stats.bavail * stats.bsize;
221
+ }
222
+ catch {
223
+ const parent = dirname(current);
224
+ if (parent === current)
225
+ return 0;
226
+ current = parent;
227
+ }
228
+ }
229
+ }
230
+ /**
231
+ * Create the prepared-assets registry.
232
+ * @param options - the cache root and the default source.
233
+ * @returns the registry.
234
+ */
235
+ export function createPreparedAssetRegistry(options) {
236
+ const cacheRoot = options.cacheRoot;
237
+ const freeSpaceProbe = options.freeSpaceBytes ?? defaultFreeSpaceBytes;
238
+ const held = new Map();
239
+ const ownersPath = join(cacheRoot, 'owners.json');
240
+ /**
241
+ * Ownership is PERSISTED, not merely computable (RES-03): a restart still knows
242
+ * which extension references which content-addressed digest, so a future purge
243
+ * can refuse to delete a blob another owner still needs.
244
+ */
245
+ function readOwners() {
246
+ if (!existsSync(ownersPath))
247
+ return {};
248
+ try {
249
+ const parsed = JSON.parse(readFileSync(ownersPath, 'utf8'));
250
+ const owners = {};
251
+ for (const [extensionId, digests] of Object.entries(parsed)) {
252
+ if (!Array.isArray(digests))
253
+ continue;
254
+ owners[extensionId] = digests.filter((digest) => typeof digest === 'string');
255
+ }
256
+ return owners;
257
+ }
258
+ catch {
259
+ // A corrupt ownership index is not evidence of zero owners; it is evidence
260
+ // that no safe deletion decision can be made, so it reads as empty and the
261
+ // caller retains blobs (deletion is conservative).
262
+ return {};
263
+ }
264
+ }
265
+ function writeOwners(owners) {
266
+ mkdirSync(cacheRoot, { recursive: true });
267
+ const temporary = `${ownersPath}.${process.pid}.tmp`;
268
+ writeFileSync(temporary, JSON.stringify(owners, null, 2));
269
+ renameSync(temporary, ownersPath);
270
+ }
271
+ function recordOwnership(extensionId, groups) {
272
+ const owners = readOwners();
273
+ owners[extensionId] = [...new Set(groups.flatMap(group => group.files.map(file => file.digest)))];
274
+ writeOwners(owners);
275
+ }
276
+ function forgetOwnership(extensionId) {
277
+ const owners = readOwners();
278
+ if (!(extensionId in owners))
279
+ return;
280
+ delete owners[extensionId];
281
+ writeOwners(owners);
282
+ }
283
+ // The content-addressed blob pool, shared across extensions (RES-03: two
284
+ // owners share one set of bytes).
285
+ return {
286
+ cacheDirectory: cacheRoot,
287
+ plans() {
288
+ return new Map([...held.entries()].map(([extensionId, preparation]) => [extensionId, preparation.plan]));
289
+ },
290
+ assetMapFor(extensionId) {
291
+ const preparation = held.get(extensionId);
292
+ if (preparation === undefined)
293
+ return undefined;
294
+ /**
295
+ * TWO projections over one verified preparation, both truthful:
296
+ *
297
+ * - the GROUP id resolves to the group directory (embeddinggemma's selective
298
+ * loading asks for `text-backbone` and reads `onnx/model.onnx` under it);
299
+ * - each ASSET id resolves to the individual materialized file (needle asks
300
+ * for `needle-engine-win-x64` and needs the executable's path).
301
+ *
302
+ * The SDK documents the map as asset ids to local handles, so the per-asset
303
+ * entries are the canonical projection and the group entry is the directory
304
+ * convenience the first-party group consumers already rely on. An exact
305
+ * asset-id match wins over a group-id match; the ids are namespaced by the
306
+ * lock and a collision is not silently served as the other kind.
307
+ */
308
+ const groupHandles = new Map();
309
+ const assetHandles = new Map();
310
+ for (const group of preparation.groups) {
311
+ groupHandles.set(group.groupId, { path: group.path, digest: group.digests.join(',') });
312
+ for (const file of group.files) {
313
+ assetHandles.set(file.assetId, { path: file.path, digest: file.digest });
314
+ }
315
+ }
316
+ return {
317
+ assetIds: [...groupHandles.keys(), ...assetHandles.keys()],
318
+ get(assetId) {
319
+ return assetHandles.get(assetId) ?? groupHandles.get(assetId);
320
+ },
321
+ };
322
+ },
323
+ groupsFor(extensionId) {
324
+ return held.get(extensionId)?.groups ?? [];
325
+ },
326
+ purge(extensionId) {
327
+ const extensionRoot = join(cacheRoot, 'groups', extensionId.replaceAll('/', '__'));
328
+ const removed = existsSync(extensionRoot);
329
+ if (removed)
330
+ rmSync(extensionRoot, { recursive: true, force: true });
331
+ held.delete(extensionId);
332
+ forgetOwnership(extensionId);
333
+ return { removed };
334
+ },
335
+ /**
336
+ * RESTART RESTORE. `prepare` is the only thing that fills the in-process map,
337
+ * and it lives in one process: after a host restart the store still says
338
+ * `prepared-cold`, the extension activates, and every tool call then fails
339
+ * with "the text-backbone asset group was not prepared" because the map is
340
+ * empty. The group directories are on disk from the earlier verified prepare,
341
+ * so rebuilding the handles from them is a stat walk, not a transfer; a file
342
+ * that is absent or no longer the recorded size refuses instead of publishing
343
+ * a handle nobody verified.
344
+ */
345
+ restore(extensionId, plan, groups) {
346
+ const prepared = [];
347
+ for (const group of groups) {
348
+ const groupDir = join(cacheRoot, 'groups', plan.identity.extensionId.replaceAll('/', '__'), plan.identity.modelId, group.id);
349
+ const digests = [];
350
+ const files = [];
351
+ for (const asset of group.assets) {
352
+ const filePath = join(groupDir, asset.file);
353
+ if (!existsSync(filePath) || statSyncSize(filePath) !== asset.bytes) {
354
+ return {
355
+ ok: false,
356
+ reason: `${group.id}/${asset.id} is not in the prepared cache at its recorded size (${filePath})`,
357
+ };
358
+ }
359
+ digests.push(asset.digest);
360
+ files.push({ assetId: asset.id, file: asset.file, path: filePath, digest: asset.digest });
361
+ }
362
+ prepared.push({ groupId: group.id, path: groupDir, digests, files });
363
+ }
364
+ held.set(extensionId, { plan, groups: prepared });
365
+ recordOwnership(extensionId, prepared);
366
+ return { ok: true, groups: prepared };
367
+ },
368
+ async prepare(extensionId, plan, groups, options) {
369
+ /**
370
+ * A lock whose assets carry PROSE sources (no URL) has no transferable
371
+ * location; refuse BEFORE any acquisition, naming the asset, instead of
372
+ * surfacing a URL-parse error from deep inside the transport. Artifacts
373
+ * already materialized in the content-addressed cache are a legitimate
374
+ * source (a later acquisition still verifies their digest).
375
+ */
376
+ const unavailable = firstUnavailableAssetSource(groups.flatMap(group => group.assets.map(asset => ({ assetId: `${group.id}/${asset.id}`, source: asset.source, digest: asset.digest }))), cacheRoot);
377
+ if (unavailable !== undefined) {
378
+ return { ok: false, reason: assetSourceUnavailableReason(unavailable.assetId, unavailable.source) };
379
+ }
380
+ /**
381
+ * TASK-131 (RC2): the disk-space preflight. Before anything transfers,
382
+ * compare the bytes that are actually MISSING from the content-addressed
383
+ * cache (a digest hit transfers nothing) against the free space at the
384
+ * cache root, and refuse with a named, actionable error quoting the
385
+ * numbers — never let a multi-GB transfer run into a mid-stream ENOSPC
386
+ * that surfaces as a bare transport failure.
387
+ */
388
+ const missingAssets = groups.flatMap(group => group.assets)
389
+ .filter(asset => !existsSync(join(cacheRoot, asset.digest)));
390
+ const missingBytes = missingAssets.reduce((sum, asset) => sum + asset.bytes, 0);
391
+ if (missingBytes > 0) {
392
+ const free = freeSpaceProbe(cacheRoot);
393
+ if (free < missingBytes) {
394
+ return {
395
+ ok: false,
396
+ reason: `[extension-asset-space-insufficient] the asset cache root ${cacheRoot} needs ${missingBytes} bytes `
397
+ + `for ${missingAssets.length} missing asset(s) but only ${free} bytes are free. `
398
+ + 'Configure assetCacheRoot on a volume with at least that much free space, or free space, and retry.',
399
+ };
400
+ }
401
+ }
402
+ if (!options.allowExecutable && plan.requiresExecutableApproval) {
403
+ return {
404
+ ok: false,
405
+ reason: 'the plan includes an EXECUTABLE asset, which requires the separate executable-preparation approval (RES-02); this call did not grant it',
406
+ };
407
+ }
408
+ const store = fsStore();
409
+ mkdirSync(cacheRoot, { recursive: true });
410
+ const prepared = [];
411
+ for (const group of groups) {
412
+ const groupDir = join(cacheRoot, 'groups', plan.identity.extensionId.replaceAll('/', '__'), plan.identity.modelId, group.id);
413
+ const digests = [];
414
+ const files = [];
415
+ for (const asset of group.assets) {
416
+ const planned = {
417
+ assetId: asset.id,
418
+ bytes: asset.bytes,
419
+ source: asset.source,
420
+ digest: asset.digest,
421
+ executable: asset.executable,
422
+ };
423
+ // NO in-memory blob shortcut: acquireAsset re-verifies the on-disk
424
+ // bytes on every call (a cache HIT transfers zero bytes but still
425
+ // checks the digest), so a blob tampered on disk is re-acquired
426
+ // rather than trusted from a stale memory record — and two owners
427
+ // still share the verified bytes.
428
+ const result = await acquireAsset(planned, {
429
+ store,
430
+ source: options.source,
431
+ root: cacheRoot,
432
+ signal: options.signal,
433
+ });
434
+ if (!result.acquired) {
435
+ return { ok: false, reason: `${group.id}/${asset.id}: ${result.reason}` };
436
+ }
437
+ const blob = { digest: result.digest, path: result.path };
438
+ // Materialize the lock's per-asset FILE layout inside the group dir via
439
+ // a hard link: the provider resolves `${groupDir}/onnx/model.onnx` etc.
440
+ // The link shares the verified blob's bytes (same volume); the digest
441
+ // was verified at acquisition and the blob path never changes.
442
+ mkdirSync(join(groupDir, asset.file, '..'), { recursive: true });
443
+ const linkTarget = join(groupDir, asset.file);
444
+ if (!existsSync(linkTarget)) {
445
+ try {
446
+ linkSync(blob.path, linkTarget);
447
+ }
448
+ catch {
449
+ // Hard links can fail across volumes; a copy is the fallback and
450
+ // is equally verified because the blob's digest was checked.
451
+ writeFileSync(linkTarget, readFileSync(blob.path));
452
+ }
453
+ }
454
+ else if (!sameDigest(createHash('sha256').update(readFileSync(linkTarget)).digest('hex'), asset.digest)) {
455
+ // A tampered FINAL path never poisons readiness: it is removed and
456
+ // the verified blob re-linked.
457
+ rmSync(linkTarget, { force: true });
458
+ linkSync(blob.path, linkTarget);
459
+ }
460
+ digests.push(asset.digest);
461
+ files.push({ assetId: asset.id, file: asset.file, path: linkTarget, digest: asset.digest });
462
+ }
463
+ prepared.push({ groupId: group.id, path: groupDir, digests, files });
464
+ }
465
+ held.set(extensionId, { plan, groups: prepared });
466
+ recordOwnership(extensionId, prepared);
467
+ return { ok: true, groups: prepared };
468
+ },
469
+ };
470
+ }
471
+ //# sourceMappingURL=prepared-assets.js.map
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Extension provider bridge.
3
+ *
4
+ * This is the ONLY route from a catalog entry to model code (BASE-09). The host
5
+ * no longer imports an adapter for any model: it resolves the extension that
6
+ * DECLARES the model, loads that extension through its public `./tool-mode`
7
+ * entry, and asks it for a provider. A first-party package and a third-party
8
+ * package take the same path, so there is no private built-in adapter route that
9
+ * only first-party code can use — which is precisely what BASE-09 forbids.
10
+ *
11
+ * The binding from a catalog model to an extension is DATA, held in the model's
12
+ * own catalog entry, not a switch on the model name. Adding a vendor therefore
13
+ * means publishing a package and adding a catalog row, with no host change.
14
+ *
15
+ * @module @try-works/dsh-tool-mode/provider-bridge
16
+ */
17
+ import { type PreparedAssetMapV1, type ProviderInspectionV1 } from '@try-works/tool-mode-extension-sdk';
18
+ import { type ToolGrant } from './authority.ts';
19
+ import type { ManagedWorkerRegistry } from './managed-workers.ts';
20
+ import type { ModelCatalogEntry } from './types.ts';
21
+ import type { ModelAdapter } from './adapters/types.ts';
22
+ /** How a model's provider is obtained. */
23
+ export interface ProviderBinding {
24
+ /**
25
+ * The extension package that implements the model, resolved like any other
26
+ * dependency. A relative path is admitted so a first-party package can be used
27
+ * from a checkout before it is published.
28
+ */
29
+ readonly extension: string;
30
+ /** The `modelId` the extension declares for this model. */
31
+ readonly modelId: string;
32
+ }
33
+ /** Raised when a model cannot be served through its declared extension. */
34
+ export declare class ProviderBridgeError extends Error {
35
+ readonly name = "ProviderBridgeError";
36
+ }
37
+ /**
38
+ * Loads extensions and adapts their providers to the host's adapter interface.
39
+ *
40
+ * One bridge per plugin activation, so an extension is imported and activated
41
+ * once no matter how many tools it serves.
42
+ */
43
+ export declare class ProviderBridge {
44
+ #private;
45
+ constructor(options: {
46
+ readonly grant: ToolGrant;
47
+ readonly activationGeneration: number;
48
+ readonly installedPath?: (extensionId: string) => string | undefined;
49
+ readonly managed?: ManagedWorkerRegistry;
50
+ readonly log?: (message: string, fields?: Record<string, unknown>) => void;
51
+ });
52
+ /** The extensions currently activated, for diagnostics. */
53
+ get activatedExtensions(): readonly string[];
54
+ /**
55
+ * Inspect one extension-backed catalog entry through its provider.
56
+ *
57
+ * Inspection is the extension's read-only readiness path (EXT-18). It may import
58
+ * and activate the extension, but it does not load model assets or invoke the
59
+ * model; the provider itself must report only approved local state. This is used
60
+ * by publication and discovery so the host does not equate "the package
61
+ * resolves" with "the selected deployment is prepared".
62
+ * @param entry - the catalog entry to inspect.
63
+ * @param signal - cancellation for the read-only inspection.
64
+ * @returns the provider's inspection, or undefined for entries with no provider binding.
65
+ */
66
+ inspect(entry: ModelCatalogEntry, signal: AbortSignal): Promise<ProviderInspectionV1 | undefined>;
67
+ /**
68
+ * Inspect one extension INSTALLED IN THE STORE, keyed by its own manifest model id.
69
+ *
70
+ * The catalog-driven {@link inspect} cannot reach an extension that has no catalog
71
+ * row (EmbeddingGemma and Needle ship declared tools but are not catalogued), which
72
+ * left their deployments permanently `needs-preparation`. This route activates the
73
+ * extension through its public entry and inspects the provider the MANIFEST declares,
74
+ * so "prepared" can become a durable fact for store-installed packages too.
75
+ *
76
+ * Inspection remains read-only (EXT-18): no model assets are loaded.
77
+ * @param specifier - the installed extension package name or ABSOLUTE install path.
78
+ * An absolute path runs the exact store copy the caller verified, rather than
79
+ * whatever the package name resolves to in the host's own dependency graph.
80
+ * @param modelId - the model id the extension's manifest declares.
81
+ * @param signal - cancellation for the read-only inspection.
82
+ * @returns the provider's inspection, or undefined when the model is not declared.
83
+ * @throws ProviderBridgeError when the package cannot be resolved or the provider
84
+ * refuses creation for this model id (the model's declaredness is the provider's
85
+ * to assert, so an undeclared id surfaces as a throw rather than undefined).
86
+ */
87
+ inspectExtension(specifier: string, modelId: string, signal: AbortSignal, assets?: Readonly<PreparedAssetMapV1>): Promise<ProviderInspectionV1 | undefined>;
88
+ /**
89
+ * Build an adapter for one catalog entry.
90
+ *
91
+ * Returns undefined when the entry declares no provider binding, which is the
92
+ * correct outcome for a model reached through a command transport instead.
93
+ *
94
+ * The adapter is LAZY: it does not import or activate the extension until the
95
+ * first invocation. Two reasons, and the second is the important one:
96
+ * registering a tool must not run somebody else's package code (EXT-19 requires
97
+ * import and `create()` to stay lightweight), and a package that fails to load
98
+ * must fail the CALL it was needed for rather than the registration of every
99
+ * other tool in the catalog.
100
+ * @param entry - the catalog entry.
101
+ * @returns the adapter, or undefined when no extension implements this model.
102
+ */
103
+ adapterFor(entry: ModelCatalogEntry): ModelAdapter | undefined;
104
+ /** Release every activated extension. */
105
+ dispose(reason?: 'deactivate' | 'upgrade' | 'uninstall' | 'shutdown' | 'fault'): Promise<void>;
106
+ }
107
+ //# sourceMappingURL=provider-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-bridge.d.ts","sourceRoot":"","sources":["../src/provider-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,oCAAoC,CAAA;AAE3C,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAGjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAgC,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAErF,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAeD,2EAA2E;AAC3E,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,SAAkB,IAAI,yBAAwB;CAC/C;AAED;;;;;GAKG;AACH,qBAAa,cAAc;;gBAuBb,OAAO,EAAE;QACnB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;QACzB,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;QACrC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;QACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAA;QACxC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;KAC3E;IAQD,2DAA2D;IAC3D,IAAI,mBAAmB,IAAI,SAAS,MAAM,EAAE,CAE3C;IAED;;;;;;;;;;;OAWG;IACG,OAAO,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAsBvG;;;;;;;;;;;;;;;;;;;OAmBG;IACG,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,WAAW,EACnB,MAAM,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GACpC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IA0B5C;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,GAAG,SAAS;IAqF9D,yCAAyC;IACnC,OAAO,CAAC,MAAM,GAAE,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,OAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CA6HjH"}