@workerstack/clients 0.0.0-stage → 1.0.0-rc.23

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 (558) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +619 -2
  3. package/bin/honey-clients.js +94 -0
  4. package/dist/cli.d.ts +102 -0
  5. package/dist/cli.js +190 -0
  6. package/dist/emit/cli/channels.d.ts +73 -0
  7. package/dist/emit/cli/channels.js +197 -0
  8. package/dist/emit/cli/commands.d.ts +27 -0
  9. package/dist/emit/cli/commands.js +187 -0
  10. package/dist/emit/cli/discovery.d.ts +35 -0
  11. package/dist/emit/cli/discovery.js +202 -0
  12. package/dist/emit/cli/flags.d.ts +59 -0
  13. package/dist/emit/cli/flags.js +186 -0
  14. package/dist/emit/cli/index.d.ts +1 -0
  15. package/dist/emit/cli/index.js +1 -0
  16. package/dist/emit/cli/install.d.ts +37 -0
  17. package/dist/emit/cli/install.js +88 -0
  18. package/dist/emit/cli/layout.d.ts +23 -0
  19. package/dist/emit/cli/layout.js +118 -0
  20. package/dist/emit/cli/module.d.ts +30 -0
  21. package/dist/emit/cli/module.js +186 -0
  22. package/dist/emit/cli/release.d.ts +40 -0
  23. package/dist/emit/cli/release.js +183 -0
  24. package/dist/emit/cli/skills.d.ts +11 -0
  25. package/dist/emit/cli/skills.js +56 -0
  26. package/dist/emit/csharp/errors.d.ts +7 -0
  27. package/dist/emit/csharp/errors.js +69 -0
  28. package/dist/emit/csharp/index.d.ts +1 -0
  29. package/dist/emit/csharp/index.js +1 -0
  30. package/dist/emit/csharp/json.d.ts +13 -0
  31. package/dist/emit/csharp/json.js +113 -0
  32. package/dist/emit/csharp/realtime.d.ts +10 -0
  33. package/dist/emit/csharp/realtime.js +33 -0
  34. package/dist/emit/csharp/sdk-answer.d.ts +48 -0
  35. package/dist/emit/csharp/sdk-answer.js +85 -0
  36. package/dist/emit/csharp/sdk-body.d.ts +10 -0
  37. package/dist/emit/csharp/sdk-body.js +87 -0
  38. package/dist/emit/csharp/sdk-client.d.ts +32 -0
  39. package/dist/emit/csharp/sdk-client.js +177 -0
  40. package/dist/emit/csharp/sdk-csproj.d.ts +36 -0
  41. package/dist/emit/csharp/sdk-csproj.js +136 -0
  42. package/dist/emit/csharp/sdk-doc.d.ts +12 -0
  43. package/dist/emit/csharp/sdk-doc.js +35 -0
  44. package/dist/emit/csharp/sdk-method.d.ts +26 -0
  45. package/dist/emit/csharp/sdk-method.js +187 -0
  46. package/dist/emit/csharp/sdk-plan.d.ts +38 -0
  47. package/dist/emit/csharp/sdk-plan.js +1 -0
  48. package/dist/emit/csharp/sdk.d.ts +40 -0
  49. package/dist/emit/csharp/sdk.js +105 -0
  50. package/dist/emit/csharp/sse.d.ts +18 -0
  51. package/dist/emit/csharp/sse.js +29 -0
  52. package/dist/emit/csharp/transport.d.ts +11 -0
  53. package/dist/emit/csharp/transport.js +67 -0
  54. package/dist/emit/csharp/types-enum.d.ts +19 -0
  55. package/dist/emit/csharp/types-enum.js +63 -0
  56. package/dist/emit/csharp/types-names.d.ts +33 -0
  57. package/dist/emit/csharp/types-names.js +182 -0
  58. package/dist/emit/csharp/types-record.d.ts +25 -0
  59. package/dist/emit/csharp/types-record.js +65 -0
  60. package/dist/emit/csharp/types-union.d.ts +27 -0
  61. package/dist/emit/csharp/types-union.js +113 -0
  62. package/dist/emit/csharp/types.d.ts +36 -0
  63. package/dist/emit/csharp/types.js +126 -0
  64. package/dist/emit/csharp/ws.d.ts +20 -0
  65. package/dist/emit/csharp/ws.js +14 -0
  66. package/dist/emit/go/errors.d.ts +7 -0
  67. package/dist/emit/go/errors.js +44 -0
  68. package/dist/emit/go/http.d.ts +11 -0
  69. package/dist/emit/go/http.js +50 -0
  70. package/dist/emit/go/index.d.ts +1 -0
  71. package/dist/emit/go/index.js +1 -0
  72. package/dist/emit/go/module-path.d.ts +2 -0
  73. package/dist/emit/go/module-path.js +27 -0
  74. package/dist/emit/go/sdk-answer.d.ts +28 -0
  75. package/dist/emit/go/sdk-answer.js +41 -0
  76. package/dist/emit/go/sdk-body.d.ts +24 -0
  77. package/dist/emit/go/sdk-body.js +76 -0
  78. package/dist/emit/go/sdk-client.d.ts +29 -0
  79. package/dist/emit/go/sdk-client.js +141 -0
  80. package/dist/emit/go/sdk-method.d.ts +68 -0
  81. package/dist/emit/go/sdk-method.js +172 -0
  82. package/dist/emit/go/sdk-mirror.d.ts +23 -0
  83. package/dist/emit/go/sdk-mirror.js +97 -0
  84. package/dist/emit/go/sdk-opts.d.ts +55 -0
  85. package/dist/emit/go/sdk-opts.js +100 -0
  86. package/dist/emit/go/sdk.d.ts +26 -0
  87. package/dist/emit/go/sdk.js +111 -0
  88. package/dist/emit/go/sse.d.ts +16 -0
  89. package/dist/emit/go/sse.js +26 -0
  90. package/dist/emit/go/types-codec.d.ts +15 -0
  91. package/dist/emit/go/types-codec.js +171 -0
  92. package/dist/emit/go/types-names.d.ts +14 -0
  93. package/dist/emit/go/types-names.js +64 -0
  94. package/dist/emit/go/types-struct.d.ts +29 -0
  95. package/dist/emit/go/types-struct.js +65 -0
  96. package/dist/emit/go/types-union.d.ts +17 -0
  97. package/dist/emit/go/types-union.js +84 -0
  98. package/dist/emit/go/types.d.ts +32 -0
  99. package/dist/emit/go/types.js +177 -0
  100. package/dist/emit/go/ws.d.ts +12 -0
  101. package/dist/emit/go/ws.js +70 -0
  102. package/dist/emit/java/gradle.d.ts +57 -0
  103. package/dist/emit/java/gradle.js +221 -0
  104. package/dist/emit/java/index.d.ts +2 -0
  105. package/dist/emit/java/index.js +2 -0
  106. package/dist/emit/java/json.d.ts +13 -0
  107. package/dist/emit/java/json.js +84 -0
  108. package/dist/emit/java/layout-ast.d.ts +146 -0
  109. package/dist/emit/java/layout-ast.js +102 -0
  110. package/dist/emit/java/layout-decl.d.ts +20 -0
  111. package/dist/emit/java/layout-decl.js +155 -0
  112. package/dist/emit/java/layout-doc.d.ts +55 -0
  113. package/dist/emit/java/layout-doc.js +166 -0
  114. package/dist/emit/java/layout-dot.d.ts +18 -0
  115. package/dist/emit/java/layout-dot.js +127 -0
  116. package/dist/emit/java/layout-strings.d.ts +8 -0
  117. package/dist/emit/java/layout-strings.js +76 -0
  118. package/dist/emit/java/layout-types.d.ts +11 -0
  119. package/dist/emit/java/layout-types.js +95 -0
  120. package/dist/emit/java/layout-visitor.d.ts +38 -0
  121. package/dist/emit/java/layout-visitor.js +232 -0
  122. package/dist/emit/java/layout.d.ts +61 -0
  123. package/dist/emit/java/layout.js +121 -0
  124. package/dist/emit/java/models-enum.d.ts +17 -0
  125. package/dist/emit/java/models-enum.js +51 -0
  126. package/dist/emit/java/models-names.d.ts +29 -0
  127. package/dist/emit/java/models-names.js +97 -0
  128. package/dist/emit/java/models-record.d.ts +24 -0
  129. package/dist/emit/java/models-record.js +79 -0
  130. package/dist/emit/java/models-union.d.ts +27 -0
  131. package/dist/emit/java/models-union.js +86 -0
  132. package/dist/emit/java/models.d.ts +28 -0
  133. package/dist/emit/java/models.js +118 -0
  134. package/dist/emit/java/realtime.d.ts +50 -0
  135. package/dist/emit/java/realtime.js +69 -0
  136. package/dist/emit/java/sdk-client.d.ts +66 -0
  137. package/dist/emit/java/sdk-client.js +207 -0
  138. package/dist/emit/java/sdk-decl.d.ts +11 -0
  139. package/dist/emit/java/sdk-decl.js +63 -0
  140. package/dist/emit/java/sdk-errors.d.ts +13 -0
  141. package/dist/emit/java/sdk-errors.js +141 -0
  142. package/dist/emit/java/sdk-headers.d.ts +12 -0
  143. package/dist/emit/java/sdk-headers.js +74 -0
  144. package/dist/emit/java/sdk-mirror.d.ts +14 -0
  145. package/dist/emit/java/sdk-mirror.js +107 -0
  146. package/dist/emit/java/sdk-models.d.ts +16 -0
  147. package/dist/emit/java/sdk-models.js +68 -0
  148. package/dist/emit/java/sdk-op.d.ts +57 -0
  149. package/dist/emit/java/sdk-op.js +216 -0
  150. package/dist/emit/java/sdk-params.d.ts +38 -0
  151. package/dist/emit/java/sdk-params.js +133 -0
  152. package/dist/emit/java/sdk-plan.d.ts +52 -0
  153. package/dist/emit/java/sdk-plan.js +1 -0
  154. package/dist/emit/java/sdk-record.d.ts +16 -0
  155. package/dist/emit/java/sdk-record.js +99 -0
  156. package/dist/emit/java/sdk.d.ts +49 -0
  157. package/dist/emit/java/sdk.js +216 -0
  158. package/dist/emit/java/sse.d.ts +35 -0
  159. package/dist/emit/java/sse.js +57 -0
  160. package/dist/emit/java/ws.d.ts +27 -0
  161. package/dist/emit/java/ws.js +31 -0
  162. package/dist/emit/mcp/annotations.d.ts +15 -0
  163. package/dist/emit/mcp/annotations.js +15 -0
  164. package/dist/emit/mcp/files.d.ts +18 -0
  165. package/dist/emit/mcp/files.js +42 -0
  166. package/dist/emit/mcp/index.d.ts +3 -0
  167. package/dist/emit/mcp/index.js +3 -0
  168. package/dist/emit/mcp/literal.d.ts +2 -0
  169. package/dist/emit/mcp/literal.js +33 -0
  170. package/dist/emit/mcp/mounted.d.ts +21 -0
  171. package/dist/emit/mcp/mounted.js +89 -0
  172. package/dist/emit/mcp/output-schema.d.ts +18 -0
  173. package/dist/emit/mcp/output-schema.js +38 -0
  174. package/dist/emit/mcp/registry.d.ts +23 -0
  175. package/dist/emit/mcp/registry.js +83 -0
  176. package/dist/emit/mcp/runtime.d.ts +10 -0
  177. package/dist/emit/mcp/runtime.js +47 -0
  178. package/dist/emit/mcp/schema.d.ts +19 -0
  179. package/dist/emit/mcp/schema.js +88 -0
  180. package/dist/emit/mcp/server.d.ts +30 -0
  181. package/dist/emit/mcp/server.js +246 -0
  182. package/dist/emit/mcp/tools.d.ts +51 -0
  183. package/dist/emit/mcp/tools.js +153 -0
  184. package/dist/emit/python/errors.d.ts +8 -0
  185. package/dist/emit/python/errors.js +68 -0
  186. package/dist/emit/python/index.d.ts +1 -0
  187. package/dist/emit/python/index.js +1 -0
  188. package/dist/emit/python/realtime.d.ts +10 -0
  189. package/dist/emit/python/realtime.js +33 -0
  190. package/dist/emit/python/sdk-answer.d.ts +49 -0
  191. package/dist/emit/python/sdk-answer.js +89 -0
  192. package/dist/emit/python/sdk-body.d.ts +11 -0
  193. package/dist/emit/python/sdk-body.js +40 -0
  194. package/dist/emit/python/sdk-client.d.ts +36 -0
  195. package/dist/emit/python/sdk-client.js +163 -0
  196. package/dist/emit/python/sdk-doc.d.ts +9 -0
  197. package/dist/emit/python/sdk-doc.js +32 -0
  198. package/dist/emit/python/sdk-imports.d.ts +14 -0
  199. package/dist/emit/python/sdk-imports.js +38 -0
  200. package/dist/emit/python/sdk-method.d.ts +29 -0
  201. package/dist/emit/python/sdk-method.js +183 -0
  202. package/dist/emit/python/sdk-plan.d.ts +33 -0
  203. package/dist/emit/python/sdk-plan.js +1 -0
  204. package/dist/emit/python/sdk-pyproject.d.ts +27 -0
  205. package/dist/emit/python/sdk-pyproject.js +103 -0
  206. package/dist/emit/python/sdk.d.ts +22 -0
  207. package/dist/emit/python/sdk.js +154 -0
  208. package/dist/emit/python/sse.d.ts +12 -0
  209. package/dist/emit/python/sse.js +23 -0
  210. package/dist/emit/python/transport.d.ts +15 -0
  211. package/dist/emit/python/transport.js +60 -0
  212. package/dist/emit/python/types-dict.d.ts +31 -0
  213. package/dist/emit/python/types-dict.js +45 -0
  214. package/dist/emit/python/types-names.d.ts +16 -0
  215. package/dist/emit/python/types-names.js +52 -0
  216. package/dist/emit/python/types-union.d.ts +32 -0
  217. package/dist/emit/python/types-union.js +46 -0
  218. package/dist/emit/python/types.d.ts +36 -0
  219. package/dist/emit/python/types.js +128 -0
  220. package/dist/emit/python/ws.d.ts +14 -0
  221. package/dist/emit/python/ws.js +16 -0
  222. package/dist/emit/rust/errors.d.ts +7 -0
  223. package/dist/emit/rust/errors.js +107 -0
  224. package/dist/emit/rust/http.d.ts +13 -0
  225. package/dist/emit/rust/http.js +67 -0
  226. package/dist/emit/rust/index.d.ts +1 -0
  227. package/dist/emit/rust/index.js +1 -0
  228. package/dist/emit/rust/realtime.d.ts +11 -0
  229. package/dist/emit/rust/realtime.js +29 -0
  230. package/dist/emit/rust/sdk-body.d.ts +19 -0
  231. package/dist/emit/rust/sdk-body.js +53 -0
  232. package/dist/emit/rust/sdk-cargo.d.ts +43 -0
  233. package/dist/emit/rust/sdk-cargo.js +178 -0
  234. package/dist/emit/rust/sdk-client.d.ts +25 -0
  235. package/dist/emit/rust/sdk-client.js +108 -0
  236. package/dist/emit/rust/sdk-method.d.ts +15 -0
  237. package/dist/emit/rust/sdk-method.js +119 -0
  238. package/dist/emit/rust/sdk-opts.d.ts +58 -0
  239. package/dist/emit/rust/sdk-opts.js +117 -0
  240. package/dist/emit/rust/sdk-plan.d.ts +33 -0
  241. package/dist/emit/rust/sdk-plan.js +1 -0
  242. package/dist/emit/rust/sdk.d.ts +23 -0
  243. package/dist/emit/rust/sdk.js +111 -0
  244. package/dist/emit/rust/sse.d.ts +19 -0
  245. package/dist/emit/rust/sse.js +20 -0
  246. package/dist/emit/rust/types-enum.d.ts +13 -0
  247. package/dist/emit/rust/types-enum.js +62 -0
  248. package/dist/emit/rust/types-names.d.ts +19 -0
  249. package/dist/emit/rust/types-names.js +66 -0
  250. package/dist/emit/rust/types-struct.d.ts +21 -0
  251. package/dist/emit/rust/types-struct.js +59 -0
  252. package/dist/emit/rust/types-union.d.ts +24 -0
  253. package/dist/emit/rust/types-union.js +97 -0
  254. package/dist/emit/rust/types.d.ts +34 -0
  255. package/dist/emit/rust/types.js +105 -0
  256. package/dist/emit/rust/ws.d.ts +21 -0
  257. package/dist/emit/rust/ws.js +20 -0
  258. package/dist/emit/shared/escape.d.ts +55 -0
  259. package/dist/emit/shared/escape.js +144 -0
  260. package/dist/emit/shared/format.d.ts +24 -0
  261. package/dist/emit/shared/format.js +23 -0
  262. package/dist/emit/shared/gofmt.d.ts +3 -0
  263. package/dist/emit/shared/gofmt.js +26 -0
  264. package/dist/emit/shared/lang.d.ts +60 -0
  265. package/dist/emit/shared/lang.js +233 -0
  266. package/dist/emit/shared/literals.d.ts +4 -0
  267. package/dist/emit/shared/literals.js +31 -0
  268. package/dist/emit/shared/metadata.d.ts +106 -0
  269. package/dist/emit/shared/metadata.js +130 -0
  270. package/dist/emit/shared/mirror.d.ts +22 -0
  271. package/dist/emit/shared/mirror.js +26 -0
  272. package/dist/emit/shared/ruff.d.ts +3 -0
  273. package/dist/emit/shared/ruff.js +31 -0
  274. package/dist/emit/shared/rustfmt.d.ts +3 -0
  275. package/dist/emit/shared/rustfmt.js +32 -0
  276. package/dist/emit/shared/status-keys.d.ts +7 -0
  277. package/dist/emit/shared/status-keys.js +67 -0
  278. package/dist/emit/shared/type-emitter.d.ts +19 -0
  279. package/dist/emit/shared/type-emitter.js +100 -0
  280. package/dist/emit/ts/app-client.d.ts +4 -0
  281. package/dist/emit/ts/app-client.js +68 -0
  282. package/dist/emit/ts/http.d.ts +20 -0
  283. package/dist/emit/ts/http.js +74 -0
  284. package/dist/emit/ts/package.d.ts +36 -0
  285. package/dist/emit/ts/package.js +126 -0
  286. package/dist/emit/ts/route-tree.d.ts +68 -0
  287. package/dist/emit/ts/route-tree.js +240 -0
  288. package/dist/emit/ts/sdk-types-preamble.d.ts +14 -0
  289. package/dist/emit/ts/sdk-types-preamble.js +123 -0
  290. package/dist/emit/ts/sdk-types.d.ts +13 -0
  291. package/dist/emit/ts/sdk-types.js +213 -0
  292. package/dist/emit/ts/sdk.d.ts +21 -0
  293. package/dist/emit/ts/sdk.js +173 -0
  294. package/dist/emit/ts/service-map.d.ts +40 -0
  295. package/dist/emit/ts/service-map.js +171 -0
  296. package/dist/emit/ts/tanstack-query.d.ts +12 -0
  297. package/dist/emit/ts/tanstack-query.js +156 -0
  298. package/dist/emit/ts/type-gen.d.ts +26 -0
  299. package/dist/emit/ts/type-gen.js +255 -0
  300. package/dist/emit/ts/webhooks.d.ts +19 -0
  301. package/dist/emit/ts/webhooks.js +81 -0
  302. package/dist/extract/chain.d.ts +34 -0
  303. package/dist/extract/chain.js +84 -0
  304. package/dist/extract/extract.d.ts +41 -0
  305. package/dist/extract/extract.js +191 -0
  306. package/dist/extract/serialize.d.ts +34 -0
  307. package/dist/extract/serialize.js +295 -0
  308. package/dist/extract/walk.d.ts +47 -0
  309. package/dist/extract/walk.js +109 -0
  310. package/dist/gen/args.d.ts +28 -0
  311. package/dist/gen/args.js +133 -0
  312. package/dist/gen/formatters.d.ts +62 -0
  313. package/dist/gen/formatters.js +146 -0
  314. package/dist/gen/process.d.ts +13 -0
  315. package/dist/gen/process.js +35 -0
  316. package/dist/gen/shipped.d.ts +17 -0
  317. package/dist/gen/shipped.js +55 -0
  318. package/dist/gen/targets.d.ts +93 -0
  319. package/dist/gen/targets.js +171 -0
  320. package/dist/gen/write.d.ts +33 -0
  321. package/dist/gen/write.js +118 -0
  322. package/dist/index.d.ts +13 -0
  323. package/dist/index.js +15 -0
  324. package/dist/ir/build.d.ts +37 -0
  325. package/dist/ir/build.js +152 -0
  326. package/dist/ir/load.d.ts +11 -0
  327. package/dist/ir/load.js +112 -0
  328. package/dist/ir/model.d.ts +206 -0
  329. package/dist/ir/model.js +5 -0
  330. package/dist/ir/resolve-refs.d.ts +11 -0
  331. package/dist/ir/resolve-refs.js +66 -0
  332. package/dist/ir/resource-tree.d.ts +9 -0
  333. package/dist/ir/resource-tree.js +53 -0
  334. package/dist/ir/route-tree-intern.d.ts +18 -0
  335. package/dist/ir/route-tree-intern.js +174 -0
  336. package/dist/ir/schema.d.ts +11 -0
  337. package/dist/ir/schema.js +192 -0
  338. package/dist/ir/sdk-model.d.ts +86 -0
  339. package/dist/ir/sdk-model.js +204 -0
  340. package/dist/ir/slots.d.ts +42 -0
  341. package/dist/ir/slots.js +245 -0
  342. package/dist/runtime/cli/body.go +176 -0
  343. package/dist/runtime/cli/config.go +243 -0
  344. package/dist/runtime/cli/discovery.go +147 -0
  345. package/dist/runtime/cli/format.go +174 -0
  346. package/dist/runtime/cli/log.go +117 -0
  347. package/dist/runtime/cli/output.go +247 -0
  348. package/dist/runtime/cli/params.go +197 -0
  349. package/dist/runtime/cli/run.go +226 -0
  350. package/dist/runtime/cli/socket.go +60 -0
  351. package/dist/runtime/cli/stream.go +217 -0
  352. package/dist/runtime/cli/target.go +117 -0
  353. package/dist/runtime/csharp/Adapters.cs +183 -0
  354. package/dist/runtime/csharp/Auth.cs +56 -0
  355. package/dist/runtime/csharp/Body.cs +135 -0
  356. package/dist/runtime/csharp/Config.cs +161 -0
  357. package/dist/runtime/csharp/Envelope.cs +149 -0
  358. package/dist/runtime/csharp/Errors.cs +194 -0
  359. package/dist/runtime/csharp/Events.cs +155 -0
  360. package/dist/runtime/csharp/Exchange.cs +247 -0
  361. package/dist/runtime/csharp/Handler.cs +103 -0
  362. package/dist/runtime/csharp/Hooks.cs +128 -0
  363. package/dist/runtime/csharp/Invalidation.cs +102 -0
  364. package/dist/runtime/csharp/Json.cs +144 -0
  365. package/dist/runtime/csharp/Log.cs +48 -0
  366. package/dist/runtime/csharp/Operation.cs +33 -0
  367. package/dist/runtime/csharp/Path.cs +65 -0
  368. package/dist/runtime/csharp/Query.cs +72 -0
  369. package/dist/runtime/csharp/Realtime.cs +118 -0
  370. package/dist/runtime/csharp/RealtimeLoop.cs +236 -0
  371. package/dist/runtime/csharp/Redirect.cs +53 -0
  372. package/dist/runtime/csharp/Result.cs +57 -0
  373. package/dist/runtime/csharp/Sse.cs +122 -0
  374. package/dist/runtime/csharp/Stale.cs +151 -0
  375. package/dist/runtime/csharp/Transport.cs +143 -0
  376. package/dist/runtime/csharp/TransportLongPoll.cs +63 -0
  377. package/dist/runtime/csharp/TransportSse.cs +54 -0
  378. package/dist/runtime/csharp/TransportWs.cs +40 -0
  379. package/dist/runtime/csharp/Wire.cs +109 -0
  380. package/dist/runtime/csharp/Ws.cs +300 -0
  381. package/dist/runtime/csharp/WsDial.cs +127 -0
  382. package/dist/runtime/go/auth.go +127 -0
  383. package/dist/runtime/go/body.go +129 -0
  384. package/dist/runtime/go/config.go +75 -0
  385. package/dist/runtime/go/errors.go +185 -0
  386. package/dist/runtime/go/export.go +37 -0
  387. package/dist/runtime/go/hooks.go +53 -0
  388. package/dist/runtime/go/invalidation.go +112 -0
  389. package/dist/runtime/go/log.go +92 -0
  390. package/dist/runtime/go/nullable.go +64 -0
  391. package/dist/runtime/go/options.go +118 -0
  392. package/dist/runtime/go/path.go +156 -0
  393. package/dist/runtime/go/query.go +147 -0
  394. package/dist/runtime/go/realtime.go +239 -0
  395. package/dist/runtime/go/realtime_loop.go +208 -0
  396. package/dist/runtime/go/redirect.go +124 -0
  397. package/dist/runtime/go/request.go +222 -0
  398. package/dist/runtime/go/result.go +86 -0
  399. package/dist/runtime/go/sse.go +186 -0
  400. package/dist/runtime/go/stale.go +229 -0
  401. package/dist/runtime/go/stream.go +105 -0
  402. package/dist/runtime/go/transport.go +242 -0
  403. package/dist/runtime/go/transport_longpoll.go +121 -0
  404. package/dist/runtime/go/transport_sse.go +175 -0
  405. package/dist/runtime/go/ws.go +205 -0
  406. package/dist/runtime/java/Answer.java +107 -0
  407. package/dist/runtime/java/ApiException.java +110 -0
  408. package/dist/runtime/java/BinaryBody.java +36 -0
  409. package/dist/runtime/java/Body.java +105 -0
  410. package/dist/runtime/java/Call.java +23 -0
  411. package/dist/runtime/java/CallLog.java +51 -0
  412. package/dist/runtime/java/ClientConfig.java +233 -0
  413. package/dist/runtime/java/ConnectionState.java +12 -0
  414. package/dist/runtime/java/Credential.java +58 -0
  415. package/dist/runtime/java/Deadline.java +38 -0
  416. package/dist/runtime/java/Decode.java +181 -0
  417. package/dist/runtime/java/Envelope.java +141 -0
  418. package/dist/runtime/java/ErrorEnvelope.java +23 -0
  419. package/dist/runtime/java/EventStream.java +129 -0
  420. package/dist/runtime/java/Exchange.java +62 -0
  421. package/dist/runtime/java/FilePart.java +5 -0
  422. package/dist/runtime/java/Flight.java +306 -0
  423. package/dist/runtime/java/HoneyException.java +14 -0
  424. package/dist/runtime/java/Hooks.java +47 -0
  425. package/dist/runtime/java/Hops.java +133 -0
  426. package/dist/runtime/java/InvalidationConfig.java +73 -0
  427. package/dist/runtime/java/Json.java +23 -0
  428. package/dist/runtime/java/Keepalive.java +60 -0
  429. package/dist/runtime/java/LogEntry.java +14 -0
  430. package/dist/runtime/java/LongPollAdapter.java +68 -0
  431. package/dist/runtime/java/Operation.java +21 -0
  432. package/dist/runtime/java/Opt.java +121 -0
  433. package/dist/runtime/java/Pump.java +160 -0
  434. package/dist/runtime/java/RawResponse.java +48 -0
  435. package/dist/runtime/java/Realtime.java +152 -0
  436. package/dist/runtime/java/RealtimeLoop.java +371 -0
  437. package/dist/runtime/java/RedirectPolicy.java +13 -0
  438. package/dist/runtime/java/Redirects.java +126 -0
  439. package/dist/runtime/java/RequestContext.java +78 -0
  440. package/dist/runtime/java/RequestHook.java +9 -0
  441. package/dist/runtime/java/RequestOptions.java +91 -0
  442. package/dist/runtime/java/ResponseContext.java +70 -0
  443. package/dist/runtime/java/ResponseHook.java +12 -0
  444. package/dist/runtime/java/Result.java +32 -0
  445. package/dist/runtime/java/ResumableConnection.java +165 -0
  446. package/dist/runtime/java/SdkException.java +11 -0
  447. package/dist/runtime/java/Socket.java +301 -0
  448. package/dist/runtime/java/Sse.java +171 -0
  449. package/dist/runtime/java/SseAdapter.java +61 -0
  450. package/dist/runtime/java/SseEvent.java +10 -0
  451. package/dist/runtime/java/StaleMeta.java +16 -0
  452. package/dist/runtime/java/StaleTracker.java +287 -0
  453. package/dist/runtime/java/Transport.java +16 -0
  454. package/dist/runtime/java/TransportAdapter.java +14 -0
  455. package/dist/runtime/java/TransportConnection.java +15 -0
  456. package/dist/runtime/java/TransportKind.java +12 -0
  457. package/dist/runtime/java/TransportMessage.java +9 -0
  458. package/dist/runtime/java/TransportOptions.java +138 -0
  459. package/dist/runtime/java/TypedWebSocket.java +83 -0
  460. package/dist/runtime/java/UrlPath.java +49 -0
  461. package/dist/runtime/java/UrlQuery.java +99 -0
  462. package/dist/runtime/java/WsAdapter.java +52 -0
  463. package/dist/runtime/java/WsClose.java +47 -0
  464. package/dist/runtime/java/WsDial.java +148 -0
  465. package/dist/runtime/java/WsMessage.java +18 -0
  466. package/dist/runtime/mcp/call.ts +167 -0
  467. package/dist/runtime/mcp/files.ts +183 -0
  468. package/dist/runtime/mcp/guard.ts +176 -0
  469. package/dist/runtime/mcp/http.ts +159 -0
  470. package/dist/runtime/mcp/jsonrpc.ts +50 -0
  471. package/dist/runtime/mcp/listen.ts +76 -0
  472. package/dist/runtime/mcp/mount.ts +123 -0
  473. package/dist/runtime/mcp/protocol.ts +219 -0
  474. package/dist/runtime/mcp/reader.ts +57 -0
  475. package/dist/runtime/mcp/result.ts +85 -0
  476. package/dist/runtime/mcp/stdio.ts +79 -0
  477. package/dist/runtime/mcp/stream.ts +62 -0
  478. package/dist/runtime/python/__init__.py +2 -0
  479. package/dist/runtime/python/auth.py +67 -0
  480. package/dist/runtime/python/body.py +83 -0
  481. package/dist/runtime/python/config.py +139 -0
  482. package/dist/runtime/python/errors.py +213 -0
  483. package/dist/runtime/python/events.py +152 -0
  484. package/dist/runtime/python/exchange.py +298 -0
  485. package/dist/runtime/python/hooks.py +86 -0
  486. package/dist/runtime/python/invalidation.py +57 -0
  487. package/dist/runtime/python/log.py +60 -0
  488. package/dist/runtime/python/operation.py +25 -0
  489. package/dist/runtime/python/path.py +41 -0
  490. package/dist/runtime/python/query.py +48 -0
  491. package/dist/runtime/python/realtime.py +244 -0
  492. package/dist/runtime/python/redirect.py +93 -0
  493. package/dist/runtime/python/result.py +58 -0
  494. package/dist/runtime/python/send_async.py +189 -0
  495. package/dist/runtime/python/send_sync.py +105 -0
  496. package/dist/runtime/python/sse.py +81 -0
  497. package/dist/runtime/python/stale.py +94 -0
  498. package/dist/runtime/python/transport.py +157 -0
  499. package/dist/runtime/python/transport_longpoll.py +60 -0
  500. package/dist/runtime/python/transport_sse.py +60 -0
  501. package/dist/runtime/python/transport_ws.py +57 -0
  502. package/dist/runtime/python/ws.py +276 -0
  503. package/dist/runtime/rust/Cargo.lock +1763 -0
  504. package/dist/runtime/rust/answer.rs +120 -0
  505. package/dist/runtime/rust/auth.rs +80 -0
  506. package/dist/runtime/rust/body.rs +150 -0
  507. package/dist/runtime/rust/call.rs +200 -0
  508. package/dist/runtime/rust/config.rs +254 -0
  509. package/dist/runtime/rust/envelope.rs +84 -0
  510. package/dist/runtime/rust/errors.rs +235 -0
  511. package/dist/runtime/rust/events.rs +177 -0
  512. package/dist/runtime/rust/exchange.rs +287 -0
  513. package/dist/runtime/rust/hooks.rs +63 -0
  514. package/dist/runtime/rust/invalidation.rs +84 -0
  515. package/dist/runtime/rust/log.rs +88 -0
  516. package/dist/runtime/rust/nullable.rs +13 -0
  517. package/dist/runtime/rust/path.rs +83 -0
  518. package/dist/runtime/rust/query.rs +84 -0
  519. package/dist/runtime/rust/realtime.rs +182 -0
  520. package/dist/runtime/rust/realtime_loop.rs +177 -0
  521. package/dist/runtime/rust/redirect.rs +121 -0
  522. package/dist/runtime/rust/request.rs +178 -0
  523. package/dist/runtime/rust/result.rs +101 -0
  524. package/dist/runtime/rust/sse.rs +104 -0
  525. package/dist/runtime/rust/stale.rs +209 -0
  526. package/dist/runtime/rust/transport.rs +221 -0
  527. package/dist/runtime/rust/transport_longpoll.rs +108 -0
  528. package/dist/runtime/rust/transport_sse.rs +91 -0
  529. package/dist/runtime/rust/transport_ws.rs +75 -0
  530. package/dist/runtime/rust/ws.rs +322 -0
  531. package/dist/runtime/ts/app-types.ts +200 -0
  532. package/dist/runtime/ts/app.ts +104 -0
  533. package/dist/runtime/ts/config.ts +124 -0
  534. package/dist/runtime/ts/defaults.ts +48 -0
  535. package/dist/runtime/ts/error.ts +113 -0
  536. package/dist/runtime/ts/hooks.ts +92 -0
  537. package/dist/runtime/ts/http.ts +228 -0
  538. package/dist/runtime/ts/media-type.ts +36 -0
  539. package/dist/runtime/ts/path.ts +152 -0
  540. package/dist/runtime/ts/realtime-connection.ts +296 -0
  541. package/dist/runtime/ts/realtime-transports.ts +149 -0
  542. package/dist/runtime/ts/realtime.ts +293 -0
  543. package/dist/runtime/ts/redirect-policy.ts +17 -0
  544. package/dist/runtime/ts/redirects.ts +74 -0
  545. package/dist/runtime/ts/request.ts +239 -0
  546. package/dist/runtime/ts/response.ts +219 -0
  547. package/dist/runtime/ts/sdk-realtime.ts +10 -0
  548. package/dist/runtime/ts/sdk-sse.ts +55 -0
  549. package/dist/runtime/ts/sdk-ws.ts +21 -0
  550. package/dist/runtime/ts/sdk.ts +242 -0
  551. package/dist/runtime/ts/sse.ts +175 -0
  552. package/dist/runtime/ts/stale.ts +137 -0
  553. package/dist/runtime/ts/stream.ts +87 -0
  554. package/dist/runtime/ts/webhook.ts +116 -0
  555. package/dist/runtime/ts/ws.ts +155 -0
  556. package/dist/runtime/ts-tanstack-query/invalidate.ts +152 -0
  557. package/dist/runtime/ts-tanstack-query/query.ts +261 -0
  558. package/package.json +84 -5
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A JSON value as a TypeScript literal (bit 18): every string through the shared escape (F2), a key quoted when it is
3
+ * no identifier, and `__proto__` as a computed key, which defines an own property where a plain `__proto__:` in an
4
+ * object literal would set the object's prototype. Keys keep their order.
5
+ */
6
+ import { tsString } from "../shared/escape.js";
7
+ import { quoteKey } from "../shared/literals.js";
8
+ /** `key` as an object literal's key: `__proto__` computed, so it is a property and never the prototype. */
9
+ const keyOf = (key) => (key === "__proto__" ? `[${tsString(key)}]` : quoteKey(key));
10
+ /** `value` as a TypeScript literal, nested lines indented after `indent`. */
11
+ export function literal(value, indent = "") {
12
+ if (value === null)
13
+ return "null";
14
+ if (typeof value === "string")
15
+ return tsString(value);
16
+ if (typeof value === "boolean")
17
+ return String(value);
18
+ if (typeof value === "number") {
19
+ if (!Number.isFinite(value))
20
+ throw new Error(`no literal for ${value}`);
21
+ return String(value);
22
+ }
23
+ const inner = `${indent}\t`;
24
+ if (Array.isArray(value)) {
25
+ if (value.length === 0)
26
+ return "[]";
27
+ return `[\n${value.map((item) => `${inner}${literal(item, inner)},`).join("\n")}\n${indent}]`;
28
+ }
29
+ const entries = Object.entries(value);
30
+ if (entries.length === 0)
31
+ return "{}";
32
+ return `{\n${entries.map(([key, item]) => `${inner}${keyOf(key)}: ${literal(item, inner)},`).join("\n")}\n${indent}}`;
33
+ }
@@ -0,0 +1,21 @@
1
+ /** How `generateMcpHandler` names what it generates; a `dir` that a relative import cannot name makes it throw. */
2
+ export type McpHandlerOptions = {
3
+ /** the server's name: lowercase words joined by `-`; by default the document title's */
4
+ readonly name?: string;
5
+ /** the companion directory's name, beside the entry; `mcp` by default */
6
+ readonly dir?: string;
7
+ };
8
+ /**
9
+ * What `generateMcpHandler` returns, as source text for the caller to write: the entry, its companion files and the
10
+ * operations no tool serves.
11
+ */
12
+ export type GeneratedMcpHandler = {
13
+ /** the entry module, exporting `mcpHandler` */
14
+ readonly entry: string;
15
+ /** the companion directory's files, by name */
16
+ readonly files: Readonly<Record<string, string>>;
17
+ /** each operation marked x-mcp that no tool serves: its id and what it is */
18
+ readonly skipped: readonly string[];
19
+ };
20
+ /** The MCP handler for `document`'s tools, as its entry and the companion directory's files. */
21
+ export declare function generateMcpHandler(spec: Record<string, unknown>, options?: McpHandlerOptions): GeneratedMcpHandler;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The MCP handler an app mounts (bit 21 e, H24.3): the honey plugin's `codegen.mcp` output, from the app's own
3
+ * document. Its entry holds the tool table and the handler (`mcpHandler`) over the portable runtime and the API's own
4
+ * TS SDK, each in the companion directory beside it; @workerstack/backend/mcp's `mcp(app, path, mcpHandler)` mounts it.
5
+ * Each call runs in-process through the app. The handler is `secured` when any tool's operation requires a credential
6
+ * (its `security`, else the document's, with no empty requirement), and carries the headers the schemes those tools
7
+ * name read (an http, OAuth or OpenID scheme's Authorization, an API key's own header or Cookie; mutual TLS and a query
8
+ * key none), and the SDK's own.
9
+ */
10
+ import { toIR } from "../../ir/build.js";
11
+ import { tsString } from "../shared/escape.js";
12
+ import { generateSdk } from "../ts/sdk.js";
13
+ import { MOUNTED_FILE_SCHEMA } from "./files.js";
14
+ import { literal } from "./literal.js";
15
+ import { MCP_PORTABLE, mcpRuntimeSource } from "./runtime.js";
16
+ import { resolved } from "./server.js";
17
+ import { isTool, toolsOf, untoolable } from "./tools.js";
18
+ const MARKER = "// Code generated by honey. DO NOT EDIT.";
19
+ /* a directory name a relative import names */
20
+ const DIR = /^[A-Za-z0-9_][A-Za-z0-9_.-]*$/;
21
+ /** `op`'s security requirements: its own, else the document's. */
22
+ function requirementsOf(spec, op) {
23
+ /* a tool's operation is the document's own, at its path and method */
24
+ const paths = spec.paths;
25
+ const own = paths[op.path][op.method.toLowerCase()];
26
+ return own.security ?? spec.security ?? [];
27
+ }
28
+ /** The request header a scheme reads its credential from, lower case; none for a query key. */
29
+ function headerOf(scheme) {
30
+ if (["http", "oauth2", "openIdConnect"].includes(String(scheme?.type)))
31
+ return "authorization";
32
+ if (scheme?.type !== "apiKey")
33
+ return undefined;
34
+ return scheme.in === "header" ? String(scheme.name).toLowerCase() : scheme.in === "cookie" ? "cookie" : undefined;
35
+ }
36
+ /** Whether any tool needs a credential, and every header the tools' schemes and the SDK's own read, sorted. */
37
+ function securityOf(spec, ir) {
38
+ const schemes = (spec.components?.securitySchemes ?? {});
39
+ const requirements = ir.operations.filter(isTool).map((op) => requirementsOf(spec, op));
40
+ const named = requirements.flat().flatMap((requirement) => Object.keys(requirement));
41
+ const headers = [ir.auth.headerName.toLowerCase(), ...named.map((name) => headerOf(schemes[name]))];
42
+ return {
43
+ credentials: [...new Set(headers.filter((header) => header !== undefined))].sort(),
44
+ secured: requirements.some((list) => list.length > 0 && list.every((each) => Object.keys(each).length > 0)),
45
+ };
46
+ }
47
+ /** The path of the API's first server, where the app's routes sit: empty for none or the root. */
48
+ const serverPath = (server) => server === undefined ? "" : new URL(server, "http://localhost").pathname.replace(/\/$/, "");
49
+ /** The MCP handler for `document`'s tools, as its entry and the companion directory's files. */
50
+ export function generateMcpHandler(spec, options = {}) {
51
+ const dir = options.dir ?? "mcp";
52
+ if (!DIR.test(dir))
53
+ throw new Error(`Invalid dir: ${JSON.stringify(dir)}`);
54
+ const ir = toIR(spec, { deriveOperationIds: true });
55
+ const { name } = resolved({ name: options.name }, ir.info.title);
56
+ const specs = toolsOf(ir, MOUNTED_FILE_SCHEMA);
57
+ if (specs.length === 0)
58
+ throw new Error("No operation marked x-mcp is one a tool can call: nothing to mount");
59
+ const { credentials, secured } = securityOf(spec, ir);
60
+ const sdk = generateSdk(spec, { name: "Api", stem: "api" });
61
+ const entry = `${MARKER}
62
+
63
+ // The ${name} API's tools, mounted in the app: mcp(app, path, mcpHandler) from @workerstack/backend/mcp serves them over
64
+ // Streamable HTTP, each call dispatched in-process through the app. ${secured ? "Its tools require a credential, so the mount needs authenticate." : "No tool requires a credential."}
65
+ import type { ToolSpec } from "./${dir}/runtime.gen"
66
+ import { mountedMcp } from "./${dir}/runtime.gen"
67
+ import { Api } from "./${dir}/api.index.gen"
68
+
69
+ const toolSpecs: readonly ToolSpec[] = ${literal(specs)}
70
+
71
+ export const mcpHandler = mountedMcp({
72
+ challenge: ${tsString(ir.auth.prefix.trim() || "ApiKey")},
73
+ client: (config) => new Api(config),
74
+ credentials: ${JSON.stringify(credentials)},
75
+ info: { name: ${tsString(name)}, version: ${tsString(ir.info.version ?? "0.0.0")} },
76
+ secured: ${secured},
77
+ server: ${tsString(serverPath(ir.servers[0]))},
78
+ specs: toolSpecs,
79
+ })
80
+ `;
81
+ return {
82
+ entry,
83
+ files: { "runtime.gen.ts": mcpRuntimeSource(MCP_PORTABLE), ...sdk.files },
84
+ skipped: ir.operations.flatMap((op) => {
85
+ const what = op.extensions.mcp === true ? untoolable(op) : undefined;
86
+ return what === undefined ? [] : [`${op.id} (${what})`];
87
+ }),
88
+ };
89
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * A tool's outputSchema (bit 18 phase d, D1): from its operation's success answer as the TS SDK picks it, when that is
3
+ * JSON with a schema. An object schema goes as it is. Any other shape is wrapped `{result}`, since structuredContent is
4
+ * an object (2025-11-25), and so is an answer whose operation declares response headers (Q11), as `{result, headers}`:
5
+ * a body key named `headers` then never meets them. Each header is a string, as it arrives. No JSON success schema
6
+ * means no outputSchema: the result is text only. An event stream's collect (phase e) is `{events, last_event_id,
7
+ * ended}`, each event's data its declared schema, else a string.
8
+ */
9
+ import type { IR } from "../../ir/model.ts";
10
+ import type { SdkOp } from "../../ir/sdk-model.ts";
11
+ import { type JsonSchema } from "./schema.ts";
12
+ /** A tool's outputSchema, and whether its structuredContent wraps the answer. */
13
+ export type Output = {
14
+ readonly outputSchema: JsonSchema;
15
+ readonly wrap?: true;
16
+ };
17
+ /** The outputSchema `op`'s success answer gives, or none. */
18
+ export declare function outputOf(op: SdkOp, ir: IR): Output | undefined;
@@ -0,0 +1,38 @@
1
+ import { jsonSchemaOf } from "./schema.js";
2
+ /** What a collect gathered, its events' data as `data` says. */
3
+ const collectedOf = (data) => ({
4
+ type: "object",
5
+ properties: {
6
+ events: {
7
+ type: "array",
8
+ items: {
9
+ type: "object",
10
+ properties: { data, event: { type: "string" }, id: { type: "string" } },
11
+ required: ["data"],
12
+ },
13
+ },
14
+ last_event_id: { anyOf: [{ type: "string" }, { type: "null" }] },
15
+ ended: { type: "string", enum: ["end", "max_events", "cap", "timeout"] },
16
+ },
17
+ required: ["events", "last_event_id", "ended"],
18
+ });
19
+ /** The outputSchema `op`'s success answer gives, or none. */
20
+ export function outputOf(op, ir) {
21
+ if (op.stream === "sse")
22
+ return {
23
+ outputSchema: collectedOf(op.events === undefined ? { type: "string" } : jsonSchemaOf(op.events, ir.schemas)),
24
+ };
25
+ /* the SDK model gives a success its schema only when it is JSON */
26
+ if (op.success.schema === undefined)
27
+ return undefined;
28
+ const result = jsonSchemaOf(op.success.schema, ir.schemas);
29
+ const names = [...new Set((op.ir.responses[op.success.status]?.headers ?? []).map(({ name }) => name.toLowerCase()))];
30
+ if (result.type === "object" && names.length === 0)
31
+ return { outputSchema: result };
32
+ /* null-prototype: a header named __proto__ is a property, never the object's prototype */
33
+ const headers = Object.create(null);
34
+ for (const name of names.sort())
35
+ headers[name] = { type: "string" };
36
+ const properties = names.length === 0 ? { result } : { result, headers: { type: "object", properties: headers } };
37
+ return { outputSchema: { type: "object", properties, required: ["result"] }, wrap: true };
38
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The MCP registry's `server.json` (plan 39 8.8), written beside package.json when the server has an `mcpName`:
3
+ * `mcp-publisher publish` reads it from the package's root, and the registry checks package.json's `mcpName` against
4
+ * its `name`. Its fields are the 2025-12-11 schema's: the name, a description of 100 characters at most (the run's,
5
+ * else the package's own), the version npm publishes, and the one npm package over stdio with every environment
6
+ * variable the server reads there. The home page is its `websiteUrl`; a GitHub or GitLab repository its `repository`.
7
+ * No `remotes`: where a server is hosted is a deployment's, not the spec's.
8
+ */
9
+ import type { IR } from "../../ir/model.ts";
10
+ import type { Metadata } from "../shared/metadata.ts";
11
+ /** The schema the file names, the registry's latest dated one. */
12
+ export declare const SERVER_SCHEMA = "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json";
13
+ /** The server as the registry lists it: its names, the version npm publishes, and what its environment holds. */
14
+ export type Listing = {
15
+ readonly name: string;
16
+ readonly mcpName: string;
17
+ readonly packageName: string;
18
+ readonly version: string;
19
+ readonly envPrefix: string;
20
+ readonly files: boolean;
21
+ };
22
+ /** server.json for `listing`, from the run's `metadata` and the API's `ir`. */
23
+ export declare function serverJson(listing: Listing, ir: IR, metadata: Metadata): string;
@@ -0,0 +1,83 @@
1
+ /** The schema the file names, the registry's latest dated one. */
2
+ export const SERVER_SCHEMA = "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json";
3
+ /* the registry's cap on a description, in characters */
4
+ const DESCRIPTION_MAX = 100;
5
+ /* the forges the registry knows by host: the `source` it validates a repository through */
6
+ const SOURCES = { "github.com": "github", "gitlab.com": "gitlab" };
7
+ /** Every variable the server reads over stdio, as its entry reads them; the HTTP transport's are not the package's. */
8
+ function variablesOf(listing, ir) {
9
+ const prefix = listing.envPrefix;
10
+ const server = ir.servers[0];
11
+ const sent = `${ir.auth.headerName}: ${ir.auth.prefix}<key>`;
12
+ return [
13
+ { description: `The API key, sent as ${sent}`, isSecret: true, name: `${prefix}_API_KEY` },
14
+ {
15
+ description: "The API's base URL",
16
+ name: `${prefix}_BASE_URL`,
17
+ ...(server === undefined ? { isRequired: true } : { default: server }),
18
+ },
19
+ { default: "30000", description: "A call's limit in milliseconds", format: "number", name: `${prefix}_TIMEOUT_MS` },
20
+ { description: "A JSON object of headers sent on every call", isSecret: true, name: `${prefix}_HEADERS` },
21
+ {
22
+ choices: ["same-origin", "follow"],
23
+ default: "same-origin",
24
+ description: "Whether a call follows a redirect to another origin",
25
+ name: `${prefix}_REDIRECT`,
26
+ },
27
+ ...(listing.files
28
+ ? [
29
+ {
30
+ description: "The directory a tool reads files from",
31
+ format: "filepath",
32
+ name: `${prefix}_FILE_ROOT`,
33
+ },
34
+ {
35
+ default: "1048576",
36
+ description: "The most bytes of a file sent inline",
37
+ format: "number",
38
+ name: `${prefix}_MAX_INLINE_BYTES`,
39
+ },
40
+ {
41
+ default: "52428800",
42
+ description: "The most bytes of a file a tool reads",
43
+ format: "number",
44
+ name: `${prefix}_MAX_FILE_BYTES`,
45
+ },
46
+ ]
47
+ : []),
48
+ ];
49
+ }
50
+ /** The description the registry shows: the run's, else the package's own, refused past the registry's cap. */
51
+ function descriptionOf(listing, metadata) {
52
+ const text = metadata.description ?? `The ${listing.name} API as MCP tools`;
53
+ if ([...text].length > DESCRIPTION_MAX)
54
+ throw new Error(`Invalid metadata.description: ${JSON.stringify(text)}: the MCP registry takes ${DESCRIPTION_MAX} characters at most`);
55
+ return text;
56
+ }
57
+ /** The repository as the registry links it, for a forge it knows; none for another host. */
58
+ function repositoryOf(repository) {
59
+ if (repository === undefined)
60
+ return {};
61
+ const source = SOURCES[new URL(repository).hostname];
62
+ return source === undefined ? {} : { repository: { source, url: repository.replace(/\.git$/, "") } };
63
+ }
64
+ /** server.json for `listing`, from the run's `metadata` and the API's `ir`. */
65
+ export function serverJson(listing, ir, metadata) {
66
+ const npm = {
67
+ environmentVariables: variablesOf(listing, ir),
68
+ identifier: listing.packageName,
69
+ registryType: "npm",
70
+ transport: { type: "stdio" },
71
+ version: listing.version,
72
+ };
73
+ const server = {
74
+ $schema: SERVER_SCHEMA,
75
+ name: listing.mcpName,
76
+ description: descriptionOf(listing, metadata),
77
+ version: listing.version,
78
+ ...(metadata.homepage === undefined ? {} : { websiteUrl: metadata.homepage }),
79
+ ...repositoryOf(metadata.repository),
80
+ packages: [npm],
81
+ };
82
+ return `${JSON.stringify(server, null, "\t")}\n`;
83
+ }
@@ -0,0 +1,10 @@
1
+ /** The portable runtime modules, each after the ones it imports: no node API, none of the node modules. */
2
+ export declare const MCP_PORTABLE: readonly string[];
3
+ /** The node modules the standalone package adds: stdio, its file reader, the HTTP listener. */
4
+ export declare const MCP_NODE: readonly string[];
5
+ /** Every runtime module under `runtime/mcp`, each after the ones it imports. */
6
+ export declare const MCP_RUNTIME: readonly string[];
7
+ /** The standalone package's: every module but the mount, which only an app's handler serves. */
8
+ export declare const MCP_STANDALONE: readonly string[];
9
+ /** The vendored runtime as one module: `names` (the standalone package's by default) in order, sibling imports dropped. */
10
+ export declare function mcpRuntimeSource(names?: readonly string[]): string;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The MCP server's vendored runtime (bit 18), as the emitter ships it: `runtime/mcp` modules joined into one, each
3
+ * after the ones it imports, their imports of each other dropped. A module of its own, so the gen mutation harness can
4
+ * swap the runtime a guard is switched off in, and every emitter call sees it. Bit 21 e: the portable modules (web
5
+ * APIs alone) are what an app mounts, on Workers too; the standalone package adds the node ones after them.
6
+ */
7
+ import { readFileSync } from "node:fs";
8
+ /** The portable runtime modules, each after the ones it imports: no node API, none of the node modules. */
9
+ export const MCP_PORTABLE = [
10
+ "jsonrpc",
11
+ "files",
12
+ "protocol",
13
+ "http",
14
+ "guard",
15
+ "result",
16
+ "stream",
17
+ "call",
18
+ "mount",
19
+ ];
20
+ /** The node modules the standalone package adds: stdio, its file reader, the HTTP listener. */
21
+ export const MCP_NODE = ["stdio", "reader", "listen"];
22
+ /** Every runtime module under `runtime/mcp`, each after the ones it imports. */
23
+ export const MCP_RUNTIME = [...MCP_PORTABLE, ...MCP_NODE];
24
+ /** The standalone package's: every module but the mount, which only an app's handler serves. */
25
+ export const MCP_STANDALONE = [
26
+ "jsonrpc",
27
+ "files",
28
+ "protocol",
29
+ "http",
30
+ "guard",
31
+ "result",
32
+ "stream",
33
+ "call",
34
+ "stdio",
35
+ "reader",
36
+ "listen",
37
+ ];
38
+ /* an import of a sibling runtime module, on one line or several */
39
+ const SIBLING_IMPORT = /^import\s+(?:type\s+)?\{[^}]*\}\s+from\s+"\.\/[\w-]+\.ts"\n/gm;
40
+ const MARKER = "// Code generated by honey. DO NOT EDIT.";
41
+ /** The vendored runtime as one module: `names` (the standalone package's by default) in order, sibling imports dropped. */
42
+ export function mcpRuntimeSource(names = MCP_STANDALONE) {
43
+ const modules = names.map((name) => readFileSync(new URL(`../../runtime/mcp/${name}.ts`, import.meta.url), "utf8")
44
+ .replace(SIBLING_IMPORT, "")
45
+ .trim());
46
+ return `${MARKER}\n\n${modules.join("\n\n")}\n`;
47
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * An IR schema as the JSON Schema a tool's inputSchema holds (bit 18 phase b): self-contained, every ref inlined, as
3
+ * terse as it can be read. A ref back to a schema being inlined becomes `{}`, any value, so a recursive model ends; a
4
+ * pure cycle of refs with no schema between is an error, as is a schema past a node budget (shared refs inlined over and
5
+ * over). Descriptions are spec text: their controls dropped (helpText), as the CLI's help drops them.
6
+ */
7
+ import type { IRSchema } from "../../ir/model.ts";
8
+ /** A JSON Schema, as plain data. */
9
+ export type JsonSchema = {
10
+ readonly [key: string]: unknown;
11
+ };
12
+ /** The most nodes one schema may inline to by default: past it, a schema is refused, not emitted. */
13
+ export declare const NODE_BUDGET = 50000;
14
+ /** `text` as a description: its controls dropped, nothing when it is empty. */
15
+ export declare const describe: (text: string | undefined) => {
16
+ description?: string;
17
+ };
18
+ /** `schema` as a self-contained JSON Schema, every ref into `schemas` inlined, refused past `budget` nodes. */
19
+ export declare function jsonSchemaOf(schema: IRSchema, schemas: Readonly<Record<string, IRSchema>>, budget?: number): JsonSchema;
@@ -0,0 +1,88 @@
1
+ import { helpText } from "../cli/flags.js";
2
+ /** The most nodes one schema may inline to by default: past it, a schema is refused, not emitted. */
3
+ export const NODE_BUDGET = 50_000;
4
+ /** `text` as a description: its controls dropped, nothing when it is empty. */
5
+ export const describe = (text) => {
6
+ const shown = helpText(text ?? "").trim();
7
+ return shown === "" ? {} : { description: shown };
8
+ };
9
+ /** An object's fields as JSON Schema properties and their required names. */
10
+ function objectOf(fields, additional, walk) {
11
+ const required = fields.filter((field) => field.required).map((field) => field.name);
12
+ return {
13
+ type: "object",
14
+ properties: Object.fromEntries(fields.map((field) => [field.name, { ...convert(field.schema, walk), ...describe(field.description) }])),
15
+ ...(required.length > 0 ? { required } : {}),
16
+ ...(additional === undefined
17
+ ? {}
18
+ : { additionalProperties: additional === false ? false : convert(additional, walk) }),
19
+ };
20
+ }
21
+ /** `name`'s schema inlined, or `{}` when it is one being inlined already. */
22
+ function inlineRef(name, walk) {
23
+ if (walk.open.includes(name))
24
+ return {};
25
+ const target = walk.schemas[name];
26
+ if (target === undefined)
27
+ return {};
28
+ if (target.kind === "ref" && (target.name === name || walk.open.includes(target.name)))
29
+ throw new Error(`a $ref cycle with no schema between: ${[...walk.open, name, target.name].join(" → ")}`);
30
+ return convert(target, { ...walk, open: [...walk.open, name] });
31
+ }
32
+ /** A scalar: its type, and its format, enum and constraint keywords when it has them. */
33
+ function scalarOf(schema) {
34
+ const { enum: values, format, kind: _kind, type, ...bounds } = schema;
35
+ return {
36
+ type,
37
+ ...(format === undefined ? {} : { format }),
38
+ ...(values === undefined || values.length === 0 ? {} : { enum: values }),
39
+ ...bounds,
40
+ };
41
+ }
42
+ /** A tuple: its fixed items, what may follow them, and how many must be there. */
43
+ function tupleOf(schema, walk) {
44
+ return {
45
+ type: "array",
46
+ prefixItems: schema.items.map((item) => convert(item, walk)),
47
+ items: schema.rest === undefined ? false : convert(schema.rest, walk),
48
+ minItems: schema.required ?? schema.items.length,
49
+ };
50
+ }
51
+ /** `schema` as JSON Schema under `walk`. */
52
+ function convert(schema, walk) {
53
+ if (++walk.nodes.count > walk.budget)
54
+ throw new Error(`a schema inlines past ${walk.budget} nodes`);
55
+ switch (schema.kind) {
56
+ case "scalar":
57
+ return scalarOf(schema);
58
+ case "const":
59
+ return { const: schema.value };
60
+ case "object":
61
+ return objectOf(schema.fields, schema.additional, walk);
62
+ case "array":
63
+ return {
64
+ type: "array",
65
+ items: convert(schema.items, walk),
66
+ ...(schema.minItems === undefined ? {} : { minItems: schema.minItems }),
67
+ ...(schema.maxItems === undefined ? {} : { maxItems: schema.maxItems }),
68
+ };
69
+ case "tuple":
70
+ return tupleOf(schema, walk);
71
+ case "union":
72
+ return { anyOf: schema.variants.map((variant) => convert(variant, walk)) };
73
+ case "allOf":
74
+ return { allOf: schema.parts.map((part) => convert(part, walk)) };
75
+ case "ref":
76
+ return inlineRef(schema.name, walk);
77
+ case "nullable":
78
+ return { anyOf: [convert(schema.inner, walk), { type: "null" }] };
79
+ case "binary":
80
+ return { type: "string", contentEncoding: "base64" };
81
+ case "unknown":
82
+ return {};
83
+ }
84
+ }
85
+ /** `schema` as a self-contained JSON Schema, every ref into `schemas` inlined, refused past `budget` nodes. */
86
+ export function jsonSchemaOf(schema, schemas, budget = NODE_BUDGET) {
87
+ return convert(schema, { budget, nodes: { count: 0 }, open: [], schemas });
88
+ }
@@ -0,0 +1,30 @@
1
+ import { type Metadata, type PackageIdentity } from "../shared/metadata.ts";
2
+ export type McpServerOptions = {
3
+ /** the server's name: lowercase words joined by `-`, at most 60 characters; by default the document title's */
4
+ readonly name?: string;
5
+ /** the prefix of its environment variables; by default the name's words, uppercased, joined by `_` */
6
+ readonly envPrefix?: string;
7
+ /** the version its server info and package.json carry, one npm accepts; by default the document's */
8
+ readonly version?: string;
9
+ /** the npm name it publishes under; `<name>-mcp` by default, the bin's name either way */
10
+ readonly packageName?: string;
11
+ /** the MCP registry's name for it, `namespace/name` (`io.github.acme/shop`): package.json's `mcpName`, which the
12
+ * registry checks the npm package by; none by default */
13
+ readonly mcpName?: string;
14
+ };
15
+ export type GeneratedMcpServer = {
16
+ readonly files: Readonly<Record<string, string>>;
17
+ /** the package as npm lists it, and as the MCP registry does when it has an `mcpName` */
18
+ readonly packages: readonly PackageIdentity[];
19
+ /** each operation marked x-mcp that no tool serves: its id and what it is */
20
+ readonly skipped: readonly string[];
21
+ };
22
+ /** The options with their defaults filled, each refused unless it matches its grammar (F2). */
23
+ export declare function resolved(options: McpServerOptions, title: string | undefined): {
24
+ envPrefix: string;
25
+ name: string;
26
+ };
27
+ /** `source` with its types erased, as ES module JavaScript; the entry gets the shebang a bin needs. */
28
+ export declare function erased(path: string, source: string): string;
29
+ /** The MCP server for `document`, as its package's files, its package.json carrying `metadata`. */
30
+ export declare function generateMcpServer(document: Record<string, unknown>, options?: McpServerOptions, metadata?: Metadata): GeneratedMcpServer;