yaml-flow 6.0.0 → 7.1.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 (166) hide show
  1. package/board-live-cards-cli.js +4 -4
  2. package/browser/asset-integrity.json +3 -3
  3. package/browser/board-livecards-client.js +2 -0
  4. package/browser/board-livecards-client.js.map +1 -0
  5. package/browser/board-livecards-localstorage.js +10 -0
  6. package/browser/board-livecards-localstorage.js.map +1 -0
  7. package/browser/board-livegraph-engine.js +2 -2
  8. package/browser/board-livegraph-engine.js.map +1 -1
  9. package/browser/card-compute.js +28 -28
  10. package/browser/compute-jsonata.js +5 -0
  11. package/browser/compute-jsonata.js.map +1 -0
  12. package/browser/live-cards.js +264 -151
  13. package/card-store.js +4 -4
  14. package/dist/{board-live-cards-public-CltXYgaY.d.cts → board-live-cards-public-5n1-syA3.d.cts} +8 -5
  15. package/dist/{board-live-cards-public-f-E-FAyp.d.ts → board-live-cards-public-CK_J8uv0.d.ts} +8 -5
  16. package/dist/board-livegraph-runtime/index.cjs +2 -2
  17. package/dist/board-livegraph-runtime/index.cjs.map +1 -1
  18. package/dist/board-livegraph-runtime/index.d.cts +11 -9
  19. package/dist/board-livegraph-runtime/index.d.ts +11 -9
  20. package/dist/board-livegraph-runtime/index.js +2 -2
  21. package/dist/board-livegraph-runtime/index.js.map +1 -1
  22. package/dist/board-livegraph-runtime/jsonata-sync.cjs +37 -1
  23. package/dist/card-compute/index.cjs +4 -4
  24. package/dist/card-compute/index.cjs.map +1 -1
  25. package/dist/card-compute/index.d.cts +5 -1
  26. package/dist/card-compute/index.d.ts +5 -1
  27. package/dist/card-compute/index.js +4 -4
  28. package/dist/card-compute/index.js.map +1 -1
  29. package/dist/card-compute/jsonata-sync.cjs +37 -1
  30. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +2 -1
  31. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +1 -1
  32. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +27 -14
  33. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.ts +27 -14
  34. package/dist/cli/browser-api/board-live-cards-browser-adapter.js +2 -1
  35. package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +1 -1
  36. package/dist/cli/browser-api/card-store-browser-api.cjs +1 -1
  37. package/dist/cli/browser-api/card-store-browser-api.cjs.map +1 -1
  38. package/dist/cli/browser-api/card-store-browser-api.js +1 -1
  39. package/dist/cli/browser-api/card-store-browser-api.js.map +1 -1
  40. package/dist/cli/browser-api/jsonata-sync.cjs +37 -1
  41. package/dist/cli/node/artifacts-store-cli.cjs +8 -8
  42. package/dist/cli/node/artifacts-store-cli.cjs.map +1 -1
  43. package/dist/cli/node/artifacts-store-cli.js +8 -8
  44. package/dist/cli/node/artifacts-store-cli.js.map +1 -1
  45. package/dist/cli/node/board-live-cards-cli.cjs +7 -7
  46. package/dist/cli/node/board-live-cards-cli.cjs.map +1 -1
  47. package/dist/cli/node/board-live-cards-cli.js +7 -7
  48. package/dist/cli/node/board-live-cards-cli.js.map +1 -1
  49. package/dist/cli/node/card-store-cli.cjs +5 -5
  50. package/dist/cli/node/card-store-cli.cjs.map +1 -1
  51. package/dist/cli/node/card-store-cli.js +5 -5
  52. package/dist/cli/node/card-store-cli.js.map +1 -1
  53. package/dist/cli/node/execution-adapter.cjs +3 -0
  54. package/dist/cli/node/execution-adapter.cjs.map +1 -0
  55. package/dist/cli/node/execution-adapter.d.cts +174 -0
  56. package/dist/cli/node/execution-adapter.d.ts +174 -0
  57. package/dist/cli/node/execution-adapter.js +3 -0
  58. package/dist/cli/node/execution-adapter.js.map +1 -0
  59. package/dist/cli/node/fs-board-adapter.cjs +7 -7
  60. package/dist/cli/node/fs-board-adapter.cjs.map +1 -1
  61. package/dist/cli/node/fs-board-adapter.d.cts +2 -2
  62. package/dist/cli/node/fs-board-adapter.d.ts +2 -2
  63. package/dist/cli/node/fs-board-adapter.js +7 -7
  64. package/dist/cli/node/fs-board-adapter.js.map +1 -1
  65. package/dist/cli/node/jsonata-sync.cjs +37 -1
  66. package/dist/cli/node/source-cli-task-executor.cjs +4 -4
  67. package/dist/cli/node/source-cli-task-executor.cjs.map +1 -1
  68. package/dist/cli/node/source-cli-task-executor.js +4 -4
  69. package/dist/cli/node/source-cli-task-executor.js.map +1 -1
  70. package/dist/continuous-event-graph/index.cjs +2 -2
  71. package/dist/continuous-event-graph/index.cjs.map +1 -1
  72. package/dist/continuous-event-graph/index.js +2 -2
  73. package/dist/continuous-event-graph/index.js.map +1 -1
  74. package/dist/continuous-event-graph/jsonata-sync.cjs +37 -1
  75. package/dist/execution-refs.cjs +2 -1
  76. package/dist/execution-refs.cjs.map +1 -1
  77. package/dist/execution-refs.d.cts +55 -12
  78. package/dist/execution-refs.d.ts +55 -12
  79. package/dist/execution-refs.js +2 -1
  80. package/dist/execution-refs.js.map +1 -1
  81. package/dist/index.cjs +10 -10
  82. package/dist/index.cjs.map +1 -1
  83. package/dist/index.js +10 -10
  84. package/dist/index.js.map +1 -1
  85. package/dist/jsonata-sync.cjs +37 -1
  86. package/dist/server-runtime/index.cjs +9 -0
  87. package/dist/server-runtime/index.cjs.map +1 -0
  88. package/dist/server-runtime/index.d.cts +31 -0
  89. package/dist/server-runtime/index.d.ts +31 -0
  90. package/dist/server-runtime/index.js +9 -0
  91. package/dist/server-runtime/index.js.map +1 -0
  92. package/dist/server-runtime/jsonata-sync.cjs +7623 -0
  93. package/dist/step-machine-public/index.cjs +3 -0
  94. package/dist/step-machine-public/index.cjs.map +1 -0
  95. package/dist/step-machine-public/index.d.cts +166 -0
  96. package/dist/step-machine-public/index.d.ts +166 -0
  97. package/dist/step-machine-public/index.js +3 -0
  98. package/dist/step-machine-public/index.js.map +1 -0
  99. package/dist/step-machine-public/jsonata-sync.cjs +7623 -0
  100. package/dist/storage-refs.cjs +2 -2
  101. package/dist/storage-refs.cjs.map +1 -1
  102. package/dist/storage-refs.d.cts +6 -6
  103. package/dist/storage-refs.d.ts +6 -6
  104. package/dist/storage-refs.js +2 -2
  105. package/dist/storage-refs.js.map +1 -1
  106. package/dist/types-CU3DjTKL.d.cts +147 -0
  107. package/dist/types-HGDTWIun.d.ts +147 -0
  108. package/examples/browser/boards/portfolio-tracker/portfolio-t4.js +9 -10
  109. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-http-test.js +370 -0
  110. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-http-test.py +398 -0
  111. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-public.js +9 -10
  112. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.js +300 -0
  113. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.py +617 -0
  114. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-sse-worker.js +48 -0
  115. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +11 -10
  116. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +19 -4
  117. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +4 -8
  118. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +6 -10
  119. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +8 -16
  120. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +2 -6
  121. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +4 -8
  122. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +3 -7
  123. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +4 -8
  124. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +7 -16
  125. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +2 -6
  126. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +13 -3
  127. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +2 -1
  128. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +2 -1
  129. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +2 -1
  130. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +20 -24
  131. package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +0 -3
  132. package/examples/cli/step-machine-demo/jsonata-init-board-cli.js +8 -13
  133. package/examples/cli/step-machine-demo/jsonata-init-board.flow.yaml +33 -9
  134. package/examples/cli/step-machine-demo/one-step-cli-only.flow.yaml +3 -1
  135. package/examples/cli/step-machine-demo/step2-double-cli.js +6 -12
  136. package/examples/cli/step-machine-demo/two-step-math.flow.yaml +66 -4
  137. package/examples/cli/step-machine-demo/two-step-mixed.flow.yaml +13 -5
  138. package/examples/example-board/agent-instructions.md +1 -1
  139. package/examples/example-board/cards/card-my-identity.json +30 -6
  140. package/examples/example-board/cards/card-portfolio-action.json +24 -6
  141. package/examples/example-board/cards/card-portfolio-intelligence.json +97 -0
  142. package/examples/example-board/cards/card-portfolio-risks.json +24 -6
  143. package/examples/example-board/cards/card-rebalance-impact.json +22 -6
  144. package/examples/example-board/cards/card-rebalance-sim.json +66 -15
  145. package/examples/example-board/cards/cardT-market-prices.json +80 -0
  146. package/examples/example-board/cards/{card-portfolio-value.json → cardT-portfolio-value.json} +38 -10
  147. package/examples/example-board/cards/cardT-portfolio.json +78 -0
  148. package/examples/example-board/demo-server-config.json +1 -1
  149. package/examples/example-board/demo-server.js +383 -69
  150. package/examples/example-board/demo-shell-localstorage.html +774 -0
  151. package/examples/example-board/demo-shell-with-server.html +18 -36
  152. package/examples/example-board/demo-shell.html +5 -4
  153. package/examples/example-board/demo-task-executor.js +213 -265
  154. package/package.json +15 -13
  155. package/step-machine-cli.js +43 -310
  156. package/board-livecards-server-runtime.js +0 -1513
  157. package/browser/board-livecards-runtime-client.js +0 -263
  158. package/dist/pycli/quickjs-board-runtime.global.js +0 -9
  159. package/dist/pycli/quickjs-board-runtime.global.js.map +0 -1
  160. package/dist/pycli/quickjs-step-machine-runtime.global.js +0 -5
  161. package/dist/pycli/quickjs-step-machine-runtime.global.js.map +0 -1
  162. package/examples/cli/step-machine-demo/two-step-math-handlers.js +0 -32
  163. package/examples/cli/step-machine-demo/two-step-mixed-handlers.js +0 -24
  164. package/examples/example-board/cards/card-market-prices.json +0 -56
  165. package/examples/example-board/cards/card-portfolio.json +0 -44
  166. package/examples/example-board/demo-shell-browser.html +0 -675
@@ -1,263 +0,0 @@
1
- (function () {
2
- function clone(x) {
3
- return JSON.parse(JSON.stringify(x));
4
- }
5
-
6
- function replaceNodeInPlace(target, source) {
7
- Object.keys(target).forEach((k) => delete target[k]);
8
- Object.assign(target, clone(source));
9
- }
10
-
11
- function stableNodeString(node) {
12
- return JSON.stringify(node);
13
- }
14
-
15
- function createBoardRuntimeClient(options) {
16
- if (!options || typeof options !== 'object') {
17
- throw new Error('options are required');
18
- }
19
-
20
- const fetchServer = options.fetchServer;
21
- const boardPaths = options.boardPaths;
22
- const buildLiveCardModelsFromArtifacts = options.buildLiveCardModelsFromArtifacts
23
- || (typeof window !== 'undefined' && window.BoardLiveGraph && window.BoardLiveGraph.buildLiveCardModelsFromArtifacts);
24
- const getServerOrigin = options.getServerOrigin;
25
-
26
- if (typeof fetchServer !== 'function') throw new Error('options.fetchServer is required');
27
- if (typeof boardPaths !== 'function') throw new Error('options.boardPaths is required');
28
- if (typeof buildLiveCardModelsFromArtifacts !== 'function') {
29
- throw new Error('options.buildLiveCardModelsFromArtifacts is required (or load board-livegraph-engine.js first)');
30
- }
31
- if (typeof getServerOrigin !== 'function') throw new Error('options.getServerOrigin is required');
32
-
33
- let nodesById = {};
34
- let board = null;
35
- let sse = null;
36
- let currentMode = String(options.initialMode || 'board');
37
- const canvas = options.canvas && typeof options.canvas === 'object'
38
- ? options.canvas
39
- : { height: '72vh', overflow: 'auto' };
40
-
41
- function syncBoardNodes(nextNodes) {
42
- const existingIds = new Set(board ? board.nodes.map((n) => n.id) : []);
43
- const nextById = Object.fromEntries(nextNodes.map((n) => [n.id, n]));
44
- let changed = false;
45
-
46
- if (board) {
47
- for (const id of existingIds) {
48
- if (!nextById[id]) {
49
- board.remove(id);
50
- changed = true;
51
- }
52
- }
53
- }
54
-
55
- for (const nextNode of nextNodes) {
56
- const existing = nodesById[nextNode.id];
57
- if (existing) {
58
- const prevStr = stableNodeString(existing);
59
- const nextStr = stableNodeString(nextNode);
60
- if (prevStr !== nextStr) {
61
- replaceNodeInPlace(existing, nextNode);
62
- changed = true;
63
- }
64
- } else {
65
- nodesById[nextNode.id] = clone(nextNode);
66
- if (board) board.add(nodesById[nextNode.id]);
67
- changed = true;
68
- }
69
- }
70
-
71
- if (board && changed) board.refresh();
72
- }
73
-
74
- async function uploadCardFile(boardId, cardId, file, opts) {
75
- if (!file) return null;
76
- const optionsObj = opts && typeof opts === 'object' ? opts : {};
77
- const inChat = optionsObj.inChat === true;
78
- const fileName = typeof file.name === 'string' ? file.name : 'upload.bin';
79
- const contentType = file.type || 'application/octet-stream';
80
- const paths = boardPaths(boardId);
81
- const uploadPath = inChat
82
- ? `${paths.cardFile(cardId)}?inChat=true`
83
- : paths.cardFile(cardId);
84
-
85
- const upload = await fetchServer(uploadPath, {
86
- method: 'POST',
87
- headers: {
88
- 'content-type': contentType,
89
- 'x-file-name': encodeURIComponent(fileName),
90
- },
91
- body: file,
92
- });
93
-
94
- if (!upload.ok) {
95
- const errText = await upload.text();
96
- throw new Error(`Upload failed (${upload.status}): ${errText || 'unknown error'}`);
97
- }
98
-
99
- const payload = await upload.json();
100
- return payload && payload.file ? payload.file : null;
101
- }
102
-
103
- async function uploadActionFiles(boardId, cardId, actionType, payload) {
104
- if (actionType !== 'chat-send' && actionType !== 'file-upload') return payload || {};
105
- const nextPayload = { ...(payload || {}) };
106
- const rawFiles = Array.isArray(nextPayload.files) ? nextPayload.files : [];
107
- if (!rawFiles.length) {
108
- nextPayload.files = [];
109
- return nextPayload;
110
- }
111
-
112
- const uploaded = [];
113
- for (const file of rawFiles) {
114
- const fileMeta = await uploadCardFile(boardId, cardId, file, { inChat: actionType === 'chat-send' });
115
- if (fileMeta) uploaded.push(fileMeta);
116
- }
117
-
118
- // For chat uploads, server-side file API already records file metadata and emits system chat logs.
119
- nextPayload.files = actionType === 'chat-send' ? [] : uploaded;
120
- return nextPayload;
121
- }
122
-
123
- async function bootstrapBoard(params) {
124
- const p = params && typeof params === 'object' ? params : {};
125
- const boardId = String(p.boardId || 'default');
126
- const taskExecutorPath = typeof p.taskExecutorPath === 'string' ? p.taskExecutorPath.trim() : '';
127
- const mode = String(p.mode || currentMode || 'board');
128
- const rootEl = p.rootElement;
129
- if (!rootEl) throw new Error('bootstrapBoard requires params.rootElement');
130
-
131
- const paths = boardPaths(boardId);
132
-
133
- const initBoardPath = taskExecutorPath
134
- ? `${paths.initBoard}?taskExecutorPath=${encodeURIComponent(taskExecutorPath)}`
135
- : paths.initBoard;
136
- const initBoardRes = await fetchServer(initBoardPath);
137
- if (!initBoardRes.ok) throw new Error(`Server init-board failed (${initBoardRes.status}).`);
138
-
139
- const bootstrapCardsRes = await fetchServer(paths.bootstrapCards);
140
- if (!bootstrapCardsRes.ok) {
141
- throw new Error(`Server bootstrap-cards failed (${bootstrapCardsRes.status}).`);
142
- }
143
-
144
- const payload = await bootstrapCardsRes.json();
145
- const cards = buildLiveCardModelsFromArtifacts(payload);
146
- if (!Array.isArray(cards)) throw new Error('Server payload missing published runtime artifacts');
147
-
148
- nodesById = {};
149
- for (const n of cards) nodesById[n.id] = clone(n);
150
-
151
- const engine = LiveCard.init({
152
- resolve: (id) => nodesById[id],
153
- markdown: (typeof marked !== 'undefined')
154
- ? (text) => marked.parse(text)
155
- : null,
156
- onPatchState: async (id, patch) => {
157
- await fetchServer(paths.patchCard(id), {
158
- method: 'PATCH',
159
- headers: { 'content-type': 'application/json' },
160
- body: JSON.stringify(patch || {}),
161
- });
162
- },
163
- onRefresh: async (id) => {
164
- await fetchServer(paths.patchCard(id), {
165
- method: 'PATCH',
166
- headers: { 'content-type': 'application/json' },
167
- body: JSON.stringify({}),
168
- });
169
- },
170
- onAction: async (id, actionType, actionPayload) => {
171
- const uploadedPayload = await uploadActionFiles(boardId, id, actionType, actionPayload);
172
- await fetchServer(paths.cardAction(id), {
173
- method: 'POST',
174
- headers: { 'content-type': 'application/json' },
175
- body: JSON.stringify({ actionType, payload: uploadedPayload || {} }),
176
- });
177
- },
178
- getChatMessages: async (id) => {
179
- const res = await fetchServer(paths.cardChats(id));
180
- if (!res.ok) return [];
181
- const chatPayload = await res.json();
182
- const items = Array.isArray(chatPayload && chatPayload.messages) ? chatPayload.messages : [];
183
- return items.map((m) => ({
184
- role: m && typeof m.role === 'string' ? m.role : 'system',
185
- text: m && typeof m.text === 'string' ? m.text : '',
186
- files: [],
187
- }));
188
- },
189
- });
190
-
191
- rootEl.innerHTML = '';
192
- board = LiveCard.Board(engine, rootEl, {
193
- nodes: Object.values(nodesById),
194
- mode,
195
- canvas,
196
- });
197
- currentMode = mode;
198
-
199
- const origin = getServerOrigin();
200
- if (!origin) {
201
- throw new Error('Server origin not resolved before SSE start');
202
- }
203
- sse = new EventSource(`${origin}${paths.stream}`);
204
- sse.onmessage = function (evt) {
205
- try {
206
- const update = JSON.parse(evt.data || '{}');
207
- syncBoardNodes(buildLiveCardModelsFromArtifacts(update));
208
- if (board && board.engine && typeof board.engine.onServerSseEvent === 'function') {
209
- board.engine.onServerSseEvent();
210
- } else if (board && board.engine && typeof board.engine.refreshOpenChatModal === 'function') {
211
- board.engine.refreshOpenChatModal();
212
- }
213
- } catch (err) {
214
- console.warn('Bad SSE payload', err);
215
- }
216
- };
217
-
218
- return board;
219
- }
220
-
221
- function dispose() {
222
- if (sse) {
223
- sse.close();
224
- sse = null;
225
- }
226
- board = null;
227
- nodesById = {};
228
- }
229
-
230
- function setMode(mode) {
231
- currentMode = String(mode || 'board');
232
- if (board) board.setMode(currentMode);
233
- }
234
-
235
- function autoLayout() {
236
- if (!board) return;
237
- board.setMode('canvas');
238
- currentMode = 'canvas';
239
- board.autoLayout();
240
- }
241
-
242
- function setDevMode(enabled) {
243
- if (board) board.setDevMode(Boolean(enabled));
244
- }
245
-
246
- function getCurrentMode() {
247
- return currentMode;
248
- }
249
-
250
- return {
251
- bootstrapBoard,
252
- dispose,
253
- setMode,
254
- autoLayout,
255
- setDevMode,
256
- getCurrentMode,
257
- };
258
- }
259
-
260
- window.ReusableBoardRuntimeClient = {
261
- createBoardRuntimeClient,
262
- };
263
- })();