yaml-flow 5.2.6 → 5.2.8

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 +57 -32
  4. package/browser/board-livegraph-engine.js.map +1 -1
  5. package/browser/card-compute.js +17 -17
  6. package/browser/live-cards.js +139 -12
  7. package/browser/live-cards.schema.json +14 -9
  8. package/dist/board-livegraph-runtime/index.cjs +57 -32
  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 +57 -32
  13. package/dist/board-livegraph-runtime/index.js.map +1 -1
  14. package/dist/card-compute/index.cjs +96 -38
  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 +96 -38
  19. package/dist/card-compute/index.js.map +1 -1
  20. package/dist/cli/board-live-cards-cli.cjs +7200 -201
  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 +7199 -201
  25. package/dist/cli/board-live-cards-cli.js.map +1 -1
  26. package/dist/continuous-event-graph/index.cjs +55 -30
  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 +55 -30
  31. package/dist/continuous-event-graph/index.js.map +1 -1
  32. package/dist/index.cjs +121 -53
  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 +121 -53
  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 +1 -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 +57 -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 +79 -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 +436 -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 +14 -9
@@ -3,8 +3,8 @@ export { B as BlockedTask, P as PendingTask, S as ScheduleResult, d as Unresolve
3
3
  import { T as TaskConfig, f as GraphEvent, G as GraphConfig } from '../types-BBhqYGhE.cjs';
4
4
  export { c as ExecutionState, e as GraphEngineStore, g as GraphSettings } from '../types-BBhqYGhE.cjs';
5
5
  export { s as schedule } from '../schedule-qWNL0RQh.cjs';
6
- import { R as ReactiveGraph, e as TaskHandlerInput, T as TaskHandlerFn } from '../live-cards-bridge-z_rJCSbi.cjs';
7
- export { L as LiveBoard, a as LiveCard, b as LiveCardsToReactiveOptions, c as LiveCardsToReactiveResult, d as ReactiveGraphOptions, f as TaskHandlerReturn, h as computeDataHash, g as createReactiveGraph, l as liveCardsToReactiveGraph } from '../live-cards-bridge-z_rJCSbi.cjs';
6
+ import { R as ReactiveGraph, e as TaskHandlerInput, T as TaskHandlerFn } from '../live-cards-bridge-x5XREkXm.cjs';
7
+ export { L as LiveBoard, a as LiveCard, b as LiveCardsToReactiveOptions, c as LiveCardsToReactiveResult, d as ReactiveGraphOptions, f as TaskHandlerReturn, h as computeDataHash, g as createReactiveGraph, l as liveCardsToReactiveGraph } from '../live-cards-bridge-x5XREkXm.cjs';
8
8
  import { a as GraphValidationResult } from '../validate-Dbu7ygys.cjs';
9
9
  export { J as Journal, M as MemoryJournal } from '../journal-B-JCfQnh.cjs';
10
10
 
@@ -3,8 +3,8 @@ export { B as BlockedTask, P as PendingTask, S as ScheduleResult, d as Unresolve
3
3
  import { T as TaskConfig, f as GraphEvent, G as GraphConfig } from '../types-BBhqYGhE.js';
4
4
  export { c as ExecutionState, e as GraphEngineStore, g as GraphSettings } from '../types-BBhqYGhE.js';
5
5
  export { s as schedule } from '../schedule-Cszq9LYY.js';
6
- import { R as ReactiveGraph, e as TaskHandlerInput, T as TaskHandlerFn } from '../live-cards-bridge-CeNxiVcm.js';
7
- export { L as LiveBoard, a as LiveCard, b as LiveCardsToReactiveOptions, c as LiveCardsToReactiveResult, d as ReactiveGraphOptions, f as TaskHandlerReturn, h as computeDataHash, g as createReactiveGraph, l as liveCardsToReactiveGraph } from '../live-cards-bridge-CeNxiVcm.js';
6
+ import { R as ReactiveGraph, e as TaskHandlerInput, T as TaskHandlerFn } from '../live-cards-bridge-EQjytzI_.js';
7
+ export { L as LiveBoard, a as LiveCard, b as LiveCardsToReactiveOptions, c as LiveCardsToReactiveResult, d as ReactiveGraphOptions, f as TaskHandlerReturn, h as computeDataHash, g as createReactiveGraph, l as liveCardsToReactiveGraph } from '../live-cards-bridge-EQjytzI_.js';
8
8
  import { a as GraphValidationResult } from '../validate-BAVzUJWa.js';
9
9
  export { J as Journal, M as MemoryJournal } from '../journal-9HEgs7dU.js';
10
10
 
@@ -1113,6 +1113,7 @@ function createReactiveGraph(configOrLive, options, executionId) {
1113
1113
  const inputQueue = new MemoryJournal();
1114
1114
  let live = "state" in configOrLive && "config" in configOrLive ? configOrLive : createLiveGraph(configOrLive, executionId);
1115
1115
  let disposed = false;
1116
+ const pendingHandlers = /* @__PURE__ */ new Set();
1116
1117
  const handlers = new Map(Object.entries(initialHandlers));
1117
1118
  const internalJournal = new MemoryJournal();
1118
1119
  let draining = false;
@@ -1155,7 +1156,7 @@ function createReactiveGraph(configOrLive, options, executionId) {
1155
1156
  const taskState = live.state.tasks[taskName];
1156
1157
  if (!taskState || taskState.status !== "running") continue;
1157
1158
  const callbackToken = encodeCallbackToken(taskName);
1158
- runPipeline(taskName, callbackToken, update).catch((error) => {
1159
+ const p = runPipeline(taskName, callbackToken, update).catch((error) => {
1159
1160
  if (disposed) return;
1160
1161
  internalJournal.append({
1161
1162
  type: "task-failed",
@@ -1164,7 +1165,10 @@ function createReactiveGraph(configOrLive, options, executionId) {
1164
1165
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
1165
1166
  });
1166
1167
  drain();
1168
+ }).finally(() => {
1169
+ pendingHandlers.delete(p);
1167
1170
  });
1171
+ pendingHandlers.add(p);
1168
1172
  }
1169
1173
  }
1170
1174
  }
@@ -1224,7 +1228,7 @@ function createReactiveGraph(configOrLive, options, executionId) {
1224
1228
  });
1225
1229
  drain();
1226
1230
  const callbackToken = encodeCallbackToken(taskName);
1227
- runPipeline(taskName, callbackToken).catch((error) => {
1231
+ const p = runPipeline(taskName, callbackToken).catch((error) => {
1228
1232
  if (disposed) return;
1229
1233
  internalJournal.append({
1230
1234
  type: "task-failed",
@@ -1233,7 +1237,10 @@ function createReactiveGraph(configOrLive, options, executionId) {
1233
1237
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
1234
1238
  });
1235
1239
  drain();
1240
+ }).finally(() => {
1241
+ pendingHandlers.delete(p);
1236
1242
  });
1243
+ pendingHandlers.add(p);
1237
1244
  }
1238
1245
  return {
1239
1246
  push(event) {
@@ -1347,7 +1354,10 @@ function createReactiveGraph(configOrLive, options, executionId) {
1347
1354
  getSchedule() {
1348
1355
  return schedule(live);
1349
1356
  },
1350
- dispose() {
1357
+ async dispose(options2) {
1358
+ if (options2?.wait && pendingHandlers.size > 0) {
1359
+ await Promise.allSettled([...pendingHandlers]);
1360
+ }
1351
1361
  disposed = true;
1352
1362
  }
1353
1363
  };
@@ -1777,7 +1787,7 @@ var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
1777
1787
  "markdown",
1778
1788
  "custom"
1779
1789
  ]);
1780
- var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "sources"]);
1790
+ var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "source_defs"]);
1781
1791
  function validateNode(node) {
1782
1792
  const errors = [];
1783
1793
  if (!node || typeof node !== "object" || Array.isArray(node)) {
@@ -1803,15 +1813,15 @@ function validateNode(node) {
1803
1813
  if (n.requires != null && !Array.isArray(n.requires)) errors.push("requires: must be an array of strings");
1804
1814
  if (n.provides != null) {
1805
1815
  if (!Array.isArray(n.provides)) {
1806
- errors.push("provides: must be an array of { bindTo, src } bindings");
1816
+ errors.push("provides: must be an array of { bindTo, ref } bindings");
1807
1817
  } else {
1808
1818
  n.provides.forEach((p, i) => {
1809
1819
  if (!p || typeof p !== "object" || Array.isArray(p)) {
1810
- errors.push(`provides[${i}]: must be an object with bindTo and src`);
1820
+ errors.push(`provides[${i}]: must be an object with bindTo and ref`);
1811
1821
  } else {
1812
1822
  const b = p;
1813
1823
  if (typeof b.bindTo !== "string" || !b.bindTo) errors.push(`provides[${i}]: missing required "bindTo" string`);
1814
- if (typeof b.src !== "string" || !b.src) errors.push(`provides[${i}]: missing required "src" string`);
1824
+ if (typeof b.ref !== "string" || !b.ref) errors.push(`provides[${i}]: missing required "ref" string`);
1815
1825
  }
1816
1826
  });
1817
1827
  }
@@ -1831,35 +1841,35 @@ function validateNode(node) {
1831
1841
  });
1832
1842
  }
1833
1843
  }
1834
- if (n.sources != null) {
1835
- if (!Array.isArray(n.sources)) {
1836
- errors.push("sources: must be an array");
1844
+ if (n.source_defs != null) {
1845
+ if (!Array.isArray(n.source_defs)) {
1846
+ errors.push("source_defs: must be an array");
1837
1847
  } else {
1838
1848
  const bindTos = /* @__PURE__ */ new Set();
1839
1849
  const outputFiles = /* @__PURE__ */ new Set();
1840
- n.sources.forEach((src, i) => {
1850
+ n.source_defs.forEach((src, i) => {
1841
1851
  if (!src || typeof src !== "object" || Array.isArray(src)) {
1842
- errors.push(`sources[${i}]: must be an object`);
1852
+ errors.push(`source_defs[${i}]: must be an object`);
1843
1853
  } else {
1844
1854
  const s = src;
1845
1855
  if (typeof s.bindTo !== "string" || !s.bindTo) {
1846
- errors.push(`sources[${i}]: missing required "bindTo" property`);
1856
+ errors.push(`source_defs[${i}]: missing required "bindTo" property`);
1847
1857
  } else {
1848
1858
  if (bindTos.has(s.bindTo)) {
1849
- errors.push(`sources[${i}]: bindTo "${s.bindTo}" is not unique across sources`);
1859
+ errors.push(`source_defs[${i}]: bindTo "${s.bindTo}" is not unique across source_defs`);
1850
1860
  }
1851
1861
  bindTos.add(s.bindTo);
1852
1862
  }
1853
1863
  if (typeof s.outputFile !== "string" || !s.outputFile) {
1854
- errors.push(`sources[${i}]: missing required "outputFile" property`);
1864
+ errors.push(`source_defs[${i}]: missing required "outputFile" property`);
1855
1865
  } else {
1856
1866
  if (outputFiles.has(s.outputFile)) {
1857
- errors.push(`sources[${i}]: outputFile "${s.outputFile}" is not unique across sources`);
1867
+ errors.push(`source_defs[${i}]: outputFile "${s.outputFile}" is not unique across source_defs`);
1858
1868
  }
1859
1869
  outputFiles.add(s.outputFile);
1860
1870
  }
1861
1871
  if (s.optionalForCompletionGating != null && typeof s.optionalForCompletionGating !== "boolean") {
1862
- errors.push(`sources[${i}]: optionalForCompletionGating must be a boolean`);
1872
+ errors.push(`source_defs[${i}]: optionalForCompletionGating must be a boolean`);
1863
1873
  }
1864
1874
  }
1865
1875
  });
@@ -1894,14 +1904,29 @@ function validateNode(node) {
1894
1904
  }
1895
1905
  return { ok: errors.length === 0, errors };
1896
1906
  }
1897
- function enrichSources(sources, context) {
1898
- if (!sources || sources.length === 0) return [];
1899
- return sources.map((src) => ({
1900
- ...src,
1901
- _requires: context.requires ?? {},
1902
- _sourcesData: context.sourcesData ?? {},
1903
- _computed_values: context.computed_values ?? {}
1904
- }));
1907
+ async function enrichSources(source_defs, context) {
1908
+ if (!source_defs || source_defs.length === 0) return [];
1909
+ const evalCtx = {
1910
+ card_data: context.card_data ?? {},
1911
+ requires: context.requires ?? {}
1912
+ };
1913
+ return Promise.all(
1914
+ source_defs.map(async (src) => {
1915
+ const _projections = {};
1916
+ if (src.projections && typeof src.projections === "object" && !Array.isArray(src.projections)) {
1917
+ for (const [key, expr] of Object.entries(src.projections)) {
1918
+ if (typeof expr === "string" && expr.trim().length > 0) {
1919
+ try {
1920
+ _projections[key] = await jsonata2(expr).evaluate(evalCtx);
1921
+ } catch {
1922
+ _projections[key] = void 0;
1923
+ }
1924
+ }
1925
+ }
1926
+ }
1927
+ return { ...src, _projections };
1928
+ })
1929
+ );
1905
1930
  }
1906
1931
  var CardCompute = {
1907
1932
  run,
@@ -1944,7 +1969,7 @@ function liveCardsToReactiveGraph(input, options = {}) {
1944
1969
  const allTokens = /* @__PURE__ */ new Set();
1945
1970
  const tokenToCardId = /* @__PURE__ */ new Map();
1946
1971
  for (const card of cards) {
1947
- for (const binding of card.provides ?? [{ bindTo: card.id, src: "card_data" }]) {
1972
+ for (const binding of card.provides ?? [{ bindTo: card.id, ref: "card_data" }]) {
1948
1973
  allTokens.add(binding.bindTo);
1949
1974
  tokenToCardId.set(binding.bindTo, card.id);
1950
1975
  }
@@ -1958,7 +1983,7 @@ function liveCardsToReactiveGraph(input, options = {}) {
1958
1983
  }
1959
1984
  tasks[card.id] = {
1960
1985
  requires: requires.length > 0 ? requires : void 0,
1961
- provides: (card.provides ?? [{ bindTo: card.id, src: "card_data" }]).map((p) => p.bindTo),
1986
+ provides: (card.provides ?? [{ bindTo: card.id, ref: "card_data" }]).map((p) => p.bindTo),
1962
1987
  taskHandlers: [card.id],
1963
1988
  description: card.meta?.title ?? card.id
1964
1989
  };
@@ -1979,7 +2004,7 @@ function liveCardsToReactiveGraph(input, options = {}) {
1979
2004
  graphRef.resolveCallback(token, data, errors);
1980
2005
  };
1981
2006
  for (const card of cards) {
1982
- if (card.sources && card.sources.length > 0) {
2007
+ if (card.source_defs && card.source_defs.length > 0) {
1983
2008
  handlers[card.id] = buildSourceHandler(card, sourceHandlers, defaultSourceHandler, sharedState, getResolve);
1984
2009
  } else {
1985
2010
  handlers[card.id] = buildCardHandler(card, cardHandlers, sharedState, cardMap, tokenToCardId, getResolve);
@@ -2043,8 +2068,8 @@ function buildCardHandler(card, cardHandlers, sharedState, _cardMap, tokenToCard
2043
2068
  let resultData;
2044
2069
  if (card.provides && card.provides.length > 0) {
2045
2070
  resultData = {};
2046
- for (const { bindTo, src } of card.provides) {
2047
- resultData[bindTo] = CardCompute.resolve(computeNode, src);
2071
+ for (const { bindTo, ref } of card.provides) {
2072
+ resultData[bindTo] = CardCompute.resolve(computeNode, ref);
2048
2073
  }
2049
2074
  } else {
2050
2075
  resultData = { ...computeNode.card_data, ...computeNode.computed_values };