@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/durable.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { truthy } from './chunk-BHM5HGXH.js';
2
2
  import { pauseForHuman, decodePause } from './chunk-UEOE6B52.js';
3
- import { getNodeKind, runFlow, resolveKindId, kindIds, RunIdentity } from './chunk-6FP3F5YR.js';
3
+ import { getNodeKind, runFlow, resolveKindId, kindIds, RunIdentity } from './chunk-XCT2CJ5O.js';
4
4
  import './chunk-F5RPRB7A.js';
5
5
  import './chunk-USL4FMFU.js';
6
6
 
package/dist/engine.cjs CHANGED
@@ -10334,6 +10334,61 @@ var RunIdentity = class _RunIdentity {
10334
10334
  }
10335
10335
  };
10336
10336
 
10337
+ // src/runtime/workflow-props.ts
10338
+ function typeOf(value) {
10339
+ if (value === null) return "null";
10340
+ if (Array.isArray(value)) return "array";
10341
+ return typeof value;
10342
+ }
10343
+ function resolveWorkflowProps(declared, passed) {
10344
+ const inputs = declared ?? [];
10345
+ const given = passed ?? {};
10346
+ const byName = new Map(inputs.map((input) => [input.name, input]));
10347
+ for (const name of Object.keys(given)) {
10348
+ if (!byName.has(name)) {
10349
+ const known = inputs.map((input) => input.name);
10350
+ const suffix = known.length === 0 ? "this workflow declares no inputs" : `known inputs: ${known.join(", ")}`;
10351
+ return {
10352
+ ok: false,
10353
+ code: "unknown_input",
10354
+ error: `Unknown workflow input "${name}" \u2014 ${suffix}.`
10355
+ };
10356
+ }
10357
+ }
10358
+ const resolved = {};
10359
+ for (const input of inputs) {
10360
+ const supplied = Object.prototype.hasOwnProperty.call(given, input.name);
10361
+ const hasDefault = Object.prototype.hasOwnProperty.call(input, "default");
10362
+ if (!supplied) {
10363
+ if (hasDefault) {
10364
+ resolved[input.name] = input.default;
10365
+ continue;
10366
+ }
10367
+ if (input.required) {
10368
+ return {
10369
+ ok: false,
10370
+ code: "missing_required",
10371
+ error: `Missing required workflow input "${input.name}"${input.type ? ` (${input.type})` : ""}.`
10372
+ };
10373
+ }
10374
+ continue;
10375
+ }
10376
+ const value = given[input.name];
10377
+ if (input.type !== void 0) {
10378
+ const actual = typeOf(value);
10379
+ if (actual !== input.type) {
10380
+ return {
10381
+ ok: false,
10382
+ code: "type_mismatch",
10383
+ error: `Workflow input "${input.name}" expects ${input.type}, got ${actual}.`
10384
+ };
10385
+ }
10386
+ }
10387
+ resolved[input.name] = value;
10388
+ }
10389
+ return { ok: true, props: resolved };
10390
+ }
10391
+
10337
10392
  // src/runtime/run-flow.ts
10338
10393
  async function runFlow(graph, executors, onEvent = () => {
10339
10394
  }, options = {}) {
@@ -10349,6 +10404,13 @@ async function runFlow(graph, executors, onEvent = () => {
10349
10404
  onEvent({ type: "run-error", error: msg });
10350
10405
  return { ok: false, outputs, error: msg };
10351
10406
  }
10407
+ const propsCheck = resolveWorkflowProps(graph.inputs, options.props);
10408
+ if (!propsCheck.ok) {
10409
+ onEvent({ type: "run-error", error: propsCheck.error });
10410
+ return { ok: false, outputs, error: propsCheck.error };
10411
+ }
10412
+ const props = propsCheck.props;
10413
+ const declaresProps = (graph.inputs?.length ?? 0) > 0;
10352
10414
  const incomingByNode = indexIncoming(graph.edges);
10353
10415
  const timer2 = timeoutMs ? setTimeout(() => errors.push(`Run timed out after ${timeoutMs}ms`), timeoutMs) : null;
10354
10416
  onEvent({ type: "run-start" });
@@ -10390,7 +10452,7 @@ async function runFlow(graph, executors, onEvent = () => {
10390
10452
  }
10391
10453
  onEvent({ type: "node-status", nodeId: node.id, status: "running" });
10392
10454
  announce(onEvent, node, "start");
10393
- const inputs = collectInputs(node, incoming, portValues, initialInputs);
10455
+ const inputs = collectInputs(node, incoming, portValues, initialInputs, props, declaresProps);
10394
10456
  const exec = pickExecutor(executors, node);
10395
10457
  if (!exec) {
10396
10458
  const msg = `No executor registered for kind=${node.type}`;
@@ -10467,14 +10529,23 @@ function topoSort(graph) {
10467
10529
  const byId = new Map(graph.nodes.map((n) => [n.id, n]));
10468
10530
  return ordered.map((id2) => byId.get(id2)).filter(Boolean);
10469
10531
  }
10470
- function collectInputs(node, incoming, portValues, initial) {
10532
+ function collectInputs(node, incoming, portValues, initial, props, declaresProps) {
10471
10533
  const inputs = { ...initial[node.id] ?? {} };
10534
+ if (incoming.length === 0) {
10535
+ for (const [name, value] of Object.entries(props)) {
10536
+ if (!(name in inputs)) inputs[name] = value;
10537
+ }
10538
+ }
10472
10539
  for (const e of incoming) {
10473
10540
  const portId = e.targetHandle ?? "in";
10474
10541
  const key2 = `${e.source}:${e.sourceHandle ?? "out"}`;
10475
10542
  if (!portValues.has(key2)) continue;
10476
10543
  inputs[portId] = portValues.get(key2);
10544
+ if (e.targetHandle == null && !(e.source in inputs)) {
10545
+ inputs[e.source] = portValues.get(key2);
10546
+ }
10477
10547
  }
10548
+ if (declaresProps) inputs.$props = props;
10478
10549
  return inputs;
10479
10550
  }
10480
10551
  function pickExecutor(executors, node) {