yaml-flow 7.0.0 → 8.0.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 (393) hide show
  1. package/browser/asset-integrity.json +8 -4
  2. package/browser/board-livecards-client.js +1 -1
  3. package/browser/board-livecards-localstorage.js +5 -5
  4. package/browser/live-cards.js +19 -3307
  5. package/cli/board-live-cards-lib-tjYsPt5U.d.ts +321 -0
  6. package/{dist/cli → cli}/browser-api/board-live-cards-browser-adapter.d.ts +3 -5
  7. package/cli/browser-api/board-live-cards-browser-adapter.js +3 -0
  8. package/{dist/cli → cli}/browser-api/card-store-browser-api.d.ts +1 -2
  9. package/{dist/cli → cli}/browser-api/card-store-browser-api.js +1 -1
  10. package/cli/execution-interface-C_A6WCiK.d.ts +284 -0
  11. package/cli/node/artifacts-store-cli.js +11 -0
  12. package/cli/node/batch-runner-cli.js +3 -0
  13. package/cli/node/board-live-cards-cli.js +15 -0
  14. package/cli/node/card-store-cli.js +8 -0
  15. package/{dist/cli → cli}/node/execution-adapter.d.ts +3 -3
  16. package/cli/node/execution-adapter.js +3 -0
  17. package/{dist/cli → cli}/node/fs-board-adapter.d.ts +24 -11
  18. package/cli/node/fs-board-adapter.js +14 -0
  19. package/{dist/cli → cli}/node/source-cli-task-executor.js +2 -2
  20. package/cli/node/step-machine-cli.d.ts +7 -0
  21. package/cli/node/step-machine-cli.js +5 -0
  22. package/{dist/board-live-cards-public-CW5074xr.d.cts → cli/types-CziUxkiv.d.ts} +69 -7
  23. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/card-store-ref.json +1 -0
  24. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/chat-handler.json +1 -0
  25. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/outputs-store-ref.json +1 -0
  26. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.config/task-executor.json +1 -0
  27. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.state-snapshot/board/graph.json +29 -0
  28. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime/.state-snapshot/board/lastJournalProcessedId.json +1 -0
  29. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/gandalf-runtime-out/.outputs/status.json +25 -0
  30. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/cards/card-market-prices/computed_values.json +67 -0
  31. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/cards/card-portfolio/computed_values.json +1 -0
  32. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/cards/card-portfolio-value/computed_values.json +52 -0
  33. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/data-objects/holdings.json +22 -0
  34. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/data-objects/positions.json +46 -0
  35. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/data-objects/quotes.json +35 -0
  36. package/examples/board/.demo-setup/run-1778643703151-3360-dopnpv/board-default/runtime-out/.outputs/status.json +113 -0
  37. package/examples/{example-board/cards/card-market-prices.json → board/cards/cardT-market-prices.json} +2 -2
  38. package/examples/{example-board/cards/card-portfolio.json → board/cards/cardT-portfolio.json} +3 -13
  39. package/examples/{example-board → board}/demo-server-config.json +0 -1
  40. package/examples/{example-board → board}/demo-server.js +70 -72
  41. package/examples/{example-board → board}/demo-shell-with-server.html +3 -3
  42. package/examples/{example-board → board}/demo-task-executor.js +75 -32
  43. package/examples/board/gandalf-cards/card-source-kinds.json +36 -0
  44. package/examples/board/gandalf-cards/cards/_index.json +7 -0
  45. package/examples/board/gandalf-cards/cards/card-source-kinds.json +64 -0
  46. package/examples/board/source-def-flows/copilot.flow.json +33 -0
  47. package/examples/board/source-def-flows/mock.flow.json +35 -0
  48. package/examples/board/source-def-flows/url-list.flow.json +33 -0
  49. package/examples/board/source-def-flows/url.flow.json +33 -0
  50. package/examples/board/source-def-flows/workiq.flow.json +34 -0
  51. package/examples/board/source-def-handlers/copilot-source-handler.js +141 -0
  52. package/examples/board/source-def-handlers/http-source-handler.js +145 -0
  53. package/examples/board/source_def_flows.json +249 -0
  54. package/examples/board/test/demo-http-test.js +317 -0
  55. package/examples/{example-board → board-local}/demo-shell-localstorage.html +4 -4
  56. package/examples/{browser/boards/portfolio-tracker → portfolio-tracker/handlers}/portfolio-tracker-fetch-prices.js +1 -1
  57. package/examples/{browser/boards/portfolio-tracker/portfolio-tracker-public.js → portfolio-tracker/portfolio-tracker.js} +11 -14
  58. package/examples/{browser/boards/portfolio-tracker → portfolio-tracker/test}/portfolio-t4.js +32 -50
  59. package/lib/artifacts-store-lib-public-BABrgFkV.d.ts +119 -0
  60. package/lib/artifacts-store-lib-public-DGa8BpJT.d.cts +119 -0
  61. package/lib/artifacts-store-public.cjs +2 -0
  62. package/lib/artifacts-store-public.d.cts +5 -0
  63. package/lib/artifacts-store-public.d.ts +5 -0
  64. package/lib/artifacts-store-public.js +2 -0
  65. package/lib/board-live-cards-node.cjs +14 -0
  66. package/{dist/cli/node/execution-adapter.d.cts → lib/board-live-cards-node.d.cts} +45 -85
  67. package/lib/board-live-cards-node.d.ts +134 -0
  68. package/lib/board-live-cards-node.js +14 -0
  69. package/lib/board-live-cards-public-BnmRAbQV.d.cts +383 -0
  70. package/{dist/board-live-cards-public-hnZo0mAf.d.ts → lib/board-live-cards-public-CsmYrvpd.d.ts} +142 -77
  71. package/lib/board-live-cards-public.cjs +3 -0
  72. package/lib/board-live-cards-public.d.cts +4 -0
  73. package/lib/board-live-cards-public.d.ts +4 -0
  74. package/lib/board-live-cards-public.js +3 -0
  75. package/lib/board-live-cards-server-runtime.cjs +9 -0
  76. package/lib/board-live-cards-server-runtime.d.cts +6 -0
  77. package/lib/board-live-cards-server-runtime.d.ts +6 -0
  78. package/lib/board-live-cards-server-runtime.js +9 -0
  79. package/lib/board-livegraph-runtime/index.cjs +3 -0
  80. package/{dist → lib}/board-livegraph-runtime/index.d.cts +1 -2
  81. package/{dist → lib}/board-livegraph-runtime/index.d.ts +1 -2
  82. package/lib/board-livegraph-runtime/index.js +3 -0
  83. package/lib/board-worker-adapter.cjs +10 -0
  84. package/{dist/storage-refs.d.cts → lib/board-worker-adapter.d.cts} +5 -5
  85. package/{dist/storage-refs.d.ts → lib/board-worker-adapter.d.ts} +5 -5
  86. package/lib/board-worker-adapter.js +10 -0
  87. package/{dist → lib}/card-compute/index.cjs +1 -1
  88. package/{dist → lib}/card-compute/index.js +1 -1
  89. package/lib/card-store-public.cjs +2 -0
  90. package/lib/card-store-public.d.cts +61 -0
  91. package/lib/card-store-public.d.ts +61 -0
  92. package/lib/card-store-public.js +2 -0
  93. package/lib/card-validation.cjs +10 -0
  94. package/lib/card-validation.d.cts +35 -0
  95. package/lib/card-validation.d.ts +35 -0
  96. package/lib/card-validation.js +10 -0
  97. package/{dist/constants-oCEbNpul.d.ts → lib/constants-BPVLb3Es.d.ts} +1 -1
  98. package/{dist/constants-BzZUyYlp.d.cts → lib/constants-DXxsRN9y.d.cts} +1 -1
  99. package/{dist → lib}/continuous-event-graph/index.cjs +2 -2
  100. package/{dist → lib}/continuous-event-graph/index.d.cts +3 -5
  101. package/{dist → lib}/continuous-event-graph/index.d.ts +3 -5
  102. package/{dist → lib}/continuous-event-graph/index.js +2 -2
  103. package/{dist → lib}/event-graph/index.d.cts +2 -2
  104. package/{dist → lib}/event-graph/index.d.ts +2 -2
  105. package/lib/execution-refs.cjs +3 -0
  106. package/{dist → lib}/execution-refs.d.cts +38 -14
  107. package/{dist → lib}/execution-refs.d.ts +38 -14
  108. package/lib/execution-refs.js +3 -0
  109. package/lib/index.cjs +25 -0
  110. package/{dist → lib}/index.d.cts +7 -8
  111. package/{dist → lib}/index.d.ts +7 -8
  112. package/lib/index.js +25 -0
  113. package/{dist/live-cards-bridge-BXbVTsna.d.cts → lib/live-cards-bridge-DC_ZU0eS.d.ts} +134 -3
  114. package/{dist/live-cards-bridge-Ds28XR15.d.ts → lib/live-cards-bridge-b25aAVvE.d.cts} +134 -3
  115. package/lib/loader-CuuLjxVA.d.cts +42 -0
  116. package/lib/loader-Zborm2pq.d.ts +42 -0
  117. package/lib/server-runtime/index.cjs +9 -0
  118. package/{dist → lib}/server-runtime/index.d.cts +4 -4
  119. package/{dist → lib}/server-runtime/index.d.ts +4 -4
  120. package/lib/server-runtime/index.js +9 -0
  121. package/lib/step-machine/index.d.cts +64 -0
  122. package/lib/step-machine/index.d.ts +64 -0
  123. package/lib/step-machine-public/index.cjs +5 -0
  124. package/{dist → lib}/step-machine-public/index.d.cts +21 -1
  125. package/{dist → lib}/step-machine-public/index.d.ts +21 -1
  126. package/lib/step-machine-public/index.js +5 -0
  127. package/lib/storage-interface-BhAON-gW.d.cts +84 -0
  128. package/lib/storage-interface-BhAON-gW.d.ts +84 -0
  129. package/lib/stores/index.cjs +3 -0
  130. package/lib/stores/index.d.cts +4 -0
  131. package/lib/stores/index.d.ts +4 -0
  132. package/lib/stores/index.js +3 -0
  133. package/lib/stores/kv.cjs +3 -0
  134. package/lib/stores/kv.d.cts +32 -0
  135. package/lib/stores/kv.d.ts +32 -0
  136. package/lib/stores/kv.js +3 -0
  137. package/{dist → lib}/stores/memory.d.cts +1 -1
  138. package/{dist → lib}/stores/memory.d.ts +1 -1
  139. package/{dist/types-B1ZRa4aI.d.ts → lib/types-CBxkYuLY.d.ts} +2 -1
  140. package/{dist/types-ycun84cq.d.cts → lib/types-DQ1bKuB1.d.cts} +11 -0
  141. package/{dist/types-ycun84cq.d.ts → lib/types-DQ1bKuB1.d.ts} +11 -0
  142. package/{dist/types-BxEFcVK9.d.cts → lib/types-DkFvgxwq.d.cts} +2 -1
  143. package/package.json +79 -119
  144. package/board-live-cards-cli.js +0 -37
  145. package/browser/board-livecards-client.js.map +0 -1
  146. package/browser/board-livecards-localstorage.js.map +0 -1
  147. package/browser/board-livegraph-engine.js +0 -3
  148. package/browser/board-livegraph-engine.js.map +0 -1
  149. package/browser/card-compute.js +0 -266
  150. package/browser/compute-jsonata.js.map +0 -1
  151. package/card-store.js +0 -37
  152. package/dist/batch/index.cjs.map +0 -1
  153. package/dist/batch/index.js.map +0 -1
  154. package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +0 -136
  155. package/dist/board-live-cards-lib-jM2uYG1v.d.ts +0 -136
  156. package/dist/board-livegraph-runtime/index.cjs +0 -3
  157. package/dist/board-livegraph-runtime/index.cjs.map +0 -1
  158. package/dist/board-livegraph-runtime/index.js +0 -3
  159. package/dist/board-livegraph-runtime/index.js.map +0 -1
  160. package/dist/card-compute/index.cjs.map +0 -1
  161. package/dist/card-compute/index.js.map +0 -1
  162. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +0 -3
  163. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +0 -1
  164. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +0 -37
  165. package/dist/cli/browser-api/board-live-cards-browser-adapter.js +0 -3
  166. package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +0 -1
  167. package/dist/cli/browser-api/card-store-browser-api.cjs +0 -2
  168. package/dist/cli/browser-api/card-store-browser-api.cjs.map +0 -1
  169. package/dist/cli/browser-api/card-store-browser-api.d.cts +0 -26
  170. package/dist/cli/browser-api/card-store-browser-api.js.map +0 -1
  171. package/dist/cli/node/artifacts-store-cli.cjs +0 -11
  172. package/dist/cli/node/artifacts-store-cli.cjs.map +0 -1
  173. package/dist/cli/node/artifacts-store-cli.d.cts +0 -8
  174. package/dist/cli/node/artifacts-store-cli.js +0 -11
  175. package/dist/cli/node/artifacts-store-cli.js.map +0 -1
  176. package/dist/cli/node/board-live-cards-cli.cjs +0 -15
  177. package/dist/cli/node/board-live-cards-cli.cjs.map +0 -1
  178. package/dist/cli/node/board-live-cards-cli.d.cts +0 -20
  179. package/dist/cli/node/board-live-cards-cli.js +0 -15
  180. package/dist/cli/node/board-live-cards-cli.js.map +0 -1
  181. package/dist/cli/node/card-store-cli.cjs +0 -8
  182. package/dist/cli/node/card-store-cli.cjs.map +0 -1
  183. package/dist/cli/node/card-store-cli.d.cts +0 -15
  184. package/dist/cli/node/card-store-cli.js +0 -8
  185. package/dist/cli/node/card-store-cli.js.map +0 -1
  186. package/dist/cli/node/execution-adapter.cjs +0 -3
  187. package/dist/cli/node/execution-adapter.cjs.map +0 -1
  188. package/dist/cli/node/execution-adapter.js +0 -3
  189. package/dist/cli/node/execution-adapter.js.map +0 -1
  190. package/dist/cli/node/fs-board-adapter.cjs +0 -14
  191. package/dist/cli/node/fs-board-adapter.cjs.map +0 -1
  192. package/dist/cli/node/fs-board-adapter.d.cts +0 -204
  193. package/dist/cli/node/fs-board-adapter.js +0 -14
  194. package/dist/cli/node/fs-board-adapter.js.map +0 -1
  195. package/dist/cli/node/source-cli-task-executor.cjs +0 -11
  196. package/dist/cli/node/source-cli-task-executor.cjs.map +0 -1
  197. package/dist/cli/node/source-cli-task-executor.js.map +0 -1
  198. package/dist/config/index.cjs.map +0 -1
  199. package/dist/config/index.js.map +0 -1
  200. package/dist/continuous-event-graph/index.cjs.map +0 -1
  201. package/dist/continuous-event-graph/index.js.map +0 -1
  202. package/dist/event-graph/index.cjs.map +0 -1
  203. package/dist/event-graph/index.js.map +0 -1
  204. package/dist/execution-refs.cjs +0 -3
  205. package/dist/execution-refs.cjs.map +0 -1
  206. package/dist/execution-refs.js +0 -3
  207. package/dist/execution-refs.js.map +0 -1
  208. package/dist/index.cjs +0 -30
  209. package/dist/index.cjs.map +0 -1
  210. package/dist/index.js +0 -30
  211. package/dist/index.js.map +0 -1
  212. package/dist/inference/index.cjs +0 -7
  213. package/dist/inference/index.cjs.map +0 -1
  214. package/dist/inference/index.d.cts +0 -229
  215. package/dist/inference/index.d.ts +0 -229
  216. package/dist/inference/index.js +0 -7
  217. package/dist/inference/index.js.map +0 -1
  218. package/dist/server-runtime/index.cjs +0 -9
  219. package/dist/server-runtime/index.cjs.map +0 -1
  220. package/dist/server-runtime/index.js +0 -9
  221. package/dist/server-runtime/index.js.map +0 -1
  222. package/dist/step-machine/index.cjs.map +0 -1
  223. package/dist/step-machine/index.d.cts +0 -102
  224. package/dist/step-machine/index.d.ts +0 -102
  225. package/dist/step-machine/index.js.map +0 -1
  226. package/dist/step-machine-public/index.cjs +0 -2
  227. package/dist/step-machine-public/index.cjs.map +0 -1
  228. package/dist/step-machine-public/index.js +0 -2
  229. package/dist/step-machine-public/index.js.map +0 -1
  230. package/dist/storage-refs.cjs +0 -10
  231. package/dist/storage-refs.cjs.map +0 -1
  232. package/dist/storage-refs.js +0 -10
  233. package/dist/storage-refs.js.map +0 -1
  234. package/dist/stores/file.cjs +0 -2
  235. package/dist/stores/file.cjs.map +0 -1
  236. package/dist/stores/file.d.cts +0 -36
  237. package/dist/stores/file.d.ts +0 -36
  238. package/dist/stores/file.js +0 -2
  239. package/dist/stores/file.js.map +0 -1
  240. package/dist/stores/index.cjs +0 -2
  241. package/dist/stores/index.cjs.map +0 -1
  242. package/dist/stores/index.d.cts +0 -4
  243. package/dist/stores/index.d.ts +0 -4
  244. package/dist/stores/index.js +0 -2
  245. package/dist/stores/index.js.map +0 -1
  246. package/dist/stores/localStorage.cjs +0 -2
  247. package/dist/stores/localStorage.cjs.map +0 -1
  248. package/dist/stores/localStorage.d.cts +0 -34
  249. package/dist/stores/localStorage.d.ts +0 -34
  250. package/dist/stores/localStorage.js +0 -2
  251. package/dist/stores/localStorage.js.map +0 -1
  252. package/dist/stores/memory.cjs.map +0 -1
  253. package/dist/stores/memory.js.map +0 -1
  254. package/dist/types-CHSdoAAA.d.cts +0 -135
  255. package/dist/types-CoW0gQl3.d.ts +0 -135
  256. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +0 -201
  257. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-http-test.js +0 -357
  258. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +0 -196
  259. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.js +0 -300
  260. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.py +0 -617
  261. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +0 -366
  262. package/examples/browser/livecards-browser/index.html +0 -41
  263. package/examples/browser/step-machine-browser/index.html +0 -367
  264. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +0 -1
  265. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +0 -32
  266. package/examples/cli/step-machine-cli/portfolio-tracker/cards/holdings-table.json +0 -22
  267. package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +0 -43
  268. package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +0 -15
  269. package/examples/cli/step-machine-cli/portfolio-tracker/cards/price-fetch.json +0 -15
  270. package/examples/cli/step-machine-cli/portfolio-tracker/fetch-prices.js +0 -48
  271. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -125
  272. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +0 -32
  273. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +0 -26
  274. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +0 -49
  275. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +0 -25
  276. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +0 -23
  277. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +0 -21
  278. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +0 -38
  279. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +0 -48
  280. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +0 -31
  281. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +0 -107
  282. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +0 -51
  283. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +0 -45
  284. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +0 -71
  285. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +0 -36
  286. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +0 -26
  287. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +0 -39
  288. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +0 -80
  289. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +0 -76
  290. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +0 -44
  291. package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +0 -43
  292. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +0 -77
  293. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +0 -28
  294. package/examples/cli/step-machine-demo/jsonata-init-board-cli.js +0 -31
  295. package/examples/cli/step-machine-demo/jsonata-init-board.flow.yaml +0 -54
  296. package/examples/cli/step-machine-demo/one-step-cli-only.flow.yaml +0 -21
  297. package/examples/cli/step-machine-demo/step-cli-echo-y.js +0 -15
  298. package/examples/cli/step-machine-demo/step2-double-cli.js +0 -33
  299. package/examples/cli/step-machine-demo/two-step-math.flow.yaml +0 -93
  300. package/examples/cli/step-machine-demo/two-step-mixed.flow.yaml +0 -43
  301. package/examples/example-board/agent-instructions-cardlayout.md +0 -56
  302. package/examples/example-board/agent-instructions.md +0 -834
  303. package/examples/example-board/cards/_index.json +0 -47
  304. package/examples/example-board/demo-shell.html +0 -63
  305. package/examples/index.html +0 -785
  306. package/examples/npm-libs/batch/batch-step-machine.ts +0 -121
  307. package/examples/npm-libs/continuous-event-graph/live-cards-board.ts +0 -215
  308. package/examples/npm-libs/continuous-event-graph/live-portfolio-dashboard.ts +0 -555
  309. package/examples/npm-libs/continuous-event-graph/portfolio-tracker.ts +0 -287
  310. package/examples/npm-libs/continuous-event-graph/reactive-monitoring.ts +0 -265
  311. package/examples/npm-libs/continuous-event-graph/reactive-pipeline.ts +0 -168
  312. package/examples/npm-libs/continuous-event-graph/soc-incident-board.ts +0 -287
  313. package/examples/npm-libs/continuous-event-graph/stock-dashboard.ts +0 -229
  314. package/examples/npm-libs/event-graph/ci-cd-pipeline.ts +0 -243
  315. package/examples/npm-libs/event-graph/executor-diamond.ts +0 -165
  316. package/examples/npm-libs/event-graph/executor-pipeline.ts +0 -161
  317. package/examples/npm-libs/event-graph/research-pipeline.ts +0 -137
  318. package/examples/npm-libs/flows/ai-conversation.yaml +0 -116
  319. package/examples/npm-libs/flows/order-processing.yaml +0 -143
  320. package/examples/npm-libs/flows/simple-greeting.yaml +0 -54
  321. package/examples/npm-libs/graph-of-graphs/multi-stage-etl.ts +0 -307
  322. package/examples/npm-libs/graph-of-graphs/url-processing-pipeline.ts +0 -254
  323. package/examples/npm-libs/inference/azure-deployment.ts +0 -149
  324. package/examples/npm-libs/inference/copilot-cli.ts +0 -138
  325. package/examples/npm-libs/inference/data-pipeline.ts +0 -145
  326. package/examples/npm-libs/inference/pluggable-adapters.ts +0 -254
  327. package/examples/npm-libs/node/ai-conversation.ts +0 -195
  328. package/examples/npm-libs/node/simple-greeting.ts +0 -101
  329. package/examples/step-machine-cli/portfolio-tracker/cards/holdings-table.json +0 -22
  330. package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +0 -43
  331. package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +0 -15
  332. package/examples/step-machine-cli/portfolio-tracker/cards/price-fetch.json +0 -15
  333. package/examples/step-machine-cli/portfolio-tracker/fetch-prices.js +0 -48
  334. package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -57
  335. package/examples/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +0 -27
  336. package/examples/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +0 -25
  337. package/examples/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +0 -29
  338. package/examples/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +0 -27
  339. package/examples/step-machine-cli/portfolio-tracker/handlers/status-cli.js +0 -25
  340. package/examples/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +0 -37
  341. package/examples/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +0 -53
  342. package/examples/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +0 -35
  343. package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
  344. package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +0 -227
  345. package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +0 -38
  346. package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +0 -28
  347. package/step-machine-cli.js +0 -407
  348. /package/{dist/board-livegraph-runtime → cli/browser-api}/jsonata-sync.cjs +0 -0
  349. /package/{dist/cli → cli}/node/artifacts-store-cli.d.ts +0 -0
  350. /package/{dist/cli/node/source-cli-task-executor.d.cts → cli/node/batch-runner-cli.d.ts} +0 -0
  351. /package/{dist/cli → cli}/node/board-live-cards-cli.d.ts +0 -0
  352. /package/{dist/cli → cli}/node/card-store-cli.d.ts +0 -0
  353. /package/{dist/card-compute → cli/node}/jsonata-sync.cjs +0 -0
  354. /package/{dist/cli → cli}/node/source-cli-task-executor.d.ts +0 -0
  355. /package/examples/{example-board → board}/cards/card-concentration.json +0 -0
  356. /package/examples/{example-board → board}/cards/card-my-identity.json +0 -0
  357. /package/examples/{example-board → board}/cards/card-portfolio-action.json +0 -0
  358. /package/examples/{example-board → board}/cards/card-portfolio-intelligence.json +0 -0
  359. /package/examples/{example-board → board}/cards/card-portfolio-risks.json +0 -0
  360. /package/examples/{example-board → board}/cards/card-rebalance-impact.json +0 -0
  361. /package/examples/{example-board → board}/cards/card-rebalance-sim.json +0 -0
  362. /package/examples/{example-board/cards/card-portfolio-value.json → board/cards/cardT-portfolio-value.json} +0 -0
  363. /package/examples/{example-board → board}/demo-chat-handler.js +0 -0
  364. /package/examples/{example-board → board}/scripts/copilot_wrapper.bat +0 -0
  365. /package/examples/{example-board → board}/scripts/copilot_wrapper_helper.ps1 +0 -0
  366. /package/examples/{example-board → board}/scripts/workiq_wrapper.mjs +0 -0
  367. /package/examples/{browser/boards/portfolio-tracker → board/test}/portfolio-tracker-sse-worker.js +0 -0
  368. /package/{dist → lib}/batch/index.cjs +0 -0
  369. /package/{dist → lib}/batch/index.d.cts +0 -0
  370. /package/{dist → lib}/batch/index.d.ts +0 -0
  371. /package/{dist → lib}/batch/index.js +0 -0
  372. /package/{dist/cli/browser-api → lib/board-livegraph-runtime}/jsonata-sync.cjs +0 -0
  373. /package/{dist → lib}/card-compute/index.d.cts +0 -0
  374. /package/{dist → lib}/card-compute/index.d.ts +0 -0
  375. /package/{dist/cli/node → lib/card-compute}/jsonata-sync.cjs +0 -0
  376. /package/{dist → lib}/config/index.cjs +0 -0
  377. /package/{dist → lib}/config/index.d.cts +0 -0
  378. /package/{dist → lib}/config/index.d.ts +0 -0
  379. /package/{dist → lib}/config/index.js +0 -0
  380. /package/{dist → lib}/continuous-event-graph/jsonata-sync.cjs +0 -0
  381. /package/{dist → lib}/event-graph/index.cjs +0 -0
  382. /package/{dist → lib}/event-graph/index.js +0 -0
  383. /package/{dist → lib}/jsonata-sync.cjs +0 -0
  384. /package/{dist → lib}/server-runtime/jsonata-sync.cjs +0 -0
  385. /package/{dist → lib}/step-machine/index.cjs +0 -0
  386. /package/{dist → lib}/step-machine/index.js +0 -0
  387. /package/{dist → lib}/step-machine-public/jsonata-sync.cjs +0 -0
  388. /package/{dist → lib}/stores/memory.cjs +0 -0
  389. /package/{dist → lib}/stores/memory.js +0 -0
  390. /package/{dist → lib}/types-BBhqYGhE.d.cts +0 -0
  391. /package/{dist → lib}/types-BBhqYGhE.d.ts +0 -0
  392. /package/{dist → lib}/validate-BAVzUJWa.d.ts +0 -0
  393. /package/{dist → lib}/validate-Dbu7ygys.d.cts +0 -0
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';var l=require('fs'),d=require('path'),child_process=require('child_process');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var l__namespace=/*#__PURE__*/_interopNamespace(l);var d__namespace=/*#__PURE__*/_interopNamespace(d);function b(e){if(e.startsWith("::fs-path::"))return {kind:"fs-path",value:e.slice(11)};if(!e.startsWith("b64:"))throw new Error(`Invalid ref format (expected b64:<base64url(json)>): ${e}`);let n=e.slice(4),o=n.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-n.length%4)%4),t;try{t=JSON.parse(Buffer.from(o,"base64").toString("utf8"));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${e}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${e}`);let r=t;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${e}`);return {kind:r.kind,value:r.value}}function I(e){return `b64:${Buffer.from(JSON.stringify(e),"utf8").toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}`}function P(){return {read(e){if(!l__namespace.existsSync(e))return null;try{return l__namespace.readFileSync(e,"utf-8")}catch{return null}},write(e,n){l__namespace.mkdirSync(d__namespace.dirname(e),{recursive:true}),l__namespace.writeFileSync(e,n,"utf-8");}}}function x(e){if(e.kind==="fs-path")return P();throw new Error(`Unsupported storage kind: "${e.kind}". Supported kinds: fs-path`)}function y(e){try{return b(e).value}catch{return e}}function _(e){let n=e.extra?.notifyChannel;return typeof n=="string"&&n.length>0?n:void 0}function O(e){if(!e.endsWith(".ts"))return {cmd:process.execPath,args:[e]};let n=d__namespace.dirname(e),o=[];for(let r=1;r<=5;r++){let s=d__namespace.join(n,...Array(r).fill(".."),"node_modules");o.push(d__namespace.join(s,"tsx","dist","cli.mjs")),o.push(d__namespace.join(s,".bin","tsx"));}let t=o.find(r=>l__namespace.existsSync(r));return t?{cmd:process.execPath,args:[t,e]}:{cmd:"npx",args:["tsx",e]}}function F(e,n){let{token:o,via:t}=e;if(t.howToRun==="local-node"||t.howToRun==="local-process"){let r=y(t.whatToRun),{cmd:s,args:p}=O(r),u=_(t),f=[...p,"source-data-fetched","--ref",I(n),"--token",o,...u?["--notify-channel",u]:[]],i=child_process.spawnSync(s,f,{encoding:"utf-8",windowsHide:true});if(i.status!==0)throw new Error(`reportComplete: board CLI exited ${i.status}: ${i.stderr?.trim()}`);return}if(t.howToRun==="http:post"){let r=y(t.whatToRun),s=JSON.stringify({status:"complete",ref:I(n),token:o});q(r,s);return}throw new Error(`reportComplete: unsupported via.howToRun "${t.howToRun}"`)}function j(e,n){let{token:o,via:t}=e;if(t.howToRun==="local-node"||t.howToRun==="local-process"){let r=y(t.whatToRun),{cmd:s,args:p}=O(r),u=_(t),f=[...p,"source-data-fetch-failure","--token",o,"--reason",n,...u?["--notify-channel",u]:[]],i=child_process.spawnSync(s,f,{encoding:"utf-8",windowsHide:true});if(i.status!==0)throw new Error(`reportFailed: board CLI exited ${i.status}: ${i.stderr?.trim()}`);return}if(t.howToRun==="http:post"){let r=y(t.whatToRun),s=JSON.stringify({status:"failed",reason:n,token:o});q(r,s);return}throw new Error(`reportFailed: unsupported via.howToRun "${t.howToRun}"`)}function q(e,n){let o=`
3
- const {request} = require(new URL('${e}').protocol === 'https:' ? 'https' : 'http');
4
- const h = ${JSON.stringify({"Content-Type":"application/json","Content-Length":Buffer.byteLength(n)})};
5
- const u = new URL('${e}');
6
- const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});
7
- req.on('error', e => { process.stderr.write(e.message); process.exit(1); });
8
- req.write(${JSON.stringify(n)});
9
- req.end();
10
- `,t=child_process.spawnSync(process.execPath,["-e",o],{encoding:"utf-8",windowsHide:true});if(t.status!==0)throw new Error(`http-post failed: ${t.stderr?.trim()}`)}function W(e){let n=[],o="",t=false,r=false;for(let s of e){if(s==="'"&&!r){t=!t;continue}if(s==='"'&&!t){r=!r;continue}s===" "&&!t&&!r?o&&(n.push(o),o=""):o+=s;}return o&&n.push(o),n}function H(e){if(process.platform!=="win32"||d__namespace.isAbsolute(e)||e.includes("/")||e.includes("\\"))return e;let n=process.env.PATH??"";for(let o of n.split(d__namespace.delimiter))for(let t of [".cmd",".bat"]){let r=d__namespace.join(o,e+t);if(l__namespace.existsSync(r))return r}return e}function z(e){let n=e.indexOf("--in-ref"),o=e.indexOf("--out-ref"),t=e.indexOf("--err-ref"),r=n!==-1?e[n+1]:void 0,s=o!==-1?e[o+1]:void 0,p=t!==-1?e[t+1]:void 0;(!r||!s)&&(console.error("[source-cli-task-executor] Usage: run-source-fetch --in-ref <b64-ref> --out-ref <b64-ref> [--err-ref <b64-ref>]"),process.exit(1));let u,f,i;try{u=b(r),f=b(s),p&&(i=b(p));}catch(c){console.error(`[source-cli-task-executor] invalid ref: ${c.message}`),process.exit(1);}let D=x(u),A=x(f),T=i?x(i):void 0;function h(c,C){if(T&&i)try{T.write(i.value,c);}catch{}if(console.error(`[source-cli-task-executor] ${c}`),C)try{j(C,c);}catch{}process.exit(1);}let $=D.read(u.value);$===null&&h(`Input not found: ${r}`);let w;try{w=JSON.parse($);}catch(c){h(`Cannot parse input envelope: ${c.message}`);}let g=w.source_def!=null?w.callback:void 0,a=w.source_def??w;(!a.cli||typeof a.cli!="string")&&h("source_def missing required field: cli (source-cli-task-executor only handles source.cli)",g);let K=typeof a.timeout=="number"?a.timeout:12e4,k=typeof a.boardDir=="string"&&a.boardDir?a.boardDir:void 0,V=k??process.cwd(),N=typeof a.bindTo=="string"?a.bindTo:"unknown",R=W(a.cli);R.length===0&&h("source_def.cli is empty",g);let J=H(R[0]),L=R.slice(1);console.log(`[source-cli-task-executor] ${N}: ${a.cli}`);let E;try{E=child_process.execFileSync(J,L,{shell:!1,encoding:"utf-8",timeout:K,cwd:V,env:{...process.env,...k?{BOARD_DIR:k}:{}},maxBuffer:50*1024*1024});}catch(c){h(`cli execution failed: ${c.message}`,g);}try{A.write(f.value,E.trim());}catch(c){h(`Cannot write output: ${c.message}`,g);}if(g)try{F(g,f);}catch(c){console.error(`[source-cli-task-executor] reportComplete failed: ${c.message}`),process.exit(1);}}var Q={version:"1.0",executor:"source-cli-task-executor",subcommands:["run-source-fetch","describe-capabilities"],sourceKinds:{cli:{description:"Execute a shell command (source_def.cli) synchronously and capture stdout as the source data.",inputSchema:{cli:{type:"string",required:true,description:"Command string to execute. Quoted arguments are supported. Runs via execFileSync (no shell)."},timeout:{type:"number",required:false,description:"Execution timeout in milliseconds (default: 120000)."},cwd:{type:"string",required:false,description:"Working directory for the command (default: process.cwd())."},boardDir:{type:"string",required:false,description:"Injected as BOARD_DIR environment variable."}},outputShape:"string \u2014 trimmed stdout of the command."}}},S=process.argv[2];S==="run-source-fetch"?z(process.argv.slice(3)):S==="describe-capabilities"?console.log(JSON.stringify(Q,null,2)):(console.warn(`[source-cli-task-executor] Unknown subcommand: ${S??"(none)"}`),process.exit(1));//# sourceMappingURL=source-cli-task-executor.cjs.map
11
- //# sourceMappingURL=source-cli-task-executor.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/cli/node/public-storage-adapter.ts","../../../src/cli/node/source-cli-task-executor.ts"],"names":["parseRef","s","payload","padded","decoded","candidate","serializeRef","ref","createFsPathBlobStorage","key","l","content","d","blobStorageForRef","_parseWhatToRun","whatToRun","_notifyChannelFromVia","via","_resolveLocalNodeInvocation","scriptPath","dir","candidates","up","base","tsx","p","reportComplete","callback","outRef","token","cmd","args","notifyChannel","callbackArgs","result","spawnSync","url","body","_httpPostSync","reportFailed","reason","script","splitCommand","parts","current","inSingle","inDouble","ch","resolveExecutable","rawCmd","m","pathEnv","ext","B","runSourceFetch","argv","inIdx","outIdx","errIdx","inRefStr","outRefStr","errRefStr","inRef","errRef","e","inStorage","outStorage","errStorage","fail","msg","rawIn","envelope","sourceDef","timeout","boardDir","cwd","bindTo","cliArgs","stdout","execFileSync","err","CAPABILITIES","sub"],"mappings":";mfA+CO,SAASA,EAASC,CAAAA,CAAyB,CAEhD,GAAIA,CAAAA,CAAE,WAAW,aAAa,CAAA,CAC5B,OAAO,CAAE,KAAM,SAAA,CAAW,KAAA,CAAOA,CAAAA,CAAE,KAAA,CAAM,EAAoB,CAAE,CAAA,CAEjE,GAAI,CAACA,EAAE,UAAA,CAAW,MAAM,CAAA,CAAG,MAAM,IAAI,KAAA,CAAM,CAAA,qDAAA,EAAwDA,CAAC,CAAA,CAAE,EACtG,IAAMC,CAAAA,CAAUD,CAAAA,CAAE,KAAA,CAAM,CAAC,CAAA,CACnBE,CAAAA,CAASD,CAAAA,CAAQ,OAAA,CAAQ,KAAM,GAAG,CAAA,CAAE,OAAA,CAAQ,IAAA,CAAM,GAAG,CAAA,CAAI,GAAA,CAAI,MAAA,CAAA,CAAQ,CAAA,CAAKA,EAAQ,MAAA,CAAS,CAAA,EAAM,CAAC,CAAA,CACpGE,EACJ,GAAI,CACFA,CAAAA,CAAU,IAAA,CAAK,MAAM,MAAA,CAAO,IAAA,CAAKD,CAAAA,CAAQ,QAAQ,EAAE,QAAA,CAAS,MAAM,CAAC,EACrE,MAAQ,CACN,MAAM,IAAI,KAAA,CAAM,kDAAkDF,CAAC,CAAA,CAAE,CACvE,CACA,GAAI,CAACG,CAAAA,EAAW,OAAOA,CAAAA,EAAY,SACjC,MAAM,IAAI,KAAA,CAAM,CAAA,8CAAA,EAAiDH,CAAC,CAAA,CAAE,CAA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,CAAU,IAAA,CACV,WAAA,CAAa,8FACf,CAAA,CACA,OAAA,CAAS,CACP,IAAA,CAAM,SACN,QAAA,CAAU,KAAA,CACV,WAAA,CAAa,sDACf,EACA,GAAA,CAAK,CACH,IAAA,CAAM,QAAA,CACN,QAAA,CAAU,KAAA,CACV,WAAA,CAAa,6DACf,EACA,QAAA,CAAU,CACR,IAAA,CAAM,QAAA,CACN,SAAU,KAAA,CACV,WAAA,CAAa,6CACf,CACF,EACA,WAAA,CAAa,8CACf,CACF,CACF,CAAA,CAMMC,CAAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CACtBA,CAAAA,GAAQ,kBAAA,CACV5B,CAAAA,CAAe,QAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,EAC3B4B,CAAAA,GAAQ,uBAAA,CACjB,OAAA,CAAQ,GAAA,CAAI,KAAK,SAAA,CAAUD,CAAAA,CAAc,IAAA,CAAM,CAAC,CAAC,CAAA,EAEjD,OAAA,CAAQ,IAAA,CAAK,CAAA,+CAAA,EAAkDC,GAAO,QAAQ,CAAA,CAAE,CAAA,CAChF,OAAA,CAAQ,KAAK,CAAC,CAAA,CAAA","file":"source-cli-task-executor.cjs","sourcesContent":["/**\n * public-storage-adapter.ts\n *\n * Standalone file — copy this to your task-executor project.\n * Zero dependencies on the rest of yaml-flow.\n *\n * Provides:\n * - KindValueRef wire format: b64:<base64url(json)>\n * - parseRef() parse a b64:<base64url(json)> string\n * - serializeRef() produce a b64:<base64url(json)> string\n * - BlobStorage read/write interface\n * - blobStorageForRef resolve a ref to its BlobStorage backend\n * - ExecutionRef portable invocation descriptor (inlined, stays standalone)\n * - TaskCallback how to report task completion back to the board\n * - reportComplete() call from executor on success\n * - reportFailed() call from executor on failure\n *\n * Supported storage kinds:\n * fs-path — ref.value is an absolute file path; reads/writes via node:fs\n *\n * Supported callback transports (via ExecutionRef.howToRun):\n * local-node — invoke board CLI as a child Node process\n * http:post — HTTP POST to a board endpoint\n *\n * Usage:\n * import { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\n *\n * const { source_def, callback } = JSON.parse(blobStorageForRef(inRef).read(inRef.value));\n * // ... do work, write to outRef ...\n * reportComplete(callback, outRef);\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\n\n// ============================================================================\n// KindValueRef\n// ============================================================================\n\nexport interface KindValueRef {\n readonly kind: string;\n readonly value: string;\n}\n\n/** Parse a wire-format ref string (b64:<base64url(json)>) into a KindValueRef.\n * Also accepts the legacy ::fs-path::<path> format for backward compatibility. */\nexport function parseRef(s: string): KindValueRef {\n // Legacy format: ::fs-path::<path>\n if (s.startsWith('::fs-path::')) {\n return { kind: 'fs-path', value: s.slice('::fs-path::'.length) };\n }\n if (!s.startsWith('b64:')) throw new Error(`Invalid ref format (expected b64:<base64url(json)>): ${s}`);\n const payload = s.slice(4);\n const padded = payload.replace(/-/g, '+').replace(/_/g, '/') + '='.repeat((4 - (payload.length % 4)) % 4);\n let decoded: unknown;\n try {\n decoded = JSON.parse(Buffer.from(padded, 'base64').toString('utf8'));\n } catch {\n throw new Error(`Invalid ref format (malformed base64url/json): ${s}`);\n }\n if (!decoded || typeof decoded !== 'object') {\n throw new Error(`Invalid ref format (expected object payload): ${s}`);\n }\n const candidate = decoded as { kind?: unknown; value?: unknown };\n if (typeof candidate.kind !== 'string' || typeof candidate.value !== 'string') {\n throw new Error(`Invalid ref format (payload must contain string kind/value): ${s}`);\n }\n return { kind: candidate.kind, value: candidate.value };\n}\n\n/** Serialize a KindValueRef to the wire format: b64:<base64url(json)> */\nexport function serializeRef(ref: KindValueRef): string {\n return `b64:${Buffer.from(JSON.stringify(ref), 'utf8').toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/g, '')}`;\n}\n\n// ============================================================================\n// BlobStorage\n// ============================================================================\n\nexport interface BlobStorage {\n /** Returns content string, or null if not found. */\n read(key: string): string | null;\n /** Write content at key. */\n write(key: string, content: string): void;\n}\n\n// ============================================================================\n// fs-path backend — key IS the absolute file path\n// ============================================================================\n\nfunction createFsPathBlobStorage(): BlobStorage {\n return {\n read(key: string): string | null {\n if (!fs.existsSync(key)) return null;\n try { return fs.readFileSync(key, 'utf-8'); } catch { return null; }\n },\n write(key: string, content: string): void {\n fs.mkdirSync(path.dirname(key), { recursive: true });\n fs.writeFileSync(key, content, 'utf-8');\n },\n };\n}\n\n// ============================================================================\n// blobStorageForRef\n// ============================================================================\n\n/**\n * Resolve a KindValueRef to its BlobStorage backend.\n * Throws a clear error for unrecognised kinds.\n */\nexport function blobStorageForRef(ref: KindValueRef): BlobStorage {\n switch (ref.kind) {\n case 'fs-path': return createFsPathBlobStorage();\n default: throw new Error(`Unsupported storage kind: \"${ref.kind}\". Supported kinds: fs-path`);\n }\n}\n\n// ============================================================================\n// TaskCallback — how a task-executor reports results back to the board\n// ============================================================================\n\n/**\n * Portable invocation descriptor for the board CLI back-channel.\n * Inlined here so this file stays standalone (zero deps on yaml-flow internals).\n * Shape matches ExecutionRef in execution-interface.ts — keep in sync.\n *\n * Supported howToRun values for TaskCallback.via:\n * local-node — invoke board CLI as: node [tsx?] <whatToRun.value> <cmd> [...argv]\n * http:post — POST to <whatToRun.value> with a JSON body\n */\nexport interface ExecutionRef {\n /** Optional human-readable label. Not used for dispatch. */\n meta?: string;\n /** Transport / runtime kind. */\n howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';\n /** Address of the target in b64:<base64url(json)> wire form. */\n whatToRun: string;\n /** Opaque executor config stored with the ref. */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Describes how the board wants to receive task completion callbacks.\n * Baked into the inRef payload as { source_def, callback }.\n * The executor treats `token` as opaque and passes it back unchanged.\n */\nexport interface TaskCallback {\n /** Opaque routing token — generated by the board, passed back unchanged. */\n token: string;\n /** Delivery mechanism — an ExecutionRef pointing at the board CLI or endpoint. */\n via: ExecutionRef;\n}\n\n/**\n * Extract the path/url value from a whatToRun b64:<base64url(json)> wire string.\n * Falls back to the raw string if it isn’t in b64:<base64url(json)> form.\n */\nfunction _parseWhatToRun(whatToRun: string): string {\n try { return parseRef(whatToRun).value; } catch { return whatToRun; }\n}\n\nfunction _notifyChannelFromVia(via: ExecutionRef): string | undefined {\n const candidate = via.extra?.['notifyChannel'];\n return typeof candidate === 'string' && candidate.length > 0 ? candidate : undefined;\n}\n\n/**\n * Resolve the Node invocation for a local board CLI script.\n * If the path ends in .ts (dev mode), attempts to locate tsx alongside it;\n * otherwise assumes it’s a compiled .js and invokes directly with node.\n */\nfunction _resolveLocalNodeInvocation(scriptPath: string): { cmd: string; args: string[] } {\n if (!scriptPath.endsWith('.ts')) {\n return { cmd: process.execPath, args: [scriptPath] };\n }\n // Dev path: look for tsx in node_modules relative to the script's package root.\n // The .ts file may be at src/cli/node/<file>.ts — walk up until we find node_modules/tsx.\n const dir = path.dirname(scriptPath);\n const candidates: string[] = [];\n for (let up = 1; up <= 5; up++) {\n const base = path.join(dir, ...Array(up).fill('..'), 'node_modules');\n candidates.push(path.join(base, 'tsx', 'dist', 'cli.mjs'));\n candidates.push(path.join(base, '.bin', 'tsx'));\n }\n const tsx = candidates.find(p => fs.existsSync(p));\n if (tsx) return { cmd: process.execPath, args: [tsx, scriptPath] };\n return { cmd: 'npx', args: ['tsx', scriptPath] };\n}\n\n/**\n * Report successful task completion back to the board.\n * Call this from a task-executor after writing the result to outRef.\n */\nexport function reportComplete(callback: TaskCallback, outRef: KindValueRef): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetched',\n '--ref', serializeRef(outRef),\n '--token', token,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportComplete: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'complete', ref: serializeRef(outRef), token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportComplete: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/**\n * Report task failure back to the board.\n * Call this from a task-executor instead of writing to outRef.\n */\nexport function reportFailed(callback: TaskCallback, reason: string): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetch-failure',\n '--token', token,\n '--reason', reason,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportFailed: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'failed', reason, token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportFailed: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/** Synchronous HTTP POST using a child node process (keeps this file free of async). */\nfunction _httpPostSync(url: string, body: string): void {\n const script = `\n const {request} = require(new URL('${url}').protocol === 'https:' ? 'https' : 'http');\n const h = ${JSON.stringify({ 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) })};\n const u = new URL('${url}');\n const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});\n req.on('error', e => { process.stderr.write(e.message); process.exit(1); });\n req.write(${JSON.stringify(body)});\n req.end();\n `;\n const result = spawnSync(process.execPath, ['-e', script], { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) throw new Error(`http-post failed: ${result.stderr?.trim()}`);\n}\n","#!/usr/bin/env node\n/**\n * source-cli-task-executor.ts — Built-in task executor for `source.cli` sources.\n *\n * Implements the standard task-executor protocol so the board CLI always dispatches\n * source fetches through the same per-source path, whether or not a custom\n * .task-executor is configured.\n *\n * Subcommands:\n * run-source-fetch --in-ref <b64-ref> --out-ref <b64-ref> [--err-ref <b64-ref>]\n * describe-capabilities\n *\n * Supported source kind:\n * cli — executes source_def.cli synchronously and writes stdout to --out-ref.\n *\n * In-ref envelope (written by board CLI dispatcher):\n * { source_def: { cli, cwd?, boardDir?, timeout?, ... }, callback: { token, via } }\n *\n * The executor writes the trimmed stdout to --out-ref, then calls reportComplete()\n * which invokes `board-live-cards source-data-fetched` back-channel via the board CLI.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { execFileSync } from 'node:child_process';\nimport { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\nimport type { KindValueRef, TaskCallback } from './public-storage-adapter.js';\n\n// ============================================================================\n// Command splitting — minimal implementation for source.cli strings.\n// Handles single- and double-quoted segments. No glob/brace expansion.\n// ============================================================================\n\nfunction splitCommand(cmd: string): string[] {\n const parts: string[] = [];\n let current = '';\n let inSingle = false;\n let inDouble = false;\n for (const ch of cmd) {\n if (ch === \"'\" && !inDouble) { inSingle = !inSingle; continue; }\n if (ch === '\"' && !inSingle) { inDouble = !inDouble; continue; }\n if (ch === ' ' && !inSingle && !inDouble) {\n if (current) { parts.push(current); current = ''; }\n } else {\n current += ch;\n }\n }\n if (current) parts.push(current);\n return parts;\n}\n\n/**\n * On Windows, execFileSync cannot find npm .cmd shims by bare name.\n * Check PATH for <name>.cmd / <name>.bat and return the resolved path.\n * Falls back to the original name (works for node.exe, python.exe, etc.).\n */\nfunction resolveExecutable(rawCmd: string): string {\n if (process.platform !== 'win32') return rawCmd;\n if (path.isAbsolute(rawCmd) || rawCmd.includes('/') || rawCmd.includes('\\\\')) return rawCmd;\n const pathEnv = process.env.PATH ?? '';\n for (const dir of pathEnv.split(path.delimiter)) {\n for (const ext of ['.cmd', '.bat']) {\n const candidate = path.join(dir, rawCmd + ext);\n if (fs.existsSync(candidate)) return candidate;\n }\n }\n return rawCmd;\n}\n\n// ============================================================================\n// run-source-fetch\n// ============================================================================\n\nfunction runSourceFetch(argv: string[]): void {\n const inIdx = argv.indexOf('--in-ref');\n const outIdx = argv.indexOf('--out-ref');\n const errIdx = argv.indexOf('--err-ref');\n const inRefStr = inIdx !== -1 ? argv[inIdx + 1] : undefined;\n const outRefStr = outIdx !== -1 ? argv[outIdx + 1] : undefined;\n const errRefStr = errIdx !== -1 ? argv[errIdx + 1] : undefined;\n\n if (!inRefStr || !outRefStr) {\n console.error('[source-cli-task-executor] Usage: run-source-fetch --in-ref <b64-ref> --out-ref <b64-ref> [--err-ref <b64-ref>]');\n process.exit(1);\n }\n\n let inRef: KindValueRef;\n let outRef: KindValueRef;\n let errRef: KindValueRef | undefined;\n try {\n inRef = parseRef(inRefStr);\n outRef = parseRef(outRefStr);\n if (errRefStr) errRef = parseRef(errRefStr);\n } catch (e) {\n console.error(`[source-cli-task-executor] invalid ref: ${(e as Error).message}`);\n process.exit(1);\n }\n\n const inStorage = blobStorageForRef(inRef!);\n const outStorage = blobStorageForRef(outRef!);\n const errStorage = errRef ? blobStorageForRef(errRef) : undefined;\n\n function fail(msg: string, callback?: TaskCallback): never {\n if (errStorage && errRef) { try { errStorage.write(errRef.value, msg); } catch { /* best-effort */ } }\n console.error(`[source-cli-task-executor] ${msg}`);\n if (callback) { try { reportFailed(callback, msg); } catch { /* best-effort */ } }\n process.exit(1);\n }\n\n const rawIn = inStorage.read(inRef!.value);\n if (rawIn === null) fail(`Input not found: ${inRefStr}`);\n\n let envelope: { source_def?: Record<string, unknown>; callback?: TaskCallback };\n try {\n envelope = JSON.parse(rawIn!) as typeof envelope;\n } catch (e) {\n fail(`Cannot parse input envelope: ${(e as Error).message}`);\n }\n\n // Support both new { source_def, callback } envelope and legacy raw source_def.\n const callback = envelope!.source_def != null ? envelope!.callback : undefined;\n const sourceDef = (envelope!.source_def ?? envelope!) as Record<string, unknown>;\n\n if (!sourceDef.cli || typeof sourceDef.cli !== 'string') {\n fail('source_def missing required field: cli (source-cli-task-executor only handles source.cli)', callback);\n }\n\n const timeout = typeof sourceDef.timeout === 'number' ? sourceDef.timeout : 120_000;\n const boardDir = typeof sourceDef.boardDir === 'string' && sourceDef.boardDir ? sourceDef.boardDir : undefined;\n const cwd = boardDir ?? process.cwd();\n const bindTo = typeof sourceDef.bindTo === 'string' ? sourceDef.bindTo : 'unknown';\n\n const parts = splitCommand(sourceDef.cli);\n if (parts.length === 0) fail('source_def.cli is empty', callback);\n\n const cmd = resolveExecutable(parts[0]);\n const cliArgs = parts.slice(1);\n\n console.log(`[source-cli-task-executor] ${bindTo}: ${sourceDef.cli}`);\n\n let stdout: string;\n try {\n stdout = execFileSync(cmd, cliArgs, {\n shell: false,\n encoding: 'utf-8',\n timeout,\n cwd,\n env: { ...process.env, ...(boardDir ? { BOARD_DIR: boardDir } : {}) },\n maxBuffer: 50 * 1024 * 1024,\n }) as string;\n } catch (err) {\n fail(`cli execution failed: ${(err as Error).message}`, callback);\n }\n\n try {\n outStorage.write(outRef!.value, stdout!.trim());\n } catch (err) {\n fail(`Cannot write output: ${(err as Error).message}`, callback);\n }\n\n if (callback) {\n try {\n reportComplete(callback, outRef!);\n } catch (err) {\n console.error(`[source-cli-task-executor] reportComplete failed: ${(err as Error).message}`);\n process.exit(1);\n }\n }\n}\n\n// ============================================================================\n// describe-capabilities\n// ============================================================================\n\nconst CAPABILITIES = {\n version: '1.0',\n executor: 'source-cli-task-executor',\n subcommands: ['run-source-fetch', 'describe-capabilities'],\n sourceKinds: {\n cli: {\n description: 'Execute a shell command (source_def.cli) synchronously and capture stdout as the source data.',\n inputSchema: {\n cli: {\n type: 'string',\n required: true,\n description: 'Command string to execute. Quoted arguments are supported. Runs via execFileSync (no shell).',\n },\n timeout: {\n type: 'number',\n required: false,\n description: 'Execution timeout in milliseconds (default: 120000).',\n },\n cwd: {\n type: 'string',\n required: false,\n description: 'Working directory for the command (default: process.cwd()).',\n },\n boardDir: {\n type: 'string',\n required: false,\n description: 'Injected as BOARD_DIR environment variable.',\n },\n },\n outputShape: 'string — trimmed stdout of the command.',\n },\n },\n};\n\n// ============================================================================\n// Entry point\n// ============================================================================\n\nconst sub = process.argv[2];\nif (sub === 'run-source-fetch') {\n runSourceFetch(process.argv.slice(3));\n} else if (sub === 'describe-capabilities') {\n console.log(JSON.stringify(CAPABILITIES, null, 2));\n} else {\n console.warn(`[source-cli-task-executor] Unknown subcommand: ${sub ?? '(none)'}`);\n process.exit(1);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/cli/node/public-storage-adapter.ts","../../../src/cli/node/source-cli-task-executor.ts"],"names":["parseRef","s","payload","padded","decoded","candidate","serializeRef","ref","createFsPathBlobStorage","key","content","blobStorageForRef","_parseWhatToRun","whatToRun","_notifyChannelFromVia","via","_resolveLocalNodeInvocation","scriptPath","dir","candidates","up","base","tsx","p","reportComplete","callback","outRef","token","cmd","args","notifyChannel","callbackArgs","result","spawnSync","url","body","_httpPostSync","reportFailed","reason","script","splitCommand","parts","current","inSingle","inDouble","ch","resolveExecutable","rawCmd","m","pathEnv","ext","B","runSourceFetch","argv","inIdx","outIdx","errIdx","inRefStr","outRefStr","errRefStr","inRef","errRef","e","inStorage","outStorage","errStorage","fail","msg","rawIn","envelope","sourceDef","timeout","boardDir","cwd","bindTo","cliArgs","stdout","execFileSync","err","CAPABILITIES","sub"],"mappings":";+FA+CO,SAASA,EAASC,CAAAA,CAAyB,CAEhD,GAAIA,CAAAA,CAAE,WAAW,aAAa,CAAA,CAC5B,OAAO,CAAE,KAAM,SAAA,CAAW,KAAA,CAAOA,CAAAA,CAAE,KAAA,CAAM,EAAoB,C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,CAAQ,GAAA,CAAI,KAAK,SAAA,CAAUD,CAAAA,CAAc,IAAA,CAAM,CAAC,CAAC,CAAA,EAEjD,OAAA,CAAQ,IAAA,CAAK,CAAA,+CAAA,EAAkDC,GAAO,QAAQ,CAAA,CAAE,CAAA,CAChF,OAAA,CAAQ,KAAK,CAAC,CAAA,CAAA","file":"source-cli-task-executor.js","sourcesContent":["/**\n * public-storage-adapter.ts\n *\n * Standalone file — copy this to your task-executor project.\n * Zero dependencies on the rest of yaml-flow.\n *\n * Provides:\n * - KindValueRef wire format: b64:<base64url(json)>\n * - parseRef() parse a b64:<base64url(json)> string\n * - serializeRef() produce a b64:<base64url(json)> string\n * - BlobStorage read/write interface\n * - blobStorageForRef resolve a ref to its BlobStorage backend\n * - ExecutionRef portable invocation descriptor (inlined, stays standalone)\n * - TaskCallback how to report task completion back to the board\n * - reportComplete() call from executor on success\n * - reportFailed() call from executor on failure\n *\n * Supported storage kinds:\n * fs-path — ref.value is an absolute file path; reads/writes via node:fs\n *\n * Supported callback transports (via ExecutionRef.howToRun):\n * local-node — invoke board CLI as a child Node process\n * http:post — HTTP POST to a board endpoint\n *\n * Usage:\n * import { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\n *\n * const { source_def, callback } = JSON.parse(blobStorageForRef(inRef).read(inRef.value));\n * // ... do work, write to outRef ...\n * reportComplete(callback, outRef);\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\n\n// ============================================================================\n// KindValueRef\n// ============================================================================\n\nexport interface KindValueRef {\n readonly kind: string;\n readonly value: string;\n}\n\n/** Parse a wire-format ref string (b64:<base64url(json)>) into a KindValueRef.\n * Also accepts the legacy ::fs-path::<path> format for backward compatibility. */\nexport function parseRef(s: string): KindValueRef {\n // Legacy format: ::fs-path::<path>\n if (s.startsWith('::fs-path::')) {\n return { kind: 'fs-path', value: s.slice('::fs-path::'.length) };\n }\n if (!s.startsWith('b64:')) throw new Error(`Invalid ref format (expected b64:<base64url(json)>): ${s}`);\n const payload = s.slice(4);\n const padded = payload.replace(/-/g, '+').replace(/_/g, '/') + '='.repeat((4 - (payload.length % 4)) % 4);\n let decoded: unknown;\n try {\n decoded = JSON.parse(Buffer.from(padded, 'base64').toString('utf8'));\n } catch {\n throw new Error(`Invalid ref format (malformed base64url/json): ${s}`);\n }\n if (!decoded || typeof decoded !== 'object') {\n throw new Error(`Invalid ref format (expected object payload): ${s}`);\n }\n const candidate = decoded as { kind?: unknown; value?: unknown };\n if (typeof candidate.kind !== 'string' || typeof candidate.value !== 'string') {\n throw new Error(`Invalid ref format (payload must contain string kind/value): ${s}`);\n }\n return { kind: candidate.kind, value: candidate.value };\n}\n\n/** Serialize a KindValueRef to the wire format: b64:<base64url(json)> */\nexport function serializeRef(ref: KindValueRef): string {\n return `b64:${Buffer.from(JSON.stringify(ref), 'utf8').toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/g, '')}`;\n}\n\n// ============================================================================\n// BlobStorage\n// ============================================================================\n\nexport interface BlobStorage {\n /** Returns content string, or null if not found. */\n read(key: string): string | null;\n /** Write content at key. */\n write(key: string, content: string): void;\n}\n\n// ============================================================================\n// fs-path backend — key IS the absolute file path\n// ============================================================================\n\nfunction createFsPathBlobStorage(): BlobStorage {\n return {\n read(key: string): string | null {\n if (!fs.existsSync(key)) return null;\n try { return fs.readFileSync(key, 'utf-8'); } catch { return null; }\n },\n write(key: string, content: string): void {\n fs.mkdirSync(path.dirname(key), { recursive: true });\n fs.writeFileSync(key, content, 'utf-8');\n },\n };\n}\n\n// ============================================================================\n// blobStorageForRef\n// ============================================================================\n\n/**\n * Resolve a KindValueRef to its BlobStorage backend.\n * Throws a clear error for unrecognised kinds.\n */\nexport function blobStorageForRef(ref: KindValueRef): BlobStorage {\n switch (ref.kind) {\n case 'fs-path': return createFsPathBlobStorage();\n default: throw new Error(`Unsupported storage kind: \"${ref.kind}\". Supported kinds: fs-path`);\n }\n}\n\n// ============================================================================\n// TaskCallback — how a task-executor reports results back to the board\n// ============================================================================\n\n/**\n * Portable invocation descriptor for the board CLI back-channel.\n * Inlined here so this file stays standalone (zero deps on yaml-flow internals).\n * Shape matches ExecutionRef in execution-interface.ts — keep in sync.\n *\n * Supported howToRun values for TaskCallback.via:\n * local-node — invoke board CLI as: node [tsx?] <whatToRun.value> <cmd> [...argv]\n * http:post — POST to <whatToRun.value> with a JSON body\n */\nexport interface ExecutionRef {\n /** Optional human-readable label. Not used for dispatch. */\n meta?: string;\n /** Transport / runtime kind. */\n howToRun: 'local-node' | 'local-python' | 'local-process' | 'http:post' | 'http:get' | 'built-in';\n /** Address of the target in b64:<base64url(json)> wire form. */\n whatToRun: string;\n /** Opaque executor config stored with the ref. */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Describes how the board wants to receive task completion callbacks.\n * Baked into the inRef payload as { source_def, callback }.\n * The executor treats `token` as opaque and passes it back unchanged.\n */\nexport interface TaskCallback {\n /** Opaque routing token — generated by the board, passed back unchanged. */\n token: string;\n /** Delivery mechanism — an ExecutionRef pointing at the board CLI or endpoint. */\n via: ExecutionRef;\n}\n\n/**\n * Extract the path/url value from a whatToRun b64:<base64url(json)> wire string.\n * Falls back to the raw string if it isn’t in b64:<base64url(json)> form.\n */\nfunction _parseWhatToRun(whatToRun: string): string {\n try { return parseRef(whatToRun).value; } catch { return whatToRun; }\n}\n\nfunction _notifyChannelFromVia(via: ExecutionRef): string | undefined {\n const candidate = via.extra?.['notifyChannel'];\n return typeof candidate === 'string' && candidate.length > 0 ? candidate : undefined;\n}\n\n/**\n * Resolve the Node invocation for a local board CLI script.\n * If the path ends in .ts (dev mode), attempts to locate tsx alongside it;\n * otherwise assumes it’s a compiled .js and invokes directly with node.\n */\nfunction _resolveLocalNodeInvocation(scriptPath: string): { cmd: string; args: string[] } {\n if (!scriptPath.endsWith('.ts')) {\n return { cmd: process.execPath, args: [scriptPath] };\n }\n // Dev path: look for tsx in node_modules relative to the script's package root.\n // The .ts file may be at src/cli/node/<file>.ts — walk up until we find node_modules/tsx.\n const dir = path.dirname(scriptPath);\n const candidates: string[] = [];\n for (let up = 1; up <= 5; up++) {\n const base = path.join(dir, ...Array(up).fill('..'), 'node_modules');\n candidates.push(path.join(base, 'tsx', 'dist', 'cli.mjs'));\n candidates.push(path.join(base, '.bin', 'tsx'));\n }\n const tsx = candidates.find(p => fs.existsSync(p));\n if (tsx) return { cmd: process.execPath, args: [tsx, scriptPath] };\n return { cmd: 'npx', args: ['tsx', scriptPath] };\n}\n\n/**\n * Report successful task completion back to the board.\n * Call this from a task-executor after writing the result to outRef.\n */\nexport function reportComplete(callback: TaskCallback, outRef: KindValueRef): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetched',\n '--ref', serializeRef(outRef),\n '--token', token,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportComplete: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'complete', ref: serializeRef(outRef), token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportComplete: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/**\n * Report task failure back to the board.\n * Call this from a task-executor instead of writing to outRef.\n */\nexport function reportFailed(callback: TaskCallback, reason: string): void {\n const { token, via } = callback;\n if (via.howToRun === 'local-node' || via.howToRun === 'local-process') {\n const scriptPath = _parseWhatToRun(via.whatToRun);\n const { cmd, args } = _resolveLocalNodeInvocation(scriptPath);\n const notifyChannel = _notifyChannelFromVia(via);\n const callbackArgs = [\n ...args,\n 'source-data-fetch-failure',\n '--token', token,\n '--reason', reason,\n ...(notifyChannel ? ['--notify-channel', notifyChannel] : []),\n ];\n const result = spawnSync(cmd, callbackArgs, { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) {\n throw new Error(`reportFailed: board CLI exited ${result.status}: ${result.stderr?.trim()}`);\n }\n return;\n }\n if (via.howToRun === 'http:post') {\n const url = _parseWhatToRun(via.whatToRun);\n const body = JSON.stringify({ status: 'failed', reason, token });\n _httpPostSync(url, body);\n return;\n }\n throw new Error(`reportFailed: unsupported via.howToRun \"${via.howToRun}\"`);\n}\n\n/** Synchronous HTTP POST using a child node process (keeps this file free of async). */\nfunction _httpPostSync(url: string, body: string): void {\n const script = `\n const {request} = require(new URL('${url}').protocol === 'https:' ? 'https' : 'http');\n const h = ${JSON.stringify({ 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) })};\n const u = new URL('${url}');\n const req = request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:'POST',headers:h});\n req.on('error', e => { process.stderr.write(e.message); process.exit(1); });\n req.write(${JSON.stringify(body)});\n req.end();\n `;\n const result = spawnSync(process.execPath, ['-e', script], { encoding: 'utf-8', windowsHide: true });\n if (result.status !== 0) throw new Error(`http-post failed: ${result.stderr?.trim()}`);\n}\n","#!/usr/bin/env node\n/**\n * source-cli-task-executor.ts — Built-in task executor for `source.cli` sources.\n *\n * Implements the standard task-executor protocol so the board CLI always dispatches\n * source fetches through the same per-source path, whether or not a custom\n * .task-executor is configured.\n *\n * Subcommands:\n * run-source-fetch --in-ref <b64-ref> --out-ref <b64-ref> [--err-ref <b64-ref>]\n * describe-capabilities\n *\n * Supported source kind:\n * cli — executes source_def.cli synchronously and writes stdout to --out-ref.\n *\n * In-ref envelope (written by board CLI dispatcher):\n * { source_def: { cli, cwd?, boardDir?, timeout?, ... }, callback: { token, via } }\n *\n * The executor writes the trimmed stdout to --out-ref, then calls reportComplete()\n * which invokes `board-live-cards source-data-fetched` back-channel via the board CLI.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { execFileSync } from 'node:child_process';\nimport { parseRef, blobStorageForRef, reportComplete, reportFailed } from './public-storage-adapter.js';\nimport type { KindValueRef, TaskCallback } from './public-storage-adapter.js';\n\n// ============================================================================\n// Command splitting — minimal implementation for source.cli strings.\n// Handles single- and double-quoted segments. No glob/brace expansion.\n// ============================================================================\n\nfunction splitCommand(cmd: string): string[] {\n const parts: string[] = [];\n let current = '';\n let inSingle = false;\n let inDouble = false;\n for (const ch of cmd) {\n if (ch === \"'\" && !inDouble) { inSingle = !inSingle; continue; }\n if (ch === '\"' && !inSingle) { inDouble = !inDouble; continue; }\n if (ch === ' ' && !inSingle && !inDouble) {\n if (current) { parts.push(current); current = ''; }\n } else {\n current += ch;\n }\n }\n if (current) parts.push(current);\n return parts;\n}\n\n/**\n * On Windows, execFileSync cannot find npm .cmd shims by bare name.\n * Check PATH for <name>.cmd / <name>.bat and return the resolved path.\n * Falls back to the original name (works for node.exe, python.exe, etc.).\n */\nfunction resolveExecutable(rawCmd: string): string {\n if (process.platform !== 'win32') return rawCmd;\n if (path.isAbsolute(rawCmd) || rawCmd.includes('/') || rawCmd.includes('\\\\')) return rawCmd;\n const pathEnv = process.env.PATH ?? '';\n for (const dir of pathEnv.split(path.delimiter)) {\n for (const ext of ['.cmd', '.bat']) {\n const candidate = path.join(dir, rawCmd + ext);\n if (fs.existsSync(candidate)) return candidate;\n }\n }\n return rawCmd;\n}\n\n// ============================================================================\n// run-source-fetch\n// ============================================================================\n\nfunction runSourceFetch(argv: string[]): void {\n const inIdx = argv.indexOf('--in-ref');\n const outIdx = argv.indexOf('--out-ref');\n const errIdx = argv.indexOf('--err-ref');\n const inRefStr = inIdx !== -1 ? argv[inIdx + 1] : undefined;\n const outRefStr = outIdx !== -1 ? argv[outIdx + 1] : undefined;\n const errRefStr = errIdx !== -1 ? argv[errIdx + 1] : undefined;\n\n if (!inRefStr || !outRefStr) {\n console.error('[source-cli-task-executor] Usage: run-source-fetch --in-ref <b64-ref> --out-ref <b64-ref> [--err-ref <b64-ref>]');\n process.exit(1);\n }\n\n let inRef: KindValueRef;\n let outRef: KindValueRef;\n let errRef: KindValueRef | undefined;\n try {\n inRef = parseRef(inRefStr);\n outRef = parseRef(outRefStr);\n if (errRefStr) errRef = parseRef(errRefStr);\n } catch (e) {\n console.error(`[source-cli-task-executor] invalid ref: ${(e as Error).message}`);\n process.exit(1);\n }\n\n const inStorage = blobStorageForRef(inRef!);\n const outStorage = blobStorageForRef(outRef!);\n const errStorage = errRef ? blobStorageForRef(errRef) : undefined;\n\n function fail(msg: string, callback?: TaskCallback): never {\n if (errStorage && errRef) { try { errStorage.write(errRef.value, msg); } catch { /* best-effort */ } }\n console.error(`[source-cli-task-executor] ${msg}`);\n if (callback) { try { reportFailed(callback, msg); } catch { /* best-effort */ } }\n process.exit(1);\n }\n\n const rawIn = inStorage.read(inRef!.value);\n if (rawIn === null) fail(`Input not found: ${inRefStr}`);\n\n let envelope: { source_def?: Record<string, unknown>; callback?: TaskCallback };\n try {\n envelope = JSON.parse(rawIn!) as typeof envelope;\n } catch (e) {\n fail(`Cannot parse input envelope: ${(e as Error).message}`);\n }\n\n // Support both new { source_def, callback } envelope and legacy raw source_def.\n const callback = envelope!.source_def != null ? envelope!.callback : undefined;\n const sourceDef = (envelope!.source_def ?? envelope!) as Record<string, unknown>;\n\n if (!sourceDef.cli || typeof sourceDef.cli !== 'string') {\n fail('source_def missing required field: cli (source-cli-task-executor only handles source.cli)', callback);\n }\n\n const timeout = typeof sourceDef.timeout === 'number' ? sourceDef.timeout : 120_000;\n const boardDir = typeof sourceDef.boardDir === 'string' && sourceDef.boardDir ? sourceDef.boardDir : undefined;\n const cwd = boardDir ?? process.cwd();\n const bindTo = typeof sourceDef.bindTo === 'string' ? sourceDef.bindTo : 'unknown';\n\n const parts = splitCommand(sourceDef.cli);\n if (parts.length === 0) fail('source_def.cli is empty', callback);\n\n const cmd = resolveExecutable(parts[0]);\n const cliArgs = parts.slice(1);\n\n console.log(`[source-cli-task-executor] ${bindTo}: ${sourceDef.cli}`);\n\n let stdout: string;\n try {\n stdout = execFileSync(cmd, cliArgs, {\n shell: false,\n encoding: 'utf-8',\n timeout,\n cwd,\n env: { ...process.env, ...(boardDir ? { BOARD_DIR: boardDir } : {}) },\n maxBuffer: 50 * 1024 * 1024,\n }) as string;\n } catch (err) {\n fail(`cli execution failed: ${(err as Error).message}`, callback);\n }\n\n try {\n outStorage.write(outRef!.value, stdout!.trim());\n } catch (err) {\n fail(`Cannot write output: ${(err as Error).message}`, callback);\n }\n\n if (callback) {\n try {\n reportComplete(callback, outRef!);\n } catch (err) {\n console.error(`[source-cli-task-executor] reportComplete failed: ${(err as Error).message}`);\n process.exit(1);\n }\n }\n}\n\n// ============================================================================\n// describe-capabilities\n// ============================================================================\n\nconst CAPABILITIES = {\n version: '1.0',\n executor: 'source-cli-task-executor',\n subcommands: ['run-source-fetch', 'describe-capabilities'],\n sourceKinds: {\n cli: {\n description: 'Execute a shell command (source_def.cli) synchronously and capture stdout as the source data.',\n inputSchema: {\n cli: {\n type: 'string',\n required: true,\n description: 'Command string to execute. Quoted arguments are supported. Runs via execFileSync (no shell).',\n },\n timeout: {\n type: 'number',\n required: false,\n description: 'Execution timeout in milliseconds (default: 120000).',\n },\n cwd: {\n type: 'string',\n required: false,\n description: 'Working directory for the command (default: process.cwd()).',\n },\n boardDir: {\n type: 'string',\n required: false,\n description: 'Injected as BOARD_DIR environment variable.',\n },\n },\n outputShape: 'string — trimmed stdout of the command.',\n },\n },\n};\n\n// ============================================================================\n// Entry point\n// ============================================================================\n\nconst sub = process.argv[2];\nif (sub === 'run-source-fetch') {\n runSourceFetch(process.argv.slice(3));\n} else if (sub === 'describe-capabilities') {\n console.log(JSON.stringify(CAPABILITIES, null, 2));\n} else {\n console.warn(`[source-cli-task-executor] Unknown subcommand: ${sub ?? '(none)'}`);\n process.exit(1);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/config/resolve-variables.ts","../../src/config/resolve-config-templates.ts"],"names":["interpolateString","template","vars","match","key","value","walkAndInterpolate","item","result","k","v","resolveVariables","config","variables","mergeConfigs","taskConfig","merged","resolveConfigTemplates","templates","tasksKey","tasks","resolvedTasks","name","task","templateName","_","rest"],"mappings":"aAuBA,SAASA,CAAAA,CAAkBC,CAAAA,CAAkBC,CAAAA,CAAyB,CACpE,OAAOD,CAAAA,CAAS,OAAA,CAAQ,gBAAA,CAAkB,CAACE,CAAAA,CAAOC,CAAAA,GAAgB,CAChE,IAAMC,EAAQH,CAAAA,CAAKE,CAAAA,CAAI,IAAA,EAAM,CAAA,CAC7B,OAAOC,CAAAA,GAAU,MAAA,CAAY,OAAOA,CAAK,CAAA,CAAIF,CAC/C,CAAC,CACH,CAMA,SAASG,CAAAA,CAAsBD,CAAAA,CAAUH,EAAoB,CAC3D,GAAI,OAAOG,CAAAA,EAAU,QAAA,CACnB,OAAOL,CAAAA,CAAkBK,CAAAA,CAAOH,CAAI,CAAA,CAEtC,GAAI,KAAA,CAAM,OAAA,CAAQG,CAAK,CAAA,CACrB,OAAOA,CAAAA,CAAM,GAAA,CAAKE,GAASD,CAAAA,CAAmBC,CAAAA,CAAML,CAAI,CAAC,CAAA,CAE3D,GAAIG,CAAAA,GAAU,IAAA,EAAQ,OAAOA,CAAAA,EAAU,QAAA,CAAU,CAC/C,IAAMG,EAAkC,EAAC,CACzC,IAAA,GAAW,CAACC,EAAGC,CAAC,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQL,CAAK,CAAA,CACvCG,CAAAA,CAAOC,CAAC,EAAIH,CAAAA,CAAmBI,CAAAA,CAAGR,CAAI,CAAA,CAExC,OAAOM,CACT,CAEA,OAAOH,CACT,CAYO,SAASM,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACG,CACH,OAAOP,CAAAA,CAAmBM,CAAAA,CAAQC,CAAS,CAC7C,CChCA,SAASC,CAAAA,CACPb,EACAc,CA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,GAAI,CAACS,GAAgB,CAACT,CAAAA,CAAY,CAChCM,CAAAA,CAAcC,CAAI,CAAA,CAAIC,CAAAA,CACtB,QACF,CAEA,IAAMtB,CAAAA,CAAWiB,CAAAA,CAAUM,CAAY,CAAA,CACvC,GAAI,CAACvB,CAAAA,CAAU,CAEb,GAAM,CAAE,iBAAA,CAAmBwB,CAAAA,CAAG,GAAGC,CAAK,CAAA,CAAIX,CAAAA,CAC1CM,CAAAA,CAAcC,CAAI,EAAI,CAAE,GAAGC,CAAAA,CAAM,MAAA,CAAQG,CAAK,CAAA,CAC9C,QACF,CAEAL,EAAcC,CAAI,CAAA,CAAI,CACpB,GAAGC,EACH,MAAA,CAAQT,CAAAA,CAAab,CAAAA,CAAUc,CAAU,CAC3C,EACF,CAGA,IAAMP,CAAAA,CAAS,CAAE,GAAGI,CAAAA,CAAQ,CAACO,CAAQ,EAAGE,CAAc,CAAA,CACtD,OAAA,OAAOb,EAAO,eAAA,CACd,OAAOA,CAAAA,CAAO,kBAAkB,EACzBA,CACT","file":"index.cjs","sourcesContent":["/**\n * Variable interpolation for workflow configs.\n *\n * Walks any object/array and replaces `${KEY}` patterns with values from\n * a variables map. Pure function — returns a new object, never mutates.\n *\n * Works on both GraphConfig and StepFlowConfig (or any plain object).\n *\n * @example\n * ```ts\n * const resolved = resolveVariables(config, {\n * ENTITY_ID: 'ticket-42',\n * TOOLS_DIR: '/opt/tools',\n * });\n * ```\n */\n\nexport type Variables = Record<string, string | number | boolean>;\n\n/**\n * Replace `${KEY}` patterns in a string with values from the variables map.\n * Unmatched variables are left as-is.\n */\nfunction interpolateString(template: string, vars: Variables): string {\n return template.replace(/\\$\\{([^}]+)\\}/g, (match, key: string) => {\n const value = vars[key.trim()];\n return value !== undefined ? String(value) : match;\n });\n}\n\n/**\n * Recursively walk a value and interpolate any `${KEY}` patterns found in strings.\n * Returns a new object/array — never mutates the input.\n */\nfunction walkAndInterpolate<T>(value: T, vars: Variables): T {\n if (typeof value === 'string') {\n return interpolateString(value, vars) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map((item) => walkAndInterpolate(item, vars)) as unknown as T;\n }\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n result[k] = walkAndInterpolate(v, vars);\n }\n return result as T;\n }\n // numbers, booleans, null, undefined — pass through\n return value;\n}\n\n/**\n * Resolve `${KEY}` variable references in a workflow config object.\n *\n * Pure function: config in → new config out. Works on any shape\n * (GraphConfig, StepFlowConfig, or arbitrary objects).\n *\n * @param config - The config object to interpolate\n * @param variables - Key-value pairs to substitute\n * @returns A new config with all `${KEY}` patterns replaced\n */\nexport function resolveVariables<T extends Record<string, unknown>>(\n config: T,\n variables: Variables,\n): T {\n return walkAndInterpolate(config, variables);\n}\n","/**\n * Config template resolution for workflow configs.\n *\n * In large graphs, many tasks share the same base config (cmd, timeout, cwd, headers, etc.).\n * Instead of duplicating, tasks reference a named template via `config-template`.\n * This function deep-merges the template into each task's config, then removes the reference.\n *\n * Pure function — returns a new config, never mutates.\n *\n * @example\n * ```ts\n * const config = {\n * configTemplates: {\n * PYTHON_TOOL: { cmd: 'python', timeout: 30000, cwd: '/workdata' }\n * },\n * tasks: {\n * analyze: {\n * provides: ['analysis'],\n * config: { 'config-template': 'PYTHON_TOOL', 'cmd-args': 'analyze.py' }\n * }\n * }\n * };\n * const resolved = resolveConfigTemplates(config);\n * // analyze.config → { cmd: 'python', timeout: 30000, cwd: '/workdata', 'cmd-args': 'analyze.py' }\n * ```\n */\n\n/** Shape of a config-templates block */\nexport type ConfigTemplates = Record<string, Record<string, unknown>>;\n\n/**\n * Deep-merge template into task config.\n * Task-level values override template values.\n * Nested objects are merged one level deep (like SwarmX's pattern).\n */\nfunction mergeConfigs(\n template: Record<string, unknown>,\n taskConfig: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...template };\n\n for (const [key, value] of Object.entries(taskConfig)) {\n if (key === 'config-template') continue; // strip the reference\n\n // One-level deep merge for nested objects (both sides must be plain objects)\n if (\n value !== null &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n merged[key] !== null &&\n typeof merged[key] === 'object' &&\n !Array.isArray(merged[key])\n ) {\n merged[key] = {\n ...(merged[key] as Record<string, unknown>),\n ...(value as Record<string, unknown>),\n };\n } else {\n merged[key] = value;\n }\n }\n\n return merged;\n}\n\n/**\n * Resolve `config-template` references in task configs against a `configTemplates` map.\n *\n * Accepts any config object that may contain:\n * - `configTemplates` (camelCase) or `config-templates` (kebab-case) at the top level\n * - `tasks` (event-graph) or `steps` (step-machine) containing task/step objects\n * - Each task/step may have a `config` sub-object with a `config-template` key\n *\n * Returns a new config with templates merged and references removed.\n * The `configTemplates` / `config-templates` key is also removed from the output.\n */\nexport function resolveConfigTemplates<T extends Record<string, unknown>>(config: T): T {\n // Find templates — support both naming conventions\n const templates: ConfigTemplates =\n (config['configTemplates'] as ConfigTemplates) ??\n (config['config-templates'] as ConfigTemplates) ??\n {};\n\n // Find the tasks/steps container\n const tasksKey = 'tasks' in config ? 'tasks' : 'steps' in config ? 'steps' : null;\n if (!tasksKey) return config; // nothing to resolve\n\n const tasks = config[tasksKey] as Record<string, Record<string, unknown>> | undefined;\n if (!tasks || typeof tasks !== 'object') return config;\n\n const resolvedTasks: Record<string, Record<string, unknown>> = {};\n\n for (const [name, task] of Object.entries(tasks)) {\n const taskConfig = task['config'] as Record<string, unknown> | undefined;\n const templateName = taskConfig?.['config-template'] as string | undefined;\n\n if (!templateName || !taskConfig) {\n resolvedTasks[name] = task;\n continue;\n }\n\n const template = templates[templateName];\n if (!template) {\n // Template not found — leave as-is but strip the reference\n const { 'config-template': _, ...rest } = taskConfig;\n resolvedTasks[name] = { ...task, config: rest };\n continue;\n }\n\n resolvedTasks[name] = {\n ...task,\n config: mergeConfigs(template, taskConfig),\n };\n }\n\n // Build result — remove the templates key from output\n const result = { ...config, [tasksKey]: resolvedTasks };\n delete result['configTemplates'];\n delete result['config-templates'];\n return result as T;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/config/resolve-variables.ts","../../src/config/resolve-config-templates.ts"],"names":["interpolateString","template","vars","match","key","value","walkAndInterpolate","item","result","k","v","resolveVariables","config","variables","mergeConfigs","taskConfig","merged","resolveConfigTemplates","templates","tasksKey","tasks","resolvedTasks","name","task","templateName","_","rest"],"mappings":"AAuBA,SAASA,CAAAA,CAAkBC,CAAAA,CAAkBC,CAAAA,CAAyB,CACpE,OAAOD,CAAAA,CAAS,OAAA,CAAQ,gBAAA,CAAkB,CAACE,CAAAA,CAAOC,CAAAA,GAAgB,CAChE,IAAMC,EAAQH,CAAAA,CAAKE,CAAAA,CAAI,IAAA,EAAM,CAAA,CAC7B,OAAOC,CAAAA,GAAU,MAAA,CAAY,OAAOA,CAAK,CAAA,CAAIF,CAC/C,CAAC,CACH,CAMA,SAASG,CAAAA,CAAsBD,CAAAA,CAAUH,EAAoB,CAC3D,GAAI,OAAOG,CAAAA,EAAU,QAAA,CACnB,OAAOL,CAAAA,CAAkBK,CAAAA,CAAOH,CAAI,CAAA,CAEtC,GAAI,KAAA,CAAM,OAAA,CAAQG,CAAK,CAAA,CACrB,OAAOA,CAAAA,CAAM,GAAA,CAAKE,GAASD,CAAAA,CAAmBC,CAAAA,CAAML,CAAI,CAAC,CAAA,CAE3D,GAAIG,CAAAA,GAAU,IAAA,EAAQ,OAAOA,CAAAA,EAAU,QAAA,CAAU,CAC/C,IAAMG,EAAkC,EAAC,CACzC,IAAA,GAAW,CAACC,EAAGC,CAAC,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQL,CAAK,CAAA,CACvCG,CAAAA,CAAOC,CAAC,EAAIH,CAAAA,CAAmBI,CAAAA,CAAGR,CAAI,CAAA,CAExC,OAAOM,CACT,CAEA,OAAOH,CACT,CAYO,SAASM,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACG,CACH,OAAOP,CAAAA,CAAmBM,CAAAA,CAAQC,CAAS,CAC7C,CChC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AA,GAAa,iBAAiB,CAAA,CAEnD,GAAI,CAACS,GAAgB,CAACT,CAAAA,CAAY,CAChCM,CAAAA,CAAcC,CAAI,CAAA,CAAIC,CAAAA,CACtB,QACF,CAEA,IAAMtB,CAAAA,CAAWiB,CAAAA,CAAUM,CAAY,CAAA,CACvC,GAAI,CAACvB,CAAAA,CAAU,CAEb,GAAM,CAAE,iBAAA,CAAmBwB,CAAAA,CAAG,GAAGC,CAAK,CAAA,CAAIX,CAAAA,CAC1CM,CAAAA,CAAcC,CAAI,EAAI,CAAE,GAAGC,CAAAA,CAAM,MAAA,CAAQG,CAAK,CAAA,CAC9C,QACF,CAEAL,EAAcC,CAAI,CAAA,CAAI,CACpB,GAAGC,EACH,MAAA,CAAQT,CAAAA,CAAab,CAAAA,CAAUc,CAAU,CAC3C,EACF,CAGA,IAAMP,CAAAA,CAAS,CAAE,GAAGI,CAAAA,CAAQ,CAACO,CAAQ,EAAGE,CAAc,CAAA,CACtD,OAAA,OAAOb,EAAO,eAAA,CACd,OAAOA,CAAAA,CAAO,kBAAkB,EACzBA,CACT","file":"index.js","sourcesContent":["/**\n * Variable interpolation for workflow configs.\n *\n * Walks any object/array and replaces `${KEY}` patterns with values from\n * a variables map. Pure function — returns a new object, never mutates.\n *\n * Works on both GraphConfig and StepFlowConfig (or any plain object).\n *\n * @example\n * ```ts\n * const resolved = resolveVariables(config, {\n * ENTITY_ID: 'ticket-42',\n * TOOLS_DIR: '/opt/tools',\n * });\n * ```\n */\n\nexport type Variables = Record<string, string | number | boolean>;\n\n/**\n * Replace `${KEY}` patterns in a string with values from the variables map.\n * Unmatched variables are left as-is.\n */\nfunction interpolateString(template: string, vars: Variables): string {\n return template.replace(/\\$\\{([^}]+)\\}/g, (match, key: string) => {\n const value = vars[key.trim()];\n return value !== undefined ? String(value) : match;\n });\n}\n\n/**\n * Recursively walk a value and interpolate any `${KEY}` patterns found in strings.\n * Returns a new object/array — never mutates the input.\n */\nfunction walkAndInterpolate<T>(value: T, vars: Variables): T {\n if (typeof value === 'string') {\n return interpolateString(value, vars) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map((item) => walkAndInterpolate(item, vars)) as unknown as T;\n }\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n result[k] = walkAndInterpolate(v, vars);\n }\n return result as T;\n }\n // numbers, booleans, null, undefined — pass through\n return value;\n}\n\n/**\n * Resolve `${KEY}` variable references in a workflow config object.\n *\n * Pure function: config in → new config out. Works on any shape\n * (GraphConfig, StepFlowConfig, or arbitrary objects).\n *\n * @param config - The config object to interpolate\n * @param variables - Key-value pairs to substitute\n * @returns A new config with all `${KEY}` patterns replaced\n */\nexport function resolveVariables<T extends Record<string, unknown>>(\n config: T,\n variables: Variables,\n): T {\n return walkAndInterpolate(config, variables);\n}\n","/**\n * Config template resolution for workflow configs.\n *\n * In large graphs, many tasks share the same base config (cmd, timeout, cwd, headers, etc.).\n * Instead of duplicating, tasks reference a named template via `config-template`.\n * This function deep-merges the template into each task's config, then removes the reference.\n *\n * Pure function — returns a new config, never mutates.\n *\n * @example\n * ```ts\n * const config = {\n * configTemplates: {\n * PYTHON_TOOL: { cmd: 'python', timeout: 30000, cwd: '/workdata' }\n * },\n * tasks: {\n * analyze: {\n * provides: ['analysis'],\n * config: { 'config-template': 'PYTHON_TOOL', 'cmd-args': 'analyze.py' }\n * }\n * }\n * };\n * const resolved = resolveConfigTemplates(config);\n * // analyze.config → { cmd: 'python', timeout: 30000, cwd: '/workdata', 'cmd-args': 'analyze.py' }\n * ```\n */\n\n/** Shape of a config-templates block */\nexport type ConfigTemplates = Record<string, Record<string, unknown>>;\n\n/**\n * Deep-merge template into task config.\n * Task-level values override template values.\n * Nested objects are merged one level deep (like SwarmX's pattern).\n */\nfunction mergeConfigs(\n template: Record<string, unknown>,\n taskConfig: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...template };\n\n for (const [key, value] of Object.entries(taskConfig)) {\n if (key === 'config-template') continue; // strip the reference\n\n // One-level deep merge for nested objects (both sides must be plain objects)\n if (\n value !== null &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n merged[key] !== null &&\n typeof merged[key] === 'object' &&\n !Array.isArray(merged[key])\n ) {\n merged[key] = {\n ...(merged[key] as Record<string, unknown>),\n ...(value as Record<string, unknown>),\n };\n } else {\n merged[key] = value;\n }\n }\n\n return merged;\n}\n\n/**\n * Resolve `config-template` references in task configs against a `configTemplates` map.\n *\n * Accepts any config object that may contain:\n * - `configTemplates` (camelCase) or `config-templates` (kebab-case) at the top level\n * - `tasks` (event-graph) or `steps` (step-machine) containing task/step objects\n * - Each task/step may have a `config` sub-object with a `config-template` key\n *\n * Returns a new config with templates merged and references removed.\n * The `configTemplates` / `config-templates` key is also removed from the output.\n */\nexport function resolveConfigTemplates<T extends Record<string, unknown>>(config: T): T {\n // Find templates — support both naming conventions\n const templates: ConfigTemplates =\n (config['configTemplates'] as ConfigTemplates) ??\n (config['config-templates'] as ConfigTemplates) ??\n {};\n\n // Find the tasks/steps container\n const tasksKey = 'tasks' in config ? 'tasks' : 'steps' in config ? 'steps' : null;\n if (!tasksKey) return config; // nothing to resolve\n\n const tasks = config[tasksKey] as Record<string, Record<string, unknown>> | undefined;\n if (!tasks || typeof tasks !== 'object') return config;\n\n const resolvedTasks: Record<string, Record<string, unknown>> = {};\n\n for (const [name, task] of Object.entries(tasks)) {\n const taskConfig = task['config'] as Record<string, unknown> | undefined;\n const templateName = taskConfig?.['config-template'] as string | undefined;\n\n if (!templateName || !taskConfig) {\n resolvedTasks[name] = task;\n continue;\n }\n\n const template = templates[templateName];\n if (!template) {\n // Template not found — leave as-is but strip the reference\n const { 'config-template': _, ...rest } = taskConfig;\n resolvedTasks[name] = { ...task, config: rest };\n continue;\n }\n\n resolvedTasks[name] = {\n ...task,\n config: mergeConfigs(template, taskConfig),\n };\n }\n\n // Build result — remove the templates key from output\n const result = { ...config, [tasksKey]: resolvedTasks };\n delete result['configTemplates'];\n delete result['config-templates'];\n return result as T;\n}\n"]}