@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,94 @@
1
+ #!/usr/bin/env node
2
+ // The honey-clients bin (bit 17 phase h). A repository checkout (marked by tsconfig.json, which is not published)
3
+ // runs the TypeScript source, natively on Bun (under the honey-source condition) and through jiti on Node, so a stale
4
+ // dist/ never runs; an installed package runs the compiled JavaScript on any runtime (the tarball ships dist/, not src/).
5
+ import { spawn } from "node:child_process"
6
+ import { existsSync } from "node:fs"
7
+ import { basename } from "node:path"
8
+ import { fileURLToPath } from "node:url"
9
+
10
+ const isBun = typeof globalThis.Bun !== "undefined"
11
+ const checkout = existsSync(new URL("../tsconfig.json", import.meta.url))
12
+
13
+ // `bun run` and `bunx` start this file through its node shebang, while what they run is meant for Bun: hand over to
14
+ // the Bun that started us, which they name in npm_execpath. Once, never again in the child.
15
+ function invokingBun() {
16
+ if (isBun || process.env.HONEY_NO_BUN_HANDOFF === "1") return null
17
+ if (!process.env.npm_config_user_agent?.startsWith("bun/")) return null
18
+ const bun = process.env.npm_execpath
19
+ if (!bun || !/^bunx?(\.exe)?$/.test(basename(bun)) || !existsSync(bun)) return null
20
+ return bun
21
+ }
22
+
23
+ // The handoff: Bun runs this file with our arguments and `env` over ours; a signal we get is passed on to it, and we
24
+ // end as it ended, its exit code or the same signal.
25
+ function handOff(bun, env) {
26
+ // Forwarders first: a signal landing as spawn returns would otherwise end this process by its default action,
27
+ // orphaning the child. A handler runs from the event loop, after this block, so `child` is set by then.
28
+ let child
29
+ const forward = (signal) => child.kill(signal)
30
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) process.on(signal, forward)
31
+ child = spawn(bun, [fileURLToPath(import.meta.url), ...process.argv.slice(2)], {
32
+ env: { ...process.env, ...env, HONEY_NO_BUN_HANDOFF: "1" },
33
+ stdio: "inherit",
34
+ })
35
+ child.on("error", (error) => {
36
+ console.error(`honey-clients: could not start ${bun}: ${error.message}`)
37
+ process.exit(1)
38
+ })
39
+ child.on("exit", (code, signal) => {
40
+ if (signal) {
41
+ for (const each of ["SIGINT", "SIGTERM", "SIGHUP"]) process.off(each, forward)
42
+ process.kill(process.pid, signal)
43
+ return
44
+ }
45
+ process.exit(code ?? 1)
46
+ })
47
+ }
48
+
49
+ // A checkout on Bun runs under the honey-source condition: an --app module's checkout core then resolves to its
50
+ // source, never to an unbuilt or stale dist/ (bit 20). Set through BUN_OPTIONS when the caller did not, in the one
51
+ // handoff, so a watch's generation children inherit it; Bun reports BUN_OPTIONS' flags in execArgv, so a Bun started
52
+ // with it never hands off again.
53
+ const SOURCE_CONDITION = "--conditions=honey-source"
54
+ const unconditioned = isBun && checkout && !process.execArgv.includes(SOURCE_CONDITION)
55
+ // The hand-off's backstop: its child carries HONEY_BUN_HANDOFF, the depth of hand-offs before it. A child that would
56
+ // hand off again (the condition set but not in its execArgv) refuses instead of re-running itself without end.
57
+ const handOffDepth = Number(process.env.HONEY_BUN_HANDOFF ?? 0)
58
+ const sourceEnv = checkout
59
+ ? {
60
+ BUN_OPTIONS: `${process.env.BUN_OPTIONS ?? ""} ${SOURCE_CONDITION}`.trim(),
61
+ HONEY_BUN_HANDOFF: String(handOffDepth + 1),
62
+ }
63
+ : {}
64
+
65
+ async function entry() {
66
+ if (checkout) {
67
+ if (isBun) return import("../src/cli.ts")
68
+ const { createJiti } = await import("jiti")
69
+ return createJiti(import.meta.url).import("../src/cli.ts")
70
+ }
71
+ try {
72
+ return await import("../dist/cli.js")
73
+ } catch (error) {
74
+ if (error?.code === "ERR_MODULE_NOT_FOUND" && String(error.url).endsWith("/dist/cli.js")) {
75
+ console.error("honey-clients: dist/ is missing from this install. Reinstall it, or run it with Bun.")
76
+ process.exit(1)
77
+ }
78
+ throw error
79
+ }
80
+ }
81
+
82
+ const bun = invokingBun()
83
+ if (bun) handOff(bun, sourceEnv)
84
+ else if (unconditioned && handOffDepth >= 1) {
85
+ console.error("honey-clients: Bun hand-off loop: --conditions=honey-source not visible after re-exec")
86
+ process.exit(1)
87
+ } else if (unconditioned) handOff(process.execPath, sourceEnv)
88
+ else {
89
+ const { main } = await entry()
90
+ const code = await main(process.argv.slice(2))
91
+ /* an --app module may leave a timer or a socket open: the run is over once main returns, its output flushed */
92
+ for (const stream of [process.stdout, process.stderr]) await new Promise((done) => stream.write("", done))
93
+ process.exit(code)
94
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,102 @@
1
+ import { type Metadata, type PackageIdentity } from "./emit/shared/metadata.ts";
2
+ import { type Target, type TargetOptions } from "./gen/targets.ts";
3
+ import { type ReadFile } from "./gen/shipped.ts";
4
+ /**
5
+ * What one run generates: its targets, and each target's options by name (a target whose options are left out
6
+ * takes its generator's defaults). The CLI parses `generate` into one of these; a consumer writes one by hand.
7
+ */
8
+ export type GenerateRun = {
9
+ /**
10
+ * Each target's options by name, as `--<target>-<option>` carries them; a target left out takes its defaults. Each
11
+ * is checked by its target's schema (`targetOptionSchemas`) before anything generates.
12
+ */
13
+ readonly options?: {
14
+ readonly [T in Target]?: TargetOptions<T>;
15
+ };
16
+ /**
17
+ * The package metadata given once for every target (`description`, `homepage`, `repository`, `license`,
18
+ * `authors`, ...): each target fills its options of the same meaning from it, its own option winning. Checked
19
+ * against the shared grammars before anything generates.
20
+ */
21
+ readonly metadata?: Metadata;
22
+ /** The targets to generate, in the order given. */
23
+ readonly targets: readonly Target[];
24
+ };
25
+ /** What a generation reads beside its run: the environment, where skips are reported, the oxfmt module to load. */
26
+ export type GenerateContext = {
27
+ /**
28
+ * Where formatters are looked up (`PATH`, `GOROOT`, `GOFMT`, `RUFF`, `RUSTFMT`); `HONEY_REQUIRE_FORMATTERS=1` makes
29
+ * a missing one throw.
30
+ */
31
+ readonly env: NodeJS.ProcessEnv;
32
+ /**
33
+ * Receives each notice as one newline-terminated line: a name an SDK renamed, an operation no MCP tool serves, a
34
+ * missing formatter.
35
+ */
36
+ readonly report: (line: string) => void;
37
+ /**
38
+ * The module specifier oxfmt is imported from, "oxfmt" by default; when it is not installed, TS goes out as
39
+ * emitted, unreported.
40
+ */
41
+ readonly oxfmt?: string;
42
+ /**
43
+ * Reads the files the metadata block names (`readme`, `licenseFile`, `icon`): `readFileSync` by default, so a path is the
44
+ * working directory's.
45
+ */
46
+ readonly read?: ReadFile;
47
+ };
48
+ /**
49
+ * One target's generation (plan 39 8.7): its files by path under the target's directory, each one's text but for the
50
+ * C# package's icon, which is its bytes, and the package they make as each registry it publishes to lists it.
51
+ */
52
+ export type GeneratedTarget<T extends Target> = {
53
+ /** each file by its path under the target's directory: its text, or its bytes (the C# package's icon) */
54
+ readonly files: Readonly<Record<string, T extends "csharp" ? string | Uint8Array : string>>;
55
+ /** the package on each registry it publishes to, which `writeTarget` records in the manifest */
56
+ readonly packages: readonly PackageIdentity[];
57
+ };
58
+ /** A run's generation: each generated target's. */
59
+ export type Generated = {
60
+ readonly [T in Target]?: GeneratedTarget<T>;
61
+ };
62
+ /**
63
+ * Every file a run writes, by target and its path under the target's directory. Go goes through gofmt, Python through
64
+ * ruff, Rust through rustfmt and TS through oxfmt; C# and Java go out as emitted, as does a target whose formatter is
65
+ * missing, unless `HONEY_REQUIRE_FORMATTERS=1` makes that throw. The README and license file the metadata block names
66
+ * go into every target's root as they are, its icon into the C# package's alone.
67
+ */
68
+ export declare function generated(run: GenerateRun, document: Record<string, unknown>, { env, oxfmt, read, report }: GenerateContext): Promise<Generated>;
69
+ /** Where the CLI writes: standard output and standard error, by default the process's. */
70
+ export type Io = {
71
+ /** Receives the CLI's standard output, whole lines ending in a newline: the usage text and each run's summary. */
72
+ readonly out: (text: string) => void;
73
+ /**
74
+ * Receives the CLI's standard error, ending in a newline: failures, usage errors, notices and stale files it kept.
75
+ */
76
+ readonly err: (text: string) => void;
77
+ };
78
+ /**
79
+ * `document`'s targets generated and written under `<out>/<target>`, stale files deleted unless edited since (those are
80
+ * kept and named on `io.err`).
81
+ */
82
+ export declare function writeGenerated(run: GenerateRun & {
83
+ /** The directory each target's directory is written under. */
84
+ readonly out: string;
85
+ }, document: Record<string, unknown>, io: Io, env: NodeJS.ProcessEnv): Promise<number>;
86
+ /** What a run takes beside its arguments: the environment, the directory paths resolve from, a watch's stop signal. */
87
+ export type RunOptions = {
88
+ /** The directory the spec, the app module and `--out` resolve from. Defaults to the process's. */
89
+ readonly cwd?: string;
90
+ /**
91
+ * The environment formatters are looked up in, laid over the process's for each `--watch` child. Defaults to the
92
+ * process's.
93
+ */
94
+ readonly env?: NodeJS.ProcessEnv;
95
+ /**
96
+ * Stops a `--watch` run, which ends with 0 once the generation in progress finishes. Without it a watch never
97
+ * returns.
98
+ */
99
+ readonly signal?: AbortSignal;
100
+ };
101
+ /** Runs `honey-clients <argv>`: the exit code it ends with (a watch ends only by `options.signal`). */
102
+ export declare function main(argv: readonly string[], io?: Io, options?: RunOptions): Promise<number>;
package/dist/cli.js ADDED
@@ -0,0 +1,190 @@
1
+ /**
2
+ * The honey-clients generate CLI (bit 17 phase h): `honey-clients generate --spec <openapi.json> --target <name>...
3
+ * --out <dir>` writes each target's generated files under `<out>/<target>`. A target's options are its generate
4
+ * function's, spelled `--<target>-<option>` and passed through untouched: each generator validates its own. The go and
5
+ * cli targets' whole trees go through gofmt (the post-pass), so a missing gofmt is a refusal, never unformatted Go; the
6
+ * ts target's files go through oxfmt, the optional peer, imported lazily, and go out as emitted without it (00-rules).
7
+ * `--watch` regenerates in a fresh child on each change of the spec. Parsing is strict: an unknown flag, a missing
8
+ * value, a stray argument or an option for a target not asked for is a usage error. Each target is written through
9
+ * write.ts: only changed files, a hashed manifest, a removed operation's unedited files deleted (bit 19 h1). `--app`
10
+ * generates from a honey app module instead of a spec, its document made by the app's own core (ir/load.ts, bit 19 h2).
11
+ */
12
+ import { readFileSync, watch } from "node:fs";
13
+ import { basename, dirname, join, resolve } from "node:path";
14
+ import { generateGoCli } from "./emit/cli/module.js";
15
+ import { generateCSharpSdk } from "./emit/csharp/sdk.js";
16
+ import { generateGoSdk } from "./emit/go/sdk.js";
17
+ import { generateJavaSdk } from "./emit/java/sdk.js";
18
+ import { generateMcpServer } from "./emit/mcp/server.js";
19
+ import { generatePythonSdk } from "./emit/python/sdk.js";
20
+ import { generateRustSdk } from "./emit/rust/sdk.js";
21
+ import { formatFiles } from "./emit/shared/format.js";
22
+ import { generateSdkPackage } from "./emit/ts/package.js";
23
+ import { parseGenerate, usage, UsageError } from "./gen/args.js";
24
+ import { FORMATTERS, formatterFor, missingFormatter } from "./gen/formatters.js";
25
+ import { runCli } from "./gen/process.js";
26
+ import { appRef, loadAppDocument } from "./ir/load.js";
27
+ import { checkedMetadata, shippedOf } from "./emit/shared/metadata.js";
28
+ import { optionsFor } from "./gen/targets.js";
29
+ import { shippedFiles } from "./gen/shipped.js";
30
+ import { writeTarget } from "./gen/write.js";
31
+ /** One SDK target's generation: its files, its package's identity on each registry, and what it reports (a name it renamed). */
32
+ function sdkOf(target, document, options, metadata) {
33
+ switch (target) {
34
+ case "ts":
35
+ /* mapped key by key, never spread: `options` holds strings, and `tanstackQuery` is a boolean —
36
+ a spread under a cast would make "false" as truthy as "true" */
37
+ return generateSdkPackage(document, {
38
+ name: options.name ?? "SDK",
39
+ ...(options.packageName === undefined ? {} : { packageName: options.packageName }),
40
+ ...(options.stem === undefined ? {} : { stem: options.stem }),
41
+ tanstackQuery: options.tanstackQuery === "true",
42
+ ...(options.version === undefined ? {} : { version: options.version }),
43
+ }, metadata);
44
+ case "go":
45
+ return generateGoSdk(document, options);
46
+ case "rust":
47
+ return generateRustSdk(document, options, shippedOf(metadata));
48
+ case "python":
49
+ return generatePythonSdk(document, options, metadata);
50
+ case "csharp":
51
+ return generateCSharpSdk(document, options, shippedOf(metadata));
52
+ case "java":
53
+ return generateJavaSdk(document, options);
54
+ }
55
+ }
56
+ /**
57
+ * One target's files for `document`, by their path under the target's directory, and its package's identity on each
58
+ * registry; what it leaves out to `report`. The metadata reaches the targets whose package files read it whole, the
59
+ * others through their options.
60
+ */
61
+ function packageOf(target, document, { metadata, options }, report) {
62
+ if (target === "cli")
63
+ return generateGoCli(document, options);
64
+ if (target === "mcp") {
65
+ const server = generateMcpServer(document, options, metadata);
66
+ for (const op of server.skipped)
67
+ report(`honey-clients: mcp: no tool serves ${op} yet: skipped\n`);
68
+ return server;
69
+ }
70
+ const sdk = sdkOf(target, document, options, metadata);
71
+ for (const notice of sdk.notices)
72
+ report(`honey-clients: ${notice}\n`);
73
+ return sdk;
74
+ }
75
+ /**
76
+ * Every file a run writes, by target and its path under the target's directory. Go goes through gofmt, Python through
77
+ * ruff, Rust through rustfmt and TS through oxfmt; C# and Java go out as emitted, as does a target whose formatter is
78
+ * missing, unless `HONEY_REQUIRE_FORMATTERS=1` makes that throw. The README and license file the metadata block names
79
+ * go into every target's root as they are, its icon into the C# package's alone.
80
+ */
81
+ export async function generated(run, document, { env, oxfmt, read = readFileSync, report }) {
82
+ const metadata = checkedMetadata(run.metadata ?? {});
83
+ const shipped = shippedFiles(metadata, read);
84
+ const options = new Map(run.targets.map((target) => [target, optionsFor(target, metadata, run.options?.[target] ?? {})]));
85
+ const out = {};
86
+ for (const [target, checked] of options) {
87
+ const { packages, ...made } = packageOf(target, document, { metadata, options: checked }, report);
88
+ let { files } = made;
89
+ const pass = FORMATTERS[target];
90
+ if (pass !== undefined) {
91
+ const formatter = await formatterFor(target, { env, oxfmt });
92
+ if (formatter === undefined)
93
+ missingFormatter(target, pass, env, report);
94
+ else
95
+ files = await formatFiles(files, { [pass.extension]: formatter });
96
+ }
97
+ const merged = { ...files, ...shipped.files };
98
+ if (target === "csharp")
99
+ out.csharp = { files: { ...merged, ...shipped.icon }, packages };
100
+ else
101
+ out[target] = { files: merged, packages };
102
+ }
103
+ return out;
104
+ }
105
+ /** The spec at `path`, parsed. */
106
+ function readSpec(path) {
107
+ const text = readFileSync(path, "utf8");
108
+ try {
109
+ return JSON.parse(text);
110
+ }
111
+ catch (error) {
112
+ throw new Error(`${path}: not a JSON document (${error.message})`, { cause: error });
113
+ }
114
+ }
115
+ const PROCESS_IO = {
116
+ err: (text) => void process.stderr.write(text),
117
+ out: (text) => void process.stdout.write(text),
118
+ };
119
+ /**
120
+ * `document`'s targets generated and written under `<out>/<target>`, stale files deleted unless edited since (those are
121
+ * kept and named on `io.err`).
122
+ */
123
+ export async function writeGenerated(run, document, io, env) {
124
+ let count = 0;
125
+ for (const [target, { files, packages }] of Object.entries(await generated(run, document, { env, report: io.err }))) {
126
+ for (const rel of writeTarget(join(run.out, target), files, packages).kept)
127
+ io.err(`honey-clients: ${join(target, rel)} is stale but edited since it was generated, or not its to delete: kept\n`);
128
+ count += Object.keys(files).length;
129
+ }
130
+ io.out(`honey-clients: generated ${count} files into ${run.out}\n`);
131
+ return 0;
132
+ }
133
+ /** One generation: the spec read, or the app's document made (the module resolved from `cwd`), then written. */
134
+ async function generateOnce(run, io, env, cwd) {
135
+ const document = run.app === "" ? readSpec(resolve(cwd, run.spec)) : await loadAppDocument(run.app, cwd);
136
+ return writeGenerated({ ...run, out: resolve(cwd, run.out) }, document, io, env);
137
+ }
138
+ /**
139
+ * Generates now and on each change of the spec, each run a fresh child after the one before it (a change during a run
140
+ * is one more run, never two at once); `signal` stops the watch, which then ends 0 once the last run is done. A
141
+ * generation child (HONEY_CODEGEN_CHILD) never watches: were `--watch` ever passed down, each child would start another.
142
+ */
143
+ function watchSpec(run, argv, io, options) {
144
+ if (options.env.HONEY_CODEGEN_CHILD === "1")
145
+ throw new Error("--watch is not allowed in a generation child");
146
+ const args = ["generate", ...argv.filter((arg) => arg !== "--watch" && !arg.startsWith("--watch="))];
147
+ const spec = resolve(options.cwd, run.app === "" ? run.spec : appRef(run.app).module);
148
+ let queue = Promise.resolve();
149
+ const generate = () => {
150
+ queue = queue.then(() => runCli(args, { cwd: options.cwd, env: options.env }).catch((error) => io.err(`honey-clients: ${error.message}\n`)));
151
+ };
152
+ let timer;
153
+ const watcher = watch(dirname(spec), (_event, name) => {
154
+ if (name !== basename(spec))
155
+ return;
156
+ clearTimeout(timer);
157
+ timer = setTimeout(generate, 100);
158
+ });
159
+ io.out(`honey-clients: watching ${spec}\n`);
160
+ generate();
161
+ return new Promise((settle) => options.signal?.addEventListener("abort", () => {
162
+ watcher.close();
163
+ clearTimeout(timer);
164
+ void queue.then(() => settle(0));
165
+ }, { once: true }));
166
+ }
167
+ /** Runs `honey-clients <argv>`: the exit code it ends with (a watch ends only by `options.signal`). */
168
+ export async function main(argv, io = PROCESS_IO, options = {}) {
169
+ try {
170
+ if (argv.length === 0 || argv[0] === "-h" || argv[0] === "--help" || argv.includes("--help")) {
171
+ io.out(`${usage()}\n`);
172
+ return argv.length === 0 ? 1 : 0;
173
+ }
174
+ if (argv[0] !== "generate")
175
+ throw new UsageError(`unknown command ${JSON.stringify(argv[0])}`);
176
+ const run = parseGenerate(argv.slice(1));
177
+ const [env, cwd] = [options.env ?? process.env, options.cwd ?? process.cwd()];
178
+ return run.watch
179
+ ? await watchSpec(run, argv.slice(1), io, { cwd, env, signal: options.signal })
180
+ : await generateOnce(run, io, env, cwd);
181
+ }
182
+ catch (error) {
183
+ if (error instanceof UsageError) {
184
+ io.err(`honey-clients: ${error.message}\n\n${usage()}\n`);
185
+ return 1;
186
+ }
187
+ io.err(`honey-clients: ${error.message}\n`);
188
+ return 1;
189
+ }
190
+ }
@@ -0,0 +1,73 @@
1
+ /** The Linux package formats nfpm builds. */
2
+ export declare const PACKAGE_FORMATS: readonly ["deb", "rpm", "apk"];
3
+ export type PackageFormat = (typeof PACKAGE_FORMATS)[number];
4
+ /** What a package manager shows about the CLI. */
5
+ type About = {
6
+ readonly description: string;
7
+ readonly homepage: string;
8
+ readonly license: string;
9
+ };
10
+ /** What a Linux package also names: who maintains it. */
11
+ type Maintained = About & {
12
+ readonly maintainer: string;
13
+ };
14
+ /** A channel the release publishes to, holding exactly the values its goreleaser block needs. */
15
+ export type Channel = {
16
+ readonly kind: "homebrew";
17
+ readonly about: About;
18
+ readonly owner: string;
19
+ readonly name: string;
20
+ } | {
21
+ readonly kind: "scoop";
22
+ readonly about: About;
23
+ readonly owner: string;
24
+ readonly name: string;
25
+ } | {
26
+ readonly kind: "winget";
27
+ readonly about: About;
28
+ readonly publisher: string;
29
+ readonly owner: string;
30
+ readonly name: string;
31
+ } | {
32
+ readonly kind: "aur";
33
+ readonly about: Maintained;
34
+ } | {
35
+ readonly kind: "packages";
36
+ readonly about: Maintained;
37
+ readonly formats: readonly PackageFormat[];
38
+ };
39
+ /** A CLI released to a GitHub repository: its owner and name, the channels, and where its install scripts live. */
40
+ export type Release = {
41
+ readonly owner: string;
42
+ readonly name: string;
43
+ readonly channels: readonly Channel[];
44
+ readonly installUrl: string;
45
+ /** whether the scripts are served from the release itself, so the release uploads them */
46
+ readonly scriptsInRelease: boolean;
47
+ };
48
+ /** The release options as `--cli-<option>` carries them: strings, `aur` a switch. */
49
+ export type ReleaseOptions = {
50
+ readonly description?: string;
51
+ readonly homepage?: string;
52
+ readonly license?: string;
53
+ readonly maintainer?: string;
54
+ readonly installUrl?: string;
55
+ readonly homebrewTap?: string;
56
+ readonly scoopBucket?: string;
57
+ readonly wingetPublisher?: string;
58
+ readonly wingetFork?: string;
59
+ readonly aur?: boolean | string;
60
+ readonly packages?: string;
61
+ };
62
+ /** The secret each channel's push reads, by the environment variable goreleaser's config names. */
63
+ export declare const SECRETS: Readonly<Record<Channel["kind"], string | undefined>>;
64
+ export declare const REPO: RegExp;
65
+ /**
66
+ * The release for `repo`: its channels from the options, each checked and given the metadata it needs, and the
67
+ * install scripts' URL (`https://github.com/<repo>/releases/latest/download` unless `installUrl` names another).
68
+ * Without a repository there is none, and a channel is refused, since each publishes from the repository's release.
69
+ */
70
+ export declare function resolvedRelease(options: ReleaseOptions, repo: string | undefined): Release | undefined;
71
+ /** The goreleaser block for one channel of `bin`. */
72
+ export declare function channelBlock(bin: string, channel: Channel): string;
73
+ export {};
@@ -0,0 +1,197 @@
1
+ /**
2
+ * The channels a generated CLI's release publishes to (release program D7): the flat `--cli-*` options parsed into
3
+ * one `Release`, each channel holding exactly the metadata its goreleaser block needs and refused, naming the flag,
4
+ * without it or without a repository; and each channel's goreleaser block and the secret its push reads. A channel
5
+ * that pushes to a package manager skips a prerelease tag (`skip_upload: auto`), as the release keeps it off `latest`:
6
+ * a user who asked for nothing gets no release candidate.
7
+ */
8
+ import { checked, HTTPS_URL, PERSON, refuse, SPDX_EXPRESSION } from "../shared/metadata.js";
9
+ import { q } from "./release.js";
10
+ /** The Linux package formats nfpm builds. */
11
+ export const PACKAGE_FORMATS = ["deb", "rpm", "apk"];
12
+ /** The secret each channel's push reads, by the environment variable goreleaser's config names. */
13
+ export const SECRETS = {
14
+ aur: "AUR_SSH_KEY",
15
+ homebrew: "HOMEBREW_TAP_TOKEN",
16
+ packages: undefined,
17
+ scoop: "SCOOP_BUCKET_TOKEN",
18
+ winget: "WINGET_TOKEN",
19
+ };
20
+ /* a description: one line of printable text, at most 256 characters (winget's ShortDescription); a winget
21
+ * publisher: a name of letters, digits, spaces and `.,&'-`, at most 64 characters; a homepage, an install URL, a
22
+ * license and a maintainer take the grammars every target's package metadata shares (../shared/metadata.ts) */
23
+ const DESCRIPTION = /^\P{Cc}{1,256}$/u;
24
+ const PUBLISHER = /^[A-Za-z0-9][A-Za-z0-9 .,&'-]{0,63}$/;
25
+ /* a GitHub repository: its owner 1 to 39 letters, digits and single inner hyphens; its name 1 to 100 of letters,
26
+ * digits, `.`, `_` and `-`, not `.` or `..` and not ending in `.git` */
27
+ export const REPO = /^[A-Za-z0-9](?:-?[A-Za-z0-9]){0,38}\/(?!\.\.?$)(?![\s\S]*\.git$)[A-Za-z0-9._-]{1,100}$/;
28
+ /** `owner/name` split, once REPO has checked it. */
29
+ const split = (repo) => {
30
+ const [owner = "", name = ""] = repo.split("/");
31
+ return { name, owner };
32
+ };
33
+ /** A repository option: checked against REPO when given. */
34
+ function repoOption(option, value) {
35
+ if (value === undefined)
36
+ return undefined;
37
+ if (!REPO.test(value))
38
+ refuse(option, value);
39
+ return split(value);
40
+ }
41
+ const known = (each) => PACKAGE_FORMATS.includes(each);
42
+ /** The Linux package formats: a comma list of deb, rpm and apk, each once. */
43
+ function formatsOf(value) {
44
+ if (value === undefined)
45
+ return undefined;
46
+ const formats = value.split(",").map((each) => each.trim());
47
+ if (formats.length === 0 || !formats.every(known) || new Set(formats).size !== formats.length)
48
+ refuse("packages", value);
49
+ return formats;
50
+ }
51
+ /** The switch as a string option carries it: `true` or `false`, or a boolean from code. */
52
+ function switchOf(option, value) {
53
+ if (value === undefined || typeof value === "boolean")
54
+ return value === true;
55
+ if (value !== "true" && value !== "false")
56
+ refuse(option, value);
57
+ return value === "true";
58
+ }
59
+ /** A value a channel needs, or a refusal naming the option and the channel. */
60
+ function needed(option, value, channel) {
61
+ if (value === undefined)
62
+ throw new Error(`--cli-${channel} needs --cli-${option}: give it, or leave --cli-${channel} out`);
63
+ return value;
64
+ }
65
+ /**
66
+ * The release for `repo`: its channels from the options, each checked and given the metadata it needs, and the
67
+ * install scripts' URL (`https://github.com/<repo>/releases/latest/download` unless `installUrl` names another).
68
+ * Without a repository there is none, and a channel is refused, since each publishes from the repository's release.
69
+ */
70
+ export function resolvedRelease(options, repo) {
71
+ const description = checked("description", options.description, DESCRIPTION);
72
+ const homepage = checked("homepage", options.homepage, HTTPS_URL);
73
+ const license = checked("license", options.license, SPDX_EXPRESSION);
74
+ const maintainer = checked("maintainer", options.maintainer, PERSON);
75
+ const installUrl = checked("installUrl", options.installUrl?.replace(/\/+$/, ""), HTTPS_URL);
76
+ const tap = repoOption("homebrewTap", options.homebrewTap);
77
+ const bucket = repoOption("scoopBucket", options.scoopBucket);
78
+ const fork = repoOption("wingetFork", options.wingetFork);
79
+ const publisher = checked("wingetPublisher", options.wingetPublisher, PUBLISHER);
80
+ const aur = switchOf("aur", options.aur);
81
+ const formats = formatsOf(options.packages);
82
+ const about = (channel) => ({
83
+ description: needed("description", description, channel),
84
+ homepage: needed("homepage", homepage, channel),
85
+ license: needed("license", license, channel),
86
+ });
87
+ const maintained = (channel) => ({
88
+ ...about(channel),
89
+ maintainer: needed("maintainer", maintainer, channel),
90
+ });
91
+ const channels = [];
92
+ if (tap !== undefined)
93
+ channels.push({ about: about("homebrew-tap"), kind: "homebrew", ...tap });
94
+ if (bucket !== undefined)
95
+ channels.push({ about: about("scoop-bucket"), kind: "scoop", ...bucket });
96
+ /* winget needs both: the fork it pushes the manifests to, and the publisher they are filed under */
97
+ if (fork === undefined && publisher !== undefined)
98
+ needed("winget-fork", undefined, "winget-publisher");
99
+ if (fork !== undefined) {
100
+ channels.push({
101
+ about: about("winget-fork"),
102
+ kind: "winget",
103
+ ...fork,
104
+ publisher: needed("winget-publisher", publisher, "winget-fork"),
105
+ });
106
+ }
107
+ if (aur)
108
+ channels.push({ about: maintained("aur"), kind: "aur" });
109
+ if (formats !== undefined)
110
+ channels.push({ about: maintained("packages"), formats, kind: "packages" });
111
+ if (repo === undefined) {
112
+ const [first] = channels;
113
+ if (first !== undefined)
114
+ throw new Error(`--cli-${optionOf(first)} needs --cli-repo: its release publishes from it`);
115
+ return undefined;
116
+ }
117
+ const github = `https://github.com/${repo}/releases/latest/download`;
118
+ return {
119
+ ...split(repo),
120
+ channels,
121
+ installUrl: installUrl ?? github,
122
+ scriptsInRelease: installUrl === undefined || installUrl === github,
123
+ };
124
+ }
125
+ /** The flag that turns `channel` on, as a refusal names it. */
126
+ const optionOf = (channel) => ({ aur: "aur", homebrew: "homebrew-tap", packages: "packages", scoop: "scoop-bucket", winget: "winget-fork" })[channel.kind];
127
+ /** A repository a channel pushes to with its token, as goreleaser's `repository` block. */
128
+ const pushTo = (owner, name, secret, indent) => `${indent}repository:
129
+ ${indent} owner: ${q(owner)}
130
+ ${indent} name: ${q(name)}
131
+ ${indent} token: "{{ .Env.${secret} }}"
132
+ `;
133
+ /** What every package manager shows: the description, homepage and license. */
134
+ const aboutLines = ({ description, homepage, license }, descriptionKey = "description") => ` homepage: ${q(homepage)}
135
+ ${descriptionKey}: ${q(description)}
136
+ license: ${q(license)}
137
+ `;
138
+ /** The goreleaser block for one channel of `bin`. */
139
+ export function channelBlock(bin, channel) {
140
+ switch (channel.kind) {
141
+ case "homebrew":
142
+ return `# the Homebrew cask, pushed to the tap; the binaries are not notarized, so it clears macOS's quarantine flag
143
+ homebrew_casks:
144
+ - name: ${q(bin)}
145
+ skip_upload: auto
146
+ ${pushTo(channel.owner, channel.name, SECRETS.homebrew, " ")}${aboutLines(channel.about)} hooks:
147
+ post:
148
+ install: |
149
+ if OS.mac?
150
+ system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/${bin}"]
151
+ end
152
+ `;
153
+ case "scoop":
154
+ return `# the Scoop manifest, pushed to the bucket
155
+ scoops:
156
+ - name: ${q(bin)}
157
+ skip_upload: auto
158
+ ${pushTo(channel.owner, channel.name, SECRETS.scoop, " ")}${aboutLines(channel.about)}`;
159
+ case "winget":
160
+ return `# the winget manifests, pushed to the fork and proposed to microsoft/winget-pkgs
161
+ winget:
162
+ - name: ${q(bin)}
163
+ skip_upload: auto
164
+ publisher: ${q(channel.publisher)}
165
+ package_identifier: ${q(`${channel.publisher.replace(/[^A-Za-z0-9]/g, "")}.${bin}`)}
166
+ ${aboutLines(channel.about, "short_description")} repository:
167
+ owner: ${q(channel.owner)}
168
+ name: ${q(channel.name)}
169
+ token: "{{ .Env.${SECRETS.winget} }}"
170
+ branch: ${q(`${bin}-{{ .Version }}`)}
171
+ pull_request:
172
+ enabled: true
173
+ base:
174
+ owner: microsoft
175
+ name: winget-pkgs
176
+ branch: master
177
+ `;
178
+ case "aur":
179
+ return `# the AUR ${bin}-bin package, pushed over SSH
180
+ aurs:
181
+ - name: ${q(`${bin}-bin`)}
182
+ skip_upload: auto
183
+ ${aboutLines(channel.about)} maintainers: [${q(channel.about.maintainer)}]
184
+ private_key: "{{ .Env.${SECRETS.aur} }}"
185
+ git_url: ${q(`ssh://aur@aur.archlinux.org/${bin}-bin.git`)}
186
+ `;
187
+ case "packages":
188
+ return `# Linux packages beside the archives, each named ${bin}_<os>_<arch>
189
+ nfpms:
190
+ - id: ${q(bin)}
191
+ package_name: ${q(bin)}
192
+ file_name_template: "{{ .PackageName }}_{{ .Os }}_{{ .Arch }}"
193
+ formats: [${channel.formats.join(", ")}]
194
+ ${aboutLines(channel.about)} maintainer: ${q(channel.about.maintainer)}
195
+ `;
196
+ }
197
+ }