yaml-flow 5.4.2 → 6.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 (199) hide show
  1. package/board-live-cards-cli.js +2 -2
  2. package/board-livecards-server-runtime.js +486 -547
  3. package/browser/asset-integrity.json +10 -0
  4. package/browser/board-livegraph-engine.js +2 -1676
  5. package/browser/board-livegraph-engine.js.map +1 -1
  6. package/browser/live-cards.js +347 -26
  7. package/browser/live-cards.schema.json +418 -132
  8. package/card-store.js +37 -0
  9. package/dist/batch/index.cjs +1 -108
  10. package/dist/batch/index.cjs.map +1 -1
  11. package/dist/batch/index.js +1 -106
  12. package/dist/batch/index.js.map +1 -1
  13. package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +136 -0
  14. package/dist/board-live-cards-lib-jM2uYG1v.d.ts +136 -0
  15. package/dist/board-live-cards-public-CltXYgaY.d.cts +314 -0
  16. package/dist/board-live-cards-public-f-E-FAyp.d.ts +314 -0
  17. package/dist/board-livegraph-runtime/index.cjs +2 -1671
  18. package/dist/board-livegraph-runtime/index.cjs.map +1 -1
  19. package/dist/board-livegraph-runtime/index.d.cts +1 -2
  20. package/dist/board-livegraph-runtime/index.d.ts +1 -2
  21. package/dist/board-livegraph-runtime/index.js +2 -1662
  22. package/dist/board-livegraph-runtime/index.js.map +1 -1
  23. package/dist/board-livegraph-runtime/jsonata-sync.cjs +7587 -0
  24. package/dist/card-compute/index.cjs +9 -7159
  25. package/dist/card-compute/index.cjs.map +1 -1
  26. package/dist/card-compute/index.d.cts +22 -0
  27. package/dist/card-compute/index.d.ts +22 -0
  28. package/dist/card-compute/index.js +9 -7145
  29. package/dist/card-compute/index.js.map +1 -1
  30. package/dist/card-compute/jsonata-sync.cjs +7587 -0
  31. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +2 -0
  32. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +1 -0
  33. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +24 -0
  34. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.ts +24 -0
  35. package/dist/cli/browser-api/board-live-cards-browser-adapter.js +2 -0
  36. package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +1 -0
  37. package/dist/cli/browser-api/card-store-browser-api.cjs +2 -0
  38. package/dist/cli/browser-api/card-store-browser-api.cjs.map +1 -0
  39. package/dist/cli/browser-api/card-store-browser-api.d.cts +26 -0
  40. package/dist/cli/browser-api/card-store-browser-api.d.ts +26 -0
  41. package/dist/cli/browser-api/card-store-browser-api.js +2 -0
  42. package/dist/cli/browser-api/card-store-browser-api.js.map +1 -0
  43. package/dist/cli/browser-api/jsonata-sync.cjs +7587 -0
  44. package/dist/cli/node/artifacts-store-cli.cjs +11 -0
  45. package/dist/cli/node/artifacts-store-cli.cjs.map +1 -0
  46. package/dist/cli/node/artifacts-store-cli.d.cts +8 -0
  47. package/dist/cli/node/artifacts-store-cli.d.ts +8 -0
  48. package/dist/cli/node/artifacts-store-cli.js +11 -0
  49. package/dist/cli/node/artifacts-store-cli.js.map +1 -0
  50. package/dist/cli/node/board-live-cards-cli.cjs +15 -0
  51. package/dist/cli/node/board-live-cards-cli.cjs.map +1 -0
  52. package/dist/cli/node/board-live-cards-cli.d.cts +20 -0
  53. package/dist/cli/node/board-live-cards-cli.d.ts +20 -0
  54. package/dist/cli/node/board-live-cards-cli.js +15 -0
  55. package/dist/cli/node/board-live-cards-cli.js.map +1 -0
  56. package/dist/cli/node/card-store-cli.cjs +8 -0
  57. package/dist/cli/node/card-store-cli.cjs.map +1 -0
  58. package/dist/cli/node/card-store-cli.d.cts +15 -0
  59. package/dist/cli/node/card-store-cli.d.ts +15 -0
  60. package/dist/cli/node/card-store-cli.js +8 -0
  61. package/dist/cli/node/card-store-cli.js.map +1 -0
  62. package/dist/cli/node/fs-board-adapter.cjs +14 -0
  63. package/dist/cli/node/fs-board-adapter.cjs.map +1 -0
  64. package/dist/cli/node/fs-board-adapter.d.cts +204 -0
  65. package/dist/cli/node/fs-board-adapter.d.ts +204 -0
  66. package/dist/cli/node/fs-board-adapter.js +14 -0
  67. package/dist/cli/node/fs-board-adapter.js.map +1 -0
  68. package/dist/cli/node/jsonata-sync.cjs +7587 -0
  69. package/dist/cli/node/source-cli-task-executor.cjs +11 -0
  70. package/dist/cli/node/source-cli-task-executor.cjs.map +1 -0
  71. package/dist/cli/node/source-cli-task-executor.d.cts +1 -0
  72. package/dist/cli/node/source-cli-task-executor.d.ts +1 -0
  73. package/dist/cli/node/source-cli-task-executor.js +11 -0
  74. package/dist/cli/node/source-cli-task-executor.js.map +1 -0
  75. package/dist/config/index.cjs +1 -79
  76. package/dist/config/index.cjs.map +1 -1
  77. package/dist/config/index.js +1 -76
  78. package/dist/config/index.js.map +1 -1
  79. package/dist/continuous-event-graph/index.cjs +2 -2129
  80. package/dist/continuous-event-graph/index.cjs.map +1 -1
  81. package/dist/continuous-event-graph/index.d.cts +81 -5
  82. package/dist/continuous-event-graph/index.d.ts +81 -5
  83. package/dist/continuous-event-graph/index.js +2 -2088
  84. package/dist/continuous-event-graph/index.js.map +1 -1
  85. package/dist/continuous-event-graph/jsonata-sync.cjs +7587 -0
  86. package/dist/event-graph/index.cjs +22 -8292
  87. package/dist/event-graph/index.cjs.map +1 -1
  88. package/dist/event-graph/index.js +22 -8237
  89. package/dist/event-graph/index.js.map +1 -1
  90. package/dist/execution-refs.cjs +2 -0
  91. package/dist/execution-refs.cjs.map +1 -0
  92. package/dist/execution-refs.d.cts +222 -0
  93. package/dist/execution-refs.d.ts +222 -0
  94. package/dist/execution-refs.js +2 -0
  95. package/dist/execution-refs.js.map +1 -0
  96. package/dist/index.cjs +29 -13221
  97. package/dist/index.cjs.map +1 -1
  98. package/dist/index.d.cts +2 -4
  99. package/dist/index.d.ts +2 -4
  100. package/dist/index.js +29 -13112
  101. package/dist/index.js.map +1 -1
  102. package/dist/inference/index.cjs +5 -617
  103. package/dist/inference/index.cjs.map +1 -1
  104. package/dist/inference/index.js +5 -610
  105. package/dist/inference/index.js.map +1 -1
  106. package/dist/jsonata-sync.cjs +7587 -0
  107. package/dist/{live-cards-bridge-x5XREkXm.d.cts → live-cards-bridge-BXbVTsna.d.cts} +27 -4
  108. package/dist/{live-cards-bridge-EQjytzI_.d.ts → live-cards-bridge-Ds28XR15.d.ts} +27 -4
  109. package/dist/pycli/quickjs-board-runtime.global.js +9 -0
  110. package/dist/pycli/quickjs-board-runtime.global.js.map +1 -0
  111. package/dist/pycli/quickjs-step-machine-runtime.global.js +5 -0
  112. package/dist/pycli/quickjs-step-machine-runtime.global.js.map +1 -0
  113. package/dist/step-machine/index.cjs +11 -7129
  114. package/dist/step-machine/index.cjs.map +1 -1
  115. package/dist/step-machine/index.js +11 -7113
  116. package/dist/step-machine/index.js.map +1 -1
  117. package/dist/storage-refs.cjs +10 -0
  118. package/dist/storage-refs.cjs.map +1 -0
  119. package/dist/storage-refs.d.cts +92 -0
  120. package/dist/storage-refs.d.ts +92 -0
  121. package/dist/storage-refs.js +10 -0
  122. package/dist/storage-refs.js.map +1 -0
  123. package/dist/stores/file.cjs +1 -114
  124. package/dist/stores/file.cjs.map +1 -1
  125. package/dist/stores/file.js +1 -112
  126. package/dist/stores/file.js.map +1 -1
  127. package/dist/stores/index.cjs +1 -231
  128. package/dist/stores/index.cjs.map +1 -1
  129. package/dist/stores/index.js +1 -227
  130. package/dist/stores/index.js.map +1 -1
  131. package/dist/stores/localStorage.cjs +1 -76
  132. package/dist/stores/localStorage.cjs.map +1 -1
  133. package/dist/stores/localStorage.js +1 -74
  134. package/dist/stores/localStorage.js.map +1 -1
  135. package/dist/stores/memory.cjs +1 -47
  136. package/dist/stores/memory.cjs.map +1 -1
  137. package/dist/stores/memory.js +1 -45
  138. package/dist/stores/memory.js.map +1 -1
  139. package/examples/browser/boards/portfolio-tracker/portfolio-t4.js +292 -0
  140. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.js +218 -0
  141. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +201 -0
  142. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +25 -16
  143. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-public.js +553 -0
  144. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +365 -0
  145. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +1 -0
  146. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +32 -0
  147. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +53 -1
  148. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +15 -6
  149. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +6 -1
  150. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +57 -0
  151. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +1 -1
  152. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +1 -1
  153. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +7 -2
  154. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +6 -2
  155. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +97 -0
  156. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +50 -0
  157. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +44 -0
  158. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +70 -0
  159. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +36 -0
  160. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +26 -0
  161. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +39 -0
  162. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +80 -0
  163. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +25 -172
  164. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +40 -34
  165. package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +46 -0
  166. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +77 -0
  167. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  168. package/examples/example-board/agent-instructions.md +11 -5
  169. package/examples/example-board/demo-chat-handler.js +14 -4
  170. package/examples/example-board/demo-server-config.json +1 -0
  171. package/examples/example-board/demo-server.js +14 -7
  172. package/examples/example-board/demo-shell-browser.html +5 -4
  173. package/examples/example-board/demo-shell-with-server.html +6 -5
  174. package/examples/example-board/demo-task-executor.js +81 -35
  175. package/examples/index.html +0 -14
  176. package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -1
  177. package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  178. package/package.json +39 -3
  179. package/schema/live-cards.schema.json +418 -132
  180. package/dist/cli/board-live-cards-cli.cjs +0 -10650
  181. package/dist/cli/board-live-cards-cli.cjs.map +0 -1
  182. package/dist/cli/board-live-cards-cli.d.cts +0 -179
  183. package/dist/cli/board-live-cards-cli.d.ts +0 -179
  184. package/dist/cli/board-live-cards-cli.js +0 -10598
  185. package/dist/cli/board-live-cards-cli.js.map +0 -1
  186. package/dist/journal-9HEgs7dU.d.ts +0 -28
  187. package/dist/journal-B-JCfQnh.d.cts +0 -28
  188. package/dist/schedule-Cszq9LYY.d.ts +0 -21
  189. package/dist/schedule-qWNL0RQh.d.cts +0 -21
  190. package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +0 -22
  191. package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +0 -16
  192. package/examples/browser/boards/portfolio-tracker/cards/portfolio-risk-assessment.json +0 -28
  193. package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +0 -15
  194. package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +0 -15
  195. package/examples/browser/boards/portfolio-tracker/cards/rebalancing-strategy.json +0 -28
  196. package/examples/browser/boards/portfolio-tracker/fetch-prices.js +0 -43
  197. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
  198. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +0 -7
  199. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +0 -351
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(distCli)) {
14
+ const { cli } = await import(pathToFileUrl(distCli).href);
15
+ await cli(process.argv.slice(2));
16
+ } else if (fs.existsSync(srcCli)) {
17
+ const result = spawnSync(process.execPath, [tsxCli, srcCli, ...process.argv.slice(2)], {
18
+ stdio: 'inherit',
19
+ shell: false,
20
+ windowsHide: true,
21
+ });
22
+
23
+ if (result.error) {
24
+ console.error(`[card-store] Failed to launch dev fallback: ${result.error.message}`);
25
+ process.exit(1);
26
+ }
27
+
28
+ process.exit(result.status ?? 0);
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,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AAA,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.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,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,CAAAA,CAA+B,CACnD,IAAMC,CAAAA,CAAOL,CAAAA,CAAYC,CAAAA,CACzB,OAAO,CACL,UAAAD,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,MAAA,CAAAG,CAAAA,CACA,OAAA,CAASP,CAAAA,CAAQQ,CAAAA,CAAOD,EACxB,KAAA,CAAAP,CAAAA,CACA,OAAA,CAASA,CAAAA,GAAU,EAAI,GAAA,CAAM,IAAA,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,CAChBb,CAAAA,CAAQU,CAAG,CAAA,CAAI,CACb,IAAA,CAAAC,CAAAA,CACA,KAAA,CAAOD,CAAAA,CACP,MAAA,CAAQ,WAAA,CACR,OAAAG,CAAAA,CACA,UAAA,CAAY,IAAA,CAAK,GAAA,EAAI,CAAID,CAC3B,CAAA,CACAV,CAAAA,EAAAA,CACAP,IAAiBgB,CAAAA,CAAME,CAAAA,CAAQH,CAAG,EACpC,CAAC,CAAA,CACA,KAAA,CAAOI,CAAAA,EAAQ,CACd,IAAMC,CAAAA,CAAQD,CAAAA,YAAe,KAAA,CAAQA,CAAAA,CAAM,IAAI,KAAA,CAAM,MAAA,CAAOA,CAAG,CAAC,CAAA,CAChEd,CAAAA,CAAQU,CAAG,CAAA,CAAI,CACb,IAAA,CAAAC,CAAAA,CACA,KAAA,CAAOD,EACP,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"],"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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ACA,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","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CAAQU,CAAG,CAAA,CAAI,CACb,IAAA,CAAAC,CAAAA,CACA,KAAA,CAAOD,EACP,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.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 };