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
@@ -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
  }
@@ -6676,7 +6681,7 @@ var live_cards_schema_default = {
6676
6681
  }
6677
6682
  },
6678
6683
  title: "LiveCard",
6679
- description: "A unified card node. Behavior depends on which sections are present (sources, compute, view, etc.)",
6684
+ description: "A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",
6680
6685
  type: "object",
6681
6686
  required: ["id"],
6682
6687
  additionalProperties: false,
@@ -6719,22 +6724,22 @@ var live_cards_schema_default = {
6719
6724
  },
6720
6725
  llm_task_completion_inference: {
6721
6726
  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.",
6727
+ 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
6728
  properties: {
6724
6729
  inferenceRequested: { type: "string", format: "date-time", description: "Timestamp when the latest inference request was initiated" },
6725
6730
  inferenceCompletedAt: { type: "string", format: "date-time", description: "Timestamp when the latest inference request completed" },
6726
6731
  isTaskCompleted: { type: "boolean", description: "Whether the task is considered complete by the adapter" },
6727
6732
  reasoning: { type: "string", description: "Explanation of completion decision" },
6728
- evidence: { type: "array", description: "Supporting evidence from sources/compute" }
6733
+ evidence: { type: "array", description: "Supporting evidence from source_defs/compute" }
6729
6734
  },
6730
6735
  additionalProperties: true
6731
6736
  }
6732
6737
  },
6733
6738
  additionalProperties: true
6734
6739
  },
