@particle-academy/fancy-flow 0.50.0 → 0.51.1

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-XJMWMU4J.js → chunk-4GO2CHAY.js} +90 -7
  8. package/dist/chunk-4GO2CHAY.js.map +1 -0
  9. package/dist/{chunk-OWDSPRAF.js → chunk-OECW2E5D.js} +4 -4
  10. package/dist/{chunk-OWDSPRAF.js.map → chunk-OECW2E5D.js.map} +1 -1
  11. package/dist/{chunk-BAHJVX3S.js → chunk-OK7KJLWA.js} +3 -3
  12. package/dist/{chunk-BAHJVX3S.js.map → chunk-OK7KJLWA.js.map} +1 -1
  13. package/dist/{chunk-I4F6GI3A.js → chunk-RSRXKZ52.js} +3 -3
  14. package/dist/{chunk-I4F6GI3A.js.map → chunk-RSRXKZ52.js.map} +1 -1
  15. package/dist/{chunk-3W26FA7Q.js → chunk-SPINP4EJ.js} +18 -4
  16. package/dist/chunk-SPINP4EJ.js.map +1 -0
  17. package/dist/{chunk-DQJIU55F.js → chunk-VUU3CDBT.js} +3 -3
  18. package/dist/{chunk-DQJIU55F.js.map → chunk-VUU3CDBT.js.map} +1 -1
  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 +88 -5
  24. package/dist/durable.cjs.map +1 -1
  25. package/dist/durable.js +1 -1
  26. package/dist/engine.cjs +88 -5
  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 +103 -6
  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 +88 -5
  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 +88 -5
  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 +103 -6
  63. package/dist/schema.cjs.map +1 -1
  64. package/dist/schema.js +2 -2
  65. package/dist/screens.cjs +88 -5
  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.cts → types-JFYjPJAG.d.cts} +37 -1
  72. package/dist/{types-7cXcSQlx.d.ts → types-JFYjPJAG.d.ts} +37 -1
  73. package/dist/{types-CDgIIj4c.d.ts → types-s643U1Hi.d.ts} +1 -1
  74. package/dist/ux.cjs +88 -5
  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-3W26FA7Q.js.map +0 -1
  81. package/dist/chunk-XJMWMU4J.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-XJMWMU4J.js';
3
+ import { getNodeKind, runFlow, resolveKindId, kindIds, RunIdentity } from './chunk-4GO2CHAY.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,10 +10452,11 @@ 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
- const msg = `No executor registered for kind=${node.type}`;
10458
+ const tried = executorLookupIds(node);
10459
+ const msg = `No executor registered for kind=${node.type} \u2014 tried ${tried.map((id2) => `"${id2}"`).join(", ")} and the wildcard "*". Key your registry by one of those.`;
10397
10460
  errors.push(msg);
10398
10461
  onEvent({ type: "node-status", nodeId: node.id, status: "error", text: msg });
10399
10462
  onEvent({ type: "log", nodeId: node.id, level: "error", message: msg });
@@ -10467,8 +10530,13 @@ function topoSort(graph) {
10467
10530
  const byId = new Map(graph.nodes.map((n) => [n.id, n]));
10468
10531
  return ordered.map((id2) => byId.get(id2)).filter(Boolean);
10469
10532
  }
10470
- function collectInputs(node, incoming, portValues, initial) {
10533
+ function collectInputs(node, incoming, portValues, initial, props, declaresProps) {
10471
10534
  const inputs = { ...initial[node.id] ?? {} };
10535
+ if (incoming.length === 0) {
10536
+ for (const [name, value] of Object.entries(props)) {
10537
+ if (!(name in inputs)) inputs[name] = value;
10538
+ }
10539
+ }
10472
10540
  for (const e of incoming) {
10473
10541
  const portId = e.targetHandle ?? "in";
10474
10542
  const key2 = `${e.source}:${e.sourceHandle ?? "out"}`;
@@ -10478,16 +10546,31 @@ function collectInputs(node, incoming, portValues, initial) {
10478
10546
  inputs[e.source] = portValues.get(key2);
10479
10547
  }
10480
10548
  }
10549
+ if (declaresProps) inputs.$props = props;
10481
10550
  return inputs;
10482
10551
  }
10552
+ function executorLookupIds(node) {
10553
+ const ids = [node.id];
10554
+ if (node.type) ids.push(node.type);
10555
+ const declared = node.data?.kind;
10556
+ const kindName2 = typeof declared === "string" && declared !== "" ? declared : node.type;
10557
+ if (kindName2 && kindName2 !== node.type) ids.push(kindName2);
10558
+ for (const name of [kindName2, node.type]) {
10559
+ const kind = name ? getNodeKind(name) : null;
10560
+ if (!kind) continue;
10561
+ for (const id2 of kindIds(kind)) ids.push(id2);
10562
+ }
10563
+ return [...new Set(ids)];
10564
+ }
10483
10565
  function pickExecutor(executors, node) {
10484
10566
  if (executors[node.id]) return executors[node.id];
10485
10567
  if (node.type && executors[node.type]) return executors[node.type];
10486
10568
  const declared = node.data?.kind;
10487
10569
  const kindName2 = typeof declared === "string" && declared !== "" ? declared : node.type;
10488
10570
  if (kindName2 && kindName2 !== node.type && executors[kindName2]) return executors[kindName2];
10489
- const kind = kindName2 ? getNodeKind(kindName2) : null;
10490
- if (kind) {
10571
+ for (const name of [kindName2, node.type]) {
10572
+ const kind = name ? getNodeKind(name) : null;
10573
+ if (!kind) continue;
10491
10574
  for (const id2 of kindIds(kind)) {
10492
10575
  if (executors[id2]) return executors[id2];
10493
10576
  }