yaml-flow 3.1.1 → 5.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 (194) hide show
  1. package/README.md +81 -20
  2. package/board-live-cards-cli.js +37 -0
  3. package/browser/board-livegraph-runtime.js +1453 -0
  4. package/browser/board-livegraph-runtime.js.map +1 -0
  5. package/browser/card-compute.js +153 -433
  6. package/browser/live-cards.js +868 -115
  7. package/browser/live-cards.schema.json +90 -83
  8. package/dist/board-livegraph-runtime/index.cjs +1448 -0
  9. package/dist/board-livegraph-runtime/index.cjs.map +1 -0
  10. package/dist/board-livegraph-runtime/index.d.cts +101 -0
  11. package/dist/board-livegraph-runtime/index.d.ts +101 -0
  12. package/dist/board-livegraph-runtime/index.js +1441 -0
  13. package/dist/board-livegraph-runtime/index.js.map +1 -0
  14. package/dist/card-compute/index.cjs +266 -431
  15. package/dist/card-compute/index.cjs.map +1 -1
  16. package/dist/card-compute/index.d.cts +77 -49
  17. package/dist/card-compute/index.d.ts +77 -49
  18. package/dist/card-compute/index.js +263 -432
  19. package/dist/card-compute/index.js.map +1 -1
  20. package/dist/cli/board-live-cards-cli.cjs +2750 -0
  21. package/dist/cli/board-live-cards-cli.cjs.map +1 -0
  22. package/dist/cli/board-live-cards-cli.d.cts +205 -0
  23. package/dist/cli/board-live-cards-cli.d.ts +205 -0
  24. package/dist/cli/board-live-cards-cli.js +2702 -0
  25. package/dist/cli/board-live-cards-cli.js.map +1 -0
  26. package/dist/{constants-B2zqu10b.d.ts → constants-DuzE5n03.d.ts} +2 -2
  27. package/dist/{constants-DJZU1pwJ.d.cts → constants-ozjf1Ejw.d.cts} +2 -2
  28. package/dist/continuous-event-graph/index.cjs +258 -464
  29. package/dist/continuous-event-graph/index.cjs.map +1 -1
  30. package/dist/continuous-event-graph/index.d.cts +18 -358
  31. package/dist/continuous-event-graph/index.d.ts +18 -358
  32. package/dist/continuous-event-graph/index.js +255 -464
  33. package/dist/continuous-event-graph/index.js.map +1 -1
  34. package/dist/event-graph/index.cjs +4 -4
  35. package/dist/event-graph/index.cjs.map +1 -1
  36. package/dist/event-graph/index.d.cts +5 -5
  37. package/dist/event-graph/index.d.ts +5 -5
  38. package/dist/event-graph/index.js +4 -4
  39. package/dist/event-graph/index.js.map +1 -1
  40. package/dist/index.cjs +1684 -555
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +26 -7
  43. package/dist/index.d.ts +26 -7
  44. package/dist/index.js +1678 -555
  45. package/dist/index.js.map +1 -1
  46. package/dist/inference/index.cjs +138 -19
  47. package/dist/inference/index.cjs.map +1 -1
  48. package/dist/inference/index.d.cts +2 -2
  49. package/dist/inference/index.d.ts +2 -2
  50. package/dist/inference/index.js +138 -19
  51. package/dist/inference/index.js.map +1 -1
  52. package/dist/journal-DRfJiheM.d.cts +28 -0
  53. package/dist/journal-NLYuqege.d.ts +28 -0
  54. package/dist/live-cards-bridge-Or7fdEJV.d.ts +316 -0
  55. package/dist/live-cards-bridge-vGJ6tMzN.d.cts +316 -0
  56. package/dist/schedule-CMcZe5Ny.d.ts +21 -0
  57. package/dist/schedule-CiucyCan.d.cts +21 -0
  58. package/dist/step-machine/index.cjs +18 -1
  59. package/dist/step-machine/index.cjs.map +1 -1
  60. package/dist/step-machine/index.d.cts +2 -2
  61. package/dist/step-machine/index.d.ts +2 -2
  62. package/dist/step-machine/index.js +18 -1
  63. package/dist/step-machine/index.js.map +1 -1
  64. package/dist/stores/file.d.cts +1 -1
  65. package/dist/stores/file.d.ts +1 -1
  66. package/dist/stores/index.d.cts +1 -1
  67. package/dist/stores/index.d.ts +1 -1
  68. package/dist/stores/localStorage.d.cts +1 -1
  69. package/dist/stores/localStorage.d.ts +1 -1
  70. package/dist/stores/memory.d.cts +1 -1
  71. package/dist/stores/memory.d.ts +1 -1
  72. package/dist/{types-BwvgvlOO.d.cts → types-BzLD8bjb.d.cts} +1 -1
  73. package/dist/{types-ClRA8hzC.d.ts → types-C2eJ7DAV.d.ts} +1 -1
  74. package/dist/{types-DEj7OakX.d.cts → types-CMFSIjpc.d.cts} +39 -4
  75. package/dist/{types-DEj7OakX.d.ts → types-CMFSIjpc.d.ts} +39 -4
  76. package/dist/{types-FZ_eyErS.d.cts → types-ycun84cq.d.cts} +1 -0
  77. package/dist/{types-FZ_eyErS.d.ts → types-ycun84cq.d.ts} +1 -0
  78. package/dist/{validate-DEZ2Ymdb.d.ts → validate-DJQTQ6bP.d.ts} +1 -1
  79. package/dist/{validate-DqKTZg_o.d.cts → validate-ke92Cleg.d.cts} +1 -1
  80. package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +22 -0
  81. package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +16 -0
  82. package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +15 -0
  83. package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +15 -0
  84. package/examples/browser/boards/portfolio-tracker/fetch-prices.js +43 -0
  85. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +96 -0
  86. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +7 -0
  87. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +217 -0
  88. package/examples/browser/livecards-browser/index.html +41 -0
  89. package/examples/browser/{index.html → step-machine-browser/index.html} +53 -53
  90. package/examples/cli/step-machine-cli/portfolio-tracker/cards/holdings-table.json +22 -0
  91. package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +43 -0
  92. package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +15 -0
  93. package/examples/cli/step-machine-cli/portfolio-tracker/cards/price-fetch.json +15 -0
  94. package/examples/cli/step-machine-cli/portfolio-tracker/fetch-prices.js +48 -0
  95. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +58 -0
  96. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +27 -0
  97. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +25 -0
  98. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +29 -0
  99. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +27 -0
  100. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +25 -0
  101. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +37 -0
  102. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +53 -0
  103. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +35 -0
  104. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +227 -0
  105. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +38 -0
  106. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +29 -0
  107. package/examples/cli/step-machine-demo/jsonata-init-board-cli.js +36 -0
  108. package/examples/cli/step-machine-demo/jsonata-init-board.flow.yaml +30 -0
  109. package/examples/cli/step-machine-demo/one-step-cli-only.flow.yaml +19 -0
  110. package/examples/cli/step-machine-demo/step-cli-echo-y.js +15 -0
  111. package/examples/cli/step-machine-demo/step2-double-cli.js +39 -0
  112. package/examples/cli/step-machine-demo/two-step-math-handlers.js +32 -0
  113. package/examples/cli/step-machine-demo/two-step-math.flow.yaml +31 -0
  114. package/examples/cli/step-machine-demo/two-step-mixed-handlers.js +24 -0
  115. package/examples/cli/step-machine-demo/two-step-mixed.flow.yaml +35 -0
  116. package/examples/example-board/board.yaml +23 -0
  117. package/examples/example-board/bootstrap_payload.json +1 -0
  118. package/examples/example-board/cards/card-chain-region-alert.json +39 -0
  119. package/examples/example-board/cards/card-chain-region-totals.json +26 -0
  120. package/examples/example-board/cards/card-chain-top-region.json +24 -0
  121. package/examples/example-board/cards/card-ex-actions.json +32 -0
  122. package/examples/example-board/cards/card-ex-chart.json +30 -0
  123. package/examples/example-board/cards/card-ex-filter.json +36 -0
  124. package/examples/example-board/cards/card-ex-filtered-by-preference.json +59 -0
  125. package/examples/example-board/cards/card-ex-form.json +91 -0
  126. package/examples/example-board/cards/card-ex-list.json +22 -0
  127. package/examples/example-board/cards/card-ex-markdown.json +17 -0
  128. package/examples/example-board/cards/card-ex-metric.json +19 -0
  129. package/examples/example-board/cards/card-ex-narrative.json +36 -0
  130. package/examples/example-board/cards/card-ex-source-http.json +28 -0
  131. package/examples/example-board/cards/card-ex-source.json +21 -0
  132. package/examples/example-board/cards/card-ex-status.json +35 -0
  133. package/examples/example-board/cards/card-ex-table.json +30 -0
  134. package/examples/example-board/cards/card-ex-todo.json +29 -0
  135. package/examples/example-board/demo-chat-handler.js +69 -0
  136. package/examples/example-board/demo-server.js +87 -0
  137. package/examples/example-board/demo-shell-browser.html +806 -0
  138. package/examples/example-board/demo-shell-with-server.html +280 -0
  139. package/examples/example-board/demo-shell.html +62 -0
  140. package/examples/example-board/demo-task-executor.js +255 -0
  141. package/examples/example-board/mock.db +15 -0
  142. package/examples/example-board/reusable-board-runtime-client.js +265 -0
  143. package/examples/example-board/reusable-runtime-artifacts-adapter.js +233 -0
  144. package/examples/example-board/reusable-server-runtime.js +1284 -0
  145. package/examples/index.html +799 -0
  146. package/examples/{batch → npm-libs/batch}/batch-step-machine.ts +1 -1
  147. package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/live-cards-board.ts +18 -18
  148. package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/live-portfolio-dashboard.ts +24 -24
  149. package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/portfolio-tracker.ts +1 -1
  150. package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/reactive-monitoring.ts +1 -1
  151. package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/reactive-pipeline.ts +1 -1
  152. package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/soc-incident-board.ts +1 -1
  153. package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/stock-dashboard.ts +1 -1
  154. package/examples/{event-graph → npm-libs/event-graph}/ci-cd-pipeline.ts +1 -1
  155. package/examples/{event-graph → npm-libs/event-graph}/executor-diamond.ts +1 -1
  156. package/examples/{event-graph → npm-libs/event-graph}/executor-pipeline.ts +1 -1
  157. package/examples/{event-graph → npm-libs/event-graph}/research-pipeline.ts +1 -1
  158. package/examples/{graph-of-graphs → npm-libs/graph-of-graphs}/multi-stage-etl.ts +1 -1
  159. package/examples/{graph-of-graphs → npm-libs/graph-of-graphs}/url-processing-pipeline.ts +1 -1
  160. package/examples/{inference → npm-libs/inference}/azure-deployment.ts +1 -1
  161. package/examples/{inference → npm-libs/inference}/copilot-cli.ts +1 -1
  162. package/examples/{inference → npm-libs/inference}/data-pipeline.ts +1 -1
  163. package/examples/{inference → npm-libs/inference}/pluggable-adapters.ts +1 -1
  164. package/examples/{node → npm-libs/node}/ai-conversation.ts +1 -1
  165. package/examples/{node → npm-libs/node}/simple-greeting.ts +2 -2
  166. package/examples/step-machine-cli/portfolio-tracker/cards/holdings-table.json +22 -0
  167. package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +43 -0
  168. package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +15 -0
  169. package/examples/step-machine-cli/portfolio-tracker/cards/price-fetch.json +15 -0
  170. package/examples/step-machine-cli/portfolio-tracker/fetch-prices.js +48 -0
  171. package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +58 -0
  172. package/examples/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +27 -0
  173. package/examples/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +25 -0
  174. package/examples/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +29 -0
  175. package/examples/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +27 -0
  176. package/examples/step-machine-cli/portfolio-tracker/handlers/status-cli.js +25 -0
  177. package/examples/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +37 -0
  178. package/examples/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +53 -0
  179. package/examples/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +35 -0
  180. package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker-task-executor.cjs +96 -0
  181. package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +227 -0
  182. package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +38 -0
  183. package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +29 -0
  184. package/package.json +27 -2
  185. package/schema/board-status.schema.json +118 -0
  186. package/schema/card-runtime.schema.json +25 -0
  187. package/schema/flow.schema.json +5 -0
  188. package/schema/live-cards.schema.json +90 -83
  189. package/step-machine-cli.js +674 -0
  190. package/browser/ingest-board.js +0 -296
  191. package/examples/ingest.js +0 -733
  192. /package/examples/{flows → npm-libs/flows}/ai-conversation.yaml +0 -0
  193. /package/examples/{flows → npm-libs/flows}/order-processing.yaml +0 -0
  194. /package/examples/{flows → npm-libs/flows}/simple-greeting.yaml +0 -0
