@particle-academy/fancy-flow 0.49.0 → 0.51.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 (81) hide show
  1. package/dist/{ConfigFieldRenderer-CrXFq6Eb.d.cts → ConfigFieldRenderer-Bc9Txnql.d.cts} +2 -2
  2. package/dist/{ConfigFieldRenderer-u3nYHovX.d.ts → ConfigFieldRenderer-Bt3RGT7Z.d.ts} +2 -2
  3. package/dist/{FlowViewer-DRgjeWJ7.d.ts → FlowViewer-BI_AyyvU.d.ts} +1 -1
  4. package/dist/{FlowViewer-CFSMlCqi.d.cts → FlowViewer-DABx-6A-.d.cts} +1 -1
  5. package/dist/{capabilities-VzgDApur.d.cts → capabilities-BYa5p5jw.d.cts} +1 -1
  6. package/dist/{capabilities-B00VXLUp.d.ts → capabilities-COOXRiNL.d.ts} +1 -1
  7. package/dist/{chunk-6XKR65XM.js → chunk-6AI6CBNL.js} +3 -3
  8. package/dist/{chunk-6XKR65XM.js.map → chunk-6AI6CBNL.js.map} +1 -1
  9. package/dist/{chunk-AVRGZFXG.js → chunk-7XTTXMGB.js} +4 -4
  10. package/dist/{chunk-AVRGZFXG.js.map → chunk-7XTTXMGB.js.map} +1 -1
  11. package/dist/{chunk-UL3DGSSG.js → chunk-HXGGCMR7.js} +3 -3
  12. package/dist/{chunk-UL3DGSSG.js.map → chunk-HXGGCMR7.js.map} +1 -1
  13. package/dist/{chunk-YOK3WKWC.js → chunk-LH76EIFL.js} +18 -4
  14. package/dist/chunk-LH76EIFL.js.map +1 -0
  15. package/dist/{chunk-VUL7CUFW.js → chunk-SKEZ5AGI.js} +3 -3
  16. package/dist/{chunk-VUL7CUFW.js.map → chunk-SKEZ5AGI.js.map} +1 -1
  17. package/dist/{chunk-6FP3F5YR.js → chunk-XCT2CJ5O.js} +75 -4
  18. package/dist/chunk-XCT2CJ5O.js.map +1 -0
  19. package/dist/connectors.d.cts +2 -2
  20. package/dist/connectors.d.ts +2 -2
  21. package/dist/durable/index.d.cts +2 -2
  22. package/dist/durable/index.d.ts +2 -2
  23. package/dist/durable.cjs +73 -2
  24. package/dist/durable.cjs.map +1 -1
  25. package/dist/durable.js +1 -1
  26. package/dist/engine.cjs +73 -2
  27. package/dist/engine.cjs.map +1 -1
  28. package/dist/engine.d.cts +7 -7
  29. package/dist/engine.d.ts +7 -7
  30. package/dist/engine.js +3 -3
  31. package/dist/fields/react-fancy.d.cts +3 -3
  32. package/dist/fields/react-fancy.d.ts +3 -3
  33. package/dist/index.cjs +88 -3
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +11 -11
  36. package/dist/index.d.ts +11 -11
  37. package/dist/index.js +11 -11
  38. package/dist/layout/index.d.cts +1 -1
  39. package/dist/layout/index.d.ts +1 -1
  40. package/dist/llm/prism.d.cts +2 -2
  41. package/dist/llm/prism.d.ts +2 -2
  42. package/dist/llm/vercel-ai.d.cts +2 -2
  43. package/dist/llm/vercel-ai.d.ts +2 -2
  44. package/dist/registry/index.d.cts +6 -6
  45. package/dist/registry/index.d.ts +6 -6
  46. package/dist/{registry-6cB5wCv6.d.ts → registry-3RkSYrMi.d.ts} +1 -1
  47. package/dist/{registry-DQh7ZmnM.d.cts → registry-C6TMfiD_.d.cts} +1 -1
  48. package/dist/registry.cjs +73 -2
  49. package/dist/registry.cjs.map +1 -1
  50. package/dist/registry.js +2 -2
  51. package/dist/{run-cohort-VX4JG21l.d.ts → run-cohort-BPIOpE8A.d.ts} +2 -2
  52. package/dist/{run-cohort-DYCL8Qv6.d.cts → run-cohort-r-L8dMED.d.cts} +2 -2
  53. package/dist/{run-flow-B24QUO1H.d.cts → run-flow-COdAOFg2.d.cts} +10 -1
  54. package/dist/{run-flow-DPUPAWk6.d.ts → run-flow-DJ7KYT6E.d.ts} +10 -1
  55. package/dist/runtime/index.d.cts +5 -5
  56. package/dist/runtime/index.d.ts +5 -5
  57. package/dist/runtime.cjs +73 -2
  58. package/dist/runtime.cjs.map +1 -1
  59. package/dist/runtime.js +3 -3
  60. package/dist/schema/index.d.cts +12 -1
  61. package/dist/schema/index.d.ts +12 -1
  62. package/dist/schema.cjs +88 -3
  63. package/dist/schema.cjs.map +1 -1
  64. package/dist/schema.js +2 -2
  65. package/dist/screens.cjs +73 -2
  66. package/dist/screens.cjs.map +1 -1
  67. package/dist/screens.d.cts +2 -2
  68. package/dist/screens.d.ts +2 -2
  69. package/dist/screens.js +4 -4
  70. package/dist/{types-BtMOnb9I.d.cts → types-3sPauVRT.d.cts} +1 -1
  71. package/dist/{types-7cXcSQlx.d.ts → types-JFYjPJAG.d.cts} +37 -1
  72. package/dist/{types-7cXcSQlx.d.cts → types-JFYjPJAG.d.ts} +37 -1
  73. package/dist/{types-CDgIIj4c.d.ts → types-s643U1Hi.d.ts} +1 -1
  74. package/dist/ux.cjs +73 -2
  75. package/dist/ux.cjs.map +1 -1
  76. package/dist/ux.d.cts +2 -2
  77. package/dist/ux.d.ts +2 -2
  78. package/dist/ux.js +1 -1
  79. package/package.json +1 -1
  80. package/dist/chunk-6FP3F5YR.js.map +0 -1
  81. package/dist/chunk-YOK3WKWC.js.map +0 -1
