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
@@ -6531,10 +6531,10 @@ var live_cards_schema_default = {
6531
6531
  type: "array",
6532
6532
  items: {
6533
6533
  type: "object",
6534
- required: ["bindTo", "src"],
6534
+ required: ["bindTo", "ref"],
6535
6535
  properties: {
6536
6536
  bindTo: { type: "string", description: "Token name published downstream" },
6537
- src: { type: "string", description: "Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)" }
6537
+ ref: { type: "string", description: "Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)" }
6538
6538
  }
6539
6539
  },
6540
6540
  description: "Explicit bindings exposing computed or card_data values downstream as named tokens"
@@ -6549,14 +6549,19 @@ var live_cards_schema_default = {
6549
6549
  }
6550
6550
  },
6551
6551
  source_def: {
6552
- description: "One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all sources in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",
6552
+ description: "One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all source_defs in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",
6553
6553
  type: "object",
6554
6554
  required: ["bindTo", "outputFile"],
6555
6555
  additionalProperties: true,
6556
6556
  properties: {
6557
6557
  bindTo: { type: "string", description: "Key under fetched_sources.* available in compute expressions" },
6558
6558
  outputFile: { type: "string", description: "Board-relative path the executor writes its JSON result to. Presence of this file signals delivery." },
6559
- optionalForCompletionGating: { type: "boolean", default: false, description: "When true this source does not gate card completion. Default false when absent, so sources are completion-gating by default." },
6559
+ projections: {
6560
+ type: "object",
6561
+ description: "Named data projections from card_data or requires, evaluated before the executor is called. Each key is a ref name; each value is a JSONata expression rooted at card_data or requires. The resolved values are passed to the executor as _projections. fetched_sources, computed_values, and source_defs are not accessible here \u2014 sources run before those exist.",
6562
+ additionalProperties: { type: "string" }
6563
+ },
6564
+ optionalForCompletionGating: { type: "boolean", default: false, description: "When true this source does not gate card completion. Default false when absent, so source_defs are completion-gating by default." },
6560
6565
  timeout: { type: "integer", minimum: 0, default: 12e4, description: "Executor/script timeout in ms. Default: 120 000 (2 min)." },
6561
6566
  script: { type: "string", description: "Legacy direct-run: shell command executed when no .task-executor is registered. stdout is captured as the result." }
6562
6567
  }
@@ -6582,6 +6587,7 @@ var live_cards_schema_default = {
6582
6587
  "badge",
6583
6588
  "text",
6584
6589
  "markdown",
6590
+ "ref",
6585
6591
  "custom",
6586
6592
  "actions"
6587
6593
  ]
@@ -6676,7 +6682,7 @@ var live_cards_schema_default = {
6676
6682
  }
6677
6683
  },
6678
6684
  title: "LiveCard",
6679
- description: "A unified card node. Behavior depends on which sections are present (sources, compute, view, etc.)",
6685
+ description: "A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",
6680
6686
  type: "object",
6681
6687
  required: ["id"],
6682
6688
  additionalProperties: false,
@@ -6719,22 +6725,22 @@ var live_cards_schema_default = {
6719
6725
  },
6720
6726
  llm_task_completion_inference: {
6721
6727
  type: "object",
6722
- description: "Runtime state written by the inference adapter (advanced/undocumented). Prefer the standard sources \u2192 compute \u2192 provides pattern for LLM-based signals.",
6728
+ description: "Runtime state written by the inference adapter (advanced/undocumented). Prefer the standard source_defs \u2192 compute \u2192 provides pattern for LLM-based signals.",
6723
6729
  properties: {
6724
6730
  inferenceRequested: { type: "string", format: "date-time", description: "Timestamp when the latest inference request was initiated" },
6725
6731
  inferenceCompletedAt: { type: "string", format: "date-time", description: "Timestamp when the latest inference request completed" },
6726
6732
  isTaskCompleted: { type: "boolean", description: "Whether the task is considered complete by the adapter" },
6727
6733
  reasoning: { type: "string", description: "Explanation of completion decision" },
6728
- evidence: { type: "array", description: "Supporting evidence from sources/compute" }
6734
+ evidence: { type: "array", description: "Supporting evidence from source_defs/compute" }
6729
6735
  },
6730
6736
  additionalProperties: true
6731
6737
  }
