yaml-flow 5.4.2 → 7.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 (252) hide show
  1. package/board-live-cards-cli.js +6 -6
  2. package/browser/asset-integrity.json +10 -0
  3. package/browser/board-livecards-client.js +2 -0
  4. package/browser/board-livecards-client.js.map +1 -0
  5. package/browser/board-livecards-localstorage.js +10 -0
  6. package/browser/board-livecards-localstorage.js.map +1 -0
  7. package/browser/board-livegraph-engine.js +2 -1676
  8. package/browser/board-livegraph-engine.js.map +1 -1
  9. package/browser/card-compute.js +28 -28
  10. package/browser/compute-jsonata.js +5 -0
  11. package/browser/compute-jsonata.js.map +1 -0
  12. package/browser/live-cards.js +561 -129
  13. package/browser/live-cards.schema.json +418 -132
  14. package/card-store.js +37 -0
  15. package/dist/batch/index.cjs +1 -108
  16. package/dist/batch/index.cjs.map +1 -1
  17. package/dist/batch/index.js +1 -106
  18. package/dist/batch/index.js.map +1 -1
  19. package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +136 -0
  20. package/dist/board-live-cards-lib-jM2uYG1v.d.ts +136 -0
  21. package/dist/board-live-cards-public-CW5074xr.d.cts +318 -0
  22. package/dist/board-live-cards-public-hnZo0mAf.d.ts +318 -0
  23. package/dist/board-livegraph-runtime/index.cjs +2 -1671
  24. package/dist/board-livegraph-runtime/index.cjs.map +1 -1
  25. package/dist/board-livegraph-runtime/index.d.cts +12 -11
  26. package/dist/board-livegraph-runtime/index.d.ts +12 -11
  27. package/dist/board-livegraph-runtime/index.js +2 -1662
  28. package/dist/board-livegraph-runtime/index.js.map +1 -1
  29. package/dist/board-livegraph-runtime/jsonata-sync.cjs +7623 -0
  30. package/dist/card-compute/index.cjs +9 -7159
  31. package/dist/card-compute/index.cjs.map +1 -1
  32. package/dist/card-compute/index.d.cts +27 -1
  33. package/dist/card-compute/index.d.ts +27 -1
  34. package/dist/card-compute/index.js +9 -7145
  35. package/dist/card-compute/index.js.map +1 -1
  36. package/dist/card-compute/jsonata-sync.cjs +7623 -0
  37. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +3 -0
  38. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +1 -0
  39. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +37 -0
  40. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.ts +37 -0
  41. package/dist/cli/browser-api/board-live-cards-browser-adapter.js +3 -0
  42. package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +1 -0
  43. package/dist/cli/browser-api/card-store-browser-api.cjs +2 -0
  44. package/dist/cli/browser-api/card-store-browser-api.cjs.map +1 -0
  45. package/dist/cli/browser-api/card-store-browser-api.d.cts +26 -0
  46. package/dist/cli/browser-api/card-store-browser-api.d.ts +26 -0
  47. package/dist/cli/browser-api/card-store-browser-api.js +2 -0
  48. package/dist/cli/browser-api/card-store-browser-api.js.map +1 -0
  49. package/dist/cli/browser-api/jsonata-sync.cjs +7623 -0
  50. package/dist/cli/node/artifacts-store-cli.cjs +11 -0
  51. package/dist/cli/node/artifacts-store-cli.cjs.map +1 -0
  52. package/dist/cli/node/artifacts-store-cli.d.cts +8 -0
  53. package/dist/cli/node/artifacts-store-cli.d.ts +8 -0
  54. package/dist/cli/node/artifacts-store-cli.js +11 -0
  55. package/dist/cli/node/artifacts-store-cli.js.map +1 -0
  56. package/dist/cli/node/board-live-cards-cli.cjs +15 -0
  57. package/dist/cli/node/board-live-cards-cli.cjs.map +1 -0
  58. package/dist/cli/node/board-live-cards-cli.d.cts +20 -0
  59. package/dist/cli/node/board-live-cards-cli.d.ts +20 -0
  60. package/dist/cli/node/board-live-cards-cli.js +15 -0
  61. package/dist/cli/node/board-live-cards-cli.js.map +1 -0
  62. package/dist/cli/node/card-store-cli.cjs +8 -0
  63. package/dist/cli/node/card-store-cli.cjs.map +1 -0
  64. package/dist/cli/node/card-store-cli.d.cts +15 -0
  65. package/dist/cli/node/card-store-cli.d.ts +15 -0
  66. package/dist/cli/node/card-store-cli.js +8 -0
  67. package/dist/cli/node/card-store-cli.js.map +1 -0
  68. package/dist/cli/node/execution-adapter.cjs +3 -0
  69. package/dist/cli/node/execution-adapter.cjs.map +1 -0
  70. package/dist/cli/node/execution-adapter.d.cts +174 -0
  71. package/dist/cli/node/execution-adapter.d.ts +174 -0
  72. package/dist/cli/node/execution-adapter.js +3 -0
  73. package/dist/cli/node/execution-adapter.js.map +1 -0
  74. package/dist/cli/node/fs-board-adapter.cjs +14 -0
  75. package/dist/cli/node/fs-board-adapter.cjs.map +1 -0
  76. package/dist/cli/node/fs-board-adapter.d.cts +204 -0
  77. package/dist/cli/node/fs-board-adapter.d.ts +204 -0
  78. package/dist/cli/node/fs-board-adapter.js +14 -0
  79. package/dist/cli/node/fs-board-adapter.js.map +1 -0
  80. package/dist/cli/node/jsonata-sync.cjs +7623 -0
  81. package/dist/cli/node/source-cli-task-executor.cjs +11 -0
  82. package/dist/cli/node/source-cli-task-executor.cjs.map +1 -0
  83. package/dist/cli/node/source-cli-task-executor.d.cts +1 -0
  84. package/dist/cli/node/source-cli-task-executor.d.ts +1 -0
  85. package/dist/cli/node/source-cli-task-executor.js +11 -0
  86. package/dist/cli/node/source-cli-task-executor.js.map +1 -0
  87. package/dist/config/index.cjs +1 -79
  88. package/dist/config/index.cjs.map +1 -1
  89. package/dist/config/index.js +1 -76
  90. package/dist/config/index.js.map +1 -1
  91. package/dist/continuous-event-graph/index.cjs +2 -2129
  92. package/dist/continuous-event-graph/index.cjs.map +1 -1
  93. package/dist/continuous-event-graph/index.d.cts +81 -5
  94. package/dist/continuous-event-graph/index.d.ts +81 -5
  95. package/dist/continuous-event-graph/index.js +2 -2088
  96. package/dist/continuous-event-graph/index.js.map +1 -1
  97. package/dist/continuous-event-graph/jsonata-sync.cjs +7623 -0
  98. package/dist/event-graph/index.cjs +22 -8292
  99. package/dist/event-graph/index.cjs.map +1 -1
  100. package/dist/event-graph/index.js +22 -8237
  101. package/dist/event-graph/index.js.map +1 -1
  102. package/dist/execution-refs.cjs +3 -0
  103. package/dist/execution-refs.cjs.map +1 -0
  104. package/dist/execution-refs.d.cts +260 -0
  105. package/dist/execution-refs.d.ts +260 -0
  106. package/dist/execution-refs.js +3 -0
  107. package/dist/execution-refs.js.map +1 -0
  108. package/dist/index.cjs +29 -13221
  109. package/dist/index.cjs.map +1 -1
  110. package/dist/index.d.cts +2 -4
  111. package/dist/index.d.ts +2 -4
  112. package/dist/index.js +29 -13112
  113. package/dist/index.js.map +1 -1
  114. package/dist/inference/index.cjs +5 -617
  115. package/dist/inference/index.cjs.map +1 -1
  116. package/dist/inference/index.js +5 -610
  117. package/dist/inference/index.js.map +1 -1
  118. package/dist/jsonata-sync.cjs +7623 -0
  119. package/dist/{live-cards-bridge-x5XREkXm.d.cts → live-cards-bridge-BXbVTsna.d.cts} +27 -4
  120. package/dist/{live-cards-bridge-EQjytzI_.d.ts → live-cards-bridge-Ds28XR15.d.ts} +27 -4
  121. package/dist/server-runtime/index.cjs +9 -0
  122. package/dist/server-runtime/index.cjs.map +1 -0
  123. package/dist/server-runtime/index.d.cts +31 -0
  124. package/dist/server-runtime/index.d.ts +31 -0
  125. package/dist/server-runtime/index.js +9 -0
  126. package/dist/server-runtime/index.js.map +1 -0
  127. package/dist/server-runtime/jsonata-sync.cjs +7623 -0
  128. package/dist/step-machine/index.cjs +11 -7129
  129. package/dist/step-machine/index.cjs.map +1 -1
  130. package/dist/step-machine/index.js +11 -7113
  131. package/dist/step-machine/index.js.map +1 -1
  132. package/dist/step-machine-public/index.cjs +2 -0
  133. package/dist/step-machine-public/index.cjs.map +1 -0
  134. package/dist/step-machine-public/index.d.cts +159 -0
  135. package/dist/step-machine-public/index.d.ts +159 -0
  136. package/dist/step-machine-public/index.js +2 -0
  137. package/dist/step-machine-public/index.js.map +1 -0
  138. package/dist/step-machine-public/jsonata-sync.cjs +7623 -0
  139. package/dist/storage-refs.cjs +10 -0
  140. package/dist/storage-refs.cjs.map +1 -0
  141. package/dist/storage-refs.d.cts +93 -0
  142. package/dist/storage-refs.d.ts +93 -0
  143. package/dist/storage-refs.js +10 -0
  144. package/dist/storage-refs.js.map +1 -0
  145. package/dist/stores/file.cjs +1 -114
  146. package/dist/stores/file.cjs.map +1 -1
  147. package/dist/stores/file.js +1 -112
  148. package/dist/stores/file.js.map +1 -1
  149. package/dist/stores/index.cjs +1 -231
  150. package/dist/stores/index.cjs.map +1 -1
  151. package/dist/stores/index.js +1 -227
  152. package/dist/stores/index.js.map +1 -1
  153. package/dist/stores/localStorage.cjs +1 -76
  154. package/dist/stores/localStorage.cjs.map +1 -1
  155. package/dist/stores/localStorage.js +1 -74
  156. package/dist/stores/localStorage.js.map +1 -1
  157. package/dist/stores/memory.cjs +1 -47
  158. package/dist/stores/memory.cjs.map +1 -1
  159. package/dist/stores/memory.js +1 -45
  160. package/dist/stores/memory.js.map +1 -1
  161. package/dist/types-B1ZRa4aI.d.ts +147 -0
  162. package/dist/types-BxEFcVK9.d.cts +147 -0
  163. package/examples/browser/boards/portfolio-tracker/portfolio-t4.js +291 -0
  164. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.js +218 -0
  165. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +201 -0
  166. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-http-test.js +357 -0
  167. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +25 -16
  168. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-public.js +552 -0
  169. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.js +300 -0
  170. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.py +617 -0
  171. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-sse-worker.js +48 -0
  172. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +366 -0
  173. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +1 -0
  174. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +32 -0
  175. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +70 -3
  176. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +16 -11
  177. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +9 -8
  178. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +49 -0
  179. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +2 -6
  180. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +4 -8
  181. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +3 -7
  182. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +9 -8
  183. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +12 -17
  184. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +2 -6
  185. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +107 -0
  186. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +51 -0
  187. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +45 -0
  188. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +71 -0
  189. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +36 -0
  190. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +26 -0
  191. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +39 -0
  192. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +80 -0
  193. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +36 -187
  194. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +40 -34
  195. package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +43 -0
  196. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +77 -0
  197. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  198. package/examples/cli/step-machine-demo/jsonata-init-board-cli.js +8 -13
  199. package/examples/cli/step-machine-demo/jsonata-init-board.flow.yaml +33 -9
  200. package/examples/cli/step-machine-demo/one-step-cli-only.flow.yaml +3 -1
  201. package/examples/cli/step-machine-demo/step2-double-cli.js +6 -12
  202. package/examples/cli/step-machine-demo/two-step-math.flow.yaml +66 -4
  203. package/examples/cli/step-machine-demo/two-step-mixed.flow.yaml +13 -5
  204. package/examples/example-board/agent-instructions.md +11 -5
  205. package/examples/example-board/cards/_index.json +47 -0
  206. package/examples/example-board/cards/card-market-prices.json +33 -9
  207. package/examples/example-board/cards/card-my-identity.json +30 -6
  208. package/examples/example-board/cards/card-portfolio-action.json +24 -6
  209. package/examples/example-board/cards/card-portfolio-intelligence.json +97 -0
  210. package/examples/example-board/cards/card-portfolio-risks.json +24 -6
  211. package/examples/example-board/cards/card-portfolio-value.json +38 -10
  212. package/examples/example-board/cards/card-portfolio.json +57 -13
  213. package/examples/example-board/cards/card-rebalance-impact.json +22 -6
  214. package/examples/example-board/cards/card-rebalance-sim.json +66 -15
  215. package/examples/example-board/demo-chat-handler.js +14 -4
  216. package/examples/example-board/demo-server-config.json +1 -0
  217. package/examples/example-board/demo-server.js +366 -68
  218. package/examples/example-board/demo-shell-localstorage.html +774 -0
  219. package/examples/example-board/demo-shell-with-server.html +20 -37
  220. package/examples/example-board/demo-shell.html +5 -4
  221. package/examples/example-board/demo-task-executor.js +273 -275
  222. package/examples/index.html +0 -14
  223. package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -1
  224. package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  225. package/package.json +46 -8
  226. package/schema/live-cards.schema.json +418 -132
  227. package/step-machine-cli.js +43 -310
  228. package/board-livecards-server-runtime.js +0 -1574
  229. package/browser/board-livecards-runtime-client.js +0 -263
  230. package/dist/cli/board-live-cards-cli.cjs +0 -10650
  231. package/dist/cli/board-live-cards-cli.cjs.map +0 -1
  232. package/dist/cli/board-live-cards-cli.d.cts +0 -179
  233. package/dist/cli/board-live-cards-cli.d.ts +0 -179
  234. package/dist/cli/board-live-cards-cli.js +0 -10598
  235. package/dist/cli/board-live-cards-cli.js.map +0 -1
  236. package/dist/journal-9HEgs7dU.d.ts +0 -28
  237. package/dist/journal-B-JCfQnh.d.cts +0 -28
  238. package/dist/schedule-Cszq9LYY.d.ts +0 -21
  239. package/dist/schedule-qWNL0RQh.d.cts +0 -21
  240. package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +0 -22
  241. package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +0 -16
  242. package/examples/browser/boards/portfolio-tracker/cards/portfolio-risk-assessment.json +0 -28
  243. package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +0 -15
  244. package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +0 -15
  245. package/examples/browser/boards/portfolio-tracker/cards/rebalancing-strategy.json +0 -28
  246. package/examples/browser/boards/portfolio-tracker/fetch-prices.js +0 -43
  247. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
  248. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +0 -7
  249. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +0 -351
  250. package/examples/cli/step-machine-demo/two-step-math-handlers.js +0 -32
  251. package/examples/cli/step-machine-demo/two-step-mixed-handlers.js +0 -24
  252. package/examples/example-board/demo-shell-browser.html +0 -674