package/dist/schema.js CHANGED
@@ -1,5 +1,5 @@
1
- export { WORKFLOW_SCHEMA_URL, WORKFLOW_SCHEMA_VERSION, exportWorkflow, importWorkflow, migrateSchema, workflowToBlob } from './chunk-YOK3WKWC.js';
2
- import './chunk-6FP3F5YR.js';
1
+ export { WORKFLOW_SCHEMA_URL, WORKFLOW_SCHEMA_VERSION, exportWorkflow, importWorkflow, migrateSchema, workflowToBlob } from './chunk-LH76EIFL.js';
2
+ import './chunk-XCT2CJ5O.js';
3
3
  import './chunk-F5RPRB7A.js';
4
4
  import './chunk-USL4FMFU.js';
5
5
  //# sourceMappingURL=schema.js.map
package/dist/screens.cjs CHANGED
@@ -9411,6 +9411,61 @@ var RunIdentity = class _RunIdentity {
9411
9411
  }
9412
9412
  };
9413
9413
 
9414
+ // src/runtime/workflow-props.ts
9415
+ function typeOf(value) {
9416
+ if (value === null) return "null";
9417
+ if (Array.isArray(value)) return "array";
9418
+ return typeof value;
9419
+ }
9420
+ function resolveWorkflowProps(declared, passed) {
9421
+ const inputs = declared ?? [];
9422
+ const given = passed ?? {};
9423
+ const byName = new Map(inputs.map((input) => [input.name, input]));
9424
+ for (const name of Object.keys(given)) {
9425
+ if (!byName.has(name)) {
9426
+ const known = inputs.map((input) => input.name);
9427
+ const suffix = known.length === 0 ? "this workflow declares no inputs" : `known inputs: ${known.join(", ")}`;
9428
+ return {
9429
+ ok: false,
9430
+ code: "unknown_input",
9431
+ error: `Unknown workflow input "${name}" \u2014 ${suffix}.`
9432
+ };
9433
+ }
9434
+ }
9435
+ const resolved = {};
9436
+ for (const input of inputs) {
9437
+ const supplied = Object.prototype.hasOwnProperty.call(given, input.name);
9438
+ const hasDefault = Object.prototype.hasOwnProperty.call(input, "default");
9439
+ if (!supplied) {
9440
+ if (hasDefault) {
9441
+ resolved[input.name] = input.default;
9442
+ continue;
9443
+ }
9444
+ if (input.required) {
9445
+ return {
9446
+ ok: false,
9447
+ code: "missing_required",
9448
+ error: `Missing required workflow input "${input.name}"${input.type ? ` (${input.type})` : ""}.`
9449
+ };
9450
+ }
9451
+ continue;
9452
+ }
9453
+ const value = given[input.name];
9454
+ if (input.type !== void 0) {
9455
+ const actual = typeOf(value);
9456
+ if (actual !== input.type) {
9457
+ return {
9458
+ ok: false,
9459
+ code: "type_mismatch",
9460
+ error: `Workflow input "${input.name}" expects ${input.type}, got ${actual}.`
9461
+ };
9462
+ }
9463
+ }
9464
+ resolved[input.name] = value;
9465
+ }
9466
+ return { ok: true, props: resolved };
9467
+ }
9468
+
9414
9469
  // src/runtime/run-flow.ts
