@particle-academy/fancy-flow 0.77.1 → 0.78.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 (82) hide show
  1. package/dist/{FlowViewer-Ak8kbY0e.d.cts → FlowViewer-BqYQl2vS.d.cts} +1 -1
  2. package/dist/{FlowViewer-BAV29Zpi.d.ts → FlowViewer-_Fq8AX9V.d.ts} +1 -1
  3. package/dist/{HumanPrompt-xYPCL2jO.d.cts → HumanPrompt-Sl1wD9Bx.d.cts} +2 -2
  4. package/dist/{HumanPrompt-Ge_ccCgS.d.ts → HumanPrompt-_SKIdSpx.d.ts} +2 -2
  5. package/dist/{chunk-G5RAGPVD.js → chunk-3EDB6ELL.js} +3 -3
  6. package/dist/{chunk-G5RAGPVD.js.map → chunk-3EDB6ELL.js.map} +1 -1
  7. package/dist/{chunk-CQAMEPPI.js → chunk-4GNDRRJ3.js} +3 -3
  8. package/dist/{chunk-CQAMEPPI.js.map → chunk-4GNDRRJ3.js.map} +1 -1
  9. package/dist/{chunk-EGXA4SYJ.js → chunk-BBFHGAEN.js} +4 -4
  10. package/dist/{chunk-EGXA4SYJ.js.map → chunk-BBFHGAEN.js.map} +1 -1
  11. package/dist/{chunk-ARSOSEJV.js → chunk-GPFIJR2K.js} +4 -4
  12. package/dist/{chunk-ARSOSEJV.js.map → chunk-GPFIJR2K.js.map} +1 -1
  13. package/dist/{chunk-EEIWAIXW.js → chunk-J5YUYDMK.js} +106 -6
  14. package/dist/chunk-J5YUYDMK.js.map +1 -0
  15. package/dist/{chunk-2VI24UPB.js → chunk-S4MOUOG4.js} +3 -3
  16. package/dist/{chunk-2VI24UPB.js.map → chunk-S4MOUOG4.js.map} +1 -1
  17. package/dist/{chunk-T6WIIGSK.js → chunk-XO4ODEY2.js} +3 -3
  18. package/dist/{chunk-T6WIIGSK.js.map → chunk-XO4ODEY2.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 +104 -4
  24. package/dist/durable.cjs.map +1 -1
  25. package/dist/durable.js +1 -1
  26. package/dist/engine.cjs +104 -4
  27. package/dist/engine.cjs.map +1 -1
  28. package/dist/engine.d.cts +6 -6
  29. package/dist/engine.d.ts +6 -6
  30. package/dist/engine.js +4 -4
  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 +104 -4
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +10 -10
  36. package/dist/index.d.ts +10 -10
  37. package/dist/index.js +12 -12
  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 +1 -1
  41. package/dist/llm/prism.d.ts +1 -1
  42. package/dist/llm/vercel-ai.d.cts +1 -1
  43. package/dist/llm/vercel-ai.d.ts +1 -1
  44. package/dist/registry/index.d.cts +5 -5
  45. package/dist/registry/index.d.ts +5 -5
  46. package/dist/{registry-JUcN_xWK.d.ts → registry-C4GcH583.d.ts} +1 -1
  47. package/dist/{registry-B6SiTaLZ.d.cts → registry-DWIY3bMP.d.cts} +1 -1
  48. package/dist/registry.cjs +104 -4
  49. package/dist/registry.cjs.map +1 -1
  50. package/dist/registry.js +2 -2
  51. package/dist/{run-cohort-rgT_FX3V.d.ts → run-cohort-DAfhZm-p.d.ts} +2 -2
  52. package/dist/{run-cohort-DNpPa0mq.d.cts → run-cohort-DRJvUWO9.d.cts} +2 -2
  53. package/dist/{run-flow-pW0PllaZ.d.cts → run-flow-Bdrn4lQV.d.cts} +1 -1
  54. package/dist/{run-flow-BLP9rXfO.d.ts → run-flow-D2iOjWsj.d.ts} +1 -1
  55. package/dist/runtime/index.d.cts +5 -5
  56. package/dist/runtime/index.d.ts +5 -5
  57. package/dist/runtime.cjs +104 -4
  58. package/dist/runtime.cjs.map +1 -1
  59. package/dist/runtime.js +3 -3
  60. package/dist/schema/index.d.cts +1 -1
  61. package/dist/schema/index.d.ts +1 -1
  62. package/dist/schema.cjs +104 -4
  63. package/dist/schema.cjs.map +1 -1
  64. package/dist/schema.js +3 -3
  65. package/dist/screens.cjs +104 -4
  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/terminal/fancy-term-host.d.cts +1 -1
  71. package/dist/terminal/fancy-term-host.d.ts +1 -1
  72. package/dist/{types-BdkXxjFh.d.cts → types-B1jftRa9.d.cts} +1 -1
  73. package/dist/{types-CbekKMMO.d.ts → types-D5SBBpbe.d.ts} +1 -1
  74. package/dist/{types-B-Syk9-M.d.ts → types-E48Dpesq.d.cts} +20 -0
  75. package/dist/{types-B-Syk9-M.d.cts → types-E48Dpesq.d.ts} +20 -0
  76. package/dist/ux.cjs +104 -4
  77. package/dist/ux.cjs.map +1 -1
  78. package/dist/ux.d.cts +2 -2
  79. package/dist/ux.d.ts +2 -2
  80. package/dist/ux.js +1 -1
  81. package/package.json +2 -2
  82. package/dist/chunk-EEIWAIXW.js.map +0 -1
package/dist/registry.js CHANGED
@@ -1,7 +1,7 @@
1
- export { ANY_PORT_TYPE, BUILTIN_KINDS, RegistryNode, buildNodeTypes, createConnectionValidator, defaultPortCompatibility, registerBuiltinKinds } from './chunk-T6WIIGSK.js';
1
+ export { ANY_PORT_TYPE, BUILTIN_KINDS, RegistryNode, buildNodeTypes, createConnectionValidator, defaultPortCompatibility, registerBuiltinKinds } from './chunk-XO4ODEY2.js';
2
2
  export { RichInputPreview, getRichInputAdapter, isRichInputEnabled, onRichInputAdapterChanged, registerRichInputAdapter } from './chunk-F5RPRB7A.js';
3
3
  import './chunk-OWENS2H5.js';
4
- export { DEFAULT_MAX_DEPTH, LEGACY_PAUSE_PREFIXES, PAUSE_PREFIX, applyKindSchemaOverlay, categoryAccent, clearKindSchemaOverlays, clearNodeKindOverrides, declaredRoutes, decodePause, defaultConfigFor, encodePause, ensureBuiltinKinds, getNodeKind, isPause, kindIds, listNodeKinds, llmRouterExecutor as llmBranchExecutor, llmRouterExecutor, nodeConfig, onNodeKindsChanged, overrideNodeKind, pauseForHuman, registerNodeKind, resolveFallbackPort, resolveKindId, resolveNodePorts, resolvePortSpec, subflowExecutor, subflowMode, subflowPorts, unregisterNodeKind, validateConfig } from './chunk-EEIWAIXW.js';
4
+ export { DEFAULT_MAX_DEPTH, LEGACY_PAUSE_PREFIXES, PAUSE_PREFIX, applyKindSchemaOverlay, categoryAccent, clearKindSchemaOverlays, clearNodeKindOverrides, declaredRoutes, decodePause, defaultConfigFor, encodePause, ensureBuiltinKinds, getNodeKind, isPause, kindIds, listNodeKinds, llmRouterExecutor as llmBranchExecutor, llmRouterExecutor, nodeConfig, onNodeKindsChanged, overrideNodeKind, pauseForHuman, registerNodeKind, resolveFallbackPort, resolveKindId, resolveNodePorts, resolvePortSpec, subflowExecutor, subflowMode, subflowPorts, unregisterNodeKind, validateConfig } from './chunk-J5YUYDMK.js';
5
5
  export { capabilityStatus, getLlmClient, getTerminalHost, getWorkflowResolver, isResolutionFailure, registerLlmClient, registerTerminalHost, registerWorkflowResolver } from './chunk-2QXKDLGT.js';
6
6
  //# sourceMappingURL=registry.js.map
7
7
  //# sourceMappingURL=registry.js.map
@@ -1,5 +1,5 @@
1
- import { F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-B-Syk9-M.js';
2
- import { R as RunOptions, a as RunResult } from './run-flow-BLP9rXfO.js';
1
+ import { F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-E48Dpesq.js';
2
+ import { R as RunOptions, a as RunResult } from './run-flow-D2iOjWsj.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-B-Syk9-M.cjs';
2
- import { R as RunOptions, a as RunResult } from './run-flow-pW0PllaZ.cjs';
1
+ import { F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-E48Dpesq.cjs';
2
+ import { R as RunOptions, a as RunResult } from './run-flow-Bdrn4lQV.cjs';
3
3
 
4
4
  /**
5
5
  * How the flows one trigger fired should treat each other.
@@ -1,4 +1,4 @@
1
- import { c as RunIdentity, d as RunIdentityJson, N as NodeExecutor, F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-B-Syk9-M.cjs';
1
+ import { c as RunIdentity, d as RunIdentityJson, N as NodeExecutor, F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-E48Dpesq.cjs';
2
2
 
3
3
  type RunOptions = {
4
4
  /** Stop the run after this many ms. Default: no timeout. */
@@ -1,4 +1,4 @@
1
- import { c as RunIdentity, d as RunIdentityJson, N as NodeExecutor, F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-B-Syk9-M.js';
1
+ import { c as RunIdentity, d as RunIdentityJson, N as NodeExecutor, F as FlowGraph, E as ExecutorRegistry, R as RunEvent } from './types-E48Dpesq.js';
2
2
 
3
3
  type RunOptions = {
4
4
  /** Stop the run after this many ms. Default: no timeout. */
@@ -1,8 +1,8 @@
1
- import { a as RunResult, R as RunOptions } from '../run-flow-pW0PllaZ.cjs';
2
- export { r as runFlow } from '../run-flow-pW0PllaZ.cjs';
3
- import { h as NodeRunStatus, F as FlowGraph, E as ExecutorRegistry, a as FlowNode, e as FlowEdge } from '../types-B-Syk9-M.cjs';
4
- export { c as RunIdentity, d as RunIdentityJson, k as escapeSegment } from '../types-B-Syk9-M.cjs';
5
- export { C as CohortGuard, a as CohortOptions, b as CohortPolicy, c as CohortResult, r as runCohort } from '../run-cohort-DNpPa0mq.cjs';
1
+ import { a as RunResult, R as RunOptions } from '../run-flow-Bdrn4lQV.cjs';
2
+ export { r as runFlow } from '../run-flow-Bdrn4lQV.cjs';
3
+ import { h as NodeRunStatus, F as FlowGraph, E as ExecutorRegistry, a as FlowNode, e as FlowEdge } from '../types-E48Dpesq.cjs';
4
+ export { c as RunIdentity, d as RunIdentityJson, k as escapeSegment } from '../types-E48Dpesq.cjs';
5
+ export { C as CohortGuard, a as CohortOptions, b as CohortPolicy, c as CohortResult, r as runCohort } from '../run-cohort-DRJvUWO9.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-BLP9rXfO.js';
2
- export { r as runFlow } from '../run-flow-BLP9rXfO.js';
3
- import { h as NodeRunStatus, F as FlowGraph, E as ExecutorRegistry, a as FlowNode, e as FlowEdge } from '../types-B-Syk9-M.js';
4
- export { c as RunIdentity, d as RunIdentityJson, k as escapeSegment } from '../types-B-Syk9-M.js';
5
- export { C as CohortGuard, a as CohortOptions, b as CohortPolicy, c as CohortResult, r as runCohort } from '../run-cohort-rgT_FX3V.js';
1
+ import { a as RunResult, R as RunOptions } from '../run-flow-D2iOjWsj.js';
2
+ export { r as runFlow } from '../run-flow-D2iOjWsj.js';
3
+ import { h as NodeRunStatus, F as FlowGraph, E as ExecutorRegistry, a as FlowNode, e as FlowEdge } from '../types-E48Dpesq.js';
4
+ export { c as RunIdentity, d as RunIdentityJson, k as escapeSegment } from '../types-E48Dpesq.js';
5
+ export { C as CohortGuard, a as CohortOptions, b as CohortPolicy, c as CohortResult, r as runCohort } from '../run-cohort-DAfhZm-p.js';
6
6
  import { NodeChange, EdgeChange, Connection } from '@xyflow/react';
7
7
 
8
8
  type FlowRunFeedEntry = {
package/dist/runtime.cjs CHANGED
@@ -469,14 +469,102 @@ var mergeExecutor = (ctx) => {
469
469
  }
470
470
  return merged;
471
471
  };
472
- var forEachExecutor = (ctx) => {
473
- const source = resolve(configOf(ctx.node).source, ctx.inputs);
472
+ var FOR_EACH_DEFAULT_MAX_ITEMS = 1e3;
473
+ var FOR_EACH_HARD_MAX_ITEMS = 1e4;
474
+ function reachable(adjacency, starts) {
475
+ const seen = /* @__PURE__ */ new Set();
476
+ const queue = [...starts];
477
+ for (let cursor = 0; cursor < queue.length; cursor += 1) {
478
+ const id2 = queue[cursor];
479
+ if (seen.has(id2)) continue;
480
+ seen.add(id2);
481
+ for (const target of adjacency.get(id2) ?? []) queue.push(target);
482
+ }
483
+ return seen;
484
+ }
485
+ function forEachLane(graph, nodeId) {
486
+ const handleOf = (edge) => edge.sourceHandle ?? "out";
487
+ const itemEdges = graph.edges.filter((e) => e.source === nodeId && handleOf(e) === "item");
488
+ if (itemEdges.length === 0) return null;
489
+ const adjacency = /* @__PURE__ */ new Map();
490
+ for (const edge of graph.edges) {
491
+ const list = adjacency.get(edge.source) ?? [];
492
+ list.push(edge.target);
493
+ adjacency.set(edge.source, list);
494
+ }
495
+ const done = reachable(
496
+ adjacency,
497
+ graph.edges.filter((e) => e.source === nodeId && handleOf(e) === "done").map((e) => e.target)
498
+ );
499
+ const body = new Set(
500
+ [...reachable(adjacency, itemEdges.map((e) => e.target))].filter(
501
+ (id2) => !done.has(id2) && id2 !== nodeId
502
+ )
503
+ );
504
+ return {
505
+ graph: {
506
+ nodes: graph.nodes.filter((n) => body.has(n.id)),
507
+ edges: graph.edges.filter((e) => body.has(e.source) && body.has(e.target)),
508
+ ...graph.inputs === void 0 ? {} : { inputs: graph.inputs }
509
+ },
510
+ entries: itemEdges.filter((e) => body.has(e.target))
511
+ };
512
+ }
513
+ var forEachExecutor = async (ctx) => {
514
+ const config = configOf(ctx.node);
515
+ const source = resolve(config.source, ctx.inputs);
474
516
  let items;
475
517
  if (Array.isArray(source)) items = source;
476
518
  else if (source === null || source === void 0) items = [];
477
519
  else if (typeof source === "object") items = Object.values(source);
478
520
  else items = [source];
479
- return { items, count: items.length };
521
+ const lane = ctx.graph ? forEachLane(ctx.graph, ctx.node.id) : null;
522
+ if (lane === null || config.mode === "collect") {
523
+ return { items, count: items.length };
524
+ }
525
+ if (lane.graph.nodes.length === 0) {
526
+ ctx.abort(`for_each "${ctx.node.id}" has an item edge but its derived lane is empty`);
527
+ }
528
+ const maxItems = Number(config.maxItems ?? FOR_EACH_DEFAULT_MAX_ITEMS);
529
+ if (!Number.isFinite(maxItems) || maxItems < 1 || maxItems > FOR_EACH_HARD_MAX_ITEMS) {
530
+ ctx.abort(`for_each "${ctx.node.id}" maxItems must be between 1 and ${FOR_EACH_HARD_MAX_ITEMS}`);
531
+ }
532
+ if (items.length > maxItems) {
533
+ ctx.abort(
534
+ `for_each "${ctx.node.id}" resolved ${items.length} items exceeds its maxItems cap of ${maxItems}`
535
+ );
536
+ }
537
+ const results = [];
538
+ const failures = [];
539
+ for (const [index2, item] of items.entries()) {
540
+ const initialInputs = {};
541
+ for (const edge of lane.entries) {
542
+ initialInputs[edge.target] = {
543
+ ...initialInputs[edge.target] ?? {},
544
+ [edge.targetHandle ?? "in"]: item
545
+ };
546
+ }
547
+ const nested = await runFlow(lane.graph, { ...ctx.executors ?? {} }, () => {
548
+ }, {
549
+ initialInputs,
550
+ depth: (ctx.depth ?? 0) + 1,
551
+ // The index rides on the identity, so a node in iteration 3 cannot share
552
+ // an idempotency key with the same node in iteration 4.
553
+ run: ctx.run?.descend(ctx.node.id, index2)
554
+ });
555
+ if (!nested.ok) {
556
+ const reason = nested.error ?? "unknown error";
557
+ if (decodePause(reason)) ctx.abort(reason);
558
+ results.push(null);
559
+ failures.push({ index: index2, item, error: reason });
560
+ continue;
561
+ }
562
+ results.push(nested.outputs);
563
+ }
564
+ return {
565
+ __port: "done",
566
+ value: { items, results, failures, count: items.length }
567
+ };
480
568
  };
481
569
  var manualTriggerExecutor = (ctx) => ctx.inputs;
482
570
  var outputExecutor = (ctx) => {
@@ -1033,6 +1121,15 @@ var KINDS = [
1033
1121
  name: "@particle-academy/for_each",
1034
1122
  outputShape: [
1035
1123
  { path: "items", type: "array" },
1124
+ // `results` and `failures` are the WIRED shape -- what a lane produces
1125
+ // when the `item` port is connected. Declared unconditionally because a
1126
+ // declaration describes the kind, not one graph's use of it, and because
1127
+ // the shared table requires them: fancy-conformance 0.30.0 added
1128
+ // `results` and 0.31.0 added `failures`, both BREAKING, both so that a
1129
+ // runtime which has not implemented iteration fails here rather than
1130
+ // reporting surface parity it does not have.
1131
+ { path: "results", type: "array" },
1132
+ { path: "failures", type: "array" },
1036
1133
  { path: "count", type: "number" }
1037
1134
  ],
1038
1135
  aliases: ["for_each", "@fancy/for_each"],
@@ -1041,7 +1138,7 @@ var KINDS = [
1041
1138
  executor: forEachExecutor,
1042
1139
  category: "logic",
1043
1140
  label: "For Each",
1044
- description: "Publishes the resolved list and its size on BOTH `item` and `done`. Fan-out as DATA, not as jobs -- nothing runs per item.",
1141
+ description: "Wire `item` to a lane and it runs once per item, aggregating `results` and `failures` on `done`. Leave `item` unwired (or set `mode: collect`) and it just publishes the list and its size -- one node, one checkpoint.",
1045
1142
  icon: "\u21BB",
1046
1143
  inputs: [{ id: "in" }],
1047
1144
  outputs: [{ id: "item", label: "item" }, { id: "done", label: "done" }],
@@ -2444,6 +2541,9 @@ async function runFlow(graph, executors, onEvent = () => {
2444
2541
  executors,
2445
2542
  depth,
2446
2543
  run,
2544
+ // Structural executors derive a nested lane from the graph they are
2545
+ // in; `for_each`'s `item` port cannot be implemented without it.
2546
+ graph,
2447
2547
  terminal: terminalAccessorFor(node)
2448
2548
  })
2449
2549
  );