6732
6738
  },
6733
6739
  additionalProperties: true
6734
6740
  },
6735
- sources: {
6741
+ source_defs: {
6736
6742
  type: "array",
6737
- description: "Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion by default. Set optionalForCompletionGating: true for enrichment-only sources that should not block task-completed.",
6743
+ description: "Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion by default. Set optionalForCompletionGating: true for enrichment-only source_defs that should not block task-completed.",
6738
6744
  items: { $ref: "#/definitions/source_def" }
6739
6745
  },
6740
6746
  compute: {
@@ -6752,8 +6758,8 @@ var live_cards_schema_default = {
6752
6758
  // src/card-compute/schema-validator.ts
6753
6759
  var import_ajv = __toESM(require_ajv());
6754
6760
  var _compiled = null;
6755
- var NAMESPACE_REFERENCE_RE = /\b(card_data|requires|fetched_sources|computed_values|sources)\b/g;
6756
- var ROOT_PATH_NAMESPACE_RE = /^\s*(card_data|requires|fetched_sources|computed_values|sources)(\.|$)/;
6761
+ var NAMESPACE_REFERENCE_RE = /\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g;
6762
+ var ROOT_PATH_NAMESPACE_RE = /^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;
6757
6763
  function referencedNamespaces(expression) {
6758
6764
  const namespaces = /* @__PURE__ */ new Set();
6759
6765
  let match;
@@ -6818,22 +6824,22 @@ function validateLiveCardSchema(node) {
6818
6824
  return `${path}: ${e.message ?? "unknown error"}`;
6819
6825
  });
6820
6826
  if (node && typeof node === "object" && !Array.isArray(node)) {
6821
- const sources = node.sources;
6822
- if (Array.isArray(sources)) {
6827
+ const source_defs = node.source_defs;
6828
+ if (Array.isArray(source_defs)) {
6823
6829
  const bindTos = /* @__PURE__ */ new Set();
6824
6830
  const outputFiles = /* @__PURE__ */ new Set();
6825
- sources.forEach((src, i) => {
6831
+ source_defs.forEach((src, i) => {
6826
6832
  if (!src || typeof src !== "object" || Array.isArray(src)) return;
6827
6833
  const s = src;
6828
6834
  if (typeof s.bindTo === "string" && s.bindTo) {
6829
6835
  if (bindTos.has(s.bindTo)) {
6830
- errors.push(`/sources/${i}/bindTo: bindTo "${s.bindTo}" must be unique across all sources`);
6836
+ errors.push(`/source_defs/${i}/bindTo: bindTo "${s.bindTo}" must be unique across all source_defs`);
6831
6837
  }
6832
6838
  bindTos.add(s.bindTo);
6833
6839
  }
6834
6840
  if (typeof s.outputFile === "string" && s.outputFile) {
6835
6841
  if (outputFiles.has(s.outputFile)) {
6836
- errors.push(`/sources/${i}/outputFile: outputFile "${s.outputFile}" must be unique across all sources`);
6842
+ errors.push(`/source_defs/${i}/outputFile: outputFile "${s.outputFile}" must be unique across all source_defs`);
6837
6843
  }
6838
6844
  outputFiles.add(s.outputFile);
6839
6845
  }
@@ -6863,10 +6869,48 @@ function validateLiveCardRuntimeExpressions(node) {
6863
6869
  );
6864
6870
  });
6865
6871
  }
6872
+ const VALID_PROVIDES_SRC_NAMESPACES = /* @__PURE__ */ new Set([
6873
+ "card_data",
6874
+ "requires",
6875
+ "fetched_sources",
6876
+ "computed_values"
6877
+ ]);
6878
+ const provides = asRecord.provides;
6879
+ if (Array.isArray(provides)) {
6880
+ provides.forEach((entry, i) => {
6881
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) return;
6882
+ const ref = entry.ref;
6883
+ if (typeof ref !== "string" || ref.trim().length === 0) return;
6884
+ const rootNamespace = parseRootPathNamespace(ref);
6885
+ if (rootNamespace === null) {
6886
+ errors.push(`/provides/${i}/ref: path "${ref}" must start with a valid namespace (${[...VALID_PROVIDES_SRC_NAMESPACES].join(", ")})`);
6887
+ } else if (!VALID_PROVIDES_SRC_NAMESPACES.has(rootNamespace)) {
6888
+ errors.push(`/provides/${i}/ref: disallowed namespace "${rootNamespace}" in path "${ref}" (valid: ${[...VALID_PROVIDES_SRC_NAMESPACES].join(", ")})`);
6889
+ }
6890
+ });
6891
+ }
6866
6892
  const view = asRecord.view;
6867
6893
  if (view && typeof view === "object" && !Array.isArray(view)) {
6868
6894
  walkViewPathReferences(view, "/view", errors);
6869
6895
  }
6896
+ const VALID_PROJECTION_NAMESPACES = /* @__PURE__ */ new Set(["card_data", "requires"]);
6897
+ const source_defs = asRecord.source_defs;
6898
+ if (Array.isArray(source_defs)) {
6899
+ source_defs.forEach((srcDef, i) => {
6900
+ if (!srcDef || typeof srcDef !== "object" || Array.isArray(srcDef)) return;
6901
+ const projections = srcDef.projections;
6902
+ if (!projections || typeof projections !== "object" || Array.isArray(projections)) return;
6903
+ for (const [key, exprVal] of Object.entries(projections)) {
6904
+ if (typeof exprVal !== "string" || exprVal.trim().length === 0) continue;
6905
+ validateJsonataExprWithNamespaces(
6906
+ exprVal,
6907
+ `/source_defs/${i}/projections/${key}`,
6908
+ VALID_PROJECTION_NAMESPACES,
6909
+ errors
6910
+ );
6911
+ }
6912
+ });
6913
+ }
6870
6914
  return { ok: errors.length === 0, errors };
6871
6915
  }
6872
6916
  function validateLiveCard(node) {
@@ -6940,6 +6984,7 @@ function resolve(node, path) {
6940
6984
  var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
6941
6985
  "metric",
6942
6986
  "table",
6987
+ "editable-table",
6943
6988
  "chart",
6944
6989
  "form",
6945
6990
  "filter",
@@ -6951,9 +6996,11 @@ var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
6951
6996
  "badge",
6952
6997
  "text",
6953
6998
  "markdown",
6954
- "custom"
6999
+ "ref",
7000
+ "custom",
7001
+ "actions"
6955
7002
  ]);
6956
- var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "sources"]);
7003
+ var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "source_defs"]);
6957
7004
  function validateNode(node) {
6958
7005
  const errors = [];
6959
7006
  if (!node || typeof node !== "object" || Array.isArray(node)) {
@@ -6979,15 +7026,15 @@ function validateNode(node) {
6979
7026
  if (n.requires != null && !Array.isArray(n.requires)) errors.push("requires: must be an array of strings");
6980
7027
  if (n.provides != null) {
6981
7028
  if (!Array.isArray(n.provides)) {
6982
- errors.push("provides: must be an array of { bindTo, src } bindings");
7029
+ errors.push("provides: must be an array of { bindTo, ref } bindings");
6983
7030
  } else {
6984
7031
  n.provides.forEach((p, i) => {
6985
7032
  if (!p || typeof p !== "object" || Array.isArray(p)) {
6986
- errors.push(`provides[${i}]: must be an object with bindTo and src`);
7033
+ errors.push(`provides[${i}]: must be an object with bindTo and ref`);
6987
7034
  } else {
6988
7035
  const b = p;
6989
7036
  if (typeof b.bindTo !== "string" || !b.bindTo) errors.push(`provides[${i}]: missing required "bindTo" string`);
6990
- if (typeof b.src !== "string" || !b.src) errors.push(`provides[${i}]: missing required "src" string`);
7037
+ if (typeof b.ref !== "string" || !b.ref) errors.push(`provides[${i}]: missing required "ref" string`);
6991
7038
  }
6992
7039
  });
6993
7040
  }
@@ -7007,35 +7054,35 @@ function validateNode(node) {
7007
7054
  });
7008
7055
  }
7009
7056
  }
7010
- if (n.sources != null) {
7011
- if (!Array.isArray(n.sources)) {
7012
- errors.push("sources: must be an array");
7057
+ if (n.source_defs != null) {
7058
+ if (!Array.isArray(n.source_defs)) {
7059
+ errors.push("source_defs: must be an array");
7013
7060
  } else {
7014
7061
  const bindTos = /* @__PURE__ */ new Set();
7015
7062
  const outputFiles = /* @__PURE__ */ new Set();
7016
- n.sources.forEach((src, i) => {
7063
+ n.source_defs.forEach((src, i) => {
7017
7064
  if (!src || typeof src !== "object" || Array.isArray(src)) {
7018
- errors.push(`sources[${i}]: must be an object`);
7065
+ errors.push(`source_defs[${i}]: must be an object`);
7019
7066
  } else {
7020
7067
  const s = src;
7021
7068
  if (typeof s.bindTo !== "string" || !s.bindTo) {
7022
- errors.push(`sources[${i}]: missing required "bindTo" property`);
7069
+ errors.push(`source_defs[${i}]: missing required "bindTo" property`);
7023
7070
  } else {
7024
7071
  if (bindTos.has(s.bindTo)) {
7025
- errors.push(`sources[${i}]: bindTo "${s.bindTo}" is not unique across sources`);
7072
+ errors.push(`source_defs[${i}]: bindTo "${s.bindTo}" is not unique across source_defs`);
7026
7073
  }
7027
7074
  bindTos.add(s.bindTo);
7028
7075
  }
7029
7076
  if (typeof s.outputFile !== "string" || !s.outputFile) {
7030
- errors.push(`sources[${i}]: missing required "outputFile" property`);
7077
+ errors.push(`source_defs[${i}]: missing required "outputFile" property`);
7031
7078
  } else {
7032
7079
  if (outputFiles.has(s.outputFile)) {
7033
- errors.push(`sources[${i}]: outputFile "${s.outputFile}" is not unique across sources`);
7080
+ errors.push(`source_defs[${i}]: outputFile "${s.outputFile}" is not unique across source_defs`);
7034
7081
  }
7035
7082
  outputFiles.add(s.outputFile);
7036
7083
  }
7037
7084
  if (s.optionalForCompletionGating != null && typeof s.optionalForCompletionGating !== "boolean") {
7038
- errors.push(`sources[${i}]: optionalForCompletionGating must be a boolean`);
7085
+ errors.push(`source_defs[${i}]: optionalForCompletionGating must be a boolean`);
7039
7086
  }
7040
7087
  }
7041
7088
  });
@@ -7070,14 +7117,29 @@ function validateNode(node) {
7070
7117
  }
7071
7118
  return { ok: errors.length === 0, errors };
7072
7119
  }
7073
- function enrichSources(sources, context) {
7074
- if (!sources || sources.length === 0) return [];
7075
- return sources.map((src) => ({
7076
- ...src,
7077
- _requires: context.requires ?? {},
7078
- _sourcesData: context.sourcesData ?? {},
7079
- _computed_values: context.computed_values ?? {}
7080
- }));
7120
+ async function enrichSources(source_defs, context) {
7121
+ if (!source_defs || source_defs.length === 0) return [];
7122
+ const evalCtx = {
7123
+ card_data: context.card_data ?? {},
7124
+ requires: context.requires ?? {}
7125
+ };
7126
+ return Promise.all(
7127
+ source_defs.map(async (src) => {
7128
+ const _projections = {};
7129
+ if (src.projections && typeof src.projections === "object" && !Array.isArray(src.projections)) {
7130
+ for (const [key, expr] of Object.entries(src.projections)) {
7131
+ if (typeof expr === "string" && expr.trim().length > 0) {
7132
+ try {
7133
+ _projections[key] = await jsonata2__default.default(expr).evaluate(evalCtx);
7134
+ } catch {
7135
+ _projections[key] = void 0;
7136
+ }
7137
+ }
7138
+ }
7139
+ }
7140
+ return { ...src, _projections };
7141
+ })
7142
+ );
7081
7143
  }
7082
7144
  var CardCompute = {
7083
7145
  run,