6735
- sources: {
6740
+ source_defs: {
6736
6741
  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.",
6742
+ 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
6743
  items: { $ref: "#/definitions/source_def" }
6739
6744
  },
6740
6745
  compute: {
@@ -6752,8 +6757,8 @@ var live_cards_schema_default = {
6752
6757
  // src/card-compute/schema-validator.ts
6753
6758
  var import_ajv = __toESM(require_ajv());
6754
6759
  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)(\.|$)/;
6760
+ var NAMESPACE_REFERENCE_RE = /\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g;
6761
+ var ROOT_PATH_NAMESPACE_RE = /^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;
6757
6762
  function referencedNamespaces(expression) {
6758
6763
  const namespaces = /* @__PURE__ */ new Set();
6759
6764
  let match;
@@ -6818,22 +6823,22 @@ function validateLiveCardSchema(node) {
6818
6823
  return `${path}: ${e.message ?? "unknown error"}`;
6819
6824
  });
6820
6825
  if (node && typeof node === "object" && !Array.isArray(node)) {
6821
- const sources = node.sources;
6822
- if (Array.isArray(sources)) {
6826
+ const source_defs = node.source_defs;
6827
+ if (Array.isArray(source_defs)) {
6823
6828
  const bindTos = /* @__PURE__ */ new Set();
6824
6829
  const outputFiles = /* @__PURE__ */ new Set();
6825
- sources.forEach((src, i) => {
6830
+ source_defs.forEach((src, i) => {
6826
6831
  if (!src || typeof src !== "object" || Array.isArray(src)) return;
6827
6832
  const s = src;
6828
6833
  if (typeof s.bindTo === "string" && s.bindTo) {
6829
6834
  if (bindTos.has(s.bindTo)) {
6830
- errors.push(`/sources/${i}/bindTo: bindTo "${s.bindTo}" must be unique across all sources`);
6835
+ errors.push(`/source_defs/${i}/bindTo: bindTo "${s.bindTo}" must be unique across all source_defs`);
6831
6836
  }
6832
6837
  bindTos.add(s.bindTo);
6833
6838
  }
6834
6839
  if (typeof s.outputFile === "string" && s.outputFile) {
6835
6840
  if (outputFiles.has(s.outputFile)) {
6836
- errors.push(`/sources/${i}/outputFile: outputFile "${s.outputFile}" must be unique across all sources`);
6841
+ errors.push(`/source_defs/${i}/outputFile: outputFile "${s.outputFile}" must be unique across all source_defs`);
6837
6842
  }
6838
6843
  outputFiles.add(s.outputFile);
6839
6844
  }
@@ -6863,10 +6868,48 @@ function validateLiveCardRuntimeExpressions(node) {
6863
6868
  );
6864
6869
  });
6865
6870
  }
6871
+ const VALID_PROVIDES_SRC_NAMESPACES = /* @__PURE__ */ new Set([
6872
+ "card_data",
6873
+ "requires",
6874
+ "fetched_sources",
6875
+ "computed_values"
6876
+ ]);
6877
+ const provides = asRecord.provides;
6878
+ if (Array.isArray(provides)) {
6879
+ provides.forEach((entry, i) => {
6880
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) return;
6881
+ const ref = entry.ref;
6882
+ if (typeof ref !== "string" || ref.trim().length === 0) return;
6883
+ const rootNamespace = parseRootPathNamespace(ref);
6884
+ if (rootNamespace === null) {
6885
+ errors.push(`/provides/${i}/ref: path "${ref}" must start with a valid namespace (${[...VALID_PROVIDES_SRC_NAMESPACES].join(", ")})`);
6886
+ } else if (!VALID_PROVIDES_SRC_NAMESPACES.has(rootNamespace)) {
6887
+ errors.push(`/provides/${i}/ref: disallowed namespace "${rootNamespace}" in path "${ref}" (valid: ${[...VALID_PROVIDES_SRC_NAMESPACES].join(", ")})`);
6888
+ }
6889
+ });
6890
+ }
6866
6891
  const view = asRecord.view;
6867
6892
  if (view && typeof view === "object" && !Array.isArray(view)) {
6868
6893
  walkViewPathReferences(view, "/view", errors);
6869
6894
  }
6895
+ const VALID_PROJECTION_NAMESPACES = /* @__PURE__ */ new Set(["card_data", "requires"]);
6896
+ const source_defs = asRecord.source_defs;
6897
+ if (Array.isArray(source_defs)) {
6898
+ source_defs.forEach((srcDef, i) => {
6899
+ if (!srcDef || typeof srcDef !== "object" || Array.isArray(srcDef)) return;
6900
+ const projections = srcDef.projections;
6901
+ if (!projections || typeof projections !== "object" || Array.isArray(projections)) return;
6902
+ for (const [key, exprVal] of Object.entries(projections)) {
6903
+ if (typeof exprVal !== "string" || exprVal.trim().length === 0) continue;
6904
+ validateJsonataExprWithNamespaces(
6905
+ exprVal,
6906
+ `/source_defs/${i}/projections/${key}`,
6907
+ VALID_PROJECTION_NAMESPACES,
6908
+ errors
6909
+ );
6910
+ }
6911
+ });
6912
+ }
6870
6913
  return { ok: errors.length === 0, errors };
6871
6914
  }
6872
6915
  function validateLiveCard(node) {
@@ -6953,7 +6996,7 @@ var VALID_ELEMENT_KINDS = /* @__PURE__ */ new Set([
6953
6996
  "markdown",
6954
6997
  "custom"
6955
6998
  ]);
6956
- var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "sources"]);
6999
+ var ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "meta", "requires", "provides", "view", "card_data", "compute", "source_defs"]);
6957
7000
  function validateNode(node) {
6958
7001
  const errors = [];
6959
7002
  if (!node || typeof node !== "object" || Array.isArray(node)) {
@@ -6979,15 +7022,15 @@ function validateNode(node) {
6979
7022
  if (n.requires != null && !Array.isArray(n.requires)) errors.push("requires: must be an array of strings");
6980
7023
  if (n.provides != null) {
6981
7024
  if (!Array.isArray(n.provides)) {
6982
- errors.push("provides: must be an array of { bindTo, src } bindings");
7025
+ errors.push("provides: must be an array of { bindTo, ref } bindings");
6983
7026
  } else {
6984
7027
  n.provides.forEach((p, i) => {
6985
7028
  if (!p || typeof p !== "object" || Array.isArray(p)) {
6986
- errors.push(`provides[${i}]: must be an object with bindTo and src`);
7029
+ errors.push(`provides[${i}]: must be an object with bindTo and ref`);
6987
7030
  } else {
6988
7031
  const b = p;
6989
7032
  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`);
7033
+ if (typeof b.ref !== "string" || !b.ref) errors.push(`provides[${i}]: missing required "ref" string`);
6991
7034
  }
6992
7035
  });
6993
7036
  }
@@ -7007,35 +7050,35 @@ function validateNode(node) {
7007
7050
  });
7008
7051
  }
7009
7052
  }
7010
- if (n.sources != null) {
7011
- if (!Array.isArray(n.sources)) {
7012
- errors.push("sources: must be an array");
7053
+ if (n.source_defs != null) {
7054
+ if (!Array.isArray(n.source_defs)) {
7055
+ errors.push("source_defs: must be an array");
7013
7056
  } else {
7014
7057
  const bindTos = /* @__PURE__ */ new Set();
7015
7058
  const outputFiles = /* @__PURE__ */ new Set();
7016
- n.sources.forEach((src, i) => {
7059
+ n.source_defs.forEach((src, i) => {
7017
7060
  if (!src || typeof src !== "object" || Array.isArray(src)) {
7018
- errors.push(`sources[${i}]: must be an object`);
7061
+ errors.push(`source_defs[${i}]: must be an object`);
7019
7062
  } else {
7020
7063
  const s = src;
7021
7064
  if (typeof s.bindTo !== "string" || !s.bindTo) {
7022
- errors.push(`sources[${i}]: missing required "bindTo" property`);
7065
+ errors.push(`source_defs[${i}]: missing required "bindTo" property`);
7023
7066
  } else {
7024
7067
  if (bindTos.has(s.bindTo)) {
7025
- errors.push(`sources[${i}]: bindTo "${s.bindTo}" is not unique across sources`);
7068
+ errors.push(`source_defs[${i}]: bindTo "${s.bindTo}" is not unique across source_defs`);
7026
7069
  }
7027
7070
  bindTos.add(s.bindTo);
7028
7071
  }
7029
7072
  if (typeof s.outputFile !== "string" || !s.outputFile) {
7030
- errors.push(`sources[${i}]: missing required "outputFile" property`);
7073
+ errors.push(`source_defs[${i}]: missing required "outputFile" property`);
7031
7074
  } else {
7032
7075
  if (outputFiles.has(s.outputFile)) {
7033
- errors.push(`sources[${i}]: outputFile "${s.outputFile}" is not unique across sources`);
7076
+ errors.push(`source_defs[${i}]: outputFile "${s.outputFile}" is not unique across source_defs`);
7034
7077
  }
7035
7078
  outputFiles.add(s.outputFile);
7036
7079
  }
7037
7080
  if (s.optionalForCompletionGating != null && typeof s.optionalForCompletionGating !== "boolean") {
7038
- errors.push(`sources[${i}]: optionalForCompletionGating must be a boolean`);
7081
+ errors.push(`source_defs[${i}]: optionalForCompletionGating must be a boolean`);
7039
7082
  }
7040
7083
  }
7041
7084
  });
@@ -7070,14 +7113,29 @@ function validateNode(node) {
7070
7113
  }
7071
7114
  return { ok: errors.length === 0, errors };
7072
7115
  }
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
- }));
7116
+ async function enrichSources(source_defs, context) {
7117
+ if (!source_defs || source_defs.length === 0) return [];
7118
+ const evalCtx = {
7119
+ card_data: context.card_data ?? {},
7120
+ requires: context.requires ?? {}
7121
+ };
7122
+ return Promise.all(
7123
+ source_defs.map(async (src) => {
7124
+ const _projections = {};
7125
+ if (src.projections && typeof src.projections === "object" && !Array.isArray(src.projections)) {
7126
+ for (const [key, expr] of Object.entries(src.projections)) {
7127
+ if (typeof expr === "string" && expr.trim().length > 0) {
7128
+ try {
7129
+ _projections[key] = await jsonata2__default.default(expr).evaluate(evalCtx);
7130
+ } catch {
7131
+ _projections[key] = void 0;
7132
+ }
7133
+ }
7134
+ }
7135
+ }
7136
+ return { ...src, _projections };
7137
+ })
7138
+ );
7081
7139
  }
7082
7140
  var CardCompute = {
7083
7141
  run,