@particle-academy/fancy-flow 0.50.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-I4F6GI3A.js → chunk-6AI6CBNL.js} +3 -3
  8. package/dist/{chunk-I4F6GI3A.js.map → chunk-6AI6CBNL.js.map} +1 -1
  9. package/dist/{chunk-OWDSPRAF.js → chunk-7XTTXMGB.js} +4 -4
  10. package/dist/{chunk-OWDSPRAF.js.map → chunk-7XTTXMGB.js.map} +1 -1
  11. package/dist/{chunk-BAHJVX3S.js → chunk-HXGGCMR7.js} +3 -3
  12. package/dist/{chunk-BAHJVX3S.js.map → chunk-HXGGCMR7.js.map} +1 -1
  13. package/dist/{chunk-3W26FA7Q.js → chunk-LH76EIFL.js} +18 -4
  14. package/dist/chunk-LH76EIFL.js.map +1 -0
  15. package/dist/{chunk-DQJIU55F.js → chunk-SKEZ5AGI.js} +3 -3
  16. package/dist/{chunk-DQJIU55F.js.map → chunk-SKEZ5AGI.js.map} +1 -1
  17. package/dist/{chunk-XJMWMU4J.js → chunk-XCT2CJ5O.js} +72 -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 +70 -2
  24. package/dist/durable.cjs.map +1 -1
  25. package/dist/durable.js +1 -1
  26. package/dist/engine.cjs +70 -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 +85 -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 +70 -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 +70 -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 +85 -3
  63. package/dist/schema.cjs.map +1 -1
  64. package/dist/schema.js +2 -2
  65. package/dist/screens.cjs +70 -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.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 +70 -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-3W26FA7Q.js.map +0 -1
  81. package/dist/chunk-XJMWMU4J.js.map +0 -1
package/dist/runtime.js CHANGED
@@ -1,6 +1,6 @@
1
- export { applyOutputsToNodes, applyStatusesToNodes, createHistory, useFlowHistory, useFlowRun, useFlowState } from './chunk-BAHJVX3S.js';
2
- export { runCohort } from './chunk-DQJIU55F.js';
3
- export { RunIdentity, escapeSegment, runFlow } from './chunk-XJMWMU4J.js';
1
+ export { applyOutputsToNodes, applyStatusesToNodes, createHistory, useFlowHistory, useFlowRun, useFlowState } from './chunk-HXGGCMR7.js';
2
+ export { runCohort } from './chunk-SKEZ5AGI.js';
3
+ export { RunIdentity, escapeSegment, runFlow } from './chunk-XCT2CJ5O.js';
4
4
  import './chunk-F5RPRB7A.js';
5
5
  import './chunk-USL4FMFU.js';
6
6
  //# sourceMappingURL=runtime.js.map
@@ -1,4 +1,4 @@
1
- import { P as PortDescriptor, F as FlowGraph } from '../types-7cXcSQlx.cjs';
1
+ import { W as WorkflowInput, P as PortDescriptor, F as FlowGraph } from '../types-JFYjPJAG.cjs';
2
2
  import '@xyflow/react';
3
3
 
4
4
  /** Schema version. Bump on breaking shape changes; add migrations as needed. */
@@ -8,6 +8,17 @@ type WorkflowSchema = {
8
8
  $schema: typeof WORKFLOW_SCHEMA_URL;
9
9
  version: typeof WORKFLOW_SCHEMA_VERSION;
10
10
  metadata?: WorkflowMetadata;
11
+ /**
12
+ * What this workflow accepts at run start, passed BY NAME.
13
+ *
14
+ * Lives beside `graph` rather than inside it because it describes the
15
+ * workflow's CONTRACT, not its topology: a caller reads this to know what to
16
+ * pass, and reading it should not mean walking nodes looking for a trigger.
17
+ *
18
+ * Omitted entirely when a workflow takes none, so every existing saved
19
+ * document is unchanged byte for byte.
20
+ */
21
+ inputs?: WorkflowInput[];
11
22
  graph: {
12
23
  nodes: WorkflowSchemaNode[];
13
24
  edges: WorkflowSchemaEdge[];
@@ -1,4 +1,4 @@
1
- import { P as PortDescriptor, F as FlowGraph } from '../types-7cXcSQlx.js';
1
+ import { W as WorkflowInput, P as PortDescriptor, F as FlowGraph } from '../types-JFYjPJAG.js';
2
2
  import '@xyflow/react';
3
3
 
4
4
  /** Schema version. Bump on breaking shape changes; add migrations as needed. */
@@ -8,6 +8,17 @@ type WorkflowSchema = {
8
8
  $schema: typeof WORKFLOW_SCHEMA_URL;
9
9
  version: typeof WORKFLOW_SCHEMA_VERSION;
10
10
  metadata?: WorkflowMetadata;
11
+ /**
12
+ * What this workflow accepts at run start, passed BY NAME.
13
+ *
14
+ * Lives beside `graph` rather than inside it because it describes the
15
+ * workflow's CONTRACT, not its topology: a caller reads this to know what to
16
+ * pass, and reading it should not mean walking nodes looking for a trigger.
17
+ *
18
+ * Omitted entirely when a workflow takes none, so every existing saved
19
+ * document is unchanged byte for byte.
20
+ */
21
+ inputs?: WorkflowInput[];
11
22
  graph: {
12
23
  nodes: WorkflowSchemaNode[];
13
24
  edges: WorkflowSchemaEdge[];
package/dist/schema.cjs CHANGED
@@ -9226,6 +9226,61 @@ var RunIdentity = class _RunIdentity {
9226
9226
  }
9227
9227
  };
9228
9228
 
9229
+ // src/runtime/workflow-props.ts
9230
+ function typeOf(value) {
9231
+ if (value === null) return "null";
9232
+ if (Array.isArray(value)) return "array";
9233
+ return typeof value;
9234
+ }
9235
+ function resolveWorkflowProps(declared, passed) {
9236
+ const inputs = declared ?? [];
9237
+ const given = passed ?? {};
9238
+ const byName = new Map(inputs.map((input) => [input.name, input]));
9239
+ for (const name of Object.keys(given)) {
9240
+ if (!byName.has(name)) {
9241
+ const known = inputs.map((input) => input.name);
9242
+ const suffix = known.length === 0 ? "this workflow declares no inputs" : `known inputs: ${known.join(", ")}`;
9243
+ return {
9244
+ ok: false,
9245
+ code: "unknown_input",
9246
+ error: `Unknown workflow input "${name}" \u2014 ${suffix}.`
9247
+ };
9248
+ }
9249
+ }
9250
+ const resolved = {};
9251
+ for (const input of inputs) {
9252
+ const supplied = Object.prototype.hasOwnProperty.call(given, input.name);
9253
+ const hasDefault = Object.prototype.hasOwnProperty.call(input, "default");
9254
+ if (!supplied) {
9255
+ if (hasDefault) {
9256
+ resolved[input.name] = input.default;
9257
+ continue;
9258
+ }
9259
+ if (input.required) {
9260
+ return {
9261
+ ok: false,
9262
+ code: "missing_required",
9263
+ error: `Missing required workflow input "${input.name}"${input.type ? ` (${input.type})` : ""}.`
9264
+ };
9265
+ }
9266
+ continue;
9267
+ }
9268
+ const value = given[input.name];
9269
+ if (input.type !== void 0) {
9270
+ const actual = typeOf(value);
9271
+ if (actual !== input.type) {
9272
+ return {
9273
+ ok: false,
9274
+ code: "type_mismatch",
9275
+ error: `Workflow input "${input.name}" expects ${input.type}, got ${actual}.`
9276
+ };
9277
+ }
9278
+ }
9279
+ resolved[input.name] = value;
9280
+ }
9281
+ return { ok: true, props: resolved };
9282
+ }
9283
+
9229
9284
  // src/runtime/run-flow.ts
9230
9285
  async function runFlow(graph, executors, onEvent = () => {
9231
9286
  }, options = {}) {
@@ -9241,6 +9296,13 @@ async function runFlow(graph, executors, onEvent = () => {
9241
9296
  onEvent({ type: "run-error", error: msg });
9242
9297
  return { ok: false, outputs, error: msg };
9243
9298
  }
9299
+ const propsCheck = resolveWorkflowProps(graph.inputs, options.props);
9300
+ if (!propsCheck.ok) {
9301
+ onEvent({ type: "run-error", error: propsCheck.error });
9302
+ return { ok: false, outputs, error: propsCheck.error };
9303
+ }
9304
+ const props = propsCheck.props;
9305
+ const declaresProps = (graph.inputs?.length ?? 0) > 0;
9244
9306
  const incomingByNode = indexIncoming(graph.edges);
9245
9307
  const timer2 = timeoutMs ? setTimeout(() => errors.push(`Run timed out after ${timeoutMs}ms`), timeoutMs) : null;
9246
9308
  onEvent({ type: "run-start" });
@@ -9282,7 +9344,7 @@ async function runFlow(graph, executors, onEvent = () => {
9282
9344
  }
9283
9345
  onEvent({ type: "node-status", nodeId: node.id, status: "running" });
9284
9346
  announce(onEvent, node, "start");
9285
- const inputs = collectInputs(node, incoming, portValues, initialInputs);
9347
+ const inputs = collectInputs(node, incoming, portValues, initialInputs, props, declaresProps);
9286
9348
  const exec = pickExecutor(executors, node);
9287
9349
  if (!exec) {
9288
9350
  const msg = `No executor registered for kind=${node.type}`;
@@ -9359,8 +9421,13 @@ function topoSort(graph) {
9359
9421
  const byId = new Map(graph.nodes.map((n) => [n.id, n]));
9360
9422
  return ordered.map((id2) => byId.get(id2)).filter(Boolean);
9361
9423
  }
9362
- function collectInputs(node, incoming, portValues, initial) {
9424
+ function collectInputs(node, incoming, portValues, initial, props, declaresProps) {
9363
9425
  const inputs = { ...initial[node.id] ?? {} };
9426
+ if (incoming.length === 0) {
9427
+ for (const [name, value] of Object.entries(props)) {
9428
+ if (!(name in inputs)) inputs[name] = value;
9429
+ }
9430
+ }
9364
9431
  for (const e of incoming) {
9365
9432
  const portId = e.targetHandle ?? "in";
9366
9433
  const key = `${e.source}:${e.sourceHandle ?? "out"}`;
@@ -9370,6 +9437,7 @@ function collectInputs(node, incoming, portValues, initial) {
9370
9437
  inputs[e.source] = portValues.get(key);
9371
9438
  }
9372
9439
  }
9440
+ if (declaresProps) inputs.$props = props;
9373
9441
  return inputs;
9374
9442
  }
9375
9443
  function pickExecutor(executors, node) {
@@ -10506,6 +10574,9 @@ function exportWorkflow(graph, metadata, view) {
10506
10574
  $schema: WORKFLOW_SCHEMA_URL,
10507
10575
  version: WORKFLOW_SCHEMA_VERSION,
10508
10576
  metadata: metadata ? { ...metadata, updatedAt: Date.now() } : void 0,
10577
+ // Round-trips, or a saved workflow silently forgets its own contract and
10578
+ // every caller's props become "unknown input" on the next load.
10579
+ ...graph.inputs && graph.inputs.length > 0 ? { inputs: graph.inputs } : {},
10509
10580
  graph: {
10510
10581
  nodes: graph.nodes.map(toSchemaNode),
10511
10582
  edges: graph.edges.map(toSchemaEdge)
@@ -10628,7 +10699,18 @@ function importWorkflow(schema, options = {}) {
10628
10699
  };
10629
10700
  }).filter((e) => e !== null);
10630
10701
  const ok = issues.every((i) => i.level !== "error");
10631
- return { ok, graph: { nodes, edges }, issues };
10702
+ const declaredInputs = Array.isArray(s.inputs) ? s.inputs.filter(
10703
+ (input) => input !== null && typeof input === "object" && typeof input.name === "string"
10704
+ ) : void 0;
10705
+ return {
10706
+ ok,
10707
+ graph: {
10708
+ nodes,
10709
+ edges,
10710
+ ...declaredInputs && declaredInputs.length > 0 ? { inputs: declaredInputs } : {}
10711
+ },
10712
+ issues
10713
+ };
10632
10714
  }
10633
10715
  function workflowToBlob(schema) {
10634
10716
  return new Blob([JSON.stringify(schema, null, 2)], { type: "application/json" });