@@ -7,7 +7,7 @@
7
7
  * - Progress tracking
8
8
  * - Mixed success/failure handling
9
9
  *
10
- * Run with: npx tsx examples/batch/batch-step-machine.ts
10
+ * Run with: npx tsx examples/npm-libs/batch/batch-step-machine.ts
11
11
  */
12
12
 
13
13
  import { batch } from '../../src/batch/index.js';
@@ -16,7 +16,7 @@
16
16
  * - LiveBoard overload — board.id, board.settings forwarded to GraphConfig
17
17
  * - validateReactiveGraph on the resulting graph
18
18
  *
19
- * Run with: npx tsx examples/continuous-event-graph/live-cards-board.ts
19
+ * Run with: npx tsx examples/npm-libs/continuous-event-graph/live-cards-board.ts
20
20
  */
21
21
 
22
22
  import {
@@ -36,31 +36,31 @@ const cards: LiveCard[] = [
36
36
  id: 'market-feed',
37
37
  type: 'source',
38
38
  meta: { title: 'Live Market Prices' },
39
- state: { prices: [142.5, 305.8, 89.2, 211.0, 178.3] },
40
- source: { kind: 'static', bindTo: 'state.prices' },
39
+ card_data: { prices: [142.5, 305.8, 89.2, 211.0, 178.3] },
40
+ source: { kind: 'static', bindTo: 'card_data.prices' },
41
41
  },
42
42
  {
43
43
  id: 'stats',
44
44
  type: 'card',
45
45
  meta: { title: 'Price Statistics' },
46
- state: {},
46
+ card_data: {},
47
47
  data: { requires: ['market-feed'] },
48
48
  compute: {
49
- total: { fn: 'sum', input: 'state.market-feed.prices' },
50
- avg: { fn: 'avg', input: 'state.market-feed.prices' },
51
- count: { fn: 'count', input: 'state.market-feed.prices' },
49
+ total: { fn: 'sum', input: 'sources.market-feed.prices' },
50
+ avg: { fn: 'avg', input: 'sources.market-feed.prices' },
51
+ count: { fn: 'count', input: 'sources.market-feed.prices' },
52
52
  },
53
53
  },
54
54
  {
55
55
  id: 'summary',
56
56
  type: 'card',
57
57
  meta: { title: 'Summary Label' },
58
- state: {},
58
+ card_data: {},
59
59
  data: { requires: ['stats'] },
60
60
  compute: {
61
61
  label: {
62
62
  fn: 'template',
63
- input: 'state.stats',
63
+ input: 'computed_values.stats',
64
64
  format: '{{count}} stocks — total ${{total}}, avg ${{avg}}',
65
65
  },
66
66
  },
@@ -115,37 +115,37 @@ const board: LiveBoard = {
115
115
  id: 'equity-feed',
116
116
  type: 'source',
117
117
  meta: { title: 'Equity Prices' },
118
- state: {},
119
- source: { kind: 'api', bindTo: 'state.raw', url_template: 'https://api.example.com/equity' },
118
+ card_data: {},
119
+ source: { kind: 'api', bindTo: 'card_data.raw', url_template: 'https://api.example.com/equity' },
120
120
  },
121
121
  {
122
122
  id: 'bond-feed',
123
123
  type: 'source',
124
124
  meta: { title: 'Bond Yields' },
125
- state: { yields: [3.2, 4.1, 2.8, 5.0] },
126
- source: { kind: 'static', bindTo: 'state.yields' },
125
+ card_data: { yields: [3.2, 4.1, 2.8, 5.0] },
126
+ source: { kind: 'static', bindTo: 'card_data.yields' },
127
127
  },
128
128
  {
129
129
  id: 'portfolio-mix',
130
130
  type: 'card',
131
131
  meta: { title: 'Portfolio Mix Calculator' },
132
- state: {},
132
+ card_data: {},
133
133
  data: { requires: ['equity-feed', 'bond-feed'] },
134
134
  compute: {
135
- equity_total: { fn: 'sum', input: 'state.equity-feed.prices' },
136
- bond_total: { fn: 'sum', input: 'state.bond-feed.yields' },
135
+ equity_total: { fn: 'sum', input: 'sources.equity-feed.prices' },
136
+ bond_total: { fn: 'sum', input: 'sources.bond-feed.yields' },
137
137
  },
138
138
  },
139
139
  {
140
140
  id: 'risk-summary',
141
141
  type: 'card',
142
142
  meta: { title: 'Risk Summary' },
143
- state: {},
143
+ card_data: {},
144
144
  data: { requires: ['portfolio-mix'] },
145
145
  compute: {
146
146
  label: {
147
147
  fn: 'template',
148
- input: 'state.portfolio-mix',
148
+ input: 'computed_values.portfolio-mix',
149
149
  format: 'Equities: ${{equity_total}} | Bonds: {{bond_total}}%',
150
150
  },
151
151
  },
@@ -22,7 +22,7 @@
22
22
  * Dynamically added: allocation-chart, risk-score, daily-pnl,
23
23
  * value-alert, summary, correlation, combined-view
24
24
  *
25
- * Run with: npx tsx examples/continuous-event-graph/live-portfolio-dashboard.ts
25
+ * Run with: npx tsx examples/npm-libs/continuous-event-graph/live-portfolio-dashboard.ts
26
26
  */
27
27
 
28
28
  import * as fs from 'node:fs';
@@ -69,8 +69,8 @@ const cards: LiveCard[] = [
69
69
  {
70
70
  id: 'holdings', type: 'source',
71
71
  meta: { title: 'Portfolio Holdings' },
72
- data: { provides: { holdings: 'state.holdings' } },
73
- state: {
72
+ data: { provides: { holdings: 'card_data.holdings' } },
73
+ card_data: {
74
74
  holdings: [
75
75
  { symbol: 'AAPL', shares: 50, sector: 'tech' },
76
76
  { symbol: 'MSFT', shares: 30, sector: 'tech' },
@@ -83,13 +83,13 @@ const cards: LiveCard[] = [
83
83
  {
84
84
  id: 'price-feed', type: 'source',
85
85
  meta: { title: 'Live Price Feed' },
86
- data: { provides: { prices: 'state.prices' } },
87
- state: { prices: { AAPL: 195.50, MSFT: 420.10, GOOG: 176.30, JPM: 198.20, JNJ: 155.80 } },
86
+ data: { provides: { prices: 'card_data.prices' } },
87
+ card_data: { prices: { AAPL: 195.50, MSFT: 420.10, GOOG: 176.30, JPM: 198.20, JNJ: 155.80 } },
88
88
  },
89
89
  {
90
90
  id: 'news-feed', type: 'source',
91
91
  meta: { title: 'Market News Feed' },
92
- state: {
92
+ card_data: {
93
93
  headlines: [
94
94
  { symbol: 'AAPL', headline: 'Apple beats Q4 estimates', sentiment: 0.8 },
95
95
  { symbol: 'JPM', headline: 'JPMorgan raises dividend', sentiment: 0.6 },
@@ -100,32 +100,32 @@ const cards: LiveCard[] = [
100
100
  {
101
101
  id: 'benchmark', type: 'source',
102
102
  meta: { title: 'S&P 500 Benchmark' },
103
- state: { index: 'SPY', value: 5280.50, dailyReturn: 0.45 },
103
+ card_data: { index: 'SPY', value: 5280.50, dailyReturn: 0.45 },
104
104
  },
105
105
  // Compute cards
106
106
  {
107
107
  id: 'valuator', type: 'card',
108
108
  meta: { title: 'Position Valuator' },
109
109
  data: { requires: ['holdings', 'price-feed'] },
110
- state: {},
110
+ card_data: {},
111
111
  },
112
112
  {
113
113
  id: 'portfolio-value', type: 'card',
114
114
  meta: { title: 'Total Portfolio Value' },
115
115
  data: { requires: ['valuator'] },
116
- state: {},
116
+ card_data: {},
117
117
  },
118
118
  {
119
119
  id: 'sector-breakdown', type: 'card',
120
120
  meta: { title: 'Sector Breakdown' },
121
121
  data: { requires: ['valuator'] },
122
- state: {},
122
+ card_data: {},
123
123
  },
124
124
  {
125
125
  id: 'sentiment', type: 'card',
126
126
  meta: { title: 'News Sentiment Score' },
127
127
  data: { requires: ['news-feed'] },
128
- state: {},
128
+ card_data: {},
129
129
  },
130
130
  ];
131
131
 
@@ -144,7 +144,7 @@ function makeHandler(
144
144
  const result = computeFn(graphRef!.getState());
145
145
  try {
146
146
  const diskCard = readCard(dir, id);
147
- diskCard.state = { ...diskCard.state, ...result };
147
+ diskCard.card_data = { ...diskCard.card_data, ...result };
148
148
  writeCard(dir, diskCard);
149
149
  } catch { /* card may not exist yet */ }
150
150
  graphRef!.resolveCallback(input.callbackToken, result);
@@ -225,7 +225,7 @@ async function main() {
225
225
  if (taskState.data && Object.keys(taskState.data).length > 0) {
226
226
  try {
227
227
  const diskCard = readCard(tmpDir, taskName);
228
- diskCard.state = { ...diskCard.state, ...taskState.data };
228
+ diskCard.card_data = { ...diskCard.card_data, ...taskState.data };
229
229
  writeCard(tmpDir, diskCard);
230
230
  } catch { /* not on disk yet */ }
231
231
  }
@@ -251,7 +251,7 @@ async function main() {
251
251
  log('PHASE 2', 'Adding 7 dynamic cards → 15 total');
252
252
 
253
253
  addDynamicCard(rg, tmpDir, {
254
- id: 'allocation-chart', type: 'card', data: { requires: ['valuator', 'portfolio-value'] }, state: {},
254
+ id: 'allocation-chart', type: 'card', data: { requires: ['valuator', 'portfolio-value'] }, card_data: {},
255
255
  }, (e) => {
256
256
  const pos = (e.state.tasks.valuator?.data as any)?.positions ?? [];
257
257
  const tot = (e.state.tasks['portfolio-value']?.data as any)?.totalValue ?? 0;
@@ -259,7 +259,7 @@ async function main() {
259
259
  }, { requires: ['valuator', 'portfolio-value'] });
260
260
 
261
261
  addDynamicCard(rg, tmpDir, {
262
- id: 'risk-score', type: 'card', data: { requires: ['valuator'] }, state: {},
262
+ id: 'risk-score', type: 'card', data: { requires: ['valuator'] }, card_data: {},
263
263
  }, (e) => {
264
264
  const pos = (e.state.tasks.valuator?.data as any)?.positions ?? [];
265
265
  const vals = pos.map((p: any) => p.value);
@@ -269,7 +269,7 @@ async function main() {
269
269
  }, { requires: ['valuator'] });
270
270
 
271
271
  addDynamicCard(rg, tmpDir, {
272
- id: 'daily-pnl', type: 'card', data: { requires: ['portfolio-value', 'benchmark'] }, state: {},
272
+ id: 'daily-pnl', type: 'card', data: { requires: ['portfolio-value', 'benchmark'] }, card_data: {},
273
273
  }, (e) => {
274
274
  const tv = (e.state.tasks['portfolio-value']?.data as any)?.totalValue ?? 0;
275
275
  const benchReturn = (e.state.tasks.benchmark?.data as any)?.dailyReturn ?? 0;
@@ -278,14 +278,14 @@ async function main() {
278
278
  }, { requires: ['portfolio-value', 'benchmark'] });
279
279
 
280
280
  addDynamicCard(rg, tmpDir, {
281
- id: 'value-alert', type: 'card', data: { requires: ['portfolio-value'] }, state: {},
281
+ id: 'value-alert', type: 'card', data: { requires: ['portfolio-value'] }, card_data: {},
282
282
  }, (e) => {
283
283
  const tv = (e.state.tasks['portfolio-value']?.data as any)?.totalValue ?? 0;
284
284
  return { triggered: tv > 25000, threshold: 25000, currentValue: tv };
285
285
  }, { requires: ['portfolio-value'] });
286
286
 
287
287
  addDynamicCard(rg, tmpDir, {
288
- id: 'summary', type: 'card', data: { requires: ['portfolio-value', 'sentiment'] }, state: {},
288
+ id: 'summary', type: 'card', data: { requires: ['portfolio-value', 'sentiment'] }, card_data: {},
289
289
  }, (e) => {
290
290
  const tv = (e.state.tasks['portfolio-value']?.data as any)?.totalValue ?? 0;
291
291
  const mood = (e.state.tasks.sentiment?.data as any)?.bullish ? 'bullish' : 'bearish';
@@ -293,7 +293,7 @@ async function main() {
293
293
  }, { requires: ['portfolio-value', 'sentiment'] });
294
294
 
295
295
  addDynamicCard(rg, tmpDir, {
296
- id: 'correlation', type: 'card', data: { requires: ['valuator', 'benchmark'] }, state: {},
296
+ id: 'correlation', type: 'card', data: { requires: ['valuator', 'benchmark'] }, card_data: {},
297
297
  }, (e) => {
298
298
  const pos = (e.state.tasks.valuator?.data as any)?.positions ?? [];
299
299
  const techVal = pos.filter((p: any) => p.sector === 'tech').reduce((s: number, p: any) => s + p.value, 0);
@@ -302,7 +302,7 @@ async function main() {
302
302
  }, { requires: ['valuator', 'benchmark'] });
303
303
 
304
304
  addDynamicCard(rg, tmpDir, {
305
- id: 'combined-view', type: 'card', data: { requires: ['summary', 'sector-breakdown', 'risk-score'] }, state: {},
305
+ id: 'combined-view', type: 'card', data: { requires: ['summary', 'sector-breakdown', 'risk-score'] }, card_data: {},
306
306
  }, (e) => ({
307
307
  summaryMood: (e.state.tasks.summary?.data as any)?.mood ?? '?',
308
308
  sectors: (e.state.tasks['sector-breakdown']?.data as any)?.sectorCount ?? 0,
@@ -326,7 +326,7 @@ async function main() {
326
326
  console.log(' benchmark provides:', rg.getState().config.tasks.benchmark.provides);
327
327
 
328
328
  addDynamicCard(rg, tmpDir, {
329
- id: 'market-context', type: 'card', data: { requires: ['market-data'] }, state: {},
329
+ id: 'market-context', type: 'card', data: { requires: ['market-data'] }, card_data: {},
330
330
  }, (e) => {
331
331
  const bench = e.state.tasks.benchmark?.data as any ?? {};
332
332
  return { indexValue: bench.value ?? 0, context: 'provided via market-data token' };
@@ -409,7 +409,7 @@ async function main() {
409
409
  console.log(' combined-view requires:', rg.getState().config.tasks['combined-view'].requires);
410
410
 
411
411
  addDynamicCard(rg, tmpDir, {
412
- id: 'allocation-chart', type: 'card', data: { requires: ['valuator'] }, state: {},
412
+ id: 'allocation-chart', type: 'card', data: { requires: ['valuator'] }, card_data: {},
413
413
  }, (e) => {
414
414
  const pos = (e.state.tasks.valuator?.data as any)?.positions ?? [];
415
415
  const total = pos.reduce((s: number, p: any) => s + p.value, 0);
@@ -436,7 +436,7 @@ async function main() {
436
436
  id: 'watchlist', type: 'source',
437
437
  meta: { title: 'Watchlist (User Input)' },
438
438
  data: { provides: { watchlist: 'state.symbols' } },
439
- state: { symbols: ['NVDA', 'AMD', 'AMZN'] },
439
+ card_data: { symbols: ['NVDA', 'AMD', 'AMZN'] },
440
440
  };
441
441
  writeCard(tmpDir, watchlistCard);
442
442
  rg.registerHandler('watchlist', makeHandler('watchlist', (engine) => {
@@ -463,7 +463,7 @@ async function main() {
463
463
  addDynamicCard(rg, tmpDir, {
464
464
  id: 'watchlist-prices', type: 'card',
465
465
  meta: { title: 'Watchlist Latest Prices' },
466
- data: { requires: ['watchlist', 'price-feed'] }, state: {},
466
+ data: { requires: ['watchlist', 'price-feed'] }, card_data: {},
467
467
  }, (engine) => {
468
468
  const symbols: string[] = (engine.state.tasks.watchlist?.data as any)?.symbols ?? [];
469
469
  const allPrices: Record<string, number> = (engine.state.tasks['price-feed']?.data as any)?.prices ?? {};
@@ -29,7 +29,7 @@
29
29
  * T3: Force price refresh without form change → retrigger('price-fetch')
30
30
  * T4: Quiescent
31
31
  *
32
- * Run with: npx tsx examples/continuous-event-graph/portfolio-tracker.ts
32
+ * Run with: npx tsx examples/npm-libs/continuous-event-graph/portfolio-tracker.ts
33
33
  */
34
34
 
35
35
  import type { GraphConfig } from '../../src/event-graph/types.js';
@@ -15,7 +15,7 @@
15
15
  * Scenario: A monitoring system that collects metrics, evaluates alerts,
16
16
  * and dynamically adds notification channels at runtime.
17
17
  *
18
- * Run with: npx tsx examples/continuous-event-graph/reactive-monitoring.ts
18
+ * Run with: npx tsx examples/npm-libs/continuous-event-graph/reactive-monitoring.ts
19
19
  */
20
20
 
21
21
  import {
@@ -9,7 +9,7 @@
9
9
  * - validateLiveGraph for runtime state-consistency checks
10
10
  * - validateReactiveGraph for handler/dispatch checks
11
11
  *
12
- * Run with: npx tsx examples/continuous-event-graph/reactive-pipeline.ts
12
+ * Run with: npx tsx examples/npm-libs/continuous-event-graph/reactive-pipeline.ts
13
13
  */
14
14
 
15
15
  import {
@@ -31,7 +31,7 @@
31
31
  * T1: New intel arrives → retrigger threat-intel → data-changed cascade
32
32
  * create-ticket skipped (once) — slack re-fires
33
33
  *
34
- * Run with: npx tsx examples/continuous-event-graph/soc-incident-board.ts
34
+ * Run with: npx tsx examples/npm-libs/continuous-event-graph/soc-incident-board.ts
35
35
  */
36
36
 
37
37
  import type { GraphConfig } from '../../src/event-graph/types.js';
@@ -10,7 +10,7 @@
10
10
  * - Scheduling adapts as the graph evolves
11
11
  * - Snapshots allow persistence and restore
12
12
  *
13
- * Run with: npx tsx examples/continuous-event-graph/stock-dashboard.ts
13
+ * Run with: npx tsx examples/npm-libs/continuous-event-graph/stock-dashboard.ts
14
14
  */
15
15
 
16
16
  import {
@@ -8,7 +8,7 @@
8
8
  * - Retry configuration
9
9
  * - Stuck detection
10
10
  *
11
- * Run with: npx tsx examples/event-graph/ci-cd-pipeline.ts
11
+ * Run with: npx tsx examples/npm-libs/event-graph/ci-cd-pipeline.ts
12
12
  */
13
13
 
14
14
  import {
@@ -12,7 +12,7 @@
12
12
  * |
13
13
  * report
14
14
  *
15
- * Run with: npx tsx examples/event-graph/executor-diamond.ts
15
+ * Run with: npx tsx examples/npm-libs/event-graph/executor-diamond.ts
16
16
  */
17
17
 
18
18
  import {
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * Contrast with reactive-pipeline.ts where the graph drives itself.
13
13
  *
14
- * Run with: npx tsx examples/event-graph/executor-pipeline.ts
14
+ * Run with: npx tsx examples/npm-libs/event-graph/executor-pipeline.ts
15
15
  */
16
16
 
17
17
  import {
@@ -6,7 +6,7 @@
6
6
  * - Goal-based completion
7
7
  * - The standard next() / apply() driver loop
8
8
  *
9
- * Run with: npx tsx examples/event-graph/research-pipeline.ts
9
+ * Run with: npx tsx examples/npm-libs/event-graph/research-pipeline.ts
10
10
  */
11
11
 
12
12
  import {
@@ -21,7 +21,7 @@
21
21
  * Inner transform flow (step-machine, per record):
22
22
  * parse → validate → normalize → enrich → (accept | reject)
23
23
  *
24
- * Run with: npx tsx examples/graph-of-graphs/multi-stage-etl.ts
24
+ * Run with: npx tsx examples/npm-libs/graph-of-graphs/multi-stage-etl.ts
25
25
  */
26
26
 
27
27
  import {
@@ -19,7 +19,7 @@
19
19
  * - resolveConfigTemplates() for DRY task configs
20
20
  * - Parallel fan-out inside inner graph
21
21
  *
22
- * Run with: npx tsx examples/graph-of-graphs/url-processing-pipeline.ts
22
+ * Run with: npx tsx examples/npm-libs/graph-of-graphs/url-processing-pipeline.ts
23
23
  */
24
24
 
25
25
  import {
@@ -5,7 +5,7 @@
5
5
  * The graph has 3 checkpoints. After deployment, the LLM analyzes
6
6
  * logs and determines what's complete.
7
7
  *
8
- * Run with: npx tsx examples/inference/azure-deployment.ts
8
+ * Run with: npx tsx examples/npm-libs/inference/azure-deployment.ts
9
9
  */
10
10
 
11
11
  import {
@@ -8,7 +8,7 @@
8
8
  * - GitHub Copilot CLI installed (comes with VS Code / GitHub Copilot extension)
9
9
  * - `copilot` available on PATH
10
10
  *
11
- * Run with: npx tsx examples/inference/copilot-cli.ts
11
+ * Run with: npx tsx examples/npm-libs/inference/copilot-cli.ts
12
12
  */
13
13
 
14
14
  import { createLiveGraph, schedule } from '../../src/continuous-event-graph/index.js';
@@ -4,7 +4,7 @@
4
4
  * Demonstrates iterative inference — run the LLM multiple times as
5
5
  * new evidence arrives. Each round may unlock more tasks.
6
6
  *
7
- * Run with: npx tsx examples/inference/data-pipeline.ts
7
+ * Run with: npx tsx examples/npm-libs/inference/data-pipeline.ts
8
8
  */
9
9
 
10
10
  import {
@@ -4,7 +4,7 @@
4
4
  * Shows how to create adapters for different LLM providers.
5
5
  * Each adapter implements InferenceAdapter.analyze(prompt) → string.
6
6
  *
7
- * Run with: npx tsx examples/inference/pluggable-adapters.ts
7
+ * Run with: npx tsx examples/npm-libs/inference/pluggable-adapters.ts
8
8
  */
9
9
 
10
10
  import {
@@ -7,7 +7,7 @@
7
7
  * - Circuit breakers
8
8
  * - Event handling
9
9
  *
10
- * Run with: npx ts-node examples/node/ai-conversation.ts
10
+ * Run with: npx ts-node examples/npm-libs/node/ai-conversation.ts
11
11
  */
12
12
 
13
13
  import { createEngine, loadFlow, MemoryStore } from '../../src/index.js';
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * Demonstrates basic usage with file-based persistence.
5
5
  *
6
- * Run with: npx ts-node examples/node/simple-greeting.ts
7
- * Or after build: node examples/node/simple-greeting.js
6
+ * Run with: npx ts-node examples/npm-libs/node/simple-greeting.ts
7
+ * Or after build: node examples/npm-libs/node/simple-greeting.js
8
8
  */
9
9
 
10
10
  import { createEngine, loadFlow, FileStore } from '../../src/index.js';
@@ -0,0 +1,22 @@
1
+ {
2
+ "id": "holdings-table",
3
+ "meta": { "title": "Holdings Table" },
4
+ "requires": ["holdings", "prices"],
5
+ "provides": [{ "bindTo": "table", "src": "computed_values.table" }],
6
+ "card_data": {},
7
+ "compute": [
8
+ {
9
+ "bindTo": "table",
10
+ "expr": "{ \"rows\": $map(requires.holdings, function($h) { { \"symbol\": $h.symbol, \"qty\": $h.qty, \"price\": $lookup(requires.prices, $h.symbol), \"value\": $h.qty * $lookup(requires.prices, $h.symbol) } }) }"
11
+ }
12
+ ],
13
+ "view": {
14
+ "elements": [
15
+ {
16
+ "kind": "table",
17
+ "label": "Portfolio Positions",
18
+ "data": { "bind": "computed_values.table.rows", "columns": ["symbol", "qty", "price", "value"] }
19
+ }
20
+ ]
21
+ }
22
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "id": "portfolio-form",
3
+ "meta": {
4
+ "title": "Portfolio Holdings Form"
5
+ },
6
+ "provides": [
7
+ {
8
+ "bindTo": "holdings",
9
+ "src": "card_data.holdings"
10
+ }
11
+ ],
12
+ "card_data": {
13
+ "holdings": [
14
+ {
15
+ "symbol": "AAPL",
16
+ "qty": 50
17
+ },
18
+ {
19
+ "symbol": "MSFT",
20
+ "qty": 30
21
+ },
22
+ {
23
+ "symbol": "GOOG",
24
+ "qty": 100
25
+ }
26
+ ]
27
+ },
28
+ "view": {
29
+ "elements": [
30
+ {
31
+ "kind": "table",
32
+ "label": "Holdings",
33
+ "data": {
34
+ "bind": "card_data.holdings",
35
+ "columns": [
36
+ "symbol",
37
+ "qty"
38
+ ]
39
+ }
40
+ }
41
+ ]
42
+ }
43
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "id": "portfolio-value",
3
+ "meta": { "title": "Portfolio Total Value" },
4
+ "requires": ["table"],
5
+ "provides": [{ "bindTo": "totalValue", "src": "computed_values.totalValue" }],
6
+ "card_data": {},
7
+ "compute": [
8
+ { "bindTo": "totalValue", "expr": "$sum(requires.table.rows.value)" }
9
+ ],
10
+ "view": {
11
+ "elements": [
12
+ { "kind": "metric", "label": "Total Portfolio Value", "data": { "bind": "computed_values.totalValue" } }
13
+ ]
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "id": "price-fetch",
3
+ "meta": { "title": "Fetch Market Prices" },
4
+ "requires": ["holdings"],
5
+ "provides": [{ "bindTo": "prices", "src": "sources.prices" }],
6
+ "card_data": {},
7
+ "sources": [
8
+ { "cli": "node ../fetch-prices.js --tmp-file-name tmp_file1", "bindTo": "prices", "outputFile": "prices.json" }
9
+ ],
10
+ "view": {
11
+ "elements": [
12
+ { "kind": "table", "label": "Market Prices", "data": { "bind": "sources.prices" } }
13
+ ]
14
+ }
15
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * fetch-prices.js
3
+ * Polls for tmp_file1 payload and outputs JSON to stdout once available.
4
+ */
5
+ import * as fs from 'node:fs';
6
+ import * as path from 'node:path';
7
+
8
+ function getArgValue(flagName) {
9
+ const idx = process.argv.indexOf(flagName);
10
+ if (idx < 0) return undefined;
11
+ return process.argv[idx + 1];
12
+ }
13
+
14
+ const envBoardDir = (process.env.BOARD_DIR ?? '').trim();
15
+ const tmpFileName = String(getArgValue('--tmp-file-name') ?? process.env.TMP_FILE_NAME ?? 'tmp_file1').trim();
16
+ const tmpFilePath = envBoardDir ? path.join(envBoardDir, tmpFileName) : '';
17
+
18
+ if (!tmpFilePath) {
19
+ console.error('BOARD_DIR environment variable is required for fetch-prices.js');
20
+ process.exit(1);
21
+ }
22
+
23
+ function getReadableTmpFile() {
24
+ if (!fs.existsSync(tmpFilePath)) return undefined;
25
+ const content = fs.readFileSync(tmpFilePath, 'utf-8').trim();
26
+ if (!content) return undefined;
27
+ return { tmpFile: tmpFilePath, content };
28
+ }
29
+
30
+ function waitForFile(timeoutMs = 120000) {
31
+ const started = Date.now();
32
+ const interval = setInterval(() => {
33
+ if (Date.now() - started > timeoutMs) {
34
+ clearInterval(interval);
35
+ console.error('Timed out waiting for tmp_file1 market prices input.');
36
+ process.exit(1);
37
+ }
38
+
39
+ const ready = getReadableTmpFile();
40
+ if (!ready) return;
41
+
42
+ clearInterval(interval);
43
+ fs.writeFileSync(ready.tmpFile, '', 'utf-8');
44
+ process.stdout.write(`${ready.content}\n`);
45
+ }, 250);
46
+ }
47
+
48
+ waitForFile();