9415
9470
  async function runFlow(graph, executors, onEvent = () => {
9416
9471
  }, options = {}) {
@@ -9426,6 +9481,13 @@ async function runFlow(graph, executors, onEvent = () => {
9426
9481
  onEvent({ type: "run-error", error: msg });
9427
9482
  return { ok: false, outputs, error: msg };
9428
9483
  }
9484
+ const propsCheck = resolveWorkflowProps(graph.inputs, options.props);
9485
+ if (!propsCheck.ok) {
9486
+ onEvent({ type: "run-error", error: propsCheck.error });
9487
+ return { ok: false, outputs, error: propsCheck.error };
9488
+ }
9489
+ const props = propsCheck.props;
9490
+ const declaresProps = (graph.inputs?.length ?? 0) > 0;
9429
9491
  const incomingByNode = indexIncoming(graph.edges);
9430
9492
  const timer2 = timeoutMs ? setTimeout(() => errors.push(`Run timed out after ${timeoutMs}ms`), timeoutMs) : null;
9431
9493
  onEvent({ type: "run-start" });
@@ -9467,7 +9529,7 @@ async function runFlow(graph, executors, onEvent = () => {
9467
9529
  }
9468
9530
  onEvent({ type: "node-status", nodeId: node.id, status: "running" });
9469
9531
  announce(onEvent, node, "start");
9470
- const inputs = collectInputs(node, incoming, portValues, initialInputs);
9532
+ const inputs = collectInputs(node, incoming, portValues, initialInputs, props, declaresProps);
9471
9533
  const exec = pickExecutor(executors, node);
9472
9534
  if (!exec) {
9473
9535
  const msg = `No executor registered for kind=${node.type}`;
@@ -9544,14 +9606,23 @@ function topoSort(graph) {
9544
9606
  const byId = new Map(graph.nodes.map((n) => [n.id, n]));
9545
9607
  return ordered.map((id2) => byId.get(id2)).filter(Boolean);
9546
9608
  }
9547
- function collectInputs(node, incoming, portValues, initial) {
9609
+ function collectInputs(node, incoming, portValues, initial, props, declaresProps) {
9548
9610
  const inputs = { ...initial[node.id] ?? {} };
9611
+ if (incoming.length === 0) {
9612
+ for (const [name, value] of Object.entries(props)) {
9613
+ if (!(name in inputs)) inputs[name] = value;
9614
+ }
9615
+ }
9549
9616
  for (const e of incoming) {
9550
9617
  const portId = e.targetHandle ?? "in";
9551
9618
  const key = `${e.source}:${e.sourceHandle ?? "out"}`;
9552
9619
  if (!portValues.has(key)) continue;
9553
9620
  inputs[portId] = portValues.get(key);
9621
+ if (e.targetHandle == null && !(e.source in inputs)) {
9622
+ inputs[e.source] = portValues.get(key);
9623
+ }
9554
9624
  }
9625
+ if (declaresProps) inputs.$props = props;
9555
9626
  return inputs;
9556
9627
  }
9557
9628
  function pickExecutor(executors, node) {