yaml-flow 5.2.6 → 5.3.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 (84) hide show
  1. package/README.md +6 -6
  2. package/board-livecards-server-runtime.js +260 -35
  3. package/browser/board-livegraph-engine.js +61 -33
  4. package/browser/board-livegraph-engine.js.map +1 -1
  5. package/browser/card-compute.js +18 -18
  6. package/browser/live-cards.js +317 -156
  7. package/browser/live-cards.schema.json +15 -10
  8. package/dist/board-livegraph-runtime/index.cjs +61 -33
  9. package/dist/board-livegraph-runtime/index.cjs.map +1 -1
  10. package/dist/board-livegraph-runtime/index.d.cts +1 -1
  11. package/dist/board-livegraph-runtime/index.d.ts +1 -1
  12. package/dist/board-livegraph-runtime/index.js +61 -33
  13. package/dist/board-livegraph-runtime/index.js.map +1 -1
  14. package/dist/card-compute/index.cjs +101 -39
  15. package/dist/card-compute/index.cjs.map +1 -1
  16. package/dist/card-compute/index.d.cts +13 -8
  17. package/dist/card-compute/index.d.ts +13 -8
  18. package/dist/card-compute/index.js +101 -39
  19. package/dist/card-compute/index.js.map +1 -1
  20. package/dist/cli/board-live-cards-cli.cjs +7205 -202
  21. package/dist/cli/board-live-cards-cli.cjs.map +1 -1
  22. package/dist/cli/board-live-cards-cli.d.cts +6 -6
  23. package/dist/cli/board-live-cards-cli.d.ts +6 -6
  24. package/dist/cli/board-live-cards-cli.js +7204 -202
  25. package/dist/cli/board-live-cards-cli.js.map +1 -1
  26. package/dist/continuous-event-graph/index.cjs +59 -31
  27. package/dist/continuous-event-graph/index.cjs.map +1 -1
  28. package/dist/continuous-event-graph/index.d.cts +2 -2
  29. package/dist/continuous-event-graph/index.d.ts +2 -2
  30. package/dist/continuous-event-graph/index.js +59 -31
  31. package/dist/continuous-event-graph/index.js.map +1 -1
  32. package/dist/index.cjs +126 -54
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +1 -1
  35. package/dist/index.d.ts +1 -1
  36. package/dist/index.js +126 -54
  37. package/dist/index.js.map +1 -1
  38. package/dist/{live-cards-bridge-CeNxiVcm.d.ts → live-cards-bridge-EQjytzI_.d.ts} +10 -5
  39. package/dist/{live-cards-bridge-z_rJCSbi.d.cts → live-cards-bridge-x5XREkXm.d.cts} +10 -5
  40. package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +1 -1
  41. package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +1 -1
  42. package/examples/browser/boards/portfolio-tracker/cards/portfolio-risk-assessment.json +1 -1
  43. package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +1 -1
  44. package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +2 -2
  45. package/examples/browser/boards/portfolio-tracker/cards/rebalancing-strategy.json +1 -1
  46. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +10 -10
  47. package/examples/cli/step-machine-cli/portfolio-tracker/cards/holdings-table.json +1 -1
  48. package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +1 -1
  49. package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +1 -1
  50. package/examples/cli/step-machine-cli/portfolio-tracker/cards/price-fetch.json +2 -2
  51. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +1 -1
  52. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +1 -1
  53. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +1 -1
  54. package/examples/example-board/agent-instructions-cardlayout.md +29 -1
  55. package/examples/example-board/agent-instructions.md +271 -45
  56. package/examples/example-board/cards/card-concentration.json +8 -5
  57. package/examples/example-board/cards/card-market-prices.json +14 -9
  58. package/examples/example-board/cards/card-my-identity.json +28 -0
  59. package/examples/example-board/cards/card-portfolio-value.json +1 -1
  60. package/examples/example-board/cards/card-portfolio.json +1 -1
  61. package/examples/example-board/cards/card-rebalance-impact.json +65 -0
  62. package/examples/example-board/cards/card-rebalance-sim.json +67 -0
  63. package/examples/example-board/demo-chat-handler.js +2 -1
  64. package/examples/example-board/demo-server-config.json +6 -1
  65. package/examples/example-board/demo-server.js +91 -8
  66. package/examples/example-board/demo-shell-browser.html +6 -6
  67. package/examples/example-board/demo-shell-with-server.html +4 -4
  68. package/examples/example-board/demo-task-executor.js +457 -246
  69. package/examples/example-board/scripts/copilot_wrapper.bat +16 -0
  70. package/examples/example-board/scripts/copilot_wrapper_helper.ps1 +19 -10
  71. package/examples/example-board/scripts/workiq_wrapper.mjs +66 -0
  72. package/examples/npm-libs/continuous-event-graph/live-cards-board.ts +5 -5
  73. package/examples/npm-libs/continuous-event-graph/soc-incident-board.ts +3 -3
  74. package/examples/npm-libs/event-graph/research-pipeline.ts +5 -5
  75. package/examples/npm-libs/graph-of-graphs/multi-stage-etl.ts +9 -9
  76. package/examples/step-machine-cli/portfolio-tracker/cards/holdings-table.json +1 -1
  77. package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +1 -1
  78. package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +1 -1
  79. package/examples/step-machine-cli/portfolio-tracker/cards/price-fetch.json +3 -3
  80. package/examples/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +1 -1
  81. package/examples/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +1 -1
  82. package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +1 -1
  83. package/package.json +2 -2
  84. package/schema/live-cards.schema.json +15 -10
