@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
package/dist/guide.md ADDED
@@ -0,0 +1,147 @@
1
+ ---
2
+ name: agent-graph-authoring
3
+ description: Write, change and debug Agent Graph flows — TypeScript files (flows/<name>.flow.ts) built with defineFlow that compile to BPMN; their typed input and start form, steps (code, agents, people, timers, parallel), forms and agent options — and check them in a loop with `nage check` / flow_check until they type-check, compile and lint clean. Use whenever creating or editing a flow file.
4
+ ---
5
+
6
+ # Writing Agent Graph flows
7
+
8
+ A flow file is TypeScript in `flows/<name>.flow.ts`. It imports from
9
+ `@nanobpm/nano-agent-graph-engine` (the old name `agent-graph-engine` still works), exports one or more `defineFlow(...)` flows, and is compiled to
10
+ BPMN with a generated diagram. The engine redeploys it when the file changes. For
11
+ running flows, answering tasks and fixing incidents, see the `agent-graph` skill.
12
+
13
+ ## The check loop: run it after every edit
14
+
15
+ ```
16
+ nage check [flows/<name>.flow.ts] [--json] # or the MCP tool flow_check; flow_write runs it too
17
+ ```
18
+
19
+ It does three things:
20
+
21
+ - **Type-checks** the file (TypeScript strict mode, against the real `@nanobpm/nano-agent-graph-engine` and `@nanobpm/workflow` types and Node's). Errors come as `flows/x.flow.ts:12:5 TS2322: …`.
22
+ - **Compiles** each flow to BPMN.
23
+ - **Lints** it: missing `run` handlers, forms, prompt files and agent profiles, job types no worker serves, start-form hints that don't match the input, and whatever the engine refuses when it deploys the BPMN.
24
+
25
+ Exit code 1 means errors; warnings don't fail. `--json` gives `{ ok, files: [{ file, flows: [{ id, input }], problems: [{ severity, element?, message }] }] }`.
26
+
27
+ **Loop: edit → `nage check` → fix every error → repeat until it reports `✓`.** Don't start runs of a flow that doesn't check clean. The engine still deploys a file with type errors (it strips types), so it would fail or carry wrong data at run time.
28
+ Find the CLI at `<plugin>/dist/cli.js`. Without a shell (Claude Desktop), use `flow_write`, which writes the file and checks it, then `flow_check`.
29
+
30
+ ## A flow
31
+
32
+ ```ts
33
+ // flows/triage.flow.ts
34
+ import { defineFlow, defineForms, defineAgents, defineStartForm, envelope, sh } from "@nanobpm/nano-agent-graph-engine";
35
+
36
+ export const description = "Triage a GitHub issue"; // shown in the explorer and to agents
37
+
38
+ // The input: what a run is started with. Typed, checked when a run starts, and it
39
+ // becomes the start form (explorer, /flows), the MCP prompt arguments and CLI flags.
40
+ const Input = envelope("TriageInput", {
41
+ issue: "integer",
42
+ repo: "string",
43
+ labels: { type: "string", list: true, optional: true },
44
+ });
45
+ export const startForm = defineStartForm(Input, { // optional display hints
46
+ title: "Triage an issue",
47
+ fields: { issue: { title: "Issue number" }, repo: { default: "nanobpm/nano-ide" } },
48
+ });
49
+
50
+ export const forms = defineForms({
51
+ "triage-review": {
52
+ title: "Confirm triage for #{{issue}}",
53
+ description: "{{summary}}", // {{var}} = instance variable
54
+ fields: {
55
+ action: { type: "string", enum: ["label", "close", "skip"] },
56
+ comment: { type: "string", title: "Comment" },
57
+ },
58
+ required: ["action"],
59
+ },
60
+ });
61
+
62
+ export const agents = defineAgents({
63
+ summarize: { // options for the agent task below
64
+ schema: { type: "object", properties: { summary: { type: "string" } }, required: ["summary"] },
65
+ allowedTools: ["Bash(gh issue view:*)"],
66
+ model: "sonnet",
67
+ },
68
+ });
69
+
70
+ // Contracts are keyed by step name; `Start` is the flow's input. A step with an `in`
71
+ // envelope gets typed job.variables.
72
+ export const triage = defineFlow("triage", { Start: { in: Input }, fetch: { in: Input } }, (w) => {
73
+ w.run("fetch", async (job) => {
74
+ const { issue, repo } = job.variables; // number, string
75
+ const r = await sh(`gh issue view ${issue} -R ${repo} --json title,body`);
76
+ return { issueJson: r.stdout }; // merged into the variables
77
+ });
78
+ w.task("summarize", { jobType: "senior:summarize", prompt: { resourceId: "summarize.md" } });
79
+ w.human("review", { form: "triage-review" });
80
+ w.switch("action", {
81
+ label: (b) => b.run("label", async (job) => { await sh(`gh issue edit ${job.variables.issue} --add-label triaged`); }),
82
+ close: (b) => b.run("close", async (job) => { await sh(`gh issue close ${job.variables.issue}`); }),
83
+ default: (b) => {},
84
+ });
85
+ });
86
+ ```
87
+
88
+ ## Input
89
+
90
+ - **Declare it** with `envelope(name, fields)` as `{ Start: { in: Input } }` in the contracts. Field types: `"string"`, `"integer"`, `"number"`, `"boolean"`, `"datetime"` (ISO 8601). A field can also be `{ type, optional: true, list: true }`.
91
+ - **Everything is derived from it**: the start form, the `flow_status` signature `triage(issue: integer, repo: string, labels?: string[])`, the MCP prompt `/start-triage` with one argument per field, and `nage start triage --issue 7 --repo x`.
92
+ - **Checked at start**: `/api/start` converts text to the declared types and refuses missing or wrong fields, naming each one.
93
+ - **Display hints** go in `defineStartForm(Input, { title, description, fields: { f: { title, description, enum, default, minimum, maximum } } })`. Field names are type-checked against the input.
94
+ - **Typing step variables**: to type a step's `job.variables`, give the step its own contract, e.g. `fetch: { in: Input }` (or a narrower envelope), plus an `out` envelope to type what it returns. Variables are `envelope & JsonObject`: a misspelled name isn't a type error, it is just untyped, so check names against the envelope.
95
+ - **No input declared**: the flow takes free-form JSON variables, and the start form is a JSON box.
96
+
97
+ ## Steps
98
+
99
+ - **`w.run(name, async (job) => vars, opts?)`** runs inline code. `job.variables` holds the instance variables; return an object (or nothing).
100
+ - Throwing fails the job: it is tried 3 times with backoff, then becomes an **incident**.
101
+ - `opts`: `{ timeoutMs }`.
102
+ - **`w.task(name, { jobType: "senior:<task>", prompt: { resourceId } })`** is an agent step. The prompt file goes in `flows/prompts/`.
103
+ - **Job type = `<rank>:<task>`** (nano-workforce convention): a rank (`senior`, `junior`, …) and the task, e.g. `senior:review`. Never name a CLI in the job type: the person running the flow decides which CLI and model serve it, so the flow works on any machine. (`"claude"` is the legacy job type; other shapes get a lint warning.)
104
+ - **Where it runs**: as a headless agent CLI when one is installed; otherwise it is handed to the chat session (`session_job_next`).
105
+ - **Per-step options** go in `export const agents = defineAgents({...})`:
106
+ - `schema`: a JSON schema for the answer, which becomes variables. Also ask for JSON in the prompt.
107
+ - `allowedTools`: headless runs never prompt, so list every tool the step needs.
108
+ - `model`, `system`.
109
+ - `context`: which variables to append to the prompt as JSON (default: all; `[]`: none).
110
+ - `{{name}}` in the prompt file is replaced by that variable. A `run` step can build the whole prompt (e.g. with an app's own prompt builder) into a variable, with the prompt file just `{{myPrompt}}` and `context: []`; a following `run` step checks the agent's output, and a `w.loop` + `switch` retries with the errors.
111
+ - `cwd`: the agent's working directory (absolute or relative to the project; `{{name}}` allowed). Default: the run's project.
112
+ - `env`: extra environment variables for the agent CLI, values with `{{name}}` placeholders, e.g. `{ AGENT_WORKSPACE: "{{workDir}}" }`.
113
+ - `abortCheck: true`: the agent gets `AGE_JOB_STATUS_URL` and a prompt section telling it to `curl -fsS` that URL before pushing or other irreversible actions. The URL 404s once the step is cancelled. A cancelled step's CLI is also killed.
114
+ - **Result file**: every agent run gets `AGENT_RESULT_FILE`. A JSON object the agent writes there becomes the step's variables, and wins over JSON in its final message. That is the Nano Workforce harness contract, so nwf prompts work unchanged (`prompt: { resourceId: "prompts/x.md" }` finds `flows/prompts/x.md`).
115
+ - `use`: a *suggested* agent — `claude`, `opencode`, `nano-coder`, `gemini`, `qwen`, `kimi`, `copilot`, or a profile from `export const agentProfiles = defineAgentProfiles({...})`. Only applies where that CLI is installed and the user hasn't assigned the flow/step/rank; otherwise their default runs it (an unknown one is a warning, not an error). Usually leave it out.
116
+ - **Flow default**: `export const defaultAgent = "…"` (also only a suggestion).
117
+ - The user picks CLIs and models with `flow_agents` / `nage agent assign`, or per run (`flow_start` `agents`); don't edit the flow for that.
118
+ - **`w.task(name, { jobType: "session", agent: true })`** is work for the live Claude Code session.
119
+ - Inside `run`, `await claude(prompt, opts)` calls an agent directly.
120
+ - **`w.human(name, { form })`** is a user task. The form comes from `export const forms = defineForms({...})`. Fields can be string (optionally `enum`/`enumNames`, `format: "date-time"`), boolean, or number/integer (`minimum`, `maximum`), plus `required: [...]`. `{{var}}` in the title and description is filled from the variables.
121
+ - **Choices**: `w.switch("var", { value: (b) => …, default: (b) => … })`, or `w.branch("<FEEL condition>", { then, else })`.
122
+ - **Repeats**: `w.loop((b) => { …; b.break(); … b.continue(); })`, e.g. draft → review → redo.
123
+ - **Ending early**: `b.end("abandoned")` ends that path; `b.end("stopped", { terminate: true })` ends the whole run (every other path is cancelled). Nothing may follow it in its block. Chain after a step: `b.run("cleanup", fn).end("merged")`.
124
+ - **First of**: `w.race({ timeout: { timer: { after: "PT1H" }, do: (b) => … }, reply: { signal: { correlationKey: "prKey" }, do: (b) => … } })` waits for whichever event comes first. A timer + signal race is a poll delay that a message can cut short.
125
+ - **SLA on a step**: `w.task(…).boundary({ timer: "PT50M", onTimeout: (b) => b.run("sla", …) })` cancels the step when the timer fires and runs `onTimeout`, which then continues with the rest of the flow.
126
+ - **Fixed branches**: `w.parallel([(b) => …, (b) => …])` runs every branch and joins them before continuing.
127
+ - **Fan-out**: `w.forEach("items", "item", (b) => …, { outputCollection: "results", outputElement: "notes" })` runs one branch per list item, with results collected in order. Options: `sequential`, `completionCondition`, and `name` to label a multi-step body (it's drawn as an expanded sub-process). Up to 4 headless agent branches run at once.
128
+ - **Waits**:
129
+ - `w.timer(name, { after: "PT1H" })` waits for a duration.
130
+ - `w.startOn({ cycle: "R/PT24H" })` starts the flow on a timer.
131
+ - `w.signal(name, { correlationKey: "orderId" })` waits for a message (`flow_operate` `message`).
132
+
133
+ ## Rules that bite
134
+
135
+ - **Names are unique per flow**: steps, ends, race arms, forms' steps. Helpers that add steps (an `escalate(b, …)` used in several places) must number their names.
136
+ - **Step names** are BPMN ids: letters, digits, `_` and `-`. Don't start them with `Gw_`, `Loop_`, `Sub_`, `Msg_` or `f_`, and don't use `Start`/`End` as step names (`Start` is only a contract key).
137
+ - **Variables are JSON**: keep them small (paths and ids, not file contents). Return values must be JSON-typed. A `{}` or `unknown` where JSON is expected is a type error: convert it with `String(…)`/`Number(…)`, or declare an `out` envelope.
138
+ - **File paths**: the engine serves every project. `sh()` and agent steps run in the run's project, but plain `fs` calls don't, so use `projectPath("file")` or absolute paths.
139
+ - **Threads**: each step runs on its own thread, so module-level state isn't shared between steps. Pass data in variables or files. Put reusable logic in normal modules and import them (they are type-checked too).
140
+ - **Timeouts**: steps time out after 25 min (agent steps after 55). `sh()` and `claude()` stop then; pass `jobSignal()` to `fetch()` and other long calls.
141
+ - **Unknown options**: an option the types don't know (for example `{ retries: 0 }`) is a type error, because the engine ignores it.
142
+
143
+ ## Changing a flow
144
+
145
+ - **Code changes** (`run` handlers, prompts, forms) apply to runs already in progress. Fix the code, check it, then `flow_operate` `retry` the incident.
146
+ - **Step changes** (added, removed or reordered steps) deploy a new version. Running instances keep the old shape.
147
+ - **Without file access**: read with `flow_read` and write with `flow_write`. Both check the flow.