package/card-store.js ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+
3
+ import * as fs from 'node:fs';
4
+ import * as path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { spawnSync } from 'node:child_process';
7
+
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
+ const distCli = path.join(__dirname, 'dist', 'cli', 'node', 'card-store-cli.js');
10
+ const srcCli = path.join(__dirname, 'src', 'cli', 'node', 'card-store-cli.ts');
11
+ const tsxCli = path.join(__dirname, 'node_modules', 'tsx', 'dist', 'cli.mjs');
12
+
13
+ if (fs.existsSync(srcCli)) {
14
+ const result = spawnSync(process.execPath, [tsxCli, srcCli, ...process.argv.slice(2)], {
15
+ stdio: 'inherit',
16
+ shell: false,
17
+ windowsHide: true,
18
+ });
19
+
20
+ if (result.error) {
21
+ console.error(`[card-store] Failed to launch dev fallback: ${result.error.message}`);
22
+ process.exit(1);
23
+ }
24
+
25
+ process.exit(result.status ?? 0);
26
+ } else if (fs.existsSync(distCli)) {
27
+ const { cli } = await import(pathToFileUrl(distCli).href);
28
+ await cli(process.argv.slice(2));
29
+ } else {
30
+ console.error('[card-store] Could not find dist or src CLI entrypoint.');
31
+ process.exit(1);
32
+ }
33
+
34
+ function pathToFileUrl(filePath) {
35
+ const resolved = path.resolve(filePath).replace(/\\/g, '/');
36
+ return new URL(`file:///${resolved.startsWith('/') ? resolved.slice(1) : resolved}`);
37
+ }
@@ -1,109 +1,2 @@
1
- 'use strict';
2
-
3
- // src/batch/runner.ts
4
- async function batch(items, options) {
5
- const {
6
- concurrency = 5,
7
- processor,
8
- onItemComplete,
9
- onItemError,
10
- onProgress,
11
- signal
12
- } = options;
13
- const total = items.length;
14
- const results = new Array(total);
15
- const batchStart = Date.now();
16
- let completed = 0;
17
- let failed = 0;
18
- let nextIndex = 0;
19
- function makeProgress(active) {
20
- const done = completed + failed;
21
- return {
22
- completed,
23
- failed,
24
- active,
25
- pending: total - done - active,
26
- total,
27
- percent: total === 0 ? 100 : Math.round(done / total * 100),
28
- elapsedMs: Date.now() - batchStart
29
- };
30
- }
31
- if (total === 0) {
32
- return { items: [], completed: 0, failed: 0, total: 0, durationMs: 0 };
33
- }
34
- return new Promise((resolve) => {
35
- let active = 0;
36
- function tryStartNext() {
37
- while (active < concurrency && nextIndex < total) {
38
- if (signal?.aborted) {
39
- while (nextIndex < total) {
40
- const idx2 = nextIndex++;
41
- results[idx2] = {
42
- item: items[idx2],
43
- index: idx2,
44
- status: "failed",
45
- error: new Error("Batch aborted"),
46
- durationMs: 0
47
- };
48
- failed++;
49
- }
50
- if (active === 0 && completed + failed === total) {
51
- resolve({
52
- items: results,
53
- completed,
54
- failed,
55
- total,
56
- durationMs: Date.now() - batchStart
57
- });
58
- }
59
- break;
60
- }
61
- const idx = nextIndex++;
62
- const item = items[idx];
63
- active++;
64
- const itemStart = Date.now();
65
- processor(item, idx).then((result) => {
66
- results[idx] = {
67
- item,
68
- index: idx,
69
- status: "completed",
70
- result,
71
- durationMs: Date.now() - itemStart
72
- };
73
- completed++;
74
- onItemComplete?.(item, result, idx);
75
- }).catch((err) => {
76
- const error = err instanceof Error ? err : new Error(String(err));
77
- results[idx] = {
78
- item,
79
- index: idx,
80
- status: "failed",
81
- error,
82
- durationMs: Date.now() - itemStart
83
- };
84
- failed++;
85
- onItemError?.(item, error, idx);
86
- }).finally(() => {
87
- active--;
88
- onProgress?.(makeProgress(active));
89
- if (completed + failed === total) {
90
- resolve({
91
- items: results,
92
- completed,
93
- failed,
94
- total,
95
- durationMs: Date.now() - batchStart
96
- });
97
- } else {
98
- tryStartNext();
99
- }
100
- });
101
- }
102
- }
103
- tryStartNext();
104
- });
105
- }
106
-
107
- exports.batch = batch;
108
- //# sourceMappingURL=index.cjs.map
1
+ 'use strict';async function y(u,f){let{concurrency:B=5,processor:w,onItemComplete:I,onItemError:R,onProgress:x,signal:T}=f,t=u.length,a=new Array(t),m=Date.now(),r=0,o=0,l=0;function g(c){let n=r+o;return {completed:r,failed:o,active:c,pending:t-n-c,total:t,percent:t===0?100:Math.round(n/t*100),elapsedMs:Date.now()-m}}return t===0?{items:[],completed:0,failed:0,total:0,durationMs:0}:new Promise(c=>{let n=0;function d(){for(;n<B&&l<t;){if(T?.aborted){for(;l<t;){let e=l++;a[e]={item:u[e],index:e,status:"failed",error:new Error("Batch aborted"),durationMs:0},o++;}n===0&&r+o===t&&c({items:a,completed:r,failed:o,total:t,durationMs:Date.now()-m});break}let s=l++,i=u[s];n++;let h=Date.now();w(i,s).then(e=>{a[s]={item:i,index:s,status:"completed",result:e,durationMs:Date.now()-h},r++,I?.(i,e,s);}).catch(e=>{let p=e instanceof Error?e:new Error(String(e));a[s]={item:i,index:s,status:"failed",error:p,durationMs:Date.now()-h},o++,R?.(i,p,s);}).finally(()=>{n--,x?.(g(n)),r+o===t?c({items:a,completed:r,failed:o,total:t,durationMs:Date.now()-m}):d();});}}d();})}exports.batch=y;//# sourceMappingURL=index.cjs.map
109
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/batch/runner.ts"],"names":["idx"],"mappings":";;;AAoDA,eAAsB,KAAA,CACpB,OACA,OAAA,EACsC;AACtC,EAAA,MAAM;AAAA,IACJ,WAAA,GAAc,CAAA;AAAA,IACd,SAAA;AAAA,IACA,cAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAEJ,EAAA,MAAM,QAAQ,KAAA,CAAM,MAAA;AACpB,EAAA,MAAM,OAAA,GAA6C,IAAI,KAAA,CAAM,KAAK,CAAA;AAClE,EAAA,MAAM,UAAA,GAAa,KAAK,GAAA,EAAI;AAE5B,EAAA,IAAI,SAAA,GAAY,CAAA;AAChB,EAAA,IAAI,MAAA,GAAS,CAAA;AACb,EAAA,IAAI,SAAA,GAAY,CAAA;AAEhB,EAAA,SAAS,aAAa,MAAA,EAA+B;AACnD,IAAA,MAAM,OAAO,SAAA,GAAY,MAAA;AACzB,IAAA,OAAO;AAAA,MACL,SAAA;AAAA,MACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,OAAA,EAAS,QAAQ,IAAA,GAAO,MAAA;AAAA,MACxB,KAAA;AAAA,MACA,OAAA,EAAS,UAAU,CAAA,GAAI,GAAA,GAAM,KAAK,KAAA,CAAO,IAAA,GAAO,QAAS,GAAG,CAAA;AAAA,MA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CAAA,MAAO;AACL,YAAA,YAAA,EAAa;AAAA,UACf;AAAA,QACF,CAAC,CAAA;AAAA,MACL;AAAA,IACF;AAEA,IAAA,YAAA,EAAa;AAAA,EACf,CAAC,CAAA;AACH","file":"index.cjs","sourcesContent":["/**\n * Batch Runner — Core\n *\n * Slot-based concurrent processor. Pure control flow — no I/O opinions.\n *\n * @example Step Machine batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { createStepMachine, loadStepFlow } from 'yaml-flow/step-machine';\n *\n * const flow = await loadStepFlow('./support-ticket.yaml');\n * const results = await batch(tickets, {\n * concurrency: 5,\n * processor: async (ticket) => {\n * const machine = createStepMachine(flow, handlers);\n * return machine.run(ticket);\n * },\n * });\n * ```\n *\n * @example Event Graph batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { next, apply, createInitialExecutionState } from 'yaml-flow/event-graph';\n *\n * const results = await batch(items, {\n * concurrency: 3,\n * processor: async (item, index) => {\n * let state = createInitialExecutionState(graph, `exec-${index}`);\n * state = apply(state, { type: 'inject-tokens', tokens: [item.token], timestamp: new Date().toISOString() }, graph);\n * // ... drive the graph loop\n * return state;\n * },\n * });\n * ```\n */\n\nimport type {\n BatchOptions,\n BatchResult,\n BatchItemResult,\n BatchProgress,\n} from './types.js';\n\n/**\n * Run an array of items through an async processor with concurrency control.\n *\n * - Items are started in order, up to `concurrency` at a time.\n * - Results are returned in the original item order.\n * - If a processor throws, the item is marked as failed; other items continue.\n * - An AbortSignal prevents new items from starting (in-flight items are not cancelled).\n */\nexport async function batch<TItem, TResult>(\n items: TItem[],\n options: BatchOptions<TItem, TResult>\n): Promise<BatchResult<TItem, TResult>> {\n const {\n concurrency = 5,\n processor,\n onItemComplete,\n onItemError,\n onProgress,\n signal,\n } = options;\n\n const total = items.length;\n const results: BatchItemResult<TItem, TResult>[] = new Array(total);\n const batchStart = Date.now();\n\n let completed = 0;\n let failed = 0;\n let nextIndex = 0;\n\n function makeProgress(active: number): BatchProgress {\n const done = completed + failed;\n return {\n completed,\n failed,\n active,\n pending: total - done - active,\n total,\n percent: total === 0 ? 100 : Math.round((done / total) * 100),\n elapsedMs: Date.now() - batchStart,\n };\n }\n\n // Empty input — short-circuit\n if (total === 0) {\n return { items: [], completed: 0, failed: 0, total: 0, durationMs: 0 };\n }\n\n return new Promise<BatchResult<TItem, TResult>>((resolve) => {\n let active = 0;\n\n function tryStartNext() {\n while (active < concurrency && nextIndex < total) {\n // Respect abort signal — don't start new items\n if (signal?.aborted) {\n // Mark remaining as failed with abort error\n while (nextIndex < total) {\n const idx = nextIndex++;\n results[idx] = {\n item: items[idx],\n index: idx,\n status: 'failed',\n error: new Error('Batch aborted'),\n durationMs: 0,\n };\n failed++;\n }\n // If nothing is in-flight, resolve immediately\n if (active === 0 && completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n }\n break;\n }\n\n const idx = nextIndex++;\n const item = items[idx];\n active++;\n const itemStart = Date.now();\n\n processor(item, idx)\n .then((result) => {\n results[idx] = {\n item,\n index: idx,\n status: 'completed',\n result,\n durationMs: Date.now() - itemStart,\n };\n completed++;\n onItemComplete?.(item, result, idx);\n })\n .catch((err) => {\n const error = err instanceof Error ? err : new Error(String(err));\n results[idx] = {\n item,\n index: idx,\n status: 'failed',\n error,\n durationMs: Date.now() - itemStart,\n };\n failed++;\n onItemError?.(item, error, idx);\n })\n .finally(() => {\n active--;\n onProgress?.(makeProgress(active));\n\n if (completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n } else {\n tryStartNext();\n }\n });\n }\n }\n\n tryStartNext();\n });\n}\n"]}
1
+ {"version":3,"sources":["../../src/batch/runner.ts"],"names":["batch","items","options","concurrency","processor","onItemComplete","onItemError","onProgress","signal","total","results","batchStart","completed","failed","nextIndex","makeProgress","active","done","resolve","tryStartNext","idx","item","itemStart","result","err","error"],"mappings":"aAoDA,eAAsBA,CAAAA,CACpB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MAAA,CAAQ,QAAA,CACR,KAAA,CAAAK,CAAAA,CACA,UAAA,CAAY,IAAA,CAAK,GAAA,EAAI,CAAIH,CAC3B,CAAA,CACAT,CAAAA,EAAAA,CACAP,CAAAA,GAAce,CAAAA,CAAMI,EAAOL,CAAG,EAChC,CAAC,CAAA,CACA,QAAQ,IAAM,CACbJ,CAAAA,EAAAA,CACAT,CAAAA,GAAaQ,CAAAA,CAAaC,CAAM,CAAC,CAAA,CAE7BJ,EAAYC,CAAAA,GAAWJ,CAAAA,CACzBS,CAAAA,CAAQ,CACN,KAAA,CAAOR,CAAAA,CACP,SAAA,CAAAE,CAAAA,CACA,OAAAC,CAAAA,CACA,KAAA,CAAAJ,CAAAA,CACA,UAAA,CAAY,IAAA,CAAK,GAAA,EAAI,CAAIE,CAC3B,CAAC,CAAA,CAEDQ,CAAAA,GAEJ,CAAC,EACL,CACF,CAEAA,CAAAA,GACF,CAAC,CACH","file":"index.cjs","sourcesContent":["/**\n * Batch Runner — Core\n *\n * Slot-based concurrent processor. Pure control flow — no I/O opinions.\n *\n * @example Step Machine batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { createStepMachine, loadStepFlow } from 'yaml-flow/step-machine';\n *\n * const flow = await loadStepFlow('./support-ticket.yaml');\n * const results = await batch(tickets, {\n * concurrency: 5,\n * processor: async (ticket) => {\n * const machine = createStepMachine(flow, handlers);\n * return machine.run(ticket);\n * },\n * });\n * ```\n *\n * @example Event Graph batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { next, apply, createInitialExecutionState } from 'yaml-flow/event-graph';\n *\n * const results = await batch(items, {\n * concurrency: 3,\n * processor: async (item, index) => {\n * let state = createInitialExecutionState(graph, `exec-${index}`);\n * state = apply(state, { type: 'inject-tokens', tokens: [item.token], timestamp: new Date().toISOString() }, graph);\n * // ... drive the graph loop\n * return state;\n * },\n * });\n * ```\n */\n\nimport type {\n BatchOptions,\n BatchResult,\n BatchItemResult,\n BatchProgress,\n} from './types.js';\n\n/**\n * Run an array of items through an async processor with concurrency control.\n *\n * - Items are started in order, up to `concurrency` at a time.\n * - Results are returned in the original item order.\n * - If a processor throws, the item is marked as failed; other items continue.\n * - An AbortSignal prevents new items from starting (in-flight items are not cancelled).\n */\nexport async function batch<TItem, TResult>(\n items: TItem[],\n options: BatchOptions<TItem, TResult>\n): Promise<BatchResult<TItem, TResult>> {\n const {\n concurrency = 5,\n processor,\n onItemComplete,\n onItemError,\n onProgress,\n signal,\n } = options;\n\n const total = items.length;\n const results: BatchItemResult<TItem, TResult>[] = new Array(total);\n const batchStart = Date.now();\n\n let completed = 0;\n let failed = 0;\n let nextIndex = 0;\n\n function makeProgress(active: number): BatchProgress {\n const done = completed + failed;\n return {\n completed,\n failed,\n active,\n pending: total - done - active,\n total,\n percent: total === 0 ? 100 : Math.round((done / total) * 100),\n elapsedMs: Date.now() - batchStart,\n };\n }\n\n // Empty input — short-circuit\n if (total === 0) {\n return { items: [], completed: 0, failed: 0, total: 0, durationMs: 0 };\n }\n\n return new Promise<BatchResult<TItem, TResult>>((resolve) => {\n let active = 0;\n\n function tryStartNext() {\n while (active < concurrency && nextIndex < total) {\n // Respect abort signal — don't start new items\n if (signal?.aborted) {\n // Mark remaining as failed with abort error\n while (nextIndex < total) {\n const idx = nextIndex++;\n results[idx] = {\n item: items[idx],\n index: idx,\n status: 'failed',\n error: new Error('Batch aborted'),\n durationMs: 0,\n };\n failed++;\n }\n // If nothing is in-flight, resolve immediately\n if (active === 0 && completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n }\n break;\n }\n\n const idx = nextIndex++;\n const item = items[idx];\n active++;\n const itemStart = Date.now();\n\n processor(item, idx)\n .then((result) => {\n results[idx] = {\n item,\n index: idx,\n status: 'completed',\n result,\n durationMs: Date.now() - itemStart,\n };\n completed++;\n onItemComplete?.(item, result, idx);\n })\n .catch((err) => {\n const error = err instanceof Error ? err : new Error(String(err));\n results[idx] = {\n item,\n index: idx,\n status: 'failed',\n error,\n durationMs: Date.now() - itemStart,\n };\n failed++;\n onItemError?.(item, error, idx);\n })\n .finally(() => {\n active--;\n onProgress?.(makeProgress(active));\n\n if (completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n } else {\n tryStartNext();\n }\n });\n }\n }\n\n tryStartNext();\n });\n}\n"]}
@@ -1,107 +1,2 @@
1
- // src/batch/runner.ts
2
- async function batch(items, options) {
3
- const {
4
- concurrency = 5,
5
- processor,
6
- onItemComplete,
7
- onItemError,
8
- onProgress,
9
- signal
10
- } = options;
11
- const total = items.length;
12
- const results = new Array(total);
13
- const batchStart = Date.now();
14
- let completed = 0;
15
- let failed = 0;
16
- let nextIndex = 0;
17
- function makeProgress(active) {
18
- const done = completed + failed;
19
- return {
20
- completed,
21
- failed,
22
- active,
23
- pending: total - done - active,
24
- total,
25
- percent: total === 0 ? 100 : Math.round(done / total * 100),
26
- elapsedMs: Date.now() - batchStart
27
- };
28
- }
29
- if (total === 0) {
30
- return { items: [], completed: 0, failed: 0, total: 0, durationMs: 0 };
31
- }
32
- return new Promise((resolve) => {
33
- let active = 0;
34
- function tryStartNext() {
35
- while (active < concurrency && nextIndex < total) {
36
- if (signal?.aborted) {
37
- while (nextIndex < total) {
38
- const idx2 = nextIndex++;
39
- results[idx2] = {
40
- item: items[idx2],
41
- index: idx2,
42
- status: "failed",
43
- error: new Error("Batch aborted"),
44
- durationMs: 0
45
- };
46
- failed++;
47
- }
48
- if (active === 0 && completed + failed === total) {
49
- resolve({
50
- items: results,
51
- completed,
52
- failed,
53
- total,
54
- durationMs: Date.now() - batchStart
55
- });
56
- }
57
- break;
58
- }
59
- const idx = nextIndex++;
60
- const item = items[idx];
61
- active++;
62
- const itemStart = Date.now();
63
- processor(item, idx).then((result) => {
64
- results[idx] = {
65
- item,
66
- index: idx,
67
- status: "completed",
68
- result,
69
- durationMs: Date.now() - itemStart
70
- };
71
- completed++;
72
- onItemComplete?.(item, result, idx);
73
- }).catch((err) => {
74
- const error = err instanceof Error ? err : new Error(String(err));
75
- results[idx] = {
76
- item,
77
- index: idx,
78
- status: "failed",
79
- error,
80
- durationMs: Date.now() - itemStart
81
- };
82
- failed++;
83
- onItemError?.(item, error, idx);
84
- }).finally(() => {
85
- active--;
86
- onProgress?.(makeProgress(active));
87
- if (completed + failed === total) {
88
- resolve({
89
- items: results,
90
- completed,
91
- failed,
92
- total,
93
- durationMs: Date.now() - batchStart
94
- });
95
- } else {
96
- tryStartNext();
97
- }
98
- });
99
- }
100
- }
101
- tryStartNext();
102
- });
103
- }
104
-
105
- export { batch };
106
- //# sourceMappingURL=index.js.map
1
+ async function y(u,f){let{concurrency:B=5,processor:w,onItemComplete:I,onItemError:R,onProgress:x,signal:T}=f,t=u.length,a=new Array(t),m=Date.now(),r=0,o=0,l=0;function g(c){let n=r+o;return {completed:r,failed:o,active:c,pending:t-n-c,total:t,percent:t===0?100:Math.round(n/t*100),elapsedMs:Date.now()-m}}return t===0?{items:[],completed:0,failed:0,total:0,durationMs:0}:new Promise(c=>{let n=0;function d(){for(;n<B&&l<t;){if(T?.aborted){for(;l<t;){let e=l++;a[e]={item:u[e],index:e,status:"failed",error:new Error("Batch aborted"),durationMs:0},o++;}n===0&&r+o===t&&c({items:a,completed:r,failed:o,total:t,durationMs:Date.now()-m});break}let s=l++,i=u[s];n++;let h=Date.now();w(i,s).then(e=>{a[s]={item:i,index:s,status:"completed",result:e,durationMs:Date.now()-h},r++,I?.(i,e,s);}).catch(e=>{let p=e instanceof Error?e:new Error(String(e));a[s]={item:i,index:s,status:"failed",error:p,durationMs:Date.now()-h},o++,R?.(i,p,s);}).finally(()=>{n--,x?.(g(n)),r+o===t?c({items:a,completed:r,failed:o,total:t,durationMs:Date.now()-m}):d();});}}d();})}export{y as batch};//# sourceMappingURL=index.js.map
107
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/batch/runner.ts"],"names":["idx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AAA,CACA,KAAA,CAAM,CAAC,GAAA,KAAQ;AACd,UAAA,MAAM,KAAA,GAAQ,eAAe,KAAA,GAAQ,GAAA,GAAM,IAAI,KAAA,CAAM,MAAA,CAAO,GAAG,CAAC,CAAA;AAChE,UAAA,OAAA,CAAQ,GAAG,CAAA,GAAI;AAAA,YACb,IAAA;AAAA,YACA,KAAA,EAAO,GAAA;AAAA,YACP,MAAA,EAAQ,QAAA;AAAA,YACR,KAAA;AAAA,YACA,UAAA,EAAY,IAAA,CAAK,GAAA,EAAI,GAAI;AAAA,WAC3B;AACA,UAAA,MAAA,EAAA;AACA,UAAA,WAAA,GAAc,IAAA,EAAM,OAAO,GAAG,CAAA;AAAA,QAChC,CAAC,CAAA,CACA,OAAA,CAAQ,MAAM;AACb,UAAA,MAAA,EAAA;AACA,UAAA,UAAA,GAAa,YAAA,CAAa,MAAM,CAAC,CAAA;AAEjC,UAAA,IAAI,SAAA,GAAY,WAAW,KAAA,EAAO;AAChC,YAAA,OAAA,CAAQ;AAAA,cACN,KAAA,EAAO,OAAA;AAAA,cACP,SAAA;AAAA,cACA,MAAA;AAAA,cACA,KAAA;AAAA,cACA,UAAA,EAAY,IAAA,CAAK,GAAA,EAAI,GAAI;AAAA,aAC1B,CAAA;AAAA,UACH,CAAA,MAAO;AACL,YAAA,YAAA,EAAa;AAAA,UACf;AAAA,QACF,CAAC,CAAA;AAAA,MACL;AAAA,IACF;AAEA,IAAA,YAAA,EAAa;AAAA,EACf,CAAC,CAAA;AACH","file":"index.js","sourcesContent":["/**\n * Batch Runner — Core\n *\n * Slot-based concurrent processor. Pure control flow — no I/O opinions.\n *\n * @example Step Machine batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { createStepMachine, loadStepFlow } from 'yaml-flow/step-machine';\n *\n * const flow = await loadStepFlow('./support-ticket.yaml');\n * const results = await batch(tickets, {\n * concurrency: 5,\n * processor: async (ticket) => {\n * const machine = createStepMachine(flow, handlers);\n * return machine.run(ticket);\n * },\n * });\n * ```\n *\n * @example Event Graph batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { next, apply, createInitialExecutionState } from 'yaml-flow/event-graph';\n *\n * const results = await batch(items, {\n * concurrency: 3,\n * processor: async (item, index) => {\n * let state = createInitialExecutionState(graph, `exec-${index}`);\n * state = apply(state, { type: 'inject-tokens', tokens: [item.token], timestamp: new Date().toISOString() }, graph);\n * // ... drive the graph loop\n * return state;\n * },\n * });\n * ```\n */\n\nimport type {\n BatchOptions,\n BatchResult,\n BatchItemResult,\n BatchProgress,\n} from './types.js';\n\n/**\n * Run an array of items through an async processor with concurrency control.\n *\n * - Items are started in order, up to `concurrency` at a time.\n * - Results are returned in the original item order.\n * - If a processor throws, the item is marked as failed; other items continue.\n * - An AbortSignal prevents new items from starting (in-flight items are not cancelled).\n */\nexport async function batch<TItem, TResult>(\n items: TItem[],\n options: BatchOptions<TItem, TResult>\n): Promise<BatchResult<TItem, TResult>> {\n const {\n concurrency = 5,\n processor,\n onItemComplete,\n onItemError,\n onProgress,\n signal,\n } = options;\n\n const total = items.length;\n const results: BatchItemResult<TItem, TResult>[] = new Array(total);\n const batchStart = Date.now();\n\n let completed = 0;\n let failed = 0;\n let nextIndex = 0;\n\n function makeProgress(active: number): BatchProgress {\n const done = completed + failed;\n return {\n completed,\n failed,\n active,\n pending: total - done - active,\n total,\n percent: total === 0 ? 100 : Math.round((done / total) * 100),\n elapsedMs: Date.now() - batchStart,\n };\n }\n\n // Empty input — short-circuit\n if (total === 0) {\n return { items: [], completed: 0, failed: 0, total: 0, durationMs: 0 };\n }\n\n return new Promise<BatchResult<TItem, TResult>>((resolve) => {\n let active = 0;\n\n function tryStartNext() {\n while (active < concurrency && nextIndex < total) {\n // Respect abort signal — don't start new items\n if (signal?.aborted) {\n // Mark remaining as failed with abort error\n while (nextIndex < total) {\n const idx = nextIndex++;\n results[idx] = {\n item: items[idx],\n index: idx,\n status: 'failed',\n error: new Error('Batch aborted'),\n durationMs: 0,\n };\n failed++;\n }\n // If nothing is in-flight, resolve immediately\n if (active === 0 && completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n }\n break;\n }\n\n const idx = nextIndex++;\n const item = items[idx];\n active++;\n const itemStart = Date.now();\n\n processor(item, idx)\n .then((result) => {\n results[idx] = {\n item,\n index: idx,\n status: 'completed',\n result,\n durationMs: Date.now() - itemStart,\n };\n completed++;\n onItemComplete?.(item, result, idx);\n })\n .catch((err) => {\n const error = err instanceof Error ? err : new Error(String(err));\n results[idx] = {\n item,\n index: idx,\n status: 'failed',\n error,\n durationMs: Date.now() - itemStart,\n };\n failed++;\n onItemError?.(item, error, idx);\n })\n .finally(() => {\n active--;\n onProgress?.(makeProgress(active));\n\n if (completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n } else {\n tryStartNext();\n }\n });\n }\n }\n\n tryStartNext();\n });\n}\n"]}
1
+ {"version":3,"sources":["../../src/batch/runner.ts"],"names":["batch","items","options","concurrency","processor","onItemComplete","onItemError","onProgress","signal","total","results","batchStart","completed","failed","nextIndex","makeProgress","active","done","resolve","tryStartNext","idx","item","itemStart","result","err","error"],"mappings":"AAoDA,eAAsBA,CAAAA,CACpBC,CAAAA,CACAC,CAAAA,CACsC,CACtC,GAAM,CACJ,WAAA,CAAAC,CAAAA,CAAc,CAAA,CACd,SAAA,CAAAC,CAAAA,CACA,cAAA,CAAAC,CAAAA,CACA,YAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,MAAA,CAAAC,CACF,CAAA,CAAIN,CAAAA,CAEEO,CAAAA,CAAQR,EAAM,MAAA,CACdS,CAAAA,CAA6C,IAAI,KAAA,CAAMD,CAAK,CAAA,CAC5DE,CAAAA,CAAa,IAAA,CAAK,KAAI,CAExBC,CAAAA,CAAY,CAAA,CACZC,CAAAA,CAAS,CAAA,CACTC,CAAAA,CAAY,CAAA,CAEhB,SAASC,EAAaC,CAAA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A,UAAA,CAAY,IAAA,CAAK,GAAA,EAAI,CAAIE,CAC3B,CAAC,CAAA,CAEDQ,CAAAA,GAEJ,CAAC,EACL,CACF,CAEAA,CAAAA,GACF,CAAC,CACH","file":"index.js","sourcesContent":["/**\n * Batch Runner — Core\n *\n * Slot-based concurrent processor. Pure control flow — no I/O opinions.\n *\n * @example Step Machine batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { createStepMachine, loadStepFlow } from 'yaml-flow/step-machine';\n *\n * const flow = await loadStepFlow('./support-ticket.yaml');\n * const results = await batch(tickets, {\n * concurrency: 5,\n * processor: async (ticket) => {\n * const machine = createStepMachine(flow, handlers);\n * return machine.run(ticket);\n * },\n * });\n * ```\n *\n * @example Event Graph batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { next, apply, createInitialExecutionState } from 'yaml-flow/event-graph';\n *\n * const results = await batch(items, {\n * concurrency: 3,\n * processor: async (item, index) => {\n * let state = createInitialExecutionState(graph, `exec-${index}`);\n * state = apply(state, { type: 'inject-tokens', tokens: [item.token], timestamp: new Date().toISOString() }, graph);\n * // ... drive the graph loop\n * return state;\n * },\n * });\n * ```\n */\n\nimport type {\n BatchOptions,\n BatchResult,\n BatchItemResult,\n BatchProgress,\n} from './types.js';\n\n/**\n * Run an array of items through an async processor with concurrency control.\n *\n * - Items are started in order, up to `concurrency` at a time.\n * - Results are returned in the original item order.\n * - If a processor throws, the item is marked as failed; other items continue.\n * - An AbortSignal prevents new items from starting (in-flight items are not cancelled).\n */\nexport async function batch<TItem, TResult>(\n items: TItem[],\n options: BatchOptions<TItem, TResult>\n): Promise<BatchResult<TItem, TResult>> {\n const {\n concurrency = 5,\n processor,\n onItemComplete,\n onItemError,\n onProgress,\n signal,\n } = options;\n\n const total = items.length;\n const results: BatchItemResult<TItem, TResult>[] = new Array(total);\n const batchStart = Date.now();\n\n let completed = 0;\n let failed = 0;\n let nextIndex = 0;\n\n function makeProgress(active: number): BatchProgress {\n const done = completed + failed;\n return {\n completed,\n failed,\n active,\n pending: total - done - active,\n total,\n percent: total === 0 ? 100 : Math.round((done / total) * 100),\n elapsedMs: Date.now() - batchStart,\n };\n }\n\n // Empty input — short-circuit\n if (total === 0) {\n return { items: [], completed: 0, failed: 0, total: 0, durationMs: 0 };\n }\n\n return new Promise<BatchResult<TItem, TResult>>((resolve) => {\n let active = 0;\n\n function tryStartNext() {\n while (active < concurrency && nextIndex < total) {\n // Respect abort signal — don't start new items\n if (signal?.aborted) {\n // Mark remaining as failed with abort error\n while (nextIndex < total) {\n const idx = nextIndex++;\n results[idx] = {\n item: items[idx],\n index: idx,\n status: 'failed',\n error: new Error('Batch aborted'),\n durationMs: 0,\n };\n failed++;\n }\n // If nothing is in-flight, resolve immediately\n if (active === 0 && completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n }\n break;\n }\n\n const idx = nextIndex++;\n const item = items[idx];\n active++;\n const itemStart = Date.now();\n\n processor(item, idx)\n .then((result) => {\n results[idx] = {\n item,\n index: idx,\n status: 'completed',\n result,\n durationMs: Date.now() - itemStart,\n };\n completed++;\n onItemComplete?.(item, result, idx);\n })\n .catch((err) => {\n const error = err instanceof Error ? err : new Error(String(err));\n results[idx] = {\n item,\n index: idx,\n status: 'failed',\n error,\n durationMs: Date.now() - itemStart,\n };\n failed++;\n onItemError?.(item, error, idx);\n })\n .finally(() => {\n active--;\n onProgress?.(makeProgress(active));\n\n if (completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n } else {\n tryStartNext();\n }\n });\n }\n }\n\n tryStartNext();\n });\n}\n"]}
@@ -0,0 +1,136 @@
1
+ import { f as GraphEvent, G as GraphConfig } from './types-BBhqYGhE.cjs';
2
+
3
+ /**
4
+ * board-live-cards-lib — Pure logic library for the board-live-cards CLI.
5
+ *
6
+ * Merged from:
7
+ * board-live-cards-all-stores.ts
8
+ * board-live-cards-lib-types.ts
9
+ * board-live-cards-lib-board-status.ts
10
+ * board-live-cards-lib-card-handler.ts
11
+ * board-live-cards-cli-board-commands.ts
12
+ * board-live-cards-cli-card-commands.ts
13
+ * board-live-cards-cli-callbacks.ts
14
+ *
15
+ * Zero platform imports. All storage is injected via adapter interfaces.
16
+ * Safe for Node, browser, and neutral (V8/PyMiniRacer) bundles.
17
+ */
18
+
19
+ interface LiveCard {
20
+ id: string;
21
+ [key: string]: unknown;
22
+ }
23
+ interface CardIndexEntry {
24
+ /** Storage-specific address (file path, Cosmos doc id, localStorage key). */
25
+ key: string;
26
+ /** Checksum of card content — computed by the adapter at write time. */
27
+ checksum: string;
28
+ updatedAt: string;
29
+ }
30
+ type CardIndex = Record<string, CardIndexEntry>;
31
+ type CardChecksumIndex = Record<string, string>;
32
+ interface CardStorageAdapter {
33
+ readIndex(): CardIndex | null;
34
+ writeIndex(index: CardIndex): void;
35
+ readCard(key: string): LiveCard | null;
36
+ /** Write card content; returns checksum of what was written. */
37
+ writeCard(key: string, card: LiveCard): string;
38
+ cardExists(key: string): boolean;
39
+ defaultCardKey(cardId: string): string;
40
+ }
41
+ interface CardStore {
42
+ readCard(id: string): LiveCard | null;
43
+ readCardKey(id: string): string | null;
44
+ readAllCards(): LiveCard[];
45
+ readChecksumIndex(): CardChecksumIndex;
46
+ changedSince(snapshotChecksumIndex: CardChecksumIndex): string[];
47
+ }
48
+ interface CardUpsertValidation {
49
+ ok: boolean;
50
+ error?: string;
51
+ }
52
+ interface CardAdminStore extends CardStore {
53
+ validateUpsert(id: string, cardKey: string): CardUpsertValidation;
54
+ writeCard(id: string, card: LiveCard, cardKey?: string): void;
55
+ patchCard(id: string, jsonPath: string, value: unknown): void;
56
+ removeCard(id: string): void;
57
+ readIndex(): CardIndex;
58
+ }
59
+ declare function createCardStore(adapter: CardStorageAdapter, onWarn?: (msg: string) => void): CardAdminStore;
60
+ interface JournalEntry {
61
+ id: string;
62
+ event: GraphEvent;
63
+ }
64
+ interface JournalStorageAdapter {
65
+ readAllEntries(): JournalEntry[];
66
+ appendEntry(entry: JournalEntry): void;
67
+ generateId(): string;
68
+ }
69
+ declare const SNAPSHOT_SCHEMA_VERSION_V1 = "v1";
70
+ declare const BOARD_GRAPH_KEY = "board/graph";
71
+ type OutputStoreEvent = {
72
+ kind: 'computed_values';
73
+ cardId: string;
74
+ values: Record<string, unknown>;
75
+ } | {
76
+ kind: 'data_object';
77
+ key: string;
78
+ payload: unknown;
79
+ } | {
80
+ kind: 'status';
81
+ status: unknown;
82
+ };
83
+ interface BoardStatusCard {
84
+ name: string;
85
+ status: string;
86
+ error?: {
87
+ message: string;
88
+ code?: string;
89
+ at?: string;
90
+ source?: 'task-runtime' | 'source-fetch' | 'timeout' | 'unknown';
91
+ };
92
+ requires: string[];
93
+ requires_satisfied: string[];
94
+ requires_missing: string[];
95
+ provides_declared: string[];
96
+ provides_runtime: string[];
97
+ blocked_by: string[];
98
+ unblocks: string[];
99
+ runtime: {
100
+ attempt_count: number;
101
+ restart_count: number;
102
+ in_progress_since: string | null;
103
+ last_transition_at: string | null;
104
+ last_completed_at: string | null;
105
+ last_restarted_at: string | null;
106
+ status_age_ms: number | null;
107
+ };
108
+ }
109
+ interface BoardStatusObject {
110
+ schema_version: 'v1';
111
+ meta: {
112
+ board: {
113
+ path: string;
114
+ };
115
+ };
116
+ summary: {
117
+ card_count: number;
118
+ completed: number;
119
+ eligible: number;
120
+ pending: number;
121
+ blocked: number;
122
+ unresolved: number;
123
+ failed?: number;
124
+ in_progress?: number;
125
+ orphan_cards?: number;
126
+ topology?: {
127
+ edge_count: number;
128
+ max_fan_out_card: string | null;
129
+ max_fan_out: number;
130
+ };
131
+ };
132
+ cards: BoardStatusCard[];
133
+ }
134
+ declare const EMPTY_CONFIG: GraphConfig;
135
+
136
+ export { type BoardStatusObject as B, type CardAdminStore as C, EMPTY_CONFIG as E, type JournalStorageAdapter as J, type LiveCard as L, type OutputStoreEvent as O, SNAPSHOT_SCHEMA_VERSION_V1 as S, BOARD_GRAPH_KEY as a, createCardStore as c };
@@ -0,0 +1,136 @@
1
+ import { f as GraphEvent, G as GraphConfig } from './types-BBhqYGhE.js';
2
+
3
+ /**
4
+ * board-live-cards-lib — Pure logic library for the board-live-cards CLI.
5
+ *
6
+ * Merged from:
7
+ * board-live-cards-all-stores.ts
8
+ * board-live-cards-lib-types.ts
9
+ * board-live-cards-lib-board-status.ts
10
+ * board-live-cards-lib-card-handler.ts
11
+ * board-live-cards-cli-board-commands.ts
12
+ * board-live-cards-cli-card-commands.ts
13
+ * board-live-cards-cli-callbacks.ts
14
+ *
15
+ * Zero platform imports. All storage is injected via adapter interfaces.
16
+ * Safe for Node, browser, and neutral (V8/PyMiniRacer) bundles.
17
+ */
18
+
19
+ interface LiveCard {
20
+ id: string;
21
+ [key: string]: unknown;
22
+ }
23
+ interface CardIndexEntry {
24
+ /** Storage-specific address (file path, Cosmos doc id, localStorage key). */
25
+ key: string;
26
+ /** Checksum of card content — computed by the adapter at write time. */
27
+ checksum: string;
28
+ updatedAt: string;
29
+ }
30
+ type CardIndex = Record<string, CardIndexEntry>;
31
+ type CardChecksumIndex = Record<string, string>;
32
+ interface CardStorageAdapter {
33
+ readIndex(): CardIndex | null;
34
+ writeIndex(index: CardIndex): void;
35
+ readCard(key: string): LiveCard | null;
36
+ /** Write card content; returns checksum of what was written. */
37
+ writeCard(key: string, card: LiveCard): string;
38
+ cardExists(key: string): boolean;
39
+ defaultCardKey(cardId: string): string;
40
+ }
41
+ interface CardStore {
42
+ readCard(id: string): LiveCard | null;
43
+ readCardKey(id: string): string | null;
44
+ readAllCards(): LiveCard[];
45
+ readChecksumIndex(): CardChecksumIndex;
46
+ changedSince(snapshotChecksumIndex: CardChecksumIndex): string[];
47
+ }
48
+ interface CardUpsertValidation {
49
+ ok: boolean;
50
+ error?: string;
51
+ }
52
+ interface CardAdminStore extends CardStore {
53
+ validateUpsert(id: string, cardKey: string): CardUpsertValidation;
54
+ writeCard(id: string, card: LiveCard, cardKey?: string): void;
55
+ patchCard(id: string, jsonPath: string, value: unknown): void;
56
+ removeCard(id: string): void;
57
+ readIndex(): CardIndex;
58
+ }
59
+ declare function createCardStore(adapter: CardStorageAdapter, onWarn?: (msg: string) => void): CardAdminStore;
60
+ interface JournalEntry {
61
+ id: string;
62
+ event: GraphEvent;
63
+ }
64
+ interface JournalStorageAdapter {
65
+ readAllEntries(): JournalEntry[];
66
+ appendEntry(entry: JournalEntry): void;
67
+ generateId(): string;
68
+ }
69
+ declare const SNAPSHOT_SCHEMA_VERSION_V1 = "v1";
70
+ declare const BOARD_GRAPH_KEY = "board/graph";
71
+ type OutputStoreEvent = {
72
+ kind: 'computed_values';
73
+ cardId: string;
74
+ values: Record<string, unknown>;
75
+ } | {
76
+ kind: 'data_object';
77
+ key: string;
78
+ payload: unknown;
79
+ } | {
80
+ kind: 'status';
81
+ status: unknown;
82
+ };
83
+ interface BoardStatusCard {
84
+ name: string;
85
+ status: string;
86
+ error?: {
87
+ message: string;
88
+ code?: string;
89
+ at?: string;
90
+ source?: 'task-runtime' | 'source-fetch' | 'timeout' | 'unknown';
91
+ };
92
+ requires: string[];
93
+ requires_satisfied: string[];
94
+ requires_missing: string[];
95
+ provides_declared: string[];
96
+ provides_runtime: string[];
97
+ blocked_by: string[];
98
+ unblocks: string[];
99
+ runtime: {
100
+ attempt_count: number;
101
+ restart_count: number;
102
+ in_progress_since: string | null;
103
+ last_transition_at: string | null;
104
+ last_completed_at: string | null;
105
+ last_restarted_at: string | null;
106
+ status_age_ms: number | null;
107
+ };
108
+ }
109
+ interface BoardStatusObject {
110
+ schema_version: 'v1';
111
+ meta: {
112
+ board: {
113
+ path: string;
114
+ };
115
+ };
116
+ summary: {
117
+ card_count: number;
118
+ completed: number;
119
+ eligible: number;
120
+ pending: number;
121
+ blocked: number;
122
+ unresolved: number;
123
+ failed?: number;
124
+ in_progress?: number;
125
+ orphan_cards?: number;
126
+ topology?: {
127
+ edge_count: number;
128
+ max_fan_out_card: string | null;
129
+ max_fan_out: number;
130
+ };
131
+ };
132
+ cards: BoardStatusCard[];
133
+ }
134
+ declare const EMPTY_CONFIG: GraphConfig;
135
+
136
+ export { type BoardStatusObject as B, type CardAdminStore as C, EMPTY_CONFIG as E, type JournalStorageAdapter as J, type LiveCard as L, type OutputStoreEvent as O, SNAPSHOT_SCHEMA_VERSION_V1 as S, BOARD_GRAPH_KEY as a, createCardStore as c };