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

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 +525 -2
  5. package/dist/cli.js +55815 -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 +1256 -0
  10. package/dist/layout-thread.js +12806 -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 +366 -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 +22 -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 +24 -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,146 @@
1
+ import type { Envelope } from "./envelope.js";
2
+ /** A JSON-serialisable value, as carried by process variables. */
3
+ export type Json = null | boolean | number | string | Json[] | {
4
+ [k: string]: Json;
5
+ };
6
+ export type JsonObject = {
7
+ [k: string]: Json;
8
+ };
9
+ /** A job as delivered by the nanobpmn gateway's `POST /v2/jobs/activation`. The
10
+ * `variables` type parameter carries the input envelope's inferred payload when
11
+ * a step is declared with a typed envelope; it defaults to the untyped
12
+ * `JsonObject`. */
13
+ export interface Job<V extends JsonObject = JsonObject> {
14
+ jobKey: string;
15
+ processInstanceKey: string;
16
+ elementId: string;
17
+ type: string;
18
+ variables: V;
19
+ }
20
+ /** The input/output data envelopes lifted onto an activity node. */
21
+ export interface NodeEnvelopes {
22
+ in?: Envelope;
23
+ out?: Envelope;
24
+ }
25
+ /** A typed I/O contract for one step: its input and/or output data envelope.
26
+ * For a `signal`, `in` types the message payload. */
27
+ export interface StepContract {
28
+ in?: Envelope;
29
+ out?: Envelope;
30
+ }
31
+ /** A flow's typed I/O registry, keyed by step name — the single source of truth
32
+ * for each step's envelopes. Passed to `defineFlow`; a step whose name is a key
33
+ * is typed (and its envelopes lifted to the model), others fall back to the
34
+ * untyped `JsonObject`. */
35
+ export type FlowContracts = Record<string, StepContract>;
36
+ /** Handler for a declarative `run` step: does real work, returns variables. */
37
+ export type StepHandler<V extends JsonObject = JsonObject, R extends JsonObject = JsonObject> = {
38
+ bivarianceHack(job: Job<V>): Promise<R | void> | R | void;
39
+ }["bivarianceHack"];
40
+ /** The OPEN registry of flow-node kinds — the single extension seam for the
41
+ * `FlowNode` union (epic #314, S0/#315). Each kind module under `src/nodes/`
42
+ * declaration-merges ONE property into this interface (`kindName: NodeShape`),
43
+ * so `FlowNode` grows without editing a central union here. The built-in kinds
44
+ * register `run`/`task`/`signal`/`timer`/`switch`/`branch`/`loop`/`break`/
45
+ * `continue`/`parallel`/`forEach` from their own modules through this same
46
+ * mechanism — see `src/nodes/README.md`.
47
+ *
48
+ * Invariant: every value type MUST be an object with a `kind` discriminant
49
+ * equal to its key, so `FlowNode` stays a discriminated union.
50
+ *
51
+ * This interface is intentionally empty here: it is the augmentation target the
52
+ * per-kind modules declaration-merge their variant into. */
53
+ export interface FlowNodeRegistry {
54
+ }
55
+ /** A node in a declarative flow tree, derived from the {@link FlowNodeRegistry}.
56
+ * Leaf activities carry optional data envelopes (lifted to `nano:shape` +
57
+ * `dataEnvelope` in the model); structural combinators carry nested
58
+ * `FlowNode[]` bodies. */
59
+ export type FlowNode = FlowNodeRegistry[keyof FlowNodeRegistry];
60
+ /** A timer intermediate-catch definition: exactly one of `after` (an ISO-8601
61
+ * delay or FEEL expression) or `at` (an absolute instant or FEEL expression).
62
+ * Encoded as an XOR so downstream consumers can rely on exactly-one. */
63
+ export type TimerAt = {
64
+ after: string;
65
+ at?: never;
66
+ } | {
67
+ at: string;
68
+ after?: never;
69
+ };
70
+ /** A flow's start-timer: the plain none start event becomes a durable timer
71
+ * start the engine fires on schedule. Exactly one of:
72
+ * - `cycle` — a recurring ISO-8601 interval (`R/PT1H`, `R5/PT30M`) or bare
73
+ * duration; the engine re-fires on each period. This is the model-native,
74
+ * durable, single-fire-per-cluster replacement for an app-side cron.
75
+ * - `after` — a one-shot ISO-8601 delay (`PT10S`) measured from deployment.
76
+ * - `at` — a one-shot absolute instant (an ISO-8601 date-time, or a FEEL
77
+ * `=` expression).
78
+ * Encoded as an XOR so the exactly-one invariant holds at the type level. */
79
+ export type TimerStart = {
80
+ cycle: string;
81
+ after?: never;
82
+ at?: never;
83
+ } | {
84
+ after: string;
85
+ cycle?: never;
86
+ at?: never;
87
+ } | {
88
+ at: string;
89
+ cycle?: never;
90
+ after?: never;
91
+ };
92
+ /** One case of a `switch`: routed when `subject = value` (FEEL equality). */
93
+ export interface SwitchCase {
94
+ value: string;
95
+ body: FlowNode[];
96
+ }
97
+ /** @deprecated Renamed to {@link FlowNode} now that a flow is a tree of nodes,
98
+ * not a flat list of steps. Kept as an alias for source compatibility. */
99
+ export type DeclarativeStep = FlowNode;
100
+ export interface DeclarativeFlow {
101
+ kind: "declarative";
102
+ id: string;
103
+ /** The flow's node tree (top-level sequence). */
104
+ steps: FlowNode[];
105
+ handlers: Record<string, StepHandler>;
106
+ /** When set, the flow's start event is a durable timer start (see
107
+ * {@link TimerStart}) rather than a plain none start. */
108
+ startTimer?: TimerStart;
109
+ /** The flow's input contract: the `in` envelope of the `Start` contract
110
+ * (`defineFlow(id, { Start: { in: MyInput } }, …)`). Lifted onto the start
111
+ * event as `io.nanobpm.dataEnvelope.in`, so the model says what a new instance
112
+ * takes; a host can render a start form from it and check start variables
113
+ * with {@link validateEnvelope}. Absent = untyped start. */
114
+ input?: Envelope;
115
+ }
116
+ /** The context passed to an imperative orchestration function. */
117
+ export interface WorkflowContext {
118
+ /** The workflow's start input (immutable across replays). */
119
+ readonly input: JsonObject;
120
+ /**
121
+ * A durable activity. On first execution the handler runs (its side effects
122
+ * happen once); on every subsequent replay the recorded result is returned
123
+ * WITHOUT invoking the handler. The handler is the only place side effects
124
+ * (I/O, network, shell, LLM) are allowed — the orchestration body itself must
125
+ * be deterministic.
126
+ */
127
+ run<T extends Json = Json>(name: string, fn: () => Promise<T> | T): Promise<T>;
128
+ }
129
+ export type Orchestration = (ctx: WorkflowContext) => Promise<void>;
130
+ export interface ImperativeWorkflow {
131
+ kind: "imperative";
132
+ id: string;
133
+ orchestrate: Orchestration;
134
+ /** Derived job type of the single orchestrator task: `<id>:__orchestrate`. */
135
+ orchestrateType: string;
136
+ }
137
+ export type Workflow = DeclarativeFlow | ImperativeWorkflow;
138
+ /** Result of deploying a workflow. */
139
+ export interface DeployResult {
140
+ [k: string]: Json;
141
+ }
142
+ /** Result of starting a workflow instance. */
143
+ export interface StartResult {
144
+ processInstanceKey?: string;
145
+ [k: string]: Json | undefined;
146
+ }
@@ -0,0 +1,92 @@
1
+ import { WorkflowClient } from "./client.js";
2
+ import type { Workflow } from "./types.js";
3
+ /** Fired after a job completes; purely observational. */
4
+ export interface ActivityEvent {
5
+ workflowId: string;
6
+ type: string;
7
+ jobKey: string;
8
+ elementId: string;
9
+ /** For an imperative orchestrator turn: the journalled step key, or "__done". */
10
+ step?: string;
11
+ }
12
+ /** Options common to both ways of building a `Worker`. */
13
+ interface WorkerCommon {
14
+ workflows: Workflow[];
15
+ /** Worker name reported to the gateway. Default "nanobpm-workflow". */
16
+ name?: string;
17
+ /** Transport for the worker's own client (used only when `client` is not
18
+ * supplied): "auto" | "falcon" | "rest". Defaults to "rest" — job serving is
19
+ * resilience-critical, and REST long-poll reconnects with backoff after an
20
+ * engine restart (the ADR 0044 property), whereas the Falcon push transport
21
+ * does not recover a mid-stream disconnect. Instance creation, by contrast,
22
+ * defaults to Falcon on its own `WorkflowClient` for throughput. */
23
+ transport?: "auto" | "falcon" | "rest";
24
+ /** Long-poll timeout per activation, ms. Also bounds stop() latency. Default 10000. */
25
+ pollTimeoutMs?: number;
26
+ /** Job lock timeout, ms. Default 30000. */
27
+ jobTimeoutMs?: number;
28
+ /** Max jobs handled in parallel per derived job type. Default 1. */
29
+ maxParallelJobs?: number;
30
+ onActivity?: (e: ActivityEvent) => void | Promise<void>;
31
+ onError?: (err: Error, context: {
32
+ type: string;
33
+ }) => void;
34
+ }
35
+ /** Build a `Worker` from **either** a `baseUrl` (a `WorkflowClient` is created)
36
+ * **or** an existing `client`. The union makes TypeScript enforce that exactly
37
+ * one is supplied, matching the constructor's runtime requirement. */
38
+ export type WorkerOptions = (WorkerCommon & {
39
+ /** Base URL of the nanobpmn gateway; a `WorkflowClient` is created for you. */
40
+ baseUrl: string;
41
+ client?: never;
42
+ }) | (WorkerCommon & {
43
+ /** An existing `WorkflowClient` to serve jobs through. */
44
+ client: WorkflowClient;
45
+ baseUrl?: never;
46
+ });
47
+ export declare class Worker {
48
+ private readonly client;
49
+ private readonly name;
50
+ private readonly pollTimeoutMs;
51
+ private readonly jobTimeoutMs;
52
+ private readonly maxParallelJobs;
53
+ private readonly onActivity?;
54
+ private readonly onError?;
55
+ /** job type → { workflowId, handle } */
56
+ private readonly routes;
57
+ /** Job lock timeout (ms) per derived job type, from a `run` step's `{ timeoutMs }`
58
+ * (issue #596). Overrides the worker-wide `jobTimeoutMs` for that type. */
59
+ private readonly typeTimeoutMs;
60
+ private running;
61
+ private workers;
62
+ constructor(opts: WorkerOptions);
63
+ private register;
64
+ /** Register a derived job type, failing fast on a collision. Two workflows can
65
+ * resolve to the same job type (duplicate workflow ids, or a declarative step
66
+ * name that collides with another workflow's); silently overwriting the route
67
+ * would drop a handler, so we reject it at construction time. */
68
+ private addRoute;
69
+ /** Invoke the onError observer hook without letting it affect the poll loop —
70
+ * a throwing observer must not permanently stop a route. */
71
+ private emitError;
72
+ /** Invoke the onActivity observer hook in isolation. It runs after the job has
73
+ * already been completed, so a throwing observer must not fall into the
74
+ * failure path and try to fail an already-completed job. */
75
+ private emitActivity;
76
+ /** The derived job types this worker serves. */
77
+ get servedTypes(): string[];
78
+ /** Begin serving. Creates one nano-sdk job worker per derived job type with
79
+ * `autoStart: false`, then starts each explicitly, so the poll lifecycle is
80
+ * deterministic and owned here rather than left to the SDK's auto-start
81
+ * default (matching the `JobWorkerConfig.autoStart` contract). Nothing polls
82
+ * before `start()` is called. */
83
+ start(): void;
84
+ /** Stop serving and wait for in-flight jobs to drain. Stopping is best-effort
85
+ * per worker: the Falcon worker's `stop` throws if it never bound a transport
86
+ * (detection still pending), which must not fail the whole shutdown. */
87
+ stop(): Promise<void>;
88
+ /** Dispatch one activated job to its route handler and acknowledge it. Returns
89
+ * the nano-sdk action receipt (its `complete`/`fail` result). */
90
+ private handleJob;
91
+ }
92
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { Workflow } from "./types.js";
2
+ export declare function escapeXml(s: string): string;
3
+ /** Derived job type for a declarative `run` step / imperative orchestrator. */
4
+ export declare const jobType: (workflowId: string, step: string) => string;
5
+ /** Derived message name for a declarative `signal` step. */
6
+ export declare const messageName: (workflowId: string, step: string) => string;
7
+ /** The single orchestrator job type of an imperative workflow. */
8
+ export declare const orchestrateType: (workflowId: string) => string;
9
+ export declare function assertIdent(kind: string, value: string): void;
10
+ export declare function assertJobType(kind: string, value: string): void;
11
+ export declare function assertTimerDuration(kind: string, value: string): void;
12
+ export declare function assertTimerCycle(kind: string, value: string): void;
13
+ export declare function assertTimerDate(kind: string, value: string): void;
14
+ export declare function assertWorkflowIds(wf: Workflow): void;
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@nanobpm/workflow",
3
+ "version": "0.18.0",
4
+ "description": "Code-first durable orchestration for nanobpmn (ADR 0044/0045). Author a durable workflow as a declarative flow — `defineFlow(id, w => { w.run(...); w.signal(...); w.task(...) })` — and the SDK derives the executable BPMN model, the job types, and the message/correlation wiring, then hosts a generic worker. `w.run` is a local step, `w.signal` is a durable human-in-the-loop wait, `w.task` is a step serviced by an external worker. `defineFlow` is the single code-first surface; the imperative `defineWorkflow` replay function is experimental/internal, not a recommended API. No diagram, no task-type wiring, no correlation plumbing authored by hand — and you can optionally auto-generate a diagram (DI) for the derived model with `declarativeToLayoutedBpmn` via the optional `bpmn-auto-layout` peer dependency. Talks to a running nanobpmn gateway through @nanobpm/nano-sdk (the shared engine-transport spine — ADR 0055), which negotiates the Falcon protocol on a Nano server and REST elsewhere.",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/nanobpm/nano-ide.git",
10
+ "directory": "packages/workflow"
11
+ },
12
+ "main": "./dist/index.js",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./test-support": {
21
+ "types": "./dist/test-support/index.d.ts",
22
+ "default": "./dist/test-support/index.js"
23
+ },
24
+ "./source": "./src/index.ts"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "src"
29
+ ],
30
+ "engines": {
31
+ "node": ">=22.6"
32
+ },
33
+ "sideEffects": [
34
+ "./dist/nodes/*.js",
35
+ "./src/nodes/*.ts"
36
+ ],
37
+ "dependencies": {
38
+ "@nanobpm/nano-sdk": "^1.2.5"
39
+ },
40
+ "scripts": {
41
+ "gen:nodes": "node scripts/gen-node-registry.mjs",
42
+ "build": "npm run gen:nodes && tsc -p tsconfig.json",
43
+ "typecheck": "npm run gen:nodes && tsc -p tsconfig.json --noEmit && tsc -p tsconfig.types.json",
44
+ "test": "npm run build && npm run test:ci",
45
+ "test:ci": "node --experimental-strip-types --test test/*.test.ts",
46
+ "test:integration": "node --experimental-strip-types --test test/integration.test.ts",
47
+ "prepack": "npm run build"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "^22.20.1",
51
+ "bpmn-auto-layout": "^2.0.0-alpha.2",
52
+ "typescript": "^5.6.3"
53
+ },
54
+ "peerDependencies": {
55
+ "bpmn-auto-layout": "^2.0.0-alpha.2"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "bpmn-auto-layout": {
59
+ "optional": true
60
+ }
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ }
65
+ }
@@ -0,0 +1,10 @@
1
+ // Minimal ambient types for `bpmn-auto-layout` (ships none of its own).
2
+ // `layoutProcess` adds diagram interchange (DI) to a BPMN XML string. The
3
+ // resolved shape has settled on `{ xml, warnings }` in 2.x (and >= 1.4); 1.3.x
4
+ // resolved to the laid-out XML string directly. We type the union and normalize
5
+ // at the call site (see `layout.ts`) so the SDK still works across that range.
6
+ declare module "bpmn-auto-layout" {
7
+ export function layoutProcess(
8
+ xml: string,
9
+ ): Promise<string | { xml: string; warnings?: unknown[] }>;
10
+ }
@@ -0,0 +1,68 @@
1
+ declare module "node:assert/strict" {
2
+ import {
3
+ Assert,
4
+ AssertionError,
5
+ AssertionErrorOptions,
6
+ AssertMessageFunction,
7
+ AssertOptions,
8
+ AssertPredicate,
9
+ AssertStrict,
10
+ deepStrictEqual,
11
+ doesNotMatch,
12
+ doesNotReject,
13
+ doesNotThrow,
14
+ fail,
15
+ ifError,
16
+ match,
17
+ notDeepStrictEqual,
18
+ notStrictEqual,
19
+ ok,
20
+ partialDeepStrictEqual,
21
+ rejects,
22
+ strictEqual,
23
+ throws,
24
+ } from "node:assert";
25
+ function strict(
26
+ value: unknown,
27
+ message?: Error | AssertMessageFunction,
28
+ ): asserts value;
29
+ function strict(
30
+ value: unknown,
31
+ message: string,
32
+ ...args: unknown[]
33
+ ): asserts value;
34
+ namespace strict {
35
+ export {
36
+ Assert,
37
+ AssertionError,
38
+ AssertionErrorOptions,
39
+ AssertOptions,
40
+ AssertPredicate,
41
+ AssertStrict,
42
+ deepStrictEqual,
43
+ deepStrictEqual as deepEqual,
44
+ doesNotMatch,
45
+ doesNotReject,
46
+ doesNotThrow,
47
+ fail,
48
+ ifError,
49
+ match,
50
+ notDeepStrictEqual,
51
+ notDeepStrictEqual as notDeepEqual,
52
+ notStrictEqual,
53
+ notStrictEqual as notEqual,
54
+ ok,
55
+ partialDeepStrictEqual,
56
+ rejects,
57
+ strict,
58
+ strictEqual,
59
+ strictEqual as equal,
60
+ throws,
61
+ };
62
+ }
63
+ export = strict;
64
+ }
65
+ declare module "assert/strict" {
66
+ import strict = require("node:assert/strict");
67
+ export = strict;
68
+ }