@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,122 @@
1
+ /**
2
+ * The host lane that turns a parsed `model-runtime` recipe into a callable tool
3
+ * (docs/runtime/PHASE2.md § Host lane).
4
+ *
5
+ * WHAT THIS MODULE OWNS, and what it deliberately does not:
6
+ *
7
+ * - It owns the CONTRACT between the recipe and DSH: the tool's name and description, the
8
+ * projection of the recipe's JSON-Schema input into what DSH can advertise, the FULL
9
+ * schema enforced at call time (the projection is intentionally looser), and the output
10
+ * check that stops a malformed payload from being published as a result.
11
+ * - It does NOT own the engine. The provider is a `ModelProviderV1` created by the factory
12
+ * the recipe names, which was resolved from the extension's own package (AT-25).
13
+ *
14
+ * TIMING IS PART OF THE DESIGN. Creating a tool resolves the provider module but does not
15
+ * import or run it; the import and the provider's `load` happen on the FIRST CALL. That keeps
16
+ * activation lightweight (EXT-19) while still refusing — at registration — a package whose
17
+ * engine is not installed, because resolution is synchronous.
18
+ *
19
+ * @module @try-works/dsh-tool-mode/model-runtime-lane
20
+ */
21
+ import { assertAgainstSchema, compileSchema, projectSchemaToDsh } from '@try-works/tool-mode-contracts';
22
+ import { importProviderFactory, readModelRuntimeSchema, resolveProviderModule, } from "./model-runtime-recipe.js";
23
+ /** DSH tool arguments are JSON; this only satisfies the index-signature boundary type. */
24
+ function asJsonObject(value) {
25
+ // SAFETY: the arguments arrived from the DSH registry (JSON by construction) and were just
26
+ // validated against the recipe's schema, so a JSON round-trip is lossless.
27
+ return JSON.parse(JSON.stringify(value));
28
+ }
29
+ /**
30
+ * Build the tool for one model-runtime implementation.
31
+ *
32
+ * @param deps - the installed package, the parsed recipe and the host's context/asset hooks.
33
+ * @returns the tool handle or a named refusal.
34
+ */
35
+ export function createModelRuntimeTool(deps) {
36
+ const inputSchema = readModelRuntimeSchema(deps.installPath, deps.recipe.tool.inputSchema);
37
+ if (!inputSchema.ok)
38
+ return inputSchema;
39
+ const outputSchema = readModelRuntimeSchema(deps.installPath, deps.recipe.tool.outputSchema);
40
+ if (!outputSchema.ok)
41
+ return outputSchema;
42
+ // Resolve (not import) the engine now: a package whose factory is missing is refused at
43
+ // registration rather than at the first caller's expense.
44
+ const providerModule = resolveProviderModule({ installPath: deps.installPath, recipe: deps.recipe });
45
+ if (!providerModule.ok)
46
+ return providerModule;
47
+ const name = deps.recipe.tool.name;
48
+ const inputValidator = compileSchema(inputSchema.schema);
49
+ const outputValidator = compileSchema(outputSchema.schema);
50
+ const parameters = projectSchemaToDsh(inputSchema.schema).parameters;
51
+ let factoryPromise;
52
+ let providerPromise;
53
+ let disposed = false;
54
+ /** Import the factory once; a failure is retried on the next call rather than cached forever. */
55
+ const ensureFactory = async () => {
56
+ factoryPromise ??= (async () => {
57
+ const imported = await importProviderFactory({ installPath: deps.installPath, recipe: deps.recipe });
58
+ if (!imported.ok)
59
+ throw new Error(`${imported.code}: ${imported.detail}`);
60
+ return imported.factory;
61
+ })();
62
+ return factoryPromise;
63
+ };
64
+ /** Create and LOAD the provider once; a failed load is retried rather than reported as ready. */
65
+ const ensureProvider = async (signal) => {
66
+ providerPromise ??= (async () => {
67
+ const factory = await ensureFactory();
68
+ const assets = deps.assets();
69
+ const provider = factory(deps.recipe, assets);
70
+ await provider.load({ assets, signal: signal ?? new AbortController().signal });
71
+ return provider;
72
+ })();
73
+ const pending = providerPromise;
74
+ pending.catch(() => {
75
+ if (providerPromise === pending)
76
+ providerPromise = undefined;
77
+ });
78
+ return pending;
79
+ };
80
+ return {
81
+ ok: true,
82
+ tool: {
83
+ name,
84
+ description: deps.recipe.tool.description,
85
+ parameters,
86
+ inputSchema: inputSchema.schema,
87
+ outputSchema: outputSchema.schema,
88
+ async execute(args, exec) {
89
+ if (disposed)
90
+ throw new Error(`${name}: the owning extension was disposed`);
91
+ // The FULL schema, before any engine work: the DSH advertisement is a projection.
92
+ assertAgainstSchema(`${name} input`, inputValidator, args ?? {});
93
+ const provider = await ensureProvider(exec?.signal);
94
+ const payload = await provider.invoke({
95
+ implementationId: deps.implementationId,
96
+ input: asJsonObject(args ?? {}),
97
+ context: deps.invocationContext(exec),
98
+ });
99
+ assertAgainstSchema(`${name} output`, outputValidator, payload);
100
+ return payload;
101
+ },
102
+ async dispose() {
103
+ if (disposed)
104
+ return;
105
+ disposed = true;
106
+ const pending = providerPromise;
107
+ providerPromise = undefined;
108
+ if (pending === undefined)
109
+ return;
110
+ try {
111
+ const provider = await pending;
112
+ await provider.dispose();
113
+ }
114
+ catch (error) {
115
+ // A disposer must not throw: deactivation continues, and the reason is recorded.
116
+ deps.onError?.(`${deps.extensionId}: ${name} teardown failed: ${error instanceof Error ? error.message : String(error)}`);
117
+ }
118
+ },
119
+ },
120
+ };
121
+ }
122
+ //# sourceMappingURL=model-runtime-lane.js.map
@@ -0,0 +1,132 @@
1
+ /**
2
+ * The `model-runtime` recipe: parsing, schema files and the provider factory binding
3
+ * (docs/runtime/PHASE2.md).
4
+ *
5
+ * WHY THE HOST OWNS THE PARSER. The recipe decides what the host will register and which
6
+ * module it will import, so it is a TRUST BOUNDARY. Validating it with code imported from
7
+ * the extension would let the extension define what counts as valid; importing a dedicated
8
+ * runtime-recipes package would put a Phase-2 runtime package in the host's dependency
9
+ * graph, which AT-25 and ARCH-02 exist to prevent. The rules are therefore structural and
10
+ * live here: data only, no engine, no model, no vendor SDK.
11
+ *
12
+ * WHAT THE HOST DOES DELEGATE — and the whole point of the recipe — is the ENGINE. The
13
+ * factory is resolved with `createRequire` anchored at the EXTENSION's own package.json, so
14
+ * a provider package that the extension installed is found, and one that only the host
15
+ * happens to have is not treated as available. The host declares no runtime; the package
16
+ * ships one and names it.
17
+ *
18
+ * @module @try-works/dsh-tool-mode/model-runtime-recipe
19
+ */
20
+ import type { ModelProviderV1, PreparedAssetMapV1 } from '@try-works/tool-mode-extension-sdk';
21
+ /** The accelerators a recipe may request; the host decides which are actually available. */
22
+ export type ModelRuntimeAccelerator = 'cpu' | 'dml' | 'webgpu';
23
+ /** The artifact formats the lane knows how to name. */
24
+ export type ModelRuntimeFormat = 'onnx' | 'tflite' | 'gguf';
25
+ /** A parsed, validated `model-runtime` recipe. */
26
+ export interface ModelRuntimeRecipe {
27
+ readonly kind: 'model-runtime';
28
+ readonly schemaVersion: 1;
29
+ readonly provider: {
30
+ readonly package: string;
31
+ readonly export: string;
32
+ readonly accelerators?: readonly ModelRuntimeAccelerator[];
33
+ };
34
+ readonly model: {
35
+ readonly assetSet: string;
36
+ readonly fileName: string;
37
+ readonly format: ModelRuntimeFormat;
38
+ };
39
+ readonly processor: {
40
+ readonly id: string;
41
+ };
42
+ readonly limits: {
43
+ readonly maxInputBytes: number;
44
+ readonly timeoutMs: number;
45
+ };
46
+ readonly tool: {
47
+ readonly name: string;
48
+ readonly description: string;
49
+ readonly inputSchema: string;
50
+ readonly outputSchema: string;
51
+ };
52
+ }
53
+ /** Why a recipe or its binding was refused. Each is a NAMED refusal, never a silent no-op. */
54
+ export type ModelRuntimeRefusalCode = 'not-model-runtime' | 'unknown-key' | 'bad-schema-version' | 'bad-provider' | 'bad-model' | 'bad-processor' | 'bad-limits' | 'bad-tool' | 'schema-unreadable' | 'factory-unresolved' | 'factory-import-failed' | 'factory-not-function';
55
+ /** A refusal with the exact reason the operator needs. */
56
+ export interface ModelRuntimeRefusal {
57
+ readonly ok: false;
58
+ readonly code: ModelRuntimeRefusalCode;
59
+ readonly detail: string;
60
+ }
61
+ /** A parsed recipe, or a refusal. */
62
+ export type ModelRuntimeRecipeResult = {
63
+ readonly ok: true;
64
+ readonly recipe: ModelRuntimeRecipe;
65
+ } | ModelRuntimeRefusal;
66
+ /** The engine binding a recipe names. */
67
+ export type ModelRuntimeProviderFactory = (recipe: ModelRuntimeRecipe, assets: Readonly<PreparedAssetMapV1>) => ModelProviderV1;
68
+ /**
69
+ * Whether an unvalidated recipe claims to be a `model-runtime` recipe.
70
+ *
71
+ * The host branches on this BEFORE any harness behaviour: a harness recipe (or one with no
72
+ * `kind`) keeps the existing path untouched.
73
+ * @param raw - the recipe as read from disk.
74
+ * @returns whether this is the model-runtime lane's business.
75
+ */
76
+ export declare function isModelRuntimeRecipe(raw: unknown): boolean;
77
+ /**
78
+ * Parse and validate a `model-runtime` recipe (PHASE2 rules).
79
+ * @param raw - the recipe as read from disk.
80
+ * @returns the typed recipe or a named refusal.
81
+ */
82
+ export declare function parseModelRuntimeRecipe(raw: unknown): ModelRuntimeRecipeResult;
83
+ /** The result of reading one schema file. */
84
+ export type ModelRuntimeSchemaResult = {
85
+ readonly ok: true;
86
+ readonly schema: Readonly<Record<string, unknown>>;
87
+ } | ModelRuntimeRefusal;
88
+ /**
89
+ * Read one package-relative schema file, refusing anything that could leave the package.
90
+ * @param installPath - the installed package directory.
91
+ * @param relative - the recipe's `./...` path.
92
+ * @returns the parsed schema or a named refusal.
93
+ */
94
+ export declare function readModelRuntimeSchema(installPath: string, relative: string): ModelRuntimeSchemaResult;
95
+ /** The result of resolving the recipe's provider module (a path, not an import). */
96
+ export type ProviderModuleResult = {
97
+ readonly ok: true;
98
+ readonly resolved: string;
99
+ } | ModelRuntimeRefusal;
100
+ /**
101
+ * Resolve the recipe's provider module from the EXTENSION's own package, without importing it.
102
+ *
103
+ * Resolution is synchronous, which is what lets `registerDeclarative` — a synchronous host
104
+ * hook — refuse a package that cannot be resolved AT REGISTRATION, instead of registering a
105
+ * tool that cannot run. The import itself stays deferred to first call, so activation remains
106
+ * lightweight (EXT-19).
107
+ * @param options - the install directory and the parsed recipe.
108
+ * @returns the resolved module path or a named refusal.
109
+ */
110
+ export declare function resolveProviderModule(options: {
111
+ readonly installPath: string;
112
+ readonly recipe: ModelRuntimeRecipe;
113
+ }): ProviderModuleResult;
114
+ /** The result of importing the recipe's provider factory. */
115
+ export type ProviderFactoryResult = {
116
+ readonly ok: true;
117
+ readonly factory: ModelRuntimeProviderFactory;
118
+ } | ModelRuntimeRefusal;
119
+ /**
120
+ * Import the provider factory the recipe names, resolving from the EXTENSION's own package.
121
+ *
122
+ * The anchor is the extension's `package.json`, not the host's module graph: a package that
123
+ * declares an engine dependency resolves it from its own install, and the host never
124
+ * carries one (AT-25, ARCH-02).
125
+ * @param options - the install directory and the parsed recipe.
126
+ * @returns the factory or a named refusal.
127
+ */
128
+ export declare function importProviderFactory(options: {
129
+ readonly installPath: string;
130
+ readonly recipe: ModelRuntimeRecipe;
131
+ }): Promise<ProviderFactoryResult>;
132
+ //# sourceMappingURL=model-runtime-recipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-runtime-recipe.d.ts","sourceRoot":"","sources":["../src/model-runtime-recipe.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,291 @@
1
+ /**
2
+ * The `model-runtime` recipe: parsing, schema files and the provider factory binding
3
+ * (docs/runtime/PHASE2.md).
4
+ *
5
+ * WHY THE HOST OWNS THE PARSER. The recipe decides what the host will register and which
6
+ * module it will import, so it is a TRUST BOUNDARY. Validating it with code imported from
7
+ * the extension would let the extension define what counts as valid; importing a dedicated
8
+ * runtime-recipes package would put a Phase-2 runtime package in the host's dependency
9
+ * graph, which AT-25 and ARCH-02 exist to prevent. The rules are therefore structural and
10
+ * live here: data only, no engine, no model, no vendor SDK.
11
+ *
12
+ * WHAT THE HOST DOES DELEGATE — and the whole point of the recipe — is the ENGINE. The
13
+ * factory is resolved with `createRequire` anchored at the EXTENSION's own package.json, so
14
+ * a provider package that the extension installed is found, and one that only the host
15
+ * happens to have is not treated as available. The host declares no runtime; the package
16
+ * ships one and names it.
17
+ *
18
+ * @module @try-works/dsh-tool-mode/model-runtime-recipe
19
+ */
20
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
21
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
22
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
23
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
24
+ });
25
+ }
26
+ return path;
27
+ };
28
+ import { createRequire } from 'node:module';
29
+ import { readFileSync } from 'node:fs';
30
+ import { isAbsolute, join, resolve, sep } from 'node:path';
31
+ import { pathToFileURL } from 'node:url';
32
+ const TOP_LEVEL_KEYS = new Set(['kind', 'schemaVersion', 'provider', 'model', 'processor', 'limits', 'tool']);
33
+ const PROVIDER_KEYS = new Set(['package', 'export', 'accelerators']);
34
+ const MODEL_KEYS = new Set(['assetSet', 'fileName', 'format']);
35
+ const PROCESSOR_KEYS = new Set(['id']);
36
+ const LIMITS_KEYS = new Set(['maxInputBytes', 'timeoutMs']);
37
+ const TOOL_KEYS = new Set(['name', 'description', 'inputSchema', 'outputSchema']);
38
+ const FORMATS = new Set(['onnx', 'tflite', 'gguf']);
39
+ const ACCELERATORS = new Set(['cpu', 'dml', 'webgpu']);
40
+ /** `namespace/processor-version`, lower-case, as documented in PHASE2. */
41
+ const PROCESSOR_ID = /^[a-z0-9]+(?:\/[a-z0-9-]+)*$/;
42
+ /** Whether a value is a non-array object. */
43
+ function isRecord(value) {
44
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
45
+ }
46
+ /** Refuse with a code and a reason. */
47
+ function refuse(code, detail) {
48
+ return { ok: false, code, detail };
49
+ }
50
+ /**
51
+ * Whether an unvalidated recipe claims to be a `model-runtime` recipe.
52
+ *
53
+ * The host branches on this BEFORE any harness behaviour: a harness recipe (or one with no
54
+ * `kind`) keeps the existing path untouched.
55
+ * @param raw - the recipe as read from disk.
56
+ * @returns whether this is the model-runtime lane's business.
57
+ */
58
+ export function isModelRuntimeRecipe(raw) {
59
+ return isRecord(raw) && raw['kind'] === 'model-runtime';
60
+ }
61
+ /** Refuse any key a section does not define, naming it. */
62
+ function unknownKey(section, record, allowed) {
63
+ for (const key of Object.keys(record)) {
64
+ if (!allowed.has(key))
65
+ return refuse('unknown-key', `${section} declares the unknown key "${key}"`);
66
+ }
67
+ return undefined;
68
+ }
69
+ /** A non-empty trimmed string, or undefined. */
70
+ function nonEmptyString(value) {
71
+ return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
72
+ }
73
+ /**
74
+ * Whether a value is a package-relative schema path that cannot leave the package.
75
+ * @param value - the declared path.
76
+ * @returns whether it is safe to resolve against the install directory.
77
+ */
78
+ function isContainedRelativePath(value) {
79
+ if (typeof value !== 'string' || !value.startsWith('./') || value.includes('\\'))
80
+ return false;
81
+ if (isAbsolute(value))
82
+ return false;
83
+ const segments = value.split('/').filter(segment => segment.length > 0);
84
+ return !segments.includes('..');
85
+ }
86
+ /**
87
+ * Parse and validate a `model-runtime` recipe (PHASE2 rules).
88
+ * @param raw - the recipe as read from disk.
89
+ * @returns the typed recipe or a named refusal.
90
+ */
91
+ export function parseModelRuntimeRecipe(raw) {
92
+ if (!isModelRuntimeRecipe(raw)) {
93
+ return refuse('not-model-runtime', 'the recipe does not declare kind "model-runtime", so the harness path applies');
94
+ }
95
+ if (!isRecord(raw))
96
+ return refuse('not-model-runtime', 'the recipe is not an object');
97
+ const top = unknownKey('the recipe', raw, TOP_LEVEL_KEYS);
98
+ if (top !== undefined)
99
+ return top;
100
+ if (raw['schemaVersion'] !== 1) {
101
+ return refuse('bad-schema-version', `schemaVersion must be 1; this recipe declares ${JSON.stringify(raw['schemaVersion'])}`);
102
+ }
103
+ const provider = raw['provider'];
104
+ if (!isRecord(provider))
105
+ return refuse('bad-provider', 'provider must be an object');
106
+ const providerUnknown = unknownKey('provider', provider, PROVIDER_KEYS);
107
+ if (providerUnknown !== undefined)
108
+ return providerUnknown;
109
+ const packageName = nonEmptyString(provider['package']);
110
+ if (packageName === undefined)
111
+ return refuse('bad-provider', 'provider.package must be a non-empty string');
112
+ const exportName = nonEmptyString(provider['export']);
113
+ if (exportName === undefined)
114
+ return refuse('bad-provider', 'provider.export must be a non-empty string');
115
+ const rawAccelerators = provider['accelerators'];
116
+ let accelerators;
117
+ if (rawAccelerators !== undefined) {
118
+ if (!Array.isArray(rawAccelerators) || rawAccelerators.length === 0) {
119
+ return refuse('bad-provider', 'provider.accelerators must be a non-empty array when declared');
120
+ }
121
+ const declared = [];
122
+ for (const accelerator of rawAccelerators) {
123
+ if (typeof accelerator !== 'string' || !ACCELERATORS.has(accelerator)) {
124
+ return refuse('bad-provider', `provider.accelerators admits cpu, dml and webgpu; got ${JSON.stringify(accelerator)}`);
125
+ }
126
+ declared.push(accelerator);
127
+ }
128
+ accelerators = declared;
129
+ }
130
+ const model = raw['model'];
131
+ if (!isRecord(model))
132
+ return refuse('bad-model', 'model must be an object');
133
+ const modelUnknown = unknownKey('model', model, MODEL_KEYS);
134
+ if (modelUnknown !== undefined)
135
+ return modelUnknown;
136
+ const assetSet = nonEmptyString(model['assetSet']);
137
+ if (assetSet === undefined)
138
+ return refuse('bad-model', 'model.assetSet must be a non-empty string');
139
+ const fileName = nonEmptyString(model['fileName']);
140
+ if (fileName === undefined)
141
+ return refuse('bad-model', 'model.fileName must be a non-empty string');
142
+ if (fileName.includes('/') || fileName.includes('\\') || fileName === '.' || fileName === '..') {
143
+ return refuse('bad-model', `model.fileName must be a bare file name; got ${JSON.stringify(fileName)}`);
144
+ }
145
+ const format = model['format'];
146
+ if (typeof format !== 'string' || !FORMATS.has(format)) {
147
+ return refuse('bad-model', `model.format admits onnx, tflite and gguf; got ${JSON.stringify(format)}`);
148
+ }
149
+ const processor = raw['processor'];
150
+ if (!isRecord(processor))
151
+ return refuse('bad-processor', 'processor must be an object');
152
+ const processorUnknown = unknownKey('processor', processor, PROCESSOR_KEYS);
153
+ if (processorUnknown !== undefined)
154
+ return processorUnknown;
155
+ const processorId = nonEmptyString(processor['id']);
156
+ if (processorId === undefined)
157
+ return refuse('bad-processor', 'processor.id must be a non-empty string');
158
+ if (!PROCESSOR_ID.test(processorId)) {
159
+ return refuse('bad-processor', `processor.id must match ${PROCESSOR_ID.source}; got ${JSON.stringify(processorId)}`);
160
+ }
161
+ const limits = raw['limits'];
162
+ if (!isRecord(limits))
163
+ return refuse('bad-limits', 'limits must be an object');
164
+ const limitsUnknown = unknownKey('limits', limits, LIMITS_KEYS);
165
+ if (limitsUnknown !== undefined)
166
+ return limitsUnknown;
167
+ for (const key of ['maxInputBytes', 'timeoutMs']) {
168
+ const value = limits[key];
169
+ if (typeof value !== 'number' || !Number.isInteger(value) || value <= 0) {
170
+ return refuse('bad-limits', `limits.${key} must be a positive integer; got ${JSON.stringify(value)}`);
171
+ }
172
+ }
173
+ const tool = raw['tool'];
174
+ if (!isRecord(tool))
175
+ return refuse('bad-tool', 'tool must be an object');
176
+ const toolUnknown = unknownKey('tool', tool, TOOL_KEYS);
177
+ if (toolUnknown !== undefined)
178
+ return toolUnknown;
179
+ const toolName = nonEmptyString(tool['name']);
180
+ if (toolName === undefined)
181
+ return refuse('bad-tool', 'tool.name must be a non-empty string');
182
+ const description = nonEmptyString(tool['description']);
183
+ if (description === undefined)
184
+ return refuse('bad-tool', 'tool.description must be a non-empty string');
185
+ for (const key of ['inputSchema', 'outputSchema']) {
186
+ if (!isContainedRelativePath(tool[key])) {
187
+ return refuse('bad-tool', `tool.${key} must be a package-relative "./..." path that stays inside the package; got ${JSON.stringify(tool[key])}`);
188
+ }
189
+ }
190
+ return {
191
+ ok: true,
192
+ recipe: {
193
+ kind: 'model-runtime',
194
+ schemaVersion: 1,
195
+ provider: { package: packageName, export: exportName, ...(accelerators === undefined ? {} : { accelerators }) },
196
+ model: { assetSet, fileName, format: format },
197
+ processor: { id: processorId },
198
+ limits: { maxInputBytes: limits['maxInputBytes'], timeoutMs: limits['timeoutMs'] },
199
+ tool: {
200
+ name: toolName,
201
+ description,
202
+ inputSchema: tool['inputSchema'],
203
+ outputSchema: tool['outputSchema'],
204
+ },
205
+ },
206
+ };
207
+ }
208
+ /**
209
+ * Read one package-relative schema file, refusing anything that could leave the package.
210
+ * @param installPath - the installed package directory.
211
+ * @param relative - the recipe's `./...` path.
212
+ * @returns the parsed schema or a named refusal.
213
+ */
214
+ export function readModelRuntimeSchema(installPath, relative) {
215
+ if (!isContainedRelativePath(relative)) {
216
+ return refuse('bad-tool', `${JSON.stringify(relative)} is not a package-relative schema path`);
217
+ }
218
+ const root = resolve(installPath);
219
+ const absolute = resolve(root, relative);
220
+ if (absolute !== root && !absolute.startsWith(root + sep)) {
221
+ return refuse('bad-tool', `${JSON.stringify(relative)} resolves outside the package`);
222
+ }
223
+ let text;
224
+ try {
225
+ text = readFileSync(absolute, 'utf8');
226
+ }
227
+ catch (error) {
228
+ return refuse('schema-unreadable', `the tool schema ${JSON.stringify(relative)} could not be read from ${absolute}: ${error instanceof Error ? error.message : String(error)}`);
229
+ }
230
+ let parsed;
231
+ try {
232
+ parsed = JSON.parse(text);
233
+ }
234
+ catch (error) {
235
+ return refuse('schema-unreadable', `the tool schema ${JSON.stringify(relative)} is not JSON: ${error instanceof Error ? error.message : String(error)}`);
236
+ }
237
+ if (!isRecord(parsed)) {
238
+ return refuse('schema-unreadable', `the tool schema ${JSON.stringify(relative)} must be a JSON object`);
239
+ }
240
+ return { ok: true, schema: parsed };
241
+ }
242
+ /**
243
+ * Resolve the recipe's provider module from the EXTENSION's own package, without importing it.
244
+ *
245
+ * Resolution is synchronous, which is what lets `registerDeclarative` — a synchronous host
246
+ * hook — refuse a package that cannot be resolved AT REGISTRATION, instead of registering a
247
+ * tool that cannot run. The import itself stays deferred to first call, so activation remains
248
+ * lightweight (EXT-19).
249
+ * @param options - the install directory and the parsed recipe.
250
+ * @returns the resolved module path or a named refusal.
251
+ */
252
+ export function resolveProviderModule(options) {
253
+ const anchor = join(options.installPath, 'package.json');
254
+ const require = createRequire(anchor);
255
+ const specifier = options.recipe.provider.package;
256
+ try {
257
+ return { ok: true, resolved: require.resolve(specifier) };
258
+ }
259
+ catch (error) {
260
+ return refuse('factory-unresolved', `the provider package ${JSON.stringify(specifier)} cannot be resolved from the extension package directory (${anchor}): `
261
+ + `${error instanceof Error ? error.message : String(error)}. The host declares no engine of its own (AT-25)`);
262
+ }
263
+ }
264
+ /**
265
+ * Import the provider factory the recipe names, resolving from the EXTENSION's own package.
266
+ *
267
+ * The anchor is the extension's `package.json`, not the host's module graph: a package that
268
+ * declares an engine dependency resolves it from its own install, and the host never
269
+ * carries one (AT-25, ARCH-02).
270
+ * @param options - the install directory and the parsed recipe.
271
+ * @returns the factory or a named refusal.
272
+ */
273
+ export async function importProviderFactory(options) {
274
+ const resolvedModule = resolveProviderModule(options);
275
+ if (!resolvedModule.ok)
276
+ return resolvedModule;
277
+ const resolved = resolvedModule.resolved;
278
+ let namespace;
279
+ try {
280
+ namespace = await import(__rewriteRelativeImportExtension(pathToFileURL(resolved).href));
281
+ }
282
+ catch (error) {
283
+ return refuse('factory-import-failed', `the provider module ${resolved} failed to import: ${error instanceof Error ? error.message : String(error)}`);
284
+ }
285
+ const candidate = namespace[options.recipe.provider.export];
286
+ if (typeof candidate !== 'function') {
287
+ return refuse('factory-not-function', `the provider module ${resolved} does not export a function named ${JSON.stringify(options.recipe.provider.export)}`);
288
+ }
289
+ return { ok: true, factory: candidate };
290
+ }
291
+ //# sourceMappingURL=model-runtime-recipe.js.map