@nanobpm/nano-agent-graph-engine 0.0.0-stage → 0.18.0

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 (270) hide show
  1. package/.claude-plugin/marketplace.json +20 -0
  2. package/.claude-plugin/plugin.json +21 -0
  3. package/.mcp.json +8 -0
  4. package/README.md +526 -2
  5. package/dist/cli.js +55833 -0
  6. package/dist/explorer-app.html +196 -0
  7. package/dist/explorer.html +196 -0
  8. package/dist/guide.md +147 -0
  9. package/dist/index.js +1262 -0
  10. package/dist/layout-thread.js +12857 -0
  11. package/dist/nanobpmn_engine_bg.wasm +0 -0
  12. package/dist/step-thread.js +55 -0
  13. package/dist/typecheck/agent-graph-engine/agents.d.ts +120 -0
  14. package/dist/typecheck/agent-graph-engine/index.d.ts +124 -0
  15. package/dist/typecheck/agent-graph-engine/input.d.ts +57 -0
  16. package/dist/typecheck/agent-graph-engine/paths.d.ts +35 -0
  17. package/dist/typecheck/lib.decorators.d.ts +384 -0
  18. package/dist/typecheck/lib.decorators.legacy.d.ts +22 -0
  19. package/dist/typecheck/lib.es2015.collection.d.ts +147 -0
  20. package/dist/typecheck/lib.es2015.core.d.ts +597 -0
  21. package/dist/typecheck/lib.es2015.d.ts +28 -0
  22. package/dist/typecheck/lib.es2015.generator.d.ts +77 -0
  23. package/dist/typecheck/lib.es2015.iterable.d.ts +605 -0
  24. package/dist/typecheck/lib.es2015.promise.d.ts +81 -0
  25. package/dist/typecheck/lib.es2015.proxy.d.ts +128 -0
  26. package/dist/typecheck/lib.es2015.reflect.d.ts +144 -0
  27. package/dist/typecheck/lib.es2015.symbol.d.ts +46 -0
  28. package/dist/typecheck/lib.es2015.symbol.wellknown.d.ts +326 -0
  29. package/dist/typecheck/lib.es2016.array.include.d.ts +116 -0
  30. package/dist/typecheck/lib.es2016.d.ts +21 -0
  31. package/dist/typecheck/lib.es2016.full.d.ts +23 -0
  32. package/dist/typecheck/lib.es2016.intl.d.ts +31 -0
  33. package/dist/typecheck/lib.es2017.arraybuffer.d.ts +21 -0
  34. package/dist/typecheck/lib.es2017.d.ts +26 -0
  35. package/dist/typecheck/lib.es2017.date.d.ts +31 -0
  36. package/dist/typecheck/lib.es2017.full.d.ts +23 -0
  37. package/dist/typecheck/lib.es2017.intl.d.ts +44 -0
  38. package/dist/typecheck/lib.es2017.object.d.ts +49 -0
  39. package/dist/typecheck/lib.es2017.sharedmemory.d.ts +135 -0
  40. package/dist/typecheck/lib.es2017.string.d.ts +45 -0
  41. package/dist/typecheck/lib.es2017.typedarrays.d.ts +53 -0
  42. package/dist/typecheck/lib.es2018.asyncgenerator.d.ts +77 -0
  43. package/dist/typecheck/lib.es2018.asynciterable.d.ts +53 -0
  44. package/dist/typecheck/lib.es2018.d.ts +24 -0
  45. package/dist/typecheck/lib.es2018.full.d.ts +24 -0
  46. package/dist/typecheck/lib.es2018.intl.d.ts +83 -0
  47. package/dist/typecheck/lib.es2018.promise.d.ts +30 -0
  48. package/dist/typecheck/lib.es2018.regexp.d.ts +37 -0
  49. package/dist/typecheck/lib.es2019.array.d.ts +79 -0
  50. package/dist/typecheck/lib.es2019.d.ts +24 -0
  51. package/dist/typecheck/lib.es2019.full.d.ts +24 -0
  52. package/dist/typecheck/lib.es2019.intl.d.ts +23 -0
  53. package/dist/typecheck/lib.es2019.object.d.ts +33 -0
  54. package/dist/typecheck/lib.es2019.string.d.ts +37 -0
  55. package/dist/typecheck/lib.es2019.symbol.d.ts +24 -0
  56. package/dist/typecheck/lib.es2020.bigint.d.ts +765 -0
  57. package/dist/typecheck/lib.es2020.d.ts +27 -0
  58. package/dist/typecheck/lib.es2020.date.d.ts +42 -0
  59. package/dist/typecheck/lib.es2020.full.d.ts +24 -0
  60. package/dist/typecheck/lib.es2020.intl.d.ts +474 -0
  61. package/dist/typecheck/lib.es2020.number.d.ts +28 -0
  62. package/dist/typecheck/lib.es2020.promise.d.ts +47 -0
  63. package/dist/typecheck/lib.es2020.sharedmemory.d.ts +99 -0
  64. package/dist/typecheck/lib.es2020.string.d.ts +44 -0
  65. package/dist/typecheck/lib.es2020.symbol.wellknown.d.ts +41 -0
  66. package/dist/typecheck/lib.es2021.d.ts +23 -0
  67. package/dist/typecheck/lib.es2021.full.d.ts +24 -0
  68. package/dist/typecheck/lib.es2021.intl.d.ts +166 -0
  69. package/dist/typecheck/lib.es2021.promise.d.ts +48 -0
  70. package/dist/typecheck/lib.es2021.string.d.ts +33 -0
  71. package/dist/typecheck/lib.es2021.weakref.d.ts +78 -0
  72. package/dist/typecheck/lib.es2022.array.d.ts +121 -0
  73. package/dist/typecheck/lib.es2022.d.ts +25 -0
  74. package/dist/typecheck/lib.es2022.error.d.ts +75 -0
  75. package/dist/typecheck/lib.es2022.full.d.ts +24 -0
  76. package/dist/typecheck/lib.es2022.intl.d.ts +145 -0
  77. package/dist/typecheck/lib.es2022.object.d.ts +26 -0
  78. package/dist/typecheck/lib.es2022.regexp.d.ts +39 -0
  79. package/dist/typecheck/lib.es2022.string.d.ts +25 -0
  80. package/dist/typecheck/lib.es2023.array.d.ts +924 -0
  81. package/dist/typecheck/lib.es2023.collection.d.ts +21 -0
  82. package/dist/typecheck/lib.es2023.d.ts +22 -0
  83. package/dist/typecheck/lib.es2023.full.d.ts +24 -0
  84. package/dist/typecheck/lib.es2023.intl.d.ts +56 -0
  85. package/dist/typecheck/lib.es2024.arraybuffer.d.ts +65 -0
  86. package/dist/typecheck/lib.es2024.collection.d.ts +29 -0
  87. package/dist/typecheck/lib.es2024.d.ts +26 -0
  88. package/dist/typecheck/lib.es2024.full.d.ts +24 -0
  89. package/dist/typecheck/lib.es2024.object.d.ts +29 -0
  90. package/dist/typecheck/lib.es2024.promise.d.ts +35 -0
  91. package/dist/typecheck/lib.es2024.regexp.d.ts +25 -0
  92. package/dist/typecheck/lib.es2024.sharedmemory.d.ts +68 -0
  93. package/dist/typecheck/lib.es2024.string.d.ts +29 -0
  94. package/dist/typecheck/lib.es5.d.ts +4601 -0
  95. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/client.d.ts +169 -0
  96. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/declarative.d.ts +365 -0
  97. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/envelope.d.ts +77 -0
  98. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/imperative.d.ts +32 -0
  99. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/index.d.ts +14 -0
  100. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/io-mapping.d.ts +32 -0
  101. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/layout.d.ts +35 -0
  102. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/boundary.d.ts +63 -0
  103. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/branch.d.ts +11 -0
  104. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/break.d.ts +8 -0
  105. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/continue.d.ts +8 -0
  106. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/end.d.ts +40 -0
  107. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/forEach.d.ts +37 -0
  108. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/human.d.ts +44 -0
  109. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/index.d.ts +15 -0
  110. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/loop.d.ts +9 -0
  111. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/parallel.d.ts +9 -0
  112. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/race.d.ts +54 -0
  113. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/registry.d.ts +33 -0
  114. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/run.d.ts +12 -0
  115. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/signal.d.ts +11 -0
  116. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/switch.d.ts +11 -0
  117. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/task.d.ts +82 -0
  118. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/timer.d.ts +9 -0
  119. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/diff.d.ts +8 -0
  120. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/index.d.ts +8 -0
  121. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/normalize.d.ts +19 -0
  122. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/parity.d.ts +28 -0
  123. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/xml.d.ts +17 -0
  124. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/types.d.ts +146 -0
  125. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/worker.d.ts +92 -0
  126. package/dist/typecheck/node_modules/@nanobpm/workflow/dist/xml.d.ts +14 -0
  127. package/dist/typecheck/node_modules/@nanobpm/workflow/package.json +65 -0
  128. package/dist/typecheck/node_modules/@nanobpm/workflow/src/bpmn-auto-layout.d.ts +10 -0
  129. package/dist/typecheck/node_modules/@types/node/assert/strict.d.ts +68 -0
  130. package/dist/typecheck/node_modules/@types/node/assert.d.ts +1077 -0
  131. package/dist/typecheck/node_modules/@types/node/async_hooks.d.ts +711 -0
  132. package/dist/typecheck/node_modules/@types/node/buffer.buffer.d.ts +471 -0
  133. package/dist/typecheck/node_modules/@types/node/buffer.d.ts +1800 -0
  134. package/dist/typecheck/node_modules/@types/node/child_process.d.ts +1361 -0
  135. package/dist/typecheck/node_modules/@types/node/cluster.d.ts +432 -0
  136. package/dist/typecheck/node_modules/@types/node/console.d.ts +93 -0
  137. package/dist/typecheck/node_modules/@types/node/constants.d.ts +14 -0
  138. package/dist/typecheck/node_modules/@types/node/crypto.d.ts +3964 -0
  139. package/dist/typecheck/node_modules/@types/node/dgram.d.ts +652 -0
  140. package/dist/typecheck/node_modules/@types/node/diagnostics_channel.d.ts +794 -0
  141. package/dist/typecheck/node_modules/@types/node/dns/promises.d.ts +497 -0
  142. package/dist/typecheck/node_modules/@types/node/dns.d.ts +876 -0
  143. package/dist/typecheck/node_modules/@types/node/domain.d.ts +150 -0
  144. package/dist/typecheck/node_modules/@types/node/events.d.ts +1008 -0
  145. package/dist/typecheck/node_modules/@types/node/ffi.d.ts +500 -0
  146. package/dist/typecheck/node_modules/@types/node/fs/promises.d.ts +1477 -0
  147. package/dist/typecheck/node_modules/@types/node/fs.d.ts +4803 -0
  148. package/dist/typecheck/node_modules/@types/node/globals.d.ts +150 -0
  149. package/dist/typecheck/node_modules/@types/node/globals.typedarray.d.ts +101 -0
  150. package/dist/typecheck/node_modules/@types/node/http.d.ts +2218 -0
  151. package/dist/typecheck/node_modules/@types/node/http2.d.ts +2498 -0
  152. package/dist/typecheck/node_modules/@types/node/https.d.ts +400 -0
  153. package/dist/typecheck/node_modules/@types/node/index.d.ts +116 -0
  154. package/dist/typecheck/node_modules/@types/node/inspector/promises.d.ts +35 -0
  155. package/dist/typecheck/node_modules/@types/node/inspector.d.ts +265 -0
  156. package/dist/typecheck/node_modules/@types/node/inspector.generated.d.ts +4406 -0
  157. package/dist/typecheck/node_modules/@types/node/module.d.ts +726 -0
  158. package/dist/typecheck/node_modules/@types/node/net.d.ts +1074 -0
  159. package/dist/typecheck/node_modules/@types/node/os.d.ts +498 -0
  160. package/dist/typecheck/node_modules/@types/node/package.json +140 -0
  161. package/dist/typecheck/node_modules/@types/node/path/posix.d.ts +8 -0
  162. package/dist/typecheck/node_modules/@types/node/path/win32.d.ts +8 -0
  163. package/dist/typecheck/node_modules/@types/node/path.d.ts +178 -0
  164. package/dist/typecheck/node_modules/@types/node/perf_hooks.d.ts +617 -0
  165. package/dist/typecheck/node_modules/@types/node/process.d.ts +2269 -0
  166. package/dist/typecheck/node_modules/@types/node/punycode.d.ts +89 -0
  167. package/dist/typecheck/node_modules/@types/node/querystring.d.ts +139 -0
  168. package/dist/typecheck/node_modules/@types/node/quic.d.ts +2191 -0
  169. package/dist/typecheck/node_modules/@types/node/readline/promises.d.ts +158 -0
  170. package/dist/typecheck/node_modules/@types/node/readline.d.ts +508 -0
  171. package/dist/typecheck/node_modules/@types/node/repl.d.ts +420 -0
  172. package/dist/typecheck/node_modules/@types/node/sea.d.ts +47 -0
  173. package/dist/typecheck/node_modules/@types/node/sqlite.d.ts +1140 -0
  174. package/dist/typecheck/node_modules/@types/node/stream/consumers.d.ts +114 -0
  175. package/dist/typecheck/node_modules/@types/node/stream/iter.d.ts +449 -0
  176. package/dist/typecheck/node_modules/@types/node/stream/promises.d.ts +211 -0
  177. package/dist/typecheck/node_modules/@types/node/stream/web.d.ts +320 -0
  178. package/dist/typecheck/node_modules/@types/node/stream.d.ts +1806 -0
  179. package/dist/typecheck/node_modules/@types/node/string_decoder.d.ts +27 -0
  180. package/dist/typecheck/node_modules/@types/node/test/reporters.d.ts +60 -0
  181. package/dist/typecheck/node_modules/@types/node/test.d.ts +2558 -0
  182. package/dist/typecheck/node_modules/@types/node/timers/promises.d.ts +93 -0
  183. package/dist/typecheck/node_modules/@types/node/timers.d.ts +149 -0
  184. package/dist/typecheck/node_modules/@types/node/tls.d.ts +1232 -0
  185. package/dist/typecheck/node_modules/@types/node/trace_events.d.ts +103 -0
  186. package/dist/typecheck/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +467 -0
  187. package/dist/typecheck/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  188. package/dist/typecheck/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  189. package/dist/typecheck/node_modules/@types/node/ts5.6/index.d.ts +118 -0
  190. package/dist/typecheck/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  191. package/dist/typecheck/node_modules/@types/node/ts5.7/index.d.ts +118 -0
  192. package/dist/typecheck/node_modules/@types/node/tty.d.ts +226 -0
  193. package/dist/typecheck/node_modules/@types/node/url.d.ts +556 -0
  194. package/dist/typecheck/node_modules/@types/node/util/types.d.ts +558 -0
  195. package/dist/typecheck/node_modules/@types/node/util.d.ts +1680 -0
  196. package/dist/typecheck/node_modules/@types/node/v8.d.ts +1059 -0
  197. package/dist/typecheck/node_modules/@types/node/vfs.d.ts +211 -0
  198. package/dist/typecheck/node_modules/@types/node/vm.d.ts +1137 -0
  199. package/dist/typecheck/node_modules/@types/node/wasi.d.ts +131 -0
  200. package/dist/typecheck/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
  201. package/dist/typecheck/node_modules/@types/node/web-globals/blob.d.ts +23 -0
  202. package/dist/typecheck/node_modules/@types/node/web-globals/console.d.ts +9 -0
  203. package/dist/typecheck/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
  204. package/dist/typecheck/node_modules/@types/node/web-globals/domexception.d.ts +83 -0
  205. package/dist/typecheck/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
  206. package/dist/typecheck/node_modules/@types/node/web-globals/events.d.ts +106 -0
  207. package/dist/typecheck/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
  208. package/dist/typecheck/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
  209. package/dist/typecheck/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
  210. package/dist/typecheck/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  211. package/dist/typecheck/node_modules/@types/node/web-globals/performance.d.ts +45 -0
  212. package/dist/typecheck/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  213. package/dist/typecheck/node_modules/@types/node/web-globals/streams.d.ts +119 -0
  214. package/dist/typecheck/node_modules/@types/node/web-globals/timers.d.ts +44 -0
  215. package/dist/typecheck/node_modules/@types/node/web-globals/url.d.ts +24 -0
  216. package/dist/typecheck/node_modules/@types/node/worker_threads.d.ts +672 -0
  217. package/dist/typecheck/node_modules/@types/node/zlib/iter.d.ts +131 -0
  218. package/dist/typecheck/node_modules/@types/node/zlib.d.ts +1364 -0
  219. package/dist/typecheck/node_modules/undici-types/agent.d.ts +30 -0
  220. package/dist/typecheck/node_modules/undici-types/api.d.ts +43 -0
  221. package/dist/typecheck/node_modules/undici-types/balanced-pool.d.ts +30 -0
  222. package/dist/typecheck/node_modules/undici-types/cache-interceptor.d.ts +179 -0
  223. package/dist/typecheck/node_modules/undici-types/cache.d.ts +36 -0
  224. package/dist/typecheck/node_modules/undici-types/client-stats.d.ts +15 -0
  225. package/dist/typecheck/node_modules/undici-types/client.d.ts +134 -0
  226. package/dist/typecheck/node_modules/undici-types/connector.d.ts +37 -0
  227. package/dist/typecheck/node_modules/undici-types/content-type.d.ts +21 -0
  228. package/dist/typecheck/node_modules/undici-types/cookies.d.ts +30 -0
  229. package/dist/typecheck/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
  230. package/dist/typecheck/node_modules/undici-types/dispatcher.d.ts +253 -0
  231. package/dist/typecheck/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
  232. package/dist/typecheck/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  233. package/dist/typecheck/node_modules/undici-types/errors.d.ts +187 -0
  234. package/dist/typecheck/node_modules/undici-types/eventsource.d.ts +66 -0
  235. package/dist/typecheck/node_modules/undici-types/fetch.d.ts +235 -0
  236. package/dist/typecheck/node_modules/undici-types/formdata.d.ts +108 -0
  237. package/dist/typecheck/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  238. package/dist/typecheck/node_modules/undici-types/global-origin.d.ts +7 -0
  239. package/dist/typecheck/node_modules/undici-types/h2c-client.d.ts +73 -0
  240. package/dist/typecheck/node_modules/undici-types/handlers.d.ts +16 -0
  241. package/dist/typecheck/node_modules/undici-types/header.d.ts +165 -0
  242. package/dist/typecheck/node_modules/undici-types/index.d.ts +93 -0
  243. package/dist/typecheck/node_modules/undici-types/interceptors.d.ts +80 -0
  244. package/dist/typecheck/node_modules/undici-types/mock-agent.d.ts +68 -0
  245. package/dist/typecheck/node_modules/undici-types/mock-call-history.d.ts +111 -0
  246. package/dist/typecheck/node_modules/undici-types/mock-client.d.ts +27 -0
  247. package/dist/typecheck/node_modules/undici-types/mock-errors.d.ts +12 -0
  248. package/dist/typecheck/node_modules/undici-types/mock-interceptor.d.ts +98 -0
  249. package/dist/typecheck/node_modules/undici-types/mock-pool.d.ts +27 -0
  250. package/dist/typecheck/node_modules/undici-types/package.json +55 -0
  251. package/dist/typecheck/node_modules/undici-types/patch.d.ts +29 -0
  252. package/dist/typecheck/node_modules/undici-types/pool-stats.d.ts +19 -0
  253. package/dist/typecheck/node_modules/undici-types/pool.d.ts +39 -0
  254. package/dist/typecheck/node_modules/undici-types/proxy-agent.d.ts +36 -0
  255. package/dist/typecheck/node_modules/undici-types/readable.d.ts +68 -0
  256. package/dist/typecheck/node_modules/undici-types/retry-agent.d.ts +8 -0
  257. package/dist/typecheck/node_modules/undici-types/retry-handler.d.ts +125 -0
  258. package/dist/typecheck/node_modules/undici-types/round-robin-pool.d.ts +39 -0
  259. package/dist/typecheck/node_modules/undici-types/snapshot-agent.d.ts +113 -0
  260. package/dist/typecheck/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  261. package/dist/typecheck/node_modules/undici-types/util.d.ts +18 -0
  262. package/dist/typecheck/node_modules/undici-types/utility.d.ts +7 -0
  263. package/dist/typecheck/node_modules/undici-types/webidl.d.ts +346 -0
  264. package/dist/typecheck/node_modules/undici-types/websocket.d.ts +188 -0
  265. package/dist/typecheck/ts.cjs +446 -0
  266. package/hooks/hooks.json +30 -0
  267. package/hooks/mod.js +461 -0
  268. package/package.json +80 -4
  269. package/skills/agent-graph/SKILL.md +47 -0
  270. package/skills/agent-graph-authoring/SKILL.md +147 -0
@@ -0,0 +1,169 @@
1
+ import type { DeclarativeFlow, DeployResult, Job, JsonObject, StartResult, Workflow } from "./types.js";
2
+ /** Render a workflow (either surface) to its executable BPMN model. */
3
+ export declare function toBpmn(wf: Workflow): string;
4
+ /**
5
+ * Render a workflow to *deployable* BPMN — the executable model plus diagram
6
+ * interchange (DI), auto-generated with `bpmn-auto-layout` — so the deployed
7
+ * process opens rendered and inspectable in a modeller/Operate rather than as a
8
+ * blank canvas. The semantic model stays authoritative; DI is derived.
9
+ *
10
+ * DI generation needs the optional peer dependency `bpmn-auto-layout`. When it is
11
+ * absent, this degrades gracefully: it warns once and returns the DI-less model
12
+ * so `deploy` still works everywhere. Pass `{ layout: false }` to skip layout
13
+ * deliberately. A genuine layout failure (the dep is installed but errors) is
14
+ * surfaced, not swallowed.
15
+ */
16
+ export declare function toDeployableBpmn(wf: Workflow, opts?: {
17
+ layout?: boolean;
18
+ }): Promise<string>;
19
+ /**
20
+ * The subset of the `@nanobpm/nano-sdk` (Camunda orchestration-cluster) client
21
+ * that the workflow surface uses. `createCamundaClient` returns a superset of
22
+ * this, so a test — or an author bringing their own transport (e.g. the embedded
23
+ * engine) — can inject any object satisfying it.
24
+ */
25
+ export interface NanoSdkClient {
26
+ createDeployment(input: {
27
+ resources: File[];
28
+ [k: string]: unknown;
29
+ }, options?: unknown): Promise<unknown>;
30
+ createProcessInstance(input: {
31
+ processDefinitionId: string;
32
+ variables?: JsonObject;
33
+ }, options?: unknown): Promise<unknown>;
34
+ correlateMessage(input: {
35
+ name: string;
36
+ correlationKey: string;
37
+ variables?: JsonObject;
38
+ }, options?: unknown): Promise<unknown>;
39
+ getProcessInstance(input: {
40
+ processInstanceKey: string;
41
+ }, consistency: {
42
+ consistency: {
43
+ waitUpToMs: number;
44
+ };
45
+ }, options?: unknown): Promise<unknown>;
46
+ createJobWorker(cfg: JobWorkerConfig): NanoJobWorker;
47
+ }
48
+ /** Config for a nano-sdk job worker (the subset the Worker runtime sets). */
49
+ export interface JobWorkerConfig {
50
+ jobType: string;
51
+ jobHandler: (job: ActivatedJob) => Promise<unknown> | unknown;
52
+ workerName?: string;
53
+ maxParallelJobs?: number;
54
+ /** Job lock timeout in ms. */
55
+ jobTimeoutMs?: number;
56
+ /** Long-poll timeout in ms. */
57
+ pollTimeoutMs?: number;
58
+ /** Start polling immediately. The Worker runtime sets this false and starts explicitly. */
59
+ autoStart?: boolean;
60
+ }
61
+ /** The handle returned by `createJobWorker`. */
62
+ export interface NanoJobWorker {
63
+ start(): void;
64
+ stop(): void | Promise<void>;
65
+ stopGracefully?(opts?: {
66
+ waitUpToMs?: number;
67
+ }): Promise<void>;
68
+ }
69
+ /** The subset of a raw `@nanobpm/nano-sdk` job worker the adapter drives. Its
70
+ * `start()` may be synchronous or async: on nano-sdk >=1.2.5's Falcon/auto path
71
+ * it is async and the SDK self-starts the worker after an asynchronous transport
72
+ * bind (see {@link adaptJobWorker}). */
73
+ export interface RawNanoJobWorker {
74
+ start(): void | Promise<void>;
75
+ stop(): void | Promise<void>;
76
+ stopGracefully(opts?: {
77
+ waitUpToMs?: number;
78
+ }): Promise<unknown>;
79
+ }
80
+ /** Adapt a raw `@nanobpm/nano-sdk` job worker to the {@link NanoJobWorker} handle
81
+ * the Worker runtime drives, making the eager `start()` NULL-SAFE.
82
+ *
83
+ * nano-sdk >=1.2.5's Falcon/auto worker SELF-STARTS after an ASYNCHRONOUS
84
+ * transport bind: `createJobWorker` hands back a worker whose transport is null
85
+ * until Nano is detected, at which point the SDK `bindTransport(t)`s it and
86
+ * `start()`s the worker ITSELF. Calling `start()` before that bind dereferences
87
+ * the null transport and — because `start()` is async — surfaces as an UNHANDLED
88
+ * REJECTION that crashes the process
89
+ * (`TypeError: Cannot read properties of null (reading 'subscribe')`, #415). The
90
+ * REST/manual worker, by contrast, never self-starts, so `start()` must still be
91
+ * called here. We resolve the version-skew by starting eagerly but NULL-SAFELY:
92
+ * swallow ONLY the pre-bind race (the SDK self-starts once the transport binds)
93
+ * and SURFACE any other start failure via `console.warn` rather than masking it.
94
+ * The SDK owns the start lifecycle end to end (it logs and falls back to REST on
95
+ * its own subscribe failure), so discarding the resolved result — as the previous
96
+ * `void worker.start()` already did — is safe. Pairs with the library-side
97
+ * null-safe, idempotent start (jwulf/nano-sdk-js#12) so neither an eager nor a
98
+ * duplicate start can crash. */
99
+ export declare function adaptJobWorker(worker: RawNanoJobWorker): NanoJobWorker;
100
+ /** An activated job as delivered to a nano-sdk job handler: the workflow `Job`
101
+ * fields plus the acknowledgement actions. */
102
+ export type ActivatedJob = Job & {
103
+ complete(variables?: JsonObject): Promise<unknown>;
104
+ fail(body: {
105
+ errorMessage: string;
106
+ retries?: number;
107
+ }): Promise<unknown>;
108
+ };
109
+ /** Options common to both ways of building a `WorkflowClient`. */
110
+ interface WorkflowClientCommon {
111
+ /** Auth token for the gateway (CAMUNDA_TOKEN). */
112
+ token?: string;
113
+ /** Transport mode passed to `createCamundaClient`: "auto" | "falcon" | "rest".
114
+ * Default "auto" (Falcon on a Nano server, REST elsewhere). */
115
+ transport?: "auto" | "falcon" | "rest";
116
+ }
117
+ /** Construct a `WorkflowClient` from **either** a `baseUrl` (a nano-sdk client is
118
+ * built for you) **or** a pre-built `client`. The union makes TypeScript enforce
119
+ * that exactly one is supplied, matching the constructor's runtime requirement. */
120
+ export type WorkflowClientOptions = (WorkflowClientCommon & {
121
+ /** Base URL of the nanobpmn gateway, e.g. `http://localhost:8080`. The
122
+ * nano-sdk client normalises this to the `/v2` REST address. */
123
+ baseUrl: string;
124
+ client?: never;
125
+ }) | (WorkflowClientCommon & {
126
+ /** Inject a pre-built nano-sdk client (or a compatible fake) instead of
127
+ * constructing one from `baseUrl`. Useful for tests, the embedded
128
+ * transport, and advanced authors who build the client themselves. */
129
+ client: NanoSdkClient;
130
+ baseUrl?: never;
131
+ });
132
+ export declare class WorkflowError extends Error {
133
+ readonly status?: number | undefined;
134
+ readonly body?: string | undefined;
135
+ constructor(message: string, status?: number | undefined, body?: string | undefined);
136
+ }
137
+ export declare class WorkflowClient {
138
+ /** The underlying nano-sdk client, exposed so the Worker runtime and app
139
+ * authors can reach the engine through the same transport (ADR 0055). The
140
+ * exported `NanoSdkClient` type intentionally models only the subset of
141
+ * methods this package uses (deploy, create, correlate, get, job workers);
142
+ * the runtime value is the full nano-sdk client. */
143
+ readonly sdk: NanoSdkClient;
144
+ constructor(opts: WorkflowClientOptions);
145
+ /**
146
+ * Deploy a workflow's derived BPMN model. The deployed model includes
147
+ * auto-generated diagram interchange (DI) so it is inspectable in a
148
+ * modeller/Operate; pass `{ layout: false }` to deploy the DI-less semantic
149
+ * model. DI needs the optional `bpmn-auto-layout` dependency — see
150
+ * `toDeployableBpmn` for the graceful-degradation behaviour when it is absent.
151
+ */
152
+ deploy(wf: Workflow, opts?: {
153
+ layout?: boolean;
154
+ }): Promise<DeployResult>;
155
+ /**
156
+ * Start a workflow instance. For imperative workflows the engine variables are
157
+ * seeded with `{ input, journal: {}, wfDone: false }` (the replay state); for
158
+ * declarative flows `input` becomes the instance variables directly.
159
+ */
160
+ start(wf: Workflow, input?: JsonObject): Promise<StartResult>;
161
+ /** Correlate a signal to a parked declarative `signal` step. Fails fast on an
162
+ * unknown signal name (a typo would otherwise send an uncorrelatable message
163
+ * that the gateway silently drops). */
164
+ signal(flow: DeclarativeFlow, signalName: string, correlationKey: string, variables?: JsonObject): Promise<JsonObject>;
165
+ /** Fetch an instance (used by demos/tests to observe completion). Reads with
166
+ * zero-wait consistency; returns null when the instance is not (yet) visible. */
167
+ getInstance(processInstanceKey: string): Promise<JsonObject | null>;
168
+ }
169
+ export {};
@@ -0,0 +1,365 @@
1
+ import type { DeclarativeFlow, FlowContracts, FlowNode, JsonObject, NodeEnvelopes, StepHandler, TimerStart } from "./types.js";
2
+ import type { Envelope } from "./envelope.js";
3
+ import type { HumanIoMapping } from "./io-mapping.js";
4
+ import type { ForEachOpts } from "./nodes/forEach.js";
5
+ import "./nodes/index.js";
6
+ /** The TS payload type of a contract's input envelope (untyped fallback). */
7
+ export type InPayload<Ct> = Ct extends {
8
+ in: Envelope;
9
+ } ? Ct["in"]["type"] & JsonObject : JsonObject;
10
+ /** The TS payload type of a contract's output envelope (untyped fallback). */
11
+ export type OutPayload<Ct> = Ct extends {
12
+ out: Envelope;
13
+ } ? Ct["out"]["type"] & JsonObject : JsonObject;
14
+ /** The input payload type of step `K` under contracts `C`. */
15
+ export type VarsOf<C, K extends string> = K extends keyof C ? InPayload<C[K]> : JsonObject;
16
+ /** The output payload type of step `K` under contracts `C`. */
17
+ export type ResultOf<C, K extends string> = K extends keyof C ? OutPayload<C[K]> : JsonObject;
18
+ /** The start variables of a flow with contracts `C`: the `in` envelope of its
19
+ * `Start` contract (the flow's input), else `JsonObject`. */
20
+ export type StartVars<C> = VarsOf<C, "Start">;
21
+ /** A typed handler for a `run` step: its job variables and result are resolved
22
+ * from the flow contracts by the step name. */
23
+ export type TypedHandler<V extends JsonObject, R extends JsonObject> = (job: {
24
+ jobKey: string;
25
+ processInstanceKey: string;
26
+ elementId: string;
27
+ type: string;
28
+ variables: V;
29
+ }) => Promise<R | void> | R | void;
30
+ /** A block: the callback that populates a nested body (a case, arm, or loop). */
31
+ export type Block<C extends object = object> = (b: FlowBuilder<C>) => void;
32
+ /** The typed builder for a flow body.
33
+ *
34
+ * `C` is the flow's contracts map (step name → `{ in, out }` envelopes). The
35
+ * default is `object`, NOT `Record<string, never>`: with a `never`-valued record
36
+ * `keyof C` is `string`, so `VarsOf`/`ResultOf` route EVERY step name into
37
+ * `InPayload<never>`/`OutPayload<never>`, which distribute over `never` to
38
+ * `never` — typing an untyped flow's `job.variables` as `never` and forcing its
39
+ * handler return to `void` (so no untyped flow that returns data compiles). With
40
+ * `object`, `keyof C` is `never`, so every step falls back to the intended
41
+ * `JsonObject`. The public `defineFlow<C extends FlowContracts>` overload keeps
42
+ * the stricter contracts constraint; this is only the untyped-builder default. */
43
+ export interface FlowBuilder<C extends object = object> {
44
+ /**
45
+ * A durable activity served by a worker THIS program hosts (a BPMN service
46
+ * task; the handler runs in the in-process `Worker`). If `name` is a key in
47
+ * the flow's contracts, the handler's job variables and return value are typed
48
+ * from that contract's `in`/`out` envelopes; otherwise they are `JsonObject`.
49
+ */
50
+ run<K extends string>(name: K, handler: TypedHandler<VarsOf<C, K>, ResultOf<C, K>>, opts?: {
51
+ io?: HumanIoMapping;
52
+ /** Job lock timeout, ms, for this step's derived worker (issue #596): how long the
53
+ * engine leases an activated job before re-activating it elsewhere. Set it above the
54
+ * handler's worst-case runtime for long steps (transcription, an agent call, a
55
+ * multi-GB upload) so the lock cannot expire mid-handler and the job run twice.
56
+ * Overrides the `Worker`'s worker-wide `jobTimeoutMs` for this step's job type. */
57
+ timeoutMs?: number;
58
+ }): FlowBuilder<C>;
59
+ /**
60
+ * A durable activity served by a worker OUTSIDE this program (a BPMN service
61
+ * task, but no locally-hosted handler). Its job type defaults to the derived
62
+ * `${flowId}:${name}`; pass `{ jobType }` to override it with an explicit
63
+ * worker token (e.g. a `rank:capability` token like `senior:pr-review` that a
64
+ * `c8ctl nano work` matrix subscribes to) so an existing pool of agents can
65
+ * service it without renaming the flow. The step name stays the BPMN element
66
+ * id; only the emitted `zeebe:taskDefinition` type changes. Use
67
+ * `externalJobTypes(flow)` to list the (possibly overridden) types those
68
+ * workers must poll. Its contract envelopes (if any) type the model, not a
69
+ * local handler.
70
+ */
71
+ task<K extends string>(name: K, opts?: {
72
+ jobType?: string;
73
+ io?: HumanIoMapping;
74
+ }): FlowBuilder<C>;
75
+ /**
76
+ * A durable wait for an external/human event, correlated on a process
77
+ * variable (a BPMN message intermediate catch event). Resume it with
78
+ * `WorkflowClient.signal(flow, name, correlationKeyValue, vars)`. The message
79
+ * payload envelope, if any, comes from the contract's `in`.
80
+ */
81
+ signal<K extends string>(name: K, opts: {
82
+ correlationKey: string;
83
+ }): FlowBuilder<C>;
84
+ /**
85
+ * A durable wait for a point in time (a BPMN timer intermediate catch event).
86
+ * Pass exactly one of `{ after }` — an ISO-8601 delay (`PT1M30S`, `P1DT6H`) or
87
+ * FEEL `=`-expression measured from when the token arrives — or `{ at }` — an
88
+ * absolute ISO-8601 instant (or FEEL expression). The engine holds the token
89
+ * durably until the timer fires, then continues. Use it for in-flow delays and
90
+ * scheduled continuations (e.g. "wait 24h, then re-poll").
91
+ */
92
+ timer<K extends string>(name: K, opts: {
93
+ after: string;
94
+ } | {
95
+ at: string;
96
+ }): FlowBuilder<C>;
97
+ /**
98
+ * Make this flow's start event a durable TIMER start rather than an explicit
99
+ * `client.start(...)`. Must be the first statement, at the top level. Pass
100
+ * exactly one of `{ cycle }` — a recurring ISO-8601 interval (`R/PT1H`,
101
+ * `R5/PT30M`) the engine re-fires each period — `{ after }` — a one-shot delay
102
+ * from deployment — or `{ at }` — a one-shot absolute instant. A `cycle` start
103
+ * is the model-native, durable, single-fire-per-cluster replacement for an
104
+ * app-side cron: the schedule lives in the deployable model, and the engine
105
+ * (not each app replica) owns firing it exactly once.
106
+ */
107
+ startOn(spec: {
108
+ cycle: string;
109
+ } | {
110
+ after: string;
111
+ } | {
112
+ at: string;
113
+ }): FlowBuilder<C>;
114
+ /**
115
+ * A multi-way exclusive choice (a BPMN exclusive gateway). `subject` is a FEEL
116
+ * expression (usually a variable name); each case routes when `subject` equals
117
+ * the case value. An optional `default` case is the unconditional fallback.
118
+ */
119
+ switch(subject: string, cases: Record<string, Block<C>> & {
120
+ default?: Block<C>;
121
+ }): FlowBuilder<C>;
122
+ /**
123
+ * A two-way exclusive choice on a FEEL boolean `condition` (a BPMN exclusive
124
+ * gateway). The `then` branch is guarded by the condition; the `else` branch
125
+ * (the gateway default) runs otherwise. Omitting `else` skips to whatever
126
+ * follows the branch when the condition is false.
127
+ */
128
+ branch(condition: string, arms: {
129
+ then: Block<C>;
130
+ else?: Block<C>;
131
+ }): FlowBuilder<C>;
132
+ /**
133
+ * A durable loop (a back-edge to the loop head). The body runs, then control
134
+ * returns to the top of the loop unless a branch calls `break()`. Nodes after
135
+ * the loop run once `break()` is reached.
136
+ */
137
+ loop(body: Block<C>): FlowBuilder<C>;
138
+ /**
139
+ * A static parallel fork/join (a pair of BPMN parallel gateways). Every block
140
+ * runs concurrently on its own branch; control continues past `parallel` only
141
+ * once ALL branches have reached the joining gateway (AND-join). Pass at least
142
+ * two branch blocks. Unlike `switch`/`branch` (exclusive choice), no branch is
143
+ * conditional — all of them run.
144
+ */
145
+ parallel(branches: Block<C>[]): FlowBuilder<C>;
146
+ /**
147
+ * A data-driven fan-out over a runtime collection (a BPMN parallel
148
+ * multi-instance activity). `collection` is a FEEL expression (no leading `=`)
149
+ * evaluating to a list; one child instance of `body` runs per item, with the
150
+ * item bound to the `itemVar` variable in the child's scope. A single-activity
151
+ * body attaches the multi-instance characteristics to that activity; a
152
+ * multi-step body is wrapped in an embedded multi-instance sub-process. Options:
153
+ * - `name` — label the multi-step body's sub-process on the diagram (e.g.
154
+ * "Review & challenge each file"); a single-step body keeps its step's name.
155
+ * - `sequential` — run children one at a time (a sequential MI) instead of all
156
+ * at once (the default: a parallel MI).
157
+ * - `outputCollection` / `outputElement` — collect each child's `outputElement`
158
+ * (a FEEL expression, no leading `=`) into the `outputCollection` list
159
+ * variable, in item order.
160
+ * - `completionCondition` — a FEEL boolean (no leading `=`); when it holds
161
+ * after a child completes, the remaining children are cancelled and the body
162
+ * completes early.
163
+ */
164
+ forEach(collection: string, itemVar: string, body: Block<C>, opts?: ForEachOpts): FlowBuilder<C>;
165
+ /** Exit the enclosing loop (routes to whatever follows it). Only valid inside
166
+ * a `loop`. */
167
+ break(): FlowBuilder<C>;
168
+ /** Jump straight back to the top of the enclosing loop, skipping the rest of
169
+ * the body. Only valid inside a `loop`. */
170
+ continue(): FlowBuilder<C>;
171
+ }
172
+ /** A builder method as stored on the dynamically-assembled builder. Its precise,
173
+ * generic user-facing signature comes from the `FlowBuilder<C>` interface (a
174
+ * built-in method declared centrally, a slice method declaration-merged from
175
+ * its module); this loose shape is only what the registry stores/installs. */
176
+ export type BuilderMethod = (...args: never[]) => unknown;
177
+ /** The per-body authoring context a kind module's `build` factory closes over to
178
+ * implement its builder method. Everything a method needs to append its node —
179
+ * claim its step name, resolve contract envelopes, recurse into nested bodies,
180
+ * and return the builder for chaining — without reaching into `declarative.ts`
181
+ * internals or the shared `FlowNode` union. */
182
+ export interface BuildApi {
183
+ /** The flow id (for error messages). */
184
+ readonly id: string;
185
+ /** Whether this is the root (top-level) builder — e.g. `startOn` is root-only. */
186
+ readonly isRoot: boolean;
187
+ /** The node list this builder appends to (`api.out.push(node)`). */
188
+ readonly out: FlowNode[];
189
+ /** The flow's typed I/O contracts, keyed by step name. */
190
+ readonly contracts: FlowContracts;
191
+ /** The flow's handler registry — a `run`-like kind registers its handler here. */
192
+ readonly handlers: Record<string, StepHandler>;
193
+ /** The current loop-nesting depth (0 outside any loop) — `break`/`continue`
194
+ * guard on it. */
195
+ readonly loopDepth: number;
196
+ /** The builder itself, for chaining (`return api.self()`). */
197
+ self(): FlowBuilder;
198
+ /** Populate a nested body block, returning its node list. `inLoop` deepens the
199
+ * loop nesting (a `loop` body); use it for bodies that can `break`/`continue`. */
200
+ child(fn: (b: FlowBuilder) => void, inLoop: boolean): FlowNode[];
201
+ /** Populate a nested body that runs in its OWN token scope (an embedded
202
+ * sub-process): `break`/`continue` cannot cross the boundary (loop depth 0). */
203
+ childScoped(fn: (b: FlowBuilder) => void): FlowNode[];
204
+ /** Claim a step name (rejects duplicates / reserved ids), as every leaf does. */
205
+ claim(name: string): void;
206
+ /** Resolve the declared envelopes for a step name from the contracts. */
207
+ contractEnvelopes(name: string): {
208
+ in?: Envelope;
209
+ out?: Envelope;
210
+ } | undefined;
211
+ /** Lift a durable timer start onto the flow (used only by `startOn`). */
212
+ setStartTimer(t: TimerStart): void;
213
+ }
214
+ /** A dynamically-assembled builder satisfies `FlowBuilder<C>` once every core
215
+ * built-in method is installed. The check is a runtime type guard (not an `as`
216
+ * cast): each own-property must be a function, AND every built-in method in
217
+ * {@link BUILTIN_BUILDER_METHODS} must be present — so a missing or
218
+ * tree-shaken node-kind registration fails fast here at builder assembly (a
219
+ * clear "missing registered methods" error) instead of surfacing later as an
220
+ * opaque `w.run is not a function` at authoring time. */
221
+ export declare function isFlowBuilder<C extends object = object>(x: object): x is FlowBuilder<C>;
222
+ /** Diagnostic for a failed builder assembly. Names the missing built-in
223
+ * method(s) when a registration was tree-shaken/omitted so the failure is
224
+ * actionable; otherwise, when every built-in is present but some own-property
225
+ * isn't a function, names that offending property instead. Exported (like
226
+ * {@link isFlowBuilder}) so the assembly invariant is unit-testable. */
227
+ export declare function assemblyFailureMessage(x: object): string;
228
+ /**
229
+ * Define a declarative flow. Pass a typed `contracts` map (keyed by step name)
230
+ * to type each step's I/O and lift its data envelopes into the model; or omit it
231
+ * for an untyped flow. `build(w)` declares a tree of nodes.
232
+ */
233
+ export declare function defineFlow<C extends FlowContracts>(id: string, contracts: C, build: (w: FlowBuilder<C>) => void): DeclarativeFlow;
234
+ export declare function defineFlow(id: string, build: (w: FlowBuilder) => void): DeclarativeFlow;
235
+ /** Depth-first visit of every node in a flow tree. Recursion into a kind's
236
+ * nested bodies is DISPATCHED through the registry (each kind's `walk` handler),
237
+ * so a slice's structural combinator recurses without editing a central switch.
238
+ * Fails fast (via `requireNodeKind`) on an unregistered kind — matching the
239
+ * emitter — so a tree-shaken/missing registration surfaces as a clear error
240
+ * rather than silently skipping recursion into that node's nested bodies. A
241
+ * registered leaf kind with no `walk` handler is fine (nothing to recurse). */
242
+ export declare function walkNodes(nodes: FlowNode[], visit: (n: FlowNode) => void): void;
243
+ /** The job types of a flow's external `task` steps (anywhere in the tree) — the
244
+ * contract workers outside this program must subscribe to. Each is the derived
245
+ * `<flowId>:<stepName>` unless the step overrode it via `w.task(name,
246
+ * { jobType })`. Deduplicated (preserving first-seen order) since several steps
247
+ * may intentionally share one override token. */
248
+ export declare function externalJobTypes(flow: DeclarativeFlow): string[];
249
+ /** The job types of a flow's inline-handled `run` steps (anywhere in the tree) —
250
+ * exactly the set the in-process `Worker` hosts (same walk, same derived
251
+ * `<flowId>:<stepName>`; a `run` step has no `jobType` override). Codegen
252
+ * consumes this to treat those steps as already-served: a worker-stub
253
+ * scaffolder must never plan a stub for them (nano-ide#595). Deduplicated,
254
+ * preserving first-seen order. */
255
+ export declare function inlineJobTypes(flow: DeclarativeFlow): string[];
256
+ /** A renderable BPMN element the emitter has placed. A kind's `emit` handler
257
+ * adds one (or more) via `api.addNode(...)` (or a typed helper like
258
+ * `api.addServiceTask`). */
259
+ export interface RenderNode {
260
+ id: string;
261
+ render(incoming: string[], outgoing: string[]): string;
262
+ /** For exclusive gateways: the flow id of the unconditional default edge. */
263
+ defaultFlow?: string;
264
+ /** Id of the embedded sub-process this node lives in, or undefined at the
265
+ * top level (the root process). */
266
+ scope?: string;
267
+ }
268
+ /** A BPMN sequence flow being wired. A kind's `emit` handler creates danglers
269
+ * with `api.newEdge(from)` and resolves them with `api.connect(edges, toId)`. */
270
+ export interface Edge {
271
+ id: string;
272
+ from: string;
273
+ to?: string;
274
+ condition?: string;
275
+ name?: string;
276
+ /** The scope (sub-process id, or undefined = root process) this flow is
277
+ * nested in — so it renders inside the right container. */
278
+ scope?: string;
279
+ }
280
+ /** The enclosing-loop context threaded through `emit`: `break`/`continue` route
281
+ * to `headId`, and `break` danglers collect in `breaks`. `null` outside a loop. */
282
+ export interface LoopCtx {
283
+ headId: string;
284
+ breaks: Edge[];
285
+ }
286
+ /** The emitter primitives a kind's `emit` handler uses to place its BPMN nodes
287
+ * and wire its sequence flows — WITHOUT reaching into `Compiler` internals or a
288
+ * central emit switch. Built-in kinds and slice-added kinds emit through this
289
+ * same surface. Node-render string helpers (`incomingOutgoing`, `escapeXml`, …)
290
+ * are exported alongside for building custom `RenderNode.render` closures. */
291
+ export interface EmitApi {
292
+ /** The flow id (for error messages). */
293
+ readonly flowId: string;
294
+ /** Create a new (dangling) sequence flow from `from`; resolve its target with
295
+ * `connect`. */
296
+ newEdge(from: string, opts?: {
297
+ condition?: string;
298
+ name?: string;
299
+ }): Edge;
300
+ /** Point every one of `incoming` at `toId`. */
301
+ connect(incoming: Edge[], toId: string): void;
302
+ /** Record a referenced data envelope so it is lifted to a `nano:shape`. */
303
+ recordEnvelope(env?: Envelope): void;
304
+ /** Emit a sequence of nodes, threading danglers; used to emit nested bodies. */
305
+ emitList(list: FlowNode[], incoming: Edge[], loop: LoopCtx | null): Edge[];
306
+ /** Place a fully custom BPMN element (a slice's own render closure). */
307
+ addNode(node: RenderNode): void;
308
+ /** Place a `<bpmn:serviceTask>` with the standard taskDefinition/envelope
309
+ * extension elements. `opts.mi` adds multi-instance characteristics; `opts.extraExt`
310
+ * injects additional `<bpmn:extensionElements>` content (e.g. a
311
+ * `zeebe:linkedResources` prompt binding) after the taskDefinition/properties,
312
+ * so a variant task only supplies its delta rather than re-rendering the shell. */
313
+ addServiceTask(node: {
314
+ name: string;
315
+ envelopes?: NodeEnvelopes;
316
+ jobType?: string;
317
+ }, opts?: {
318
+ mi?: string;
319
+ extraExt?: string;
320
+ }): void;
321
+ /** Place a `<bpmn:intermediateCatchEvent>` with a message event definition. */
322
+ addCatchEvent(node: {
323
+ name: string;
324
+ }): void;
325
+ /** Place a `<bpmn:intermediateCatchEvent>` with a timer event definition. */
326
+ addTimerCatchEvent(node: {
327
+ name: string;
328
+ after?: string;
329
+ at?: string;
330
+ }): void;
331
+ /** Place a `<bpmn:exclusiveGateway>`, returning it so `defaultFlow` can be set. */
332
+ addGateway(id: string, name?: string): RenderNode;
333
+ /** Place a `<bpmn:parallelGateway>`. */
334
+ addParallelGateway(id: string): RenderNode;
335
+ /** Place an embedded `<bpmn:subProcess>` whose body renders in its own scope,
336
+ * optionally labelled with `name`. */
337
+ addSubProcess(id: string, mi: string, name?: string): RenderNode;
338
+ /** Place a plain none `<bpmn:startEvent>` (for an embedded sub-process). */
339
+ addPlainStart(id: string): void;
340
+ /** Place a plain `<bpmn:endEvent>` (for an embedded sub-process). */
341
+ addPlainEnd(id: string): void;
342
+ /** A fresh monotonic counter value for generated gateway/loop/sub ids. */
343
+ nextGw(): number;
344
+ /** The current scope (enclosing sub-process id, or undefined at the top level). */
345
+ currentScope(): string | undefined;
346
+ /** Open a sub-process scope (subsequent nodes/edges nest inside it). */
347
+ pushScope(id: string): void;
348
+ /** Close the current sub-process scope. */
349
+ popScope(): void;
350
+ }
351
+ /** Derive an executable BPMN model from a declarative flow. */
352
+ export declare function declarativeToBpmn(flow: DeclarativeFlow): string;
353
+ /** Wrap a raw FEEL expression as a Zeebe condition body (leading `=`). Exported
354
+ * for slice-added combinators that emit conditional sequence flows. */
355
+ export declare const feel: (expr: string) => string;
356
+ /** A FEEL equality test `subject = "value"`, with the value as a FEEL string.
357
+ * Exported for slice-added combinators that emit an XOR gateway. */
358
+ export declare const feelEquals: (subject: string, value: string) => string;
359
+ /** Render the `<bpmn:incoming>`/`<bpmn:outgoing>` refs of a flow node. Exported
360
+ * for slice `RenderNode.render` closures. */
361
+ export declare function incomingOutgoing(inc: string[], outg: string[]): string;
362
+ /** Render only the `<bpmn:incoming>` refs (for end-like events). Exported. */
363
+ export declare const incomingOnly: (inc: string[]) => string;
364
+ /** Render only the `<bpmn:outgoing>` refs (for start-like events). Exported. */
365
+ export declare const outgoingOnly: (outg: string[]) => string;
@@ -0,0 +1,77 @@
1
+ /** The scalar types a `nano:extend` field may declare (mirrors the vocabulary
2
+ * the console's shape scan understands). `integer`/`number` are both `number`
3
+ * in TS; `datetime` is an ISO `string`. */
4
+ export type ScalarType = "string" | "integer" | "number" | "boolean" | "datetime";
5
+ /** Map a scalar envelope type to its TypeScript representation. */
6
+ export type ScalarTs<T extends ScalarType> = T extends "string" | "datetime" ? string : T extends "integer" | "number" ? number : T extends "boolean" ? boolean : never;
7
+ /** A field spec: either a bare scalar type, or an object with modifiers. */
8
+ export type FieldSpec = ScalarType | {
9
+ type: ScalarType;
10
+ optional?: boolean;
11
+ list?: boolean;
12
+ };
13
+ /** The TS type of a single field spec (applies `list` before `optional`). A spec
14
+ * whose `list` isn't a literal (the widened `FieldSpec` of a plain `Envelope`) may
15
+ * be either, so a declared envelope with list fields still fits `Envelope`. */
16
+ export type FieldTs<F> = F extends ScalarType ? ScalarTs<F> : F extends {
17
+ type: infer T extends ScalarType;
18
+ list: true;
19
+ } ? ScalarTs<T>[] : F extends {
20
+ type: infer T extends ScalarType;
21
+ list?: false;
22
+ } ? ScalarTs<T> : F extends {
23
+ type: infer T extends ScalarType;
24
+ } ? ScalarTs<T> | ScalarTs<T>[] : never;
25
+ type OptionalKeys<S> = {
26
+ [K in keyof S]: S[K] extends {
27
+ optional: true;
28
+ } ? K : never;
29
+ }[keyof S];
30
+ type RequiredKeys<S> = Exclude<keyof S, OptionalKeys<S>>;
31
+ /** The inferred payload type of an envelope: required + optional fields. */
32
+ export type EnvelopeType<S extends Record<string, FieldSpec>> = {
33
+ [K in RequiredKeys<S>]: FieldTs<S[K]>;
34
+ } & {
35
+ [K in OptionalKeys<S>]?: FieldTs<S[K]>;
36
+ };
37
+ /** A normalised field, as stored on an `Envelope` and lifted to `nano:extend`. */
38
+ export interface EnvelopeField {
39
+ name: string;
40
+ type: ScalarType;
41
+ optional: boolean;
42
+ list: boolean;
43
+ }
44
+ /**
45
+ * A typed data envelope: a named schema (for the model) plus a phantom TS type
46
+ * (for the call site). Construct with {@link envelope}. `type` is a phantom
47
+ * property — it is `undefined` at runtime and exists only to carry the inferred
48
+ * payload type (use `typeof env.type` in type positions).
49
+ */
50
+ export interface Envelope<S extends Record<string, FieldSpec> = Record<string, FieldSpec>> {
51
+ readonly name: string;
52
+ readonly fields: EnvelopeField[];
53
+ /** Phantom: the inferred payload type. Do not read at runtime. */
54
+ readonly type: EnvelopeType<S>;
55
+ }
56
+ /**
57
+ * Declare a typed data envelope. `name` becomes the `nano:shape` id lifted into
58
+ * the model (must be a valid BPMN identifier); `fields` declares the payload.
59
+ * The returned envelope's `type` phantom carries the inferred TS payload type.
60
+ */
61
+ export declare function envelope<const S extends Record<string, FieldSpec>>(name: string, fields: S): Envelope<S>;
62
+ /** One way a value fails its envelope: the field (or "" for the value itself) and why. */
63
+ export interface EnvelopeProblem {
64
+ field: string;
65
+ message: string;
66
+ }
67
+ /**
68
+ * Check a value against an envelope: every required field present (not `undefined`
69
+ * or `null`), and each supplied field of its declared scalar type (a `list` field an
70
+ * array of it). An optional field may be absent, but a supplied `null` is checked like
71
+ * any other value (and fails). Fields the envelope doesn't declare are allowed — an envelope is the
72
+ * data a step needs, not all it may see. Returns the problems (empty = valid); it
73
+ * does not coerce. Use it where untyped data enters a typed flow, e.g. the variables
74
+ * a new instance is started with, checked against `flow.input`.
75
+ */
76
+ export declare function validateEnvelope(env: Pick<Envelope, "name" | "fields">, value: unknown): EnvelopeProblem[];
77
+ export {};
@@ -0,0 +1,32 @@
1
+ import type { ImperativeWorkflow, Json, JsonObject, Orchestration } from "./types.js";
2
+ /** Define an imperative, replay-driven durable workflow.
3
+ *
4
+ * @experimental Not the recommended code-first surface. Prefer `defineFlow`
5
+ * (declarative), whose steps are engine-visible BPMN nodes. This imperative
6
+ * replay surface compiles to a single opaque looping orchestrator and requires
7
+ * determinism discipline in the orchestration body; it is retained for advanced
8
+ * durable-orchestration use only. */
9
+ export declare function defineWorkflow(id: string, orchestrate: Orchestration): ImperativeWorkflow;
10
+ /** The looped-orchestrator model: start → orchestrate → gw → (done ? end : loop). */
11
+ export declare function imperativeToBpmn(wf: ImperativeWorkflow): string;
12
+ /** A journal of recorded step results, keyed by call-ordinal + name. */
13
+ export type Journal = Record<string, Json>;
14
+ /** Outcome of a single replay pass. */
15
+ export type ReplayStep = {
16
+ done: true;
17
+ } | {
18
+ done: false;
19
+ frontier: {
20
+ key: string;
21
+ result: Json;
22
+ };
23
+ };
24
+ /**
25
+ * Replay the orchestration function against a journal. Returns `{ done: true }`
26
+ * if the function ran to completion, or the frontier step (the one un-recorded
27
+ * `ctx.run`) whose handler was just executed and must be journalled next turn.
28
+ *
29
+ * Duplicate `ctx.run` names within a single pass are disambiguated by ordinal,
30
+ * so a loop that calls `ctx.run("x", …)` repeatedly still gets distinct keys.
31
+ */
32
+ export declare function replayOnce(wf: ImperativeWorkflow, input: JsonObject, journal: Journal): Promise<ReplayStep>;
@@ -0,0 +1,14 @@
1
+ export { defineWorkflow, imperativeToBpmn, replayOnce } from "./imperative.js";
2
+ export type { Journal, ReplayStep } from "./imperative.js";
3
+ export { defineFlow, declarativeToBpmn, externalJobTypes, inlineJobTypes, walkNodes } from "./declarative.js";
4
+ export type { FlowBuilder, StartVars } from "./declarative.js";
5
+ export type { BoundaryOptions } from "./nodes/boundary.js";
6
+ export type { HumanOptions, HumanIoMapping, HumanIoEntry } from "./nodes/human.js";
7
+ export { layoutBpmn, declarativeToLayoutedBpmn } from "./layout.js";
8
+ export { envelope, validateEnvelope } from "./envelope.js";
9
+ export type { Envelope, EnvelopeProblem, EnvelopeType, EnvelopeField, FieldSpec, ScalarType, ScalarTs, FieldTs, } from "./envelope.js";
10
+ export { WorkflowClient, WorkflowError, toBpmn, toDeployableBpmn } from "./client.js";
11
+ export type { WorkflowClientOptions, NanoSdkClient, NanoJobWorker, JobWorkerConfig, ActivatedJob, } from "./client.js";
12
+ export { Worker } from "./worker.js";
13
+ export type { WorkerOptions, ActivityEvent } from "./worker.js";
14
+ export type { Json, JsonObject, Job, StepHandler, DeclarativeFlow, DeclarativeStep, FlowNode, SwitchCase, TimerStart, NodeEnvelopes, StepContract, FlowContracts, ImperativeWorkflow, Orchestration, WorkflowContext, Workflow, DeployResult, StartResult, } from "./types.js";