yaml-flow 3.1.0 → 4.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 (149) hide show
  1. package/README.md +81 -20
  2. package/board-live-cards-cli.js +37 -0
  3. package/browser/card-compute.js +132 -431
  4. package/browser/live-cards.js +41 -27
  5. package/browser/live-cards.schema.json +59 -77
  6. package/dist/card-compute/index.cjs +135 -415
  7. package/dist/card-compute/index.cjs.map +1 -1
  8. package/dist/card-compute/index.d.cts +52 -49
  9. package/dist/card-compute/index.d.ts +52 -49
  10. package/dist/card-compute/index.js +134 -415
  11. package/dist/card-compute/index.js.map +1 -1
  12. package/dist/cli/board-live-cards-cli.cjs +2379 -0
  13. package/dist/cli/board-live-cards-cli.cjs.map +1 -0
  14. package/dist/cli/board-live-cards-cli.d.cts +213 -0
  15. package/dist/cli/board-live-cards-cli.d.ts +213 -0
  16. package/dist/cli/board-live-cards-cli.js +2332 -0
  17. package/dist/cli/board-live-cards-cli.js.map +1 -0
  18. package/dist/{constants-B2zqu10b.d.ts → constants-DuzE5n03.d.ts} +2 -2
  19. package/dist/{constants-DJZU1pwJ.d.cts → constants-ozjf1Ejw.d.cts} +2 -2
  20. package/dist/continuous-event-graph/index.cjs +201 -448
  21. package/dist/continuous-event-graph/index.cjs.map +1 -1
  22. package/dist/continuous-event-graph/index.d.cts +16 -340
  23. package/dist/continuous-event-graph/index.d.ts +16 -340
  24. package/dist/continuous-event-graph/index.js +198 -448
  25. package/dist/continuous-event-graph/index.js.map +1 -1
  26. package/dist/event-graph/index.cjs +4 -4
  27. package/dist/event-graph/index.cjs.map +1 -1
  28. package/dist/event-graph/index.d.cts +5 -5
  29. package/dist/event-graph/index.d.ts +5 -5
  30. package/dist/event-graph/index.js +4 -4
  31. package/dist/event-graph/index.js.map +1 -1
  32. package/dist/index.cjs +278 -533
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +8 -7
  35. package/dist/index.d.ts +8 -7
  36. package/dist/index.js +278 -533
  37. package/dist/index.js.map +1 -1
  38. package/dist/inference/index.cjs +138 -19
  39. package/dist/inference/index.cjs.map +1 -1
  40. package/dist/inference/index.d.cts +2 -2
  41. package/dist/inference/index.d.ts +2 -2
  42. package/dist/inference/index.js +138 -19
  43. package/dist/inference/index.js.map +1 -1
  44. package/dist/journal-BJDjWb5Q.d.cts +343 -0
  45. package/dist/journal-B_2JnBMF.d.ts +343 -0
  46. package/dist/step-machine/index.cjs +18 -1
  47. package/dist/step-machine/index.cjs.map +1 -1
  48. package/dist/step-machine/index.d.cts +2 -2
  49. package/dist/step-machine/index.d.ts +2 -2
  50. package/dist/step-machine/index.js +18 -1
  51. package/dist/step-machine/index.js.map +1 -1
  52. package/dist/stores/file.d.cts +1 -1
  53. package/dist/stores/file.d.ts +1 -1
  54. package/dist/stores/index.d.cts +1 -1
  55. package/dist/stores/index.d.ts +1 -1
  56. package/dist/stores/localStorage.d.cts +1 -1
  57. package/dist/stores/localStorage.d.ts +1 -1
  58. package/dist/stores/memory.d.cts +1 -1
  59. package/dist/stores/memory.d.ts +1 -1
  60. package/dist/{types-BwvgvlOO.d.cts → types-BzLD8bjb.d.cts} +1 -1
  61. package/dist/{types-ClRA8hzC.d.ts → types-C2eJ7DAV.d.ts} +1 -1
  62. package/dist/{types-DEj7OakX.d.cts → types-CMFSIjpc.d.cts} +39 -4
  63. package/dist/{types-DEj7OakX.d.ts → types-CMFSIjpc.d.ts} +39 -4
  64. package/dist/{types-FZ_eyErS.d.cts → types-ycun84cq.d.cts} +1 -0
  65. package/dist/{types-FZ_eyErS.d.ts → types-ycun84cq.d.ts} +1 -0
  66. package/dist/{validate-DEZ2Ymdb.d.ts → validate-DJQTQ6bP.d.ts} +1 -1
  67. package/dist/{validate-DqKTZg_o.d.cts → validate-ke92Cleg.d.cts} +1 -1
  68. package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +22 -0
  69. package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +16 -0
  70. package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +15 -0
  71. package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +15 -0
  72. package/examples/browser/boards/portfolio-tracker/fetch-prices.js +43 -0
  73. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +7 -0
  74. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +189 -0
  75. package/examples/browser/livecards-browser/index.html +688 -0
  76. package/examples/browser/step-machine-browser/index.html +367 -0
  77. package/examples/cli/step-machine-cli/portfolio-tracker/cards/holdings-table.json +22 -0
  78. package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +43 -0
  79. package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +15 -0
  80. package/examples/cli/step-machine-cli/portfolio-tracker/cards/price-fetch.json +15 -0
  81. package/examples/cli/step-machine-cli/portfolio-tracker/fetch-prices.js +48 -0
  82. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +58 -0
  83. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +27 -0
  84. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +25 -0
  85. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +29 -0
  86. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +27 -0
  87. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +25 -0
  88. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +37 -0
  89. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +53 -0
  90. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +35 -0
  91. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +227 -0
  92. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +38 -0
  93. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +29 -0
  94. package/examples/cli/step-machine-demo/jsonata-init-board-cli.js +36 -0
  95. package/examples/cli/step-machine-demo/jsonata-init-board.flow.yaml +30 -0
  96. package/examples/cli/step-machine-demo/one-step-cli-only.flow.yaml +19 -0
  97. package/examples/cli/step-machine-demo/step-cli-echo-y.js +15 -0
  98. package/examples/cli/step-machine-demo/step2-double-cli.js +39 -0
  99. package/examples/cli/step-machine-demo/two-step-math-handlers.js +32 -0
  100. package/examples/cli/step-machine-demo/two-step-math.flow.yaml +31 -0
  101. package/examples/cli/step-machine-demo/two-step-mixed-handlers.js +24 -0
  102. package/examples/cli/step-machine-demo/two-step-mixed.flow.yaml +35 -0
  103. package/examples/index.html +792 -0
  104. package/examples/ingest.js +733 -0
  105. package/examples/npm-libs/batch/batch-step-machine.ts +121 -0
  106. package/examples/npm-libs/continuous-event-graph/live-cards-board.ts +215 -0
  107. package/examples/npm-libs/continuous-event-graph/live-portfolio-dashboard.ts +555 -0
  108. package/examples/npm-libs/continuous-event-graph/portfolio-tracker.ts +287 -0
  109. package/examples/npm-libs/continuous-event-graph/reactive-monitoring.ts +265 -0
  110. package/examples/npm-libs/continuous-event-graph/reactive-pipeline.ts +168 -0
  111. package/examples/npm-libs/continuous-event-graph/soc-incident-board.ts +287 -0
  112. package/examples/npm-libs/continuous-event-graph/stock-dashboard.ts +229 -0
  113. package/examples/npm-libs/event-graph/ci-cd-pipeline.ts +243 -0
  114. package/examples/npm-libs/event-graph/executor-diamond.ts +165 -0
  115. package/examples/npm-libs/event-graph/executor-pipeline.ts +161 -0
  116. package/examples/npm-libs/event-graph/research-pipeline.ts +137 -0
  117. package/examples/npm-libs/flows/ai-conversation.yaml +116 -0
  118. package/examples/npm-libs/flows/order-processing.yaml +143 -0
  119. package/examples/npm-libs/flows/simple-greeting.yaml +54 -0
  120. package/examples/npm-libs/graph-of-graphs/multi-stage-etl.ts +307 -0
  121. package/examples/npm-libs/graph-of-graphs/url-processing-pipeline.ts +254 -0
  122. package/examples/npm-libs/inference/azure-deployment.ts +149 -0
  123. package/examples/npm-libs/inference/copilot-cli.ts +138 -0
  124. package/examples/npm-libs/inference/data-pipeline.ts +145 -0
  125. package/examples/npm-libs/inference/pluggable-adapters.ts +254 -0
  126. package/examples/npm-libs/node/ai-conversation.ts +195 -0
  127. package/examples/npm-libs/node/simple-greeting.ts +101 -0
  128. package/examples/step-machine-cli/portfolio-tracker/cards/holdings-table.json +22 -0
  129. package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +43 -0
  130. package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +15 -0
  131. package/examples/step-machine-cli/portfolio-tracker/cards/price-fetch.json +15 -0
  132. package/examples/step-machine-cli/portfolio-tracker/fetch-prices.js +48 -0
  133. package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +58 -0
  134. package/examples/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +27 -0
  135. package/examples/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +25 -0
  136. package/examples/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +29 -0
  137. package/examples/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +27 -0
  138. package/examples/step-machine-cli/portfolio-tracker/handlers/status-cli.js +25 -0
  139. package/examples/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +37 -0
  140. package/examples/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +53 -0
  141. package/examples/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +35 -0
  142. package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +227 -0
  143. package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +38 -0
  144. package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +29 -0
  145. package/package.json +14 -2
  146. package/schema/board-status.schema.json +118 -0
  147. package/schema/flow.schema.json +5 -0
  148. package/schema/live-cards.schema.json +59 -77
  149. package/step-machine-cli.js +674 -0
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readStdinJson, runBoardCli, writeFailure, writeResult } from './_board-cli.js';
4
+
5
+ try {
6
+ const input = await readStdinJson();
7
+ const boardDir = String(input.BOARD_DIR ?? '').trim();
8
+
9
+ if (!boardDir) {
10
+ writeFailure('BOARD_DIR is required');
11
+ process.exit(0);
12
+ }
13
+
14
+ const status = runBoardCli(['status', '--rg', boardDir], { capture: true });
15
+
16
+ writeResult({
17
+ result: 'success',
18
+ data: {
19
+ status,
20
+ },
21
+ });
22
+ } catch (error) {
23
+ const message = error instanceof Error ? error.message : String(error);
24
+ writeFailure(message);
25
+ }
@@ -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 { readStdinJson, runBoardCli, writeFailure, writeResult } from './_board-cli.js';
6
+
7
+ try {
8
+ const input = await readStdinJson();
9
+ const boardDir = String(input.BOARD_DIR ?? '').trim();
10
+ const cardsDir = String(input.CARDS_DIR ?? '').trim();
11
+ const holdings = input.HOLDINGS;
12
+
13
+ if (!boardDir || !cardsDir || !Array.isArray(holdings)) {
14
+ writeFailure('BOARD_DIR, CARDS_DIR and HOLDINGS array are required');
15
+ process.exit(0);
16
+ }
17
+
18
+ const cardPath = path.join(cardsDir, 'portfolio-form.json');
19
+ const raw = fs.readFileSync(cardPath, 'utf-8');
20
+ const card = JSON.parse(raw);
21
+ card.state = card.state ?? {};
22
+ card.state.holdings = holdings;
23
+ fs.writeFileSync(cardPath, `${JSON.stringify(card, null, 2)}\n`, 'utf-8');
24
+
25
+ runBoardCli(['update-card', '--rg', boardDir, '--card-id', 'portfolio-form', '--restart']);
26
+
27
+ writeResult({
28
+ result: 'success',
29
+ data: {
30
+ saved: true,
31
+ holdings_count: holdings.length,
32
+ },
33
+ });
34
+ } catch (error) {
35
+ const message = error instanceof Error ? error.message : String(error);
36
+ writeFailure(message);
37
+ }
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readStdinJson, runBoardCli, writeFailure, writeResult } from './_board-cli.js';
4
+
5
+ function sleep(ms) {
6
+ return new Promise((resolve) => setTimeout(resolve, ms));
7
+ }
8
+
9
+ try {
10
+ const input = await readStdinJson();
11
+ const boardDir = String(input.BOARD_DIR ?? '').trim();
12
+ const tasks = Array.isArray(input.COMPLETION_TASKS) ? input.COMPLETION_TASKS : [];
13
+ const label = String(input.LABEL ?? 'WAIT');
14
+ const timeoutMs = Number(input.TIMEOUT_MS ?? 30000);
15
+ const pollMs = Number(input.POLL_MS ?? 500);
16
+
17
+ if (!boardDir || tasks.length === 0) {
18
+ writeFailure('BOARD_DIR and COMPLETION_TASKS are required');
19
+ process.exit(0);
20
+ }
21
+
22
+ const started = Date.now();
23
+
24
+ while (Date.now() - started < timeoutMs) {
25
+ const status = runBoardCli(['status', '--rg', boardDir], { capture: true });
26
+ const complete = tasks.every((task) => new RegExp(`\\bcompleted\\s+${task}\\b`).test(status));
27
+
28
+ if (complete) {
29
+ writeResult({
30
+ result: 'success',
31
+ data: {
32
+ label,
33
+ completed: true,
34
+ },
35
+ });
36
+ process.exit(0);
37
+ }
38
+
39
+ await sleep(pollMs);
40
+ }
41
+
42
+ writeResult({
43
+ result: 'timeout',
44
+ data: {
45
+ label,
46
+ completed: false,
47
+ error: `${label}: timed out waiting for completion`,
48
+ },
49
+ });
50
+ } catch (error) {
51
+ const message = error instanceof Error ? error.message : String(error);
52
+ writeFailure(message);
53
+ }
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+
3
+ import * as fs from 'node:fs';
4
+ import * as path from 'node:path';
5
+ import { readStdinJson, writeFailure, writeResult } from './_board-cli.js';
6
+
7
+ try {
8
+ const input = await readStdinJson();
9
+ const boardDirInput = String(input.BOARD_DIR ?? '').trim();
10
+ const tmpFileName = String(input.TMP_FILE_NAME ?? '').trim() || 'tmp_file1';
11
+ const prices = input.PRICES;
12
+
13
+ if (!boardDirInput || !prices || typeof prices !== 'object' || Array.isArray(prices)) {
14
+ writeFailure('BOARD_DIR and PRICES object are required');
15
+ process.exit(0);
16
+ }
17
+
18
+ const boardDir = path.resolve(boardDirInput);
19
+ const payload = JSON.stringify(prices);
20
+ const tmpFile = path.join(boardDir, tmpFileName);
21
+
22
+ fs.mkdirSync(path.dirname(tmpFile), { recursive: true });
23
+ fs.writeFileSync(tmpFile, payload, 'utf-8');
24
+
25
+ writeResult({
26
+ result: 'success',
27
+ data: {
28
+ wrote: true,
29
+ tmp_file: tmpFile,
30
+ },
31
+ });
32
+ } catch (error) {
33
+ const message = error instanceof Error ? error.message : String(error);
34
+ writeFailure(message);
35
+ }
@@ -0,0 +1,227 @@
1
+ id: portfolio-tracker-step-machine
2
+ handler_vars:
3
+ BOARDCLI_CMD: ../../../../board-live-cards-cli.js
4
+ TMP_FILE_NAME: tmp_file1
5
+ settings:
6
+ start_step: t0_reset_board
7
+ max_total_steps: 150
8
+ timeout_ms: 300000
9
+
10
+ steps:
11
+ t0_reset_board:
12
+ description: Reset board runtime directory for idempotent reruns
13
+ expects_data: [runtime_root, board_name]
14
+ produces_data: [board_dir]
15
+ handler:
16
+ cli: node ./handlers/reset-board-dir-cli.js
17
+ input-transforms:
18
+ BOARD_DIR: runtime_root & "/" & board_name
19
+ output-transforms:
20
+ board_dir: data.board_dir
21
+ transitions:
22
+ success: t0_init_board
23
+ failure_transitions:
24
+ failure: failed_state
25
+
26
+ t0_init_board:
27
+ description: Initialize board runtime directory
28
+ expects_data: [board_dir]
29
+ produces_data: [board_dir]
30
+ handler:
31
+ cli: node %%BOARDCLI_CMD%% init "%%BOARD_DIR%%"
32
+ result-mode: exit-code
33
+ input-transforms:
34
+ BOARD_DIR: board_dir
35
+ output-transforms:
36
+ board_dir: BOARD_DIR
37
+ transitions:
38
+ success: t0_add_cards
39
+ failure_transitions:
40
+ failure: failed_state
41
+
42
+ t0_add_cards:
43
+ description: Add local portfolio cards
44
+ expects_data: [board_dir, cards_template_dir]
45
+ produces_data: [cards_dir]
46
+ handler:
47
+ cli: node %%BOARDCLI_CMD%% add-cards --rg "%%BOARD_DIR%%" --card-glob "%%CARDS_GLOB%%"
48
+ result-mode: exit-code
49
+ input-transforms:
50
+ BOARD_DIR: board_dir
51
+ CARDS_GLOB: cards_template_dir & "/*.json"
52
+ output-transforms:
53
+ cards_dir: cards_template_dir
54
+ transitions:
55
+ success: t1_write_prices
56
+ failure_transitions:
57
+ failure: failed_state
58
+
59
+ t1_write_prices:
60
+ description: Write baseline prices
61
+ expects_data: [board_dir, prices_t1]
62
+ produces_data: [prices_written_t1]
63
+ handler:
64
+ cli: node ./handlers/write-prices-cli.js
65
+ input-transforms:
66
+ BOARD_DIR: board_dir
67
+ TMP_FILE_NAME: TMP_FILE_NAME
68
+ PRICES: prices_t1
69
+ output-transforms:
70
+ prices_written_t1: data.wrote
71
+ transitions:
72
+ success: t1_wait
73
+ failure_transitions:
74
+ failure: failed_state
75
+
76
+ t1_wait:
77
+ description: Wait for cards to complete after T1
78
+ expects_data: [board_dir, completion_tasks]
79
+ produces_data: [t1_done]
80
+ handler:
81
+ cli: node ./handlers/wait-completed-cli.js
82
+ input-transforms:
83
+ BOARD_DIR: board_dir
84
+ COMPLETION_TASKS: completion_tasks
85
+ LABEL: "'T1'"
86
+ TIMEOUT_MS: "60000"
87
+ POLL_MS: "500"
88
+ output-transforms:
89
+ t1_done: data.completed
90
+ transitions:
91
+ success: t2_update_holdings
92
+ failure_transitions:
93
+ timeout: failed_state
94
+ failure: failed_state
95
+
96
+ t2_update_holdings:
97
+ description: Add GOOG position to holdings
98
+ expects_data: [board_dir, cards_dir, holdings_t2]
99
+ produces_data: [t2_holdings_saved]
100
+ handler:
101
+ cli: node ./handlers/update-holdings-cli.js
102
+ input-transforms:
103
+ BOARD_DIR: board_dir
104
+ CARDS_DIR: cards_dir
105
+ HOLDINGS: holdings_t2
106
+ output-transforms:
107
+ t2_holdings_saved: data.saved
108
+ transitions:
109
+ success: t2_write_prices
110
+ failure_transitions:
111
+ failure: failed_state
112
+
113
+ t2_write_prices:
114
+ description: Write prices after T2 holdings update
115
+ expects_data: [board_dir, prices_t2]
116
+ produces_data: [prices_written_t2]
117
+ handler:
118
+ cli: node ./handlers/write-prices-cli.js
119
+ input-transforms:
120
+ BOARD_DIR: board_dir
121
+ TMP_FILE_NAME: TMP_FILE_NAME
122
+ PRICES: prices_t2
123
+ output-transforms:
124
+ prices_written_t2: data.wrote
125
+ transitions:
126
+ success: t2_wait
127
+ failure_transitions:
128
+ failure: failed_state
129
+
130
+ t2_wait:
131
+ description: Wait for cards to complete after T2
132
+ expects_data: [board_dir, completion_tasks]
133
+ produces_data: [t2_done]
134
+ handler:
135
+ cli: node ./handlers/wait-completed-cli.js
136
+ input-transforms:
137
+ BOARD_DIR: board_dir
138
+ COMPLETION_TASKS: completion_tasks
139
+ LABEL: "'T2'"
140
+ TIMEOUT_MS: "60000"
141
+ POLL_MS: "500"
142
+ output-transforms:
143
+ t2_done: data.completed
144
+ transitions:
145
+ success: t3_retrigger
146
+ failure_transitions:
147
+ timeout: failed_state
148
+ failure: failed_state
149
+
150
+ t3_retrigger:
151
+ description: Retrigger price-fetch task
152
+ expects_data: [board_dir, price_fetch_task]
153
+ produces_data: [t3_retriggered]
154
+ handler:
155
+ cli: node %%BOARDCLI_CMD%% retrigger --rg "%%BOARD_DIR%%" --task "%%TASK%%"
156
+ result-mode: exit-code
157
+ input-transforms:
158
+ BOARD_DIR: board_dir
159
+ TASK: price_fetch_task
160
+ output-transforms:
161
+ t3_retriggered: true
162
+ transitions:
163
+ success: t3_write_prices
164
+ failure_transitions:
165
+ failure: failed_state
166
+
167
+ t3_write_prices:
168
+ description: Write final refreshed prices
169
+ expects_data: [board_dir, prices_t3]
170
+ produces_data: [prices_written_t3]
171
+ handler:
172
+ cli: node ./handlers/write-prices-cli.js
173
+ input-transforms:
174
+ BOARD_DIR: board_dir
175
+ TMP_FILE_NAME: TMP_FILE_NAME
176
+ PRICES: prices_t3
177
+ output-transforms:
178
+ prices_written_t3: data.wrote
179
+ transitions:
180
+ success: t3_wait
181
+ failure_transitions:
182
+ failure: failed_state
183
+
184
+ t3_wait:
185
+ description: Wait for cards to complete after T3
186
+ expects_data: [board_dir, completion_tasks]
187
+ produces_data: [t3_done]
188
+ handler:
189
+ cli: node ./handlers/wait-completed-cli.js
190
+ input-transforms:
191
+ BOARD_DIR: board_dir
192
+ COMPLETION_TASKS: completion_tasks
193
+ LABEL: "'T3'"
194
+ TIMEOUT_MS: "60000"
195
+ POLL_MS: "500"
196
+ output-transforms:
197
+ t3_done: data.completed
198
+ transitions:
199
+ success: t4_status
200
+ failure_transitions:
201
+ timeout: failed_state
202
+ failure: failed_state
203
+
204
+ t4_status:
205
+ description: Capture final board status
206
+ expects_data: [board_dir]
207
+ produces_data: [final_status]
208
+ handler:
209
+ cli: node %%BOARDCLI_CMD%% status --rg "%%BOARD_DIR%%"
210
+ result-mode: exit-code
211
+ input-transforms:
212
+ BOARD_DIR: board_dir
213
+ output-transforms:
214
+ final_status: stdout
215
+ transitions:
216
+ success: success_state
217
+ failure_transitions:
218
+ failure: failed_state
219
+
220
+ terminal_states:
221
+ success_state:
222
+ return_intent: success
223
+ return_artifacts: [board_dir, t1_done, t2_done, t3_done, final_status]
224
+
225
+ failed_state:
226
+ return_intent: failure
227
+ return_artifacts: [error, board_dir, final_status]
@@ -0,0 +1,38 @@
1
+ {
2
+ "runtime_root": "./runtime",
3
+ "board_name": "portfolio-tracker-board",
4
+ "cards_template_dir": "./cards",
5
+ "completion_tasks": [
6
+ "portfolio-form",
7
+ "price-fetch",
8
+ "holdings-table",
9
+ "portfolio-value"
10
+ ],
11
+ "price_fetch_task": "price-fetch",
12
+ "prices_t1": {
13
+ "AAPL": 198.5,
14
+ "MSFT": 425.3,
15
+ "GOOG": 178.9,
16
+ "AMZN": 192.4,
17
+ "TSLA": 168.75
18
+ },
19
+ "holdings_t2": [
20
+ { "symbol": "AAPL", "qty": 50 },
21
+ { "symbol": "MSFT", "qty": 30 },
22
+ { "symbol": "GOOG", "qty": 100 }
23
+ ],
24
+ "prices_t2": {
25
+ "AAPL": 198.5,
26
+ "MSFT": 425.3,
27
+ "GOOG": 178.9,
28
+ "AMZN": 192.4,
29
+ "TSLA": 168.75
30
+ },
31
+ "prices_t3": {
32
+ "AAPL": 205,
33
+ "MSFT": 425.3,
34
+ "GOOG": 178.9,
35
+ "AMZN": 192.4,
36
+ "TSLA": 168.75
37
+ }
38
+ }
@@ -0,0 +1,29 @@
1
+ @echo off
2
+ setlocal
3
+ cd /d "%~dp0"
4
+
5
+ set "BOARD_LIVE_CARDS_NO_SPAWN=1"
6
+ set "EXAMPLE_TEMP_ROOT=%TEMP%\yaml-flow-step-machine-portfolio-tracker"
7
+ set "STORE_DIR=%EXAMPLE_TEMP_ROOT%\store"
8
+ set "RUNTIME_ROOT=%EXAMPLE_TEMP_ROOT%\runtime"
9
+
10
+ if /I "%~1"=="pause" goto :pause
11
+ if /I "%~1"=="resume" goto :resume
12
+ if /I "%~1"=="status" goto :status
13
+ goto :run
14
+
15
+ :pause
16
+ node ..\..\..\..\step-machine-cli.js --store file --store-dir "%STORE_DIR%" --pause
17
+ exit /b %ERRORLEVEL%
18
+
19
+ :resume
20
+ node ..\..\..\..\step-machine-cli.js portfolio-tracker.flow.yaml --store file --store-dir "%STORE_DIR%" --resume
21
+ exit /b %ERRORLEVEL%
22
+
23
+ :status
24
+ node ..\..\..\..\step-machine-cli.js --store file --store-dir "%STORE_DIR%" --status
25
+ exit /b %ERRORLEVEL%
26
+
27
+ :run
28
+ node -e "const fs=require('fs');const cp=require('child_process');const raw=JSON.parse(fs.readFileSync('portfolio-tracker.input.json','utf8'));raw.runtime_root=(process.env.RUNTIME_ROOT||'').replace(/\\/g,'/');const input=JSON.stringify(raw);const r=cp.spawnSync(process.execPath,['..\\..\\..\\..\\step-machine-cli.js','portfolio-tracker.flow.yaml','--store','file','--store-dir',process.env.STORE_DIR,'--initial-data',input],{stdio:'inherit',windowsHide:true,env:{...process.env,BOARD_LIVE_CARDS_NO_SPAWN:'1'}});process.exit(r.status??1);"
29
+ exit /b %ERRORLEVEL%
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+
3
+ let raw = '';
4
+ process.stdin.setEncoding('utf-8');
5
+ process.stdin.on('data', (chunk) => {
6
+ raw += chunk;
7
+ });
8
+
9
+ process.stdin.on('end', () => {
10
+ try {
11
+ const input = JSON.parse(raw || '{}');
12
+ const boardDirFromArg = process.argv[2] ?? '';
13
+ const boardDirFromInput = input.BOARD_DIR ?? '';
14
+
15
+ if (!boardDirFromArg || !boardDirFromInput || boardDirFromArg !== boardDirFromInput) {
16
+ process.stdout.write(JSON.stringify({
17
+ result: 'failure',
18
+ error: 'BOARD_DIR missing or mismatch between cli arg and stdin payload',
19
+ }));
20
+ return;
21
+ }
22
+
23
+ process.stdout.write(JSON.stringify({
24
+ result: 'success',
25
+ data: {
26
+ message: `initialized ${boardDirFromArg}`,
27
+ ignored: 'will be filtered by produces_data',
28
+ },
29
+ }));
30
+ } catch (error) {
31
+ const message = error instanceof Error ? error.message : String(error);
32
+ process.stdout.write(JSON.stringify({ result: 'failure', error: message }));
33
+ }
34
+ });
35
+
36
+ process.stdin.resume();
@@ -0,0 +1,30 @@
1
+ id: jsonata-init-board-demo
2
+ settings:
3
+ start_step: t0_init_board
4
+ max_total_steps: 10
5
+ timeout_ms: 30000
6
+
7
+ steps:
8
+ t0_init_board:
9
+ description: Build board path with JSONata and invoke CLI with command templating
10
+ expects_data: [runtime_root, board_name]
11
+ produces_data: [board_dir, init_message]
12
+ handler:
13
+ cli: node ./jsonata-init-board-cli.js "%%BOARD_DIR%%"
14
+ input-transforms:
15
+ BOARD_DIR: runtime_root & "/" & board_name
16
+ output-transforms:
17
+ board_dir: BOARD_DIR
18
+ init_message: data.message
19
+ transitions:
20
+ success: success_state
21
+ failure: failed_state
22
+
23
+ terminal_states:
24
+ success_state:
25
+ return_intent: success
26
+ return_artifacts: [board_dir, init_message]
27
+
28
+ failed_state:
29
+ return_intent: failure
30
+ return_artifacts: [error]
@@ -0,0 +1,19 @@
1
+ id: one-step-cli-only
2
+ settings:
3
+ start_step: run_cli
4
+ steps:
5
+ run_cli:
6
+ expects_data: [x]
7
+ produces_data: [y]
8
+ handler:
9
+ cli: node ./step-cli-echo-y.js
10
+ transitions:
11
+ success: success_state
12
+ failure: failed_state
13
+ terminal_states:
14
+ success_state:
15
+ return_intent: success
16
+ return_artifacts: [x, y]
17
+ failed_state:
18
+ return_intent: failure
19
+ return_artifacts: [error]
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+
3
+ let raw = '';
4
+ process.stdin.setEncoding('utf-8');
5
+ process.stdin.on('data', (chunk) => { raw += chunk; });
6
+ process.stdin.on('end', () => {
7
+ const input = JSON.parse(raw || '{}');
8
+ const x = Number(input.x);
9
+ if (!Number.isFinite(x)) {
10
+ process.stdout.write(JSON.stringify({ result: 'failure', error: 'x must be numeric' }));
11
+ return;
12
+ }
13
+ process.stdout.write(JSON.stringify({ result: 'success', data: { y: x + 10, z: 999 } }));
14
+ });
15
+ process.stdin.resume();
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+
3
+ let raw = '';
4
+
5
+ process.stdin.setEncoding('utf-8');
6
+ process.stdin.on('data', (chunk) => {
7
+ raw += chunk;
8
+ });
9
+
10
+ process.stdin.on('end', () => {
11
+ try {
12
+ const input = JSON.parse(raw || '{}');
13
+ const c = Number(input.c);
14
+
15
+ if (!Number.isFinite(c)) {
16
+ process.stdout.write(JSON.stringify({
17
+ result: 'failure',
18
+ error: 'step2_double requires numeric c',
19
+ }));
20
+ process.exit(0);
21
+ return;
22
+ }
23
+
24
+ const d = c * 2;
25
+ process.stdout.write(JSON.stringify({
26
+ status: 'success',
27
+ data: {
28
+ a: 123,
29
+ d,
30
+ },
31
+ }));
32
+ } catch (error) {
33
+ const message = error instanceof Error ? error.message : String(error);
34
+ process.stdout.write(JSON.stringify({ result: 'failure', error: message }));
35
+ process.exit(0);
36
+ }
37
+ });
38
+
39
+ process.stdin.resume();
@@ -0,0 +1,32 @@
1
+ export default {
2
+ async step1_add(input) {
3
+ const a = Number(input.a);
4
+ const b = Number(input.b);
5
+
6
+ if (!Number.isFinite(a) || !Number.isFinite(b)) {
7
+ return {
8
+ result: 'failure',
9
+ data: { error: 'step1_add requires numeric input a and b' },
10
+ };
11
+ }
12
+
13
+ const c = a + b;
14
+ console.log(`[step1_add] a=${a}, b=${b}, c=${c}`);
15
+ return { result: 'success', data: { a, b, c } };
16
+ },
17
+
18
+ async step2_double(input) {
19
+ const c = Number(input.c);
20
+
21
+ if (!Number.isFinite(c)) {
22
+ return {
23
+ result: 'failure',
24
+ data: { error: 'step2_double requires numeric input c' },
25
+ };
26
+ }
27
+
28
+ const d = c * 2;
29
+ console.log(`[step2_double] c=${c}, d=${d}`);
30
+ return { result: 'success', data: { d } };
31
+ },
32
+ };
@@ -0,0 +1,31 @@
1
+ id: two-step-math
2
+ settings:
3
+ start_step: step1_add
4
+ max_total_steps: 10
5
+ timeout_ms: 10000
6
+
7
+ steps:
8
+ step1_add:
9
+ description: Compute c = a + b
10
+ expects_data: [a, b]
11
+ produces_data: [c]
12
+ transitions:
13
+ success: step2_double
14
+ failure: failed_state
15
+
16
+ step2_double:
17
+ description: Compute d = c * 2
18
+ expects_data: [c]
19
+ produces_data: [d]
20
+ transitions:
21
+ success: success_state
22
+ failure: failed_state
23
+
24
+ terminal_states:
25
+ success_state:
26
+ return_intent: success
27
+ return_artifacts: [a, b, c, d]
28
+
29
+ failed_state:
30
+ return_intent: failure
31
+ return_artifacts: [error]
@@ -0,0 +1,24 @@
1
+ export default {
2
+ async step1_add(input) {
3
+ const a = Number(input.a);
4
+ const b = Number(input.b);
5
+
6
+ if (!Number.isFinite(a) || !Number.isFinite(b)) {
7
+ return {
8
+ result: 'failure',
9
+ data: { error: 'step1_add expects numeric a and b' },
10
+ };
11
+ }
12
+
13
+ const c = a + b;
14
+
15
+ return {
16
+ result: 'success',
17
+ data: {
18
+ a,
19
+ b,
20
+ c,
21
+ },
22
+ };
23
+ },
24
+ };