@@ -1,7 +1,7 @@
1
1
  import { G as GraphConfig, f as GraphEvent } from '../types-BBhqYGhE.cjs';
2
2
  import { L as LiveGraph } from '../types-CHSdoAAA.cjs';
3
3
  import { s as schedule } from '../schedule-qWNL0RQh.cjs';
4
- import { R as ReactiveGraph, a as LiveCard, e as TaskHandlerInput, d as ReactiveGraphOptions, L as LiveBoard } from '../live-cards-bridge-z_rJCSbi.cjs';
4
+ import { R as ReactiveGraph, a as LiveCard, e as TaskHandlerInput, d as ReactiveGraphOptions, L as LiveBoard } from '../live-cards-bridge-x5XREkXm.cjs';
5
5
 
6
6
  interface BrowserSourceAdapterContext {
7
7
  card: LiveCard;
@@ -1,7 +1,7 @@
1
1
  import { G as GraphConfig, f as GraphEvent } from '../types-BBhqYGhE.js';
2
2
  import { L as LiveGraph } from '../types-CoW0gQl3.js';
3
3
  import { s as schedule } from '../schedule-Cszq9LYY.js';
4
- import { R as ReactiveGraph, a as LiveCard, e as TaskHandlerInput, d as ReactiveGraphOptions, L as LiveBoard } from '../live-cards-bridge-CeNxiVcm.js';
4
+ import { R as ReactiveGraph, a as LiveCard, e as TaskHandlerInput, d as ReactiveGraphOptions, L as LiveBoard } from '../live-cards-bridge-EQjytzI_.js';
5
5
 
6
6
  interface BrowserSourceAdapterContext {
7
7
  card: LiveCard;
@@ -64,6 +64,7 @@ function resolve(node, path) {
64
64
  var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
65
65
  "metric",
66
66
  "table",
67
+ "editable-table",
67
68
  "chart",
68
69
  "form",
69
70
  "filter",
@@ -75,9 +76,11 @@ var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
75
76
  "badge",
76
77
  "text",
77
78
  "markdown",
78
- "custom"
79
+ "ref",
80
+ "custom",
81
+ "actions"
79
82
  ]);
80
- var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "sources"]);
83
+ var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "source_defs"]);
81
84
  function validateNode(node) {
82
85
  const errors = [];
83
86
  if (!node || typeof node !== "object" || Array.isArray(node)) {
@@ -103,15 +106,15 @@ function validateNode(node) {
103
106
  if (n.requires != null && !Array.isArray(n.requires)) errors.push("requires: must be an array of strings");
104
107
  if (n.provides != null) {
105
108
  if (!Array.isArray(n.provides)) {
106
- errors.push("provides: must be an array of { bindTo, src } bindings");
109
+ errors.push("provides: must be an array of { bindTo, ref } bindings");
107
110
  } else {
108
111
  n.provides.forEach((p, i) => {
109
112
  if (!p || typeof p !== "object" || Array.isArray(p)) {
110
- errors.push(`provides[${i}]: must be an object with bindTo and src`);
113
+ errors.push(`provides[${i}]: must be an object with bindTo and ref`);
111
114
  } else {
112
115
  const b = p;
113
116
  if (typeof b.bindTo !== "string" || !b.bindTo) errors.push(`provides[${i}]: missing required "bindTo" string`);
114
- if (typeof b.src !== "string" || !b.src) errors.push(`provides[${i}]: missing required "src" string`);
117
+ if (typeof b.ref !== "string" || !b.ref) errors.push(`provides[${i}]: missing required "ref" string`);
115
118
  }
116
119
  });
117
120
  }
@@ -131,35 +134,35 @@ function validateNode(node) {
131
134
  });
132
135
  }
133
136
  }
134
- if (n.sources != null) {
135
- if (!Array.isArray(n.sources)) {
136
- errors.push("sources: must be an array");
137
+ if (n.source_defs != null) {
138
+ if (!Array.isArray(n.source_defs)) {
139
+ errors.push("source_defs: must be an array");
137
140
  } else {
138
141
  const bindTos = /* @__PURE__ */ new Set();
139
142
  const outputFiles = /* @__PURE__ */ new Set();
140
- n.sources.forEach((src, i) => {
143
+ n.source_defs.forEach((src, i) => {
141
144
  if (!src || typeof src !== "object" || Array.isArray(src)) {
142
- errors.push(`sources[${i}]: must be an object`);
145
+ errors.push(`source_defs[${i}]: must be an object`);
143
146
  } else {
144
147
  const s = src;
145
148
  if (typeof s.bindTo !== "string" || !s.bindTo) {
146
- errors.push(`sources[${i}]: missing required "bindTo" property`);
149
+ errors.push(`source_defs[${i}]: missing required "bindTo" property`);
147
150
  } else {
148
151
  if (bindTos.has(s.bindTo)) {
149
- errors.push(`sources[${i}]: bindTo "${s.bindTo}" is not unique across sources`);
152
+ errors.push(`source_defs[${i}]: bindTo "${s.bindTo}" is not unique across source_defs`);
150
153
  }
151
154
  bindTos.add(s.bindTo);
152
155
  }
153
156
  if (typeof s.outputFile !== "string" || !s.outputFile) {
154
- errors.push(`sources[${i}]: missing required "outputFile" property`);
157
+ errors.push(`source_defs[${i}]: missing required "outputFile" property`);
155
158
  } else {
156
159
  if (outputFiles.has(s.outputFile)) {
157
- errors.push(`sources[${i}]: outputFile "${s.outputFile}" is not unique across sources`);
160
+ errors.push(`source_defs[${i}]: outputFile "${s.outputFile}" is not unique across source_defs`);
158
161
  }
159
162
  outputFiles.add(s.outputFile);
160
163
  }
161
164
  if (s.optionalForCompletionGating != null && typeof s.optionalForCompletionGating !== "boolean") {
162
- errors.push(`sources[${i}]: optionalForCompletionGating must be a boolean`);
165
+ errors.push(`source_defs[${i}]: optionalForCompletionGating must be a boolean`);
163
166
  }
164
167
  }
165
168
  });
@@ -194,14 +197,29 @@ function validateNode(node) {
194
197
  }
195
198
  return { ok: errors.length === 0, errors };
196
199
  }
197
- function enrichSources(sources, context) {
198
- if (!sources || sources.length === 0) return [];
199
- return sources.map((src) => ({
200
- ...src,
201
- _requires: context.requires ?? {},
202
- _sourcesData: context.sourcesData ?? {},
203
- _computed_values: context.computed_values ?? {}
204
- }));
200
+ async function enrichSources(source_defs, context) {
201
+ if (!source_defs || source_defs.length === 0) return [];
202
+ const evalCtx = {
203
+ card_data: context.card_data ?? {},
204
+ requires: context.requires ?? {}
205
+ };
206
+ return Promise.all(
207
+ source_defs.map(async (src) => {
208
+ const _projections = {};
209
+ if (src.projections && typeof src.projections === "object" && !Array.isArray(src.projections)) {
210
+ for (const [key, expr] of Object.entries(src.projections)) {
211
+ if (typeof expr === "string" && expr.trim().length > 0) {
212
+ try {
213
+ _projections[key] = await jsonata2(expr).evaluate(evalCtx);
214
+ } catch {
215
+ _projections[key] = void 0;
216
+ }
217
+ }
218
+ }
219
+ }
220
+ return { ...src, _projections };
221
+ })
222
+ );
205
223
  }
206
224
  var CardCompute = {
207
225
  run,
@@ -902,6 +920,7 @@ function createReactiveGraph(configOrLive, options, executionId) {
902
920
  const inputQueue = new MemoryJournal();
903
921
  let live = "state" in configOrLive && "config" in configOrLive ? configOrLive : createLiveGraph(configOrLive, executionId);
904
922
  let disposed = false;
923
+ const pendingHandlers = /* @__PURE__ */ new Set();
905
924
  const handlers = new Map(Object.entries(initialHandlers));
906
925
  const internalJournal = new MemoryJournal();
907
926
  let draining = false;
@@ -944,7 +963,7 @@ function createReactiveGraph(configOrLive, options, executionId) {
944
963
  const taskState = live.state.tasks[taskName];
945
964
  if (!taskState || taskState.status !== "running") continue;
946
965
  const callbackToken = encodeCallbackToken(taskName);
947
- runPipeline(taskName, callbackToken, update).catch((error) => {
966
+ const p = runPipeline(taskName, callbackToken, update).catch((error) => {
948
967
  if (disposed) return;
949
968
  internalJournal.append({
950
969
  type: "task-failed",
@@ -953,7 +972,10 @@ function createReactiveGraph(configOrLive, options, executionId) {
953
972
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
954
973
  });
955
974
  drain();
975
+ }).finally(() => {
976
+ pendingHandlers.delete(p);
956
977
  });
978
+ pendingHandlers.add(p);
957
979
  }
958
980
  }
959
981
  }
@@ -1013,7 +1035,7 @@ function createReactiveGraph(configOrLive, options, executionId) {
1013
1035
  });
1014
1036
  drain();
1015
1037
  const callbackToken = encodeCallbackToken(taskName);
1016
- runPipeline(taskName, callbackToken).catch((error) => {
1038
+ const p = runPipeline(taskName, callbackToken).catch((error) => {
1017
1039
  if (disposed) return;
1018
1040
  internalJournal.append({
1019
1041
  type: "task-failed",
@@ -1022,7 +1044,10 @@ function createReactiveGraph(configOrLive, options, executionId) {
1022
1044
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
1023
1045
  });
1024
1046
  drain();
1047
+ }).finally(() => {
1048
+ pendingHandlers.delete(p);
1025
1049
  });
1050
+ pendingHandlers.add(p);
1026
1051
  }
1027
1052
  return {
1028
1053
  push(event) {
@@ -1136,7 +1161,10 @@ function createReactiveGraph(configOrLive, options, executionId) {
1136
1161
  getSchedule() {
1137
1162
  return schedule(live);
1138
1163
  },
1139
- dispose() {
1164
+ async dispose(options2) {
1165
+ if (options2?.wait && pendingHandlers.size > 0) {
1166
+ await Promise.allSettled([...pendingHandlers]);
1167
+ }
1140
1168
  disposed = true;
1141
1169
  }
1142
1170
  };
@@ -1158,7 +1186,7 @@ function toTaskConfig(card) {
1158
1186
  function buildTokenProviders(cards) {
1159
1187
  const tokenToCardId = /* @__PURE__ */ new Map();
1160
1188
  for (const [cardId, card] of cards.entries()) {
1161
- const bindings = card.provides && card.provides.length > 0 ? card.provides : [{ bindTo: cardId, src: "card_data" }];
1189
+ const bindings = card.provides && card.provides.length > 0 ? card.provides : [{ bindTo: cardId, ref: "card_data" }];
1162
1190
  for (const binding of bindings) tokenToCardId.set(binding.bindTo, cardId);
1163
1191
  }
1164
1192
  return tokenToCardId;
@@ -1304,14 +1332,14 @@ function createBoardLiveGraphRuntime(input, options = {}) {
1304
1332
  requiresData[token] = providesData2[token];
1305
1333
  }
1306
1334
  const sourcesData = {};
1307
- if (card.sources && card.sources.length > 0) {
1335
+ if (card.source_defs && card.source_defs.length > 0) {
1308
1336
  const adapter = sourceAdapters[cardId] ?? defaultSourceAdapter;
1309
1337
  const fetched = taskExecutor ? await taskExecutor({ card, input: inputArgs }) : adapter ? await adapter({ card, input: inputArgs }) : void 0;
1310
1338
  if (fetched && typeof fetched === "object") {
1311
- for (const src of card.sources) {
1339
+ for (const src of card.source_defs) {
1312
1340
  if (Object.prototype.hasOwnProperty.call(fetched, src.bindTo)) {
1313
1341
  sourcesData[src.bindTo] = fetched[src.bindTo];
1314
- } else if (card.sources.length === 1) {
1342
+ } else if (card.source_defs.length === 1) {
1315
1343
  sourcesData[src.bindTo] = fetched;
1316
1344
  }
1317
1345
  }
@@ -1321,7 +1349,7 @@ function createBoardLiveGraphRuntime(input, options = {}) {
1321
1349
  id: card.id,
1322
1350
  card_data: deepClone(card.card_data ?? {}),
1323
1351
  requires: requiresData,
1324
- sources: card.sources,
1352
+ source_defs: card.source_defs,
1325
1353
  compute: card.compute
1326
1354
  };
1327
1355
  computeNode._sourcesData = sourcesData;
@@ -1330,8 +1358,8 @@ function createBoardLiveGraphRuntime(input, options = {}) {
1330
1358
  }
1331
1359
  const providesData = {};
1332
1360
  if (card.provides && card.provides.length > 0) {
1333
- for (const { bindTo, src } of card.provides) {
1334
- providesData[bindTo] = CardCompute.resolve(computeNode, src);
1361
+ for (const { bindTo, ref } of card.provides) {
1362
+ providesData[bindTo] = CardCompute.resolve(computeNode, ref);
1335
1363
  }
1336
1364
  } else {
1337
1365
  providesData[card.id] = {