@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/registry.js CHANGED
@@ -1,6 +1,6 @@
1
- export { ANY_PORT_TYPE, RegistryNode, buildNodeTypes, createConnectionValidator, defaultPortCompatibility } from './chunk-I4F6GI3A.js';
1
+ export { ANY_PORT_TYPE, RegistryNode, buildNodeTypes, createConnectionValidator, defaultPortCompatibility } from './chunk-RSRXKZ52.js';
2
2
  export { LEGACY_PAUSE_PREFIXES, PAUSE_PREFIX, decodePause, encodePause, isPause, pauseForHuman } from './chunk-UEOE6B52.js';
3
- export { BUILTIN_KINDS, DEFAULT_MAX_DEPTH, categoryAccent, clearNodeKindOverrides, declaredRoutes, defaultConfigFor, ensureBuiltinKinds, getNodeKind, kindIds, listNodeKinds, llmRouterExecutor as llmBranchExecutor, llmRouterExecutor, nodeConfig, onNodeKindsChanged, overrideNodeKind, registerBuiltinKinds, registerNodeKind, resolveFallbackPort, resolveKindId, resolveNodePorts, resolvePortSpec, subflowExecutor, subflowMode, subflowPorts, validateConfig } from './chunk-XJMWMU4J.js';
3
+ export { BUILTIN_KINDS, DEFAULT_MAX_DEPTH, categoryAccent, clearNodeKindOverrides, declaredRoutes, defaultConfigFor, ensureBuiltinKinds, getNodeKind, kindIds, listNodeKinds, llmRouterExecutor as llmBranchExecutor, llmRouterExecutor, nodeConfig, onNodeKindsChanged, overrideNodeKind, registerBuiltinKinds, registerNodeKind, resolveFallbackPort, resolveKindId, resolveNodePorts, resolvePortSpec, subflowExecutor, subflowMode, subflowPorts, validateConfig } from './chunk-4GO2CHAY.js';
4
4
  export { RichInputPreview, getRichInputAdapter, isRichInputEnabled, onRichInputAdapterChanged, registerRichInputAdapter } from './chunk-F5RPRB7A.js';
5
5
  export { capabilityStatus, getLlmClient, getWorkflowResolver, isResolutionFailure, registerLlmClient, registerWorkflowResolver } from './chunk-USL4FMFU.js';
6
6
  //# sourceMappingURL=registry.js.map
@@ -1,5 +1,5 @@
1
- import { F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-7cXcSQlx.js';
2
- import { R as RunOptions, a as RunResult } from './run-flow-DPUPAWk6.js';
1
+ import { F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-JFYjPJAG.js';
2
+ import { R as RunOptions, a as RunResult } from './run-flow-DJ7KYT6E.js';
3
3
 
4
4
  /**
5
5
  * How the flows one trigger fired should treat each other.
@@ -1,5 +1,5 @@
1
- import { F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-7cXcSQlx.cjs';
2
- import { R as RunOptions, a as RunResult } from './run-flow-B24QUO1H.cjs';
1
+ import { F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-JFYjPJAG.cjs';
2
+ import { R as RunOptions, a as RunResult } from './run-flow-COdAOFg2.cjs';
3
3
 
4
4
  /**
5
5
  * How the flows one trigger fired should treat each other.
@@ -1,4 +1,4 @@
1
- import { b as RunIdentity, c as RunIdentityJson, F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-7cXcSQlx.cjs';
1
+ import { b as RunIdentity, c as RunIdentityJson, F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-JFYjPJAG.cjs';
2
2
 
3
3
  type RunOptions = {
4
4
  /** Stop the run after this many ms. Default: no timeout. */
@@ -7,6 +7,15 @@ type RunOptions = {
7
7
  signal?: AbortSignal;
8
8
  /** Initial inputs supplied to entry-point nodes (no incoming edges). */
9
9
  initialInputs?: Record<string, Record<string, unknown>>;
10
+ /**
11
+ * Values for the inputs the graph DECLARES, passed by name.
12
+ *
13
+ * The flat, node-id-free way to configure a run. `initialInputs` is keyed by
14
+ * node id, so a caller had to know the trigger was called `t` and a rename
15
+ * broke every caller while the graph stayed valid. Props are checked against
16
+ * `graph.inputs`, so a misspelling fails the run instead of sitting unread.
17
+ */
18
+ props?: Record<string, unknown>;
10
19
  /** Nesting depth — set by `subflow` when it runs a child graph. */
11
20
  depth?: number;
12
21
  /**
@@ -1,4 +1,4 @@
1
- import { b as RunIdentity, c as RunIdentityJson, F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-7cXcSQlx.js';
1
+ import { b as RunIdentity, c as RunIdentityJson, F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-JFYjPJAG.js';
2
2
 
3
3
  type RunOptions = {
4
4
  /** Stop the run after this many ms. Default: no timeout. */
@@ -7,6 +7,15 @@ type RunOptions = {
7
7
  signal?: AbortSignal;
8
8
  /** Initial inputs supplied to entry-point nodes (no incoming edges). */
9
9
  initialInputs?: Record<string, Record<string, unknown>>;
10
+ /**
11
+ * Values for the inputs the graph DECLARES, passed by name.
12
+ *
13
+ * The flat, node-id-free way to configure a run. `initialInputs` is keyed by
14
+ * node id, so a caller had to know the trigger was called `t` and a rename
15
+ * broke every caller while the graph stayed valid. Props are checked against
16
+ * `graph.inputs`, so a misspelling fails the run instead of sitting unread.
17
+ */
18
+ props?: Record<string, unknown>;
10
19
  /** Nesting depth — set by `subflow` when it runs a child graph. */
11
20
  depth?: number;
12
21
  /**
@@ -1,8 +1,8 @@
1
- import { a as RunResult, R as RunOptions } from '../run-flow-B24QUO1H.cjs';
2
- export { r as runFlow } from '../run-flow-B24QUO1H.cjs';
3
- import { g as NodeRunStatus, F as FlowGraph, E as ExecutorRegistry, a as FlowNode, d as FlowEdge } from '../types-7cXcSQlx.cjs';
4
- export { b as RunIdentity, c as RunIdentityJson, i as escapeSegment } from '../types-7cXcSQlx.cjs';
5
- export { C as CohortGuard, a as CohortOptions, b as CohortPolicy, c as CohortResult, r as runCohort } from '../run-cohort-DYCL8Qv6.cjs';
1
+ import { a as RunResult, R as RunOptions } from '../run-flow-COdAOFg2.cjs';
2
+ export { r as runFlow } from '../run-flow-COdAOFg2.cjs';
3
+ import { g as NodeRunStatus, F as FlowGraph, E as ExecutorRegistry, a as FlowNode, d as FlowEdge } from '../types-JFYjPJAG.cjs';
4
+ export { b as RunIdentity, c as RunIdentityJson, i as escapeSegment } from '../types-JFYjPJAG.cjs';
5
+ export { C as CohortGuard, a as CohortOptions, b as CohortPolicy, c as CohortResult, r as runCohort } from '../run-cohort-r-L8dMED.cjs';
6
6
  import { NodeChange, EdgeChange, Connection } from '@xyflow/react';
7
7
 
8
8
  type FlowRunFeedEntry = {
@@ -1,8 +1,8 @@
1
- import { a as RunResult, R as RunOptions } from '../run-flow-DPUPAWk6.js';
2
- export { r as runFlow } from '../run-flow-DPUPAWk6.js';
3
- import { g as NodeRunStatus, F as FlowGraph, E as ExecutorRegistry, a as FlowNode, d as FlowEdge } from '../types-7cXcSQlx.js';
4
- export { b as RunIdentity, c as RunIdentityJson, i as escapeSegment } from '../types-7cXcSQlx.js';
5
- export { C as CohortGuard, a as CohortOptions, b as CohortPolicy, c as CohortResult, r as runCohort } from '../run-cohort-VX4JG21l.js';
1
+ import { a as RunResult, R as RunOptions } from '../run-flow-DJ7KYT6E.js';
2
+ export { r as runFlow } from '../run-flow-DJ7KYT6E.js';
3
+ import { g as NodeRunStatus, F as FlowGraph, E as ExecutorRegistry, a as FlowNode, d as FlowEdge } from '../types-JFYjPJAG.js';
4
+ export { b as RunIdentity, c as RunIdentityJson, i as escapeSegment } from '../types-JFYjPJAG.js';
5
+ export { C as CohortGuard, a as CohortOptions, b as CohortPolicy, c as CohortResult, r as runCohort } from '../run-cohort-BPIOpE8A.js';
6
6
  import { NodeChange, EdgeChange, Connection } from '@xyflow/react';
7
7
 
8
8
  type FlowRunFeedEntry = {
package/dist/runtime.cjs CHANGED
@@ -10224,6 +10224,61 @@ var RunIdentity = class _RunIdentity {
10224
10224
  }
10225
10225
  };
10226
10226
 
10227
+ // src/runtime/workflow-props.ts
10228
+ function typeOf(value) {
10229
+ if (value === null) return "null";
10230
+ if (Array.isArray(value)) return "array";
10231
+ return typeof value;
10232
+ }
10233
+ function resolveWorkflowProps(declared, passed) {
10234
+ const inputs = declared ?? [];
10235
+ const given = passed ?? {};
10236
+ const byName = new Map(inputs.map((input) => [input.name, input]));
10237
+ for (const name of Object.keys(given)) {
10238
+ if (!byName.has(name)) {
10239
+ const known = inputs.map((input) => input.name);
10240
+ const suffix = known.length === 0 ? "this workflow declares no inputs" : `known inputs: ${known.join(", ")}`;
10241
+ return {
10242
+ ok: false,
10243
+ code: "unknown_input",
10244
+ error: `Unknown workflow input "${name}" \u2014 ${suffix}.`
10245
+ };
10246
+ }
10247
+ }
10248
+ const resolved = {};
10249
+ for (const input of inputs) {
10250
+ const supplied = Object.prototype.hasOwnProperty.call(given, input.name);
10251
+ const hasDefault = Object.prototype.hasOwnProperty.call(input, "default");
10252
+ if (!supplied) {
10253
+ if (hasDefault) {
10254
+ resolved[input.name] = input.default;
10255
+ continue;
10256
+ }
10257
+ if (input.required) {
10258
+ return {
10259
+ ok: false,
10260
+ code: "missing_required",
10261
+ error: `Missing required workflow input "${input.name}"${input.type ? ` (${input.type})` : ""}.`
10262
+ };
10263
+ }
10264
+ continue;
10265
+ }
10266
+ const value = given[input.name];
10267
+ if (input.type !== void 0) {
10268
+ const actual = typeOf(value);
10269
+ if (actual !== input.type) {
10270
+ return {
10271
+ ok: false,
10272
+ code: "type_mismatch",
10273
+ error: `Workflow input "${input.name}" expects ${input.type}, got ${actual}.`
10274
+ };
10275
+ }
10276
+ }
10277
+ resolved[input.name] = value;
10278
+ }
10279
+ return { ok: true, props: resolved };
10280
+ }
10281
+
10227
10282
  // src/runtime/run-flow.ts
10228
10283
  async function runFlow(graph, executors, onEvent = () => {
10229
10284
  }, options = {}) {
@@ -10239,6 +10294,13 @@ async function runFlow(graph, executors, onEvent = () => {
10239
10294
  onEvent({ type: "run-error", error: msg });
10240
10295
  return { ok: false, outputs, error: msg };
10241
10296
  }
10297
+ const propsCheck = resolveWorkflowProps(graph.inputs, options.props);
10298
+ if (!propsCheck.ok) {
10299
+ onEvent({ type: "run-error", error: propsCheck.error });
10300
+ return { ok: false, outputs, error: propsCheck.error };
10301
+ }
10302
+ const props = propsCheck.props;
10303
+ const declaresProps = (graph.inputs?.length ?? 0) > 0;
10242
10304
  const incomingByNode = indexIncoming(graph.edges);
10243
10305
  const timer2 = timeoutMs ? setTimeout(() => errors.push(`Run timed out after ${timeoutMs}ms`), timeoutMs) : null;
10244
10306
  onEvent({ type: "run-start" });
@@ -10280,10 +10342,11 @@ async function runFlow(graph, executors, onEvent = () => {
10280
10342
  }
10281
10343
  onEvent({ type: "node-status", nodeId: node.id, status: "running" });
10282
10344
  announce(onEvent, node, "start");
10283
- const inputs = collectInputs(node, incoming, portValues, initialInputs);
10345
+ const inputs = collectInputs(node, incoming, portValues, initialInputs, props, declaresProps);
10284
10346
  const exec = pickExecutor(executors, node);
10285
10347
  if (!exec) {
10286
- const msg = `No executor registered for kind=${node.type}`;
10348
+ const tried = executorLookupIds(node);
10349
+ 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.`;
10287
10350
  errors.push(msg);
10288
10351
  onEvent({ type: "node-status", nodeId: node.id, status: "error", text: msg });
10289
10352
  onEvent({ type: "log", nodeId: node.id, level: "error", message: msg });
@@ -10357,8 +10420,13 @@ function topoSort(graph) {
10357
10420
  const byId = new Map(graph.nodes.map((n) => [n.id, n]));
10358
10421
  return ordered.map((id2) => byId.get(id2)).filter(Boolean);
10359
10422
  }
10360
- function collectInputs(node, incoming, portValues, initial) {
10423
+ function collectInputs(node, incoming, portValues, initial, props, declaresProps) {
10361
10424
  const inputs = { ...initial[node.id] ?? {} };
10425
+ if (incoming.length === 0) {
10426
+ for (const [name, value] of Object.entries(props)) {
10427
+ if (!(name in inputs)) inputs[name] = value;
10428
+ }
10429
+ }
10362
10430
  for (const e of incoming) {
10363
10431
  const portId = e.targetHandle ?? "in";
10364
10432
  const key = `${e.source}:${e.sourceHandle ?? "out"}`;
@@ -10368,16 +10436,31 @@ function collectInputs(node, incoming, portValues, initial) {
10368
10436
  inputs[e.source] = portValues.get(key);
10369
10437
  }
10370
10438
  }
10439
+ if (declaresProps) inputs.$props = props;
10371
10440
  return inputs;
10372
10441
  }
10442
+ function executorLookupIds(node) {
10443
+ const ids = [node.id];
10444
+ if (node.type) ids.push(node.type);
10445
+ const declared = node.data?.kind;
10446
+ const kindName = typeof declared === "string" && declared !== "" ? declared : node.type;
10447
+ if (kindName && kindName !== node.type) ids.push(kindName);
10448
+ for (const name of [kindName, node.type]) {
10449
+ const kind = name ? getNodeKind(name) : null;
10450
+ if (!kind) continue;
10451
+ for (const id2 of kindIds(kind)) ids.push(id2);
10452
+ }
10453
+ return [...new Set(ids)];
10454
+ }
10373
10455
  function pickExecutor(executors, node) {
10374
10456
  if (executors[node.id]) return executors[node.id];
10375
10457
  if (node.type && executors[node.type]) return executors[node.type];
10376
10458
  const declared = node.data?.kind;
10377
10459
  const kindName = typeof declared === "string" && declared !== "" ? declared : node.type;
10378
10460
  if (kindName && kindName !== node.type && executors[kindName]) return executors[kindName];
10379
- const kind = kindName ? getNodeKind(kindName) : null;
10380
- if (kind) {
10461
+ for (const name of [kindName, node.type]) {
10462
+ const kind = name ? getNodeKind(name) : null;
10463
+ if (!kind) continue;
10381
10464
  for (const id2 of kindIds(kind)) {
10382
10465
  if (executors[id2]) return executors[id2];
10383
10466
  }