@particle-academy/fancy-flow 0.75.0 → 0.77.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 (46) hide show
  1. package/dist/{chunk-2H5H2DDP.js → chunk-44VXYZ4M.js} +4 -4
  2. package/dist/{chunk-2H5H2DDP.js.map → chunk-44VXYZ4M.js.map} +1 -1
  3. package/dist/{chunk-4BPCA3ZO.js → chunk-66JAEWPP.js} +3 -3
  4. package/dist/{chunk-4BPCA3ZO.js.map → chunk-66JAEWPP.js.map} +1 -1
  5. package/dist/{chunk-LKEDPVR3.js → chunk-KFC3BURT.js} +3 -3
  6. package/dist/{chunk-LKEDPVR3.js.map → chunk-KFC3BURT.js.map} +1 -1
  7. package/dist/{chunk-XZFLPKO2.js → chunk-MMCHYY6B.js} +3 -3
  8. package/dist/{chunk-XZFLPKO2.js.map → chunk-MMCHYY6B.js.map} +1 -1
  9. package/dist/{chunk-T7E7QPHI.js → chunk-OOQ2MMBE.js} +4 -4
  10. package/dist/{chunk-T7E7QPHI.js.map → chunk-OOQ2MMBE.js.map} +1 -1
  11. package/dist/{chunk-ZBHIEKCN.js → chunk-X2UHP2S5.js} +3 -3
  12. package/dist/{chunk-ZBHIEKCN.js.map → chunk-X2UHP2S5.js.map} +1 -1
  13. package/dist/{chunk-W7DMO3H7.js → chunk-YNKOEQLI.js} +48 -7
  14. package/dist/chunk-YNKOEQLI.js.map +1 -0
  15. package/dist/durable.cjs +42 -37
  16. package/dist/durable.cjs.map +1 -1
  17. package/dist/durable.js +1 -2
  18. package/dist/durable.js.map +1 -1
  19. package/dist/engine.cjs +45 -40
  20. package/dist/engine.cjs.map +1 -1
  21. package/dist/engine.js +4 -6
  22. package/dist/engine.js.map +1 -1
  23. package/dist/index.cjs +45 -40
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.js +12 -13
  26. package/dist/index.js.map +1 -1
  27. package/dist/registry.cjs +45 -40
  28. package/dist/registry.cjs.map +1 -1
  29. package/dist/registry.js +2 -3
  30. package/dist/runtime.cjs +35 -4
  31. package/dist/runtime.cjs.map +1 -1
  32. package/dist/runtime.js +3 -3
  33. package/dist/schema.cjs +35 -4
  34. package/dist/schema.cjs.map +1 -1
  35. package/dist/schema.js +3 -3
  36. package/dist/screens.cjs +35 -4
  37. package/dist/screens.cjs.map +1 -1
  38. package/dist/screens.js +4 -5
  39. package/dist/screens.js.map +1 -1
  40. package/dist/ux.cjs +35 -4
  41. package/dist/ux.cjs.map +1 -1
  42. package/dist/ux.js +1 -1
  43. package/package.json +2 -2
  44. package/dist/chunk-UEOE6B52.js +0 -39
  45. package/dist/chunk-UEOE6B52.js.map +0 -1
  46. package/dist/chunk-W7DMO3H7.js.map +0 -1
package/dist/registry.cjs CHANGED
@@ -583,8 +583,9 @@ function possiblePortIds(node) {
583
583
  if (!kind) return ["out"];
584
584
  const config = nodeConfig(node);
585
585
  const representative = typeof kind.outputs === "function" && !configDeclaresPorts(kind.name, config);
586
- const ids = (resolvePortSpec(kind.outputs, representative ? defaultConfigFor(kind) : config) ?? []).map((p) => p.id);
587
- return ids.length > 0 ? ids : ["out"];
586
+ const resolved = resolvePortSpec(kind.outputs, representative ? defaultConfigFor(kind) : config);
587
+ if (resolved === void 0) return ["out"];
588
+ return resolved.map((p) => p.id);
588
589
  }
589
590
  function configDeclaresPorts(kindName, config) {
590
591
  const bare = kindName.startsWith("@") ? kindName.slice(kindName.lastIndexOf("/") + 1) : kindName;
@@ -910,7 +911,7 @@ function activatedPorts(node, result) {
910
911
  }
911
912
  const kind = getNodeKind(node.data?.kind ?? node.type ?? "") ?? void 0;
912
913
  const declared = resolveNodePorts(node, kind).outputs?.map((p) => p.id);
913
- return { ports: declared?.length ? declared : ["out"], value: result };
914
+ return { ports: declared ?? ["out"], value: result };
914
915
  }
915
916
  function portValueOf(activated, portId) {
916
917
  return activated.values && Object.prototype.hasOwnProperty.call(activated.values, portId) ? activated.values[portId] : activated.value;
@@ -924,6 +925,42 @@ function announce(onEvent, node, phase) {
924
925
  onEvent({ type: "node-message", nodeId: node.id, phase, message });
925
926
  }
926
927
 
928
+ // src/registry/pause.ts
929
+ var PAUSE_PREFIX = "fancy-flow:pause:";
930
+ var LEGACY_PAUSE_PREFIXES = [
931
+ ["awaiting-approval:", "approval"],
932
+ ["awaiting-input:", "input"]
933
+ ];
934
+ function encodePause(signal) {
935
+ const { nodeId, awaiting, detail } = signal;
936
+ return PAUSE_PREFIX + JSON.stringify(detail === void 0 ? { nodeId, awaiting } : { nodeId, awaiting, detail });
937
+ }
938
+ function decodePause(reason) {
939
+ if (typeof reason !== "string") return null;
940
+ if (reason.startsWith(PAUSE_PREFIX)) {
941
+ const body = reason.slice(PAUSE_PREFIX.length);
942
+ try {
943
+ const parsed = JSON.parse(body);
944
+ if (typeof parsed?.nodeId !== "string" || typeof parsed?.awaiting !== "string") return null;
945
+ return "detail" in parsed ? { nodeId: parsed.nodeId, awaiting: parsed.awaiting, detail: parsed.detail } : { nodeId: parsed.nodeId, awaiting: parsed.awaiting };
946
+ } catch {
947
+ return null;
948
+ }
949
+ }
950
+ for (const [prefix, awaiting] of LEGACY_PAUSE_PREFIXES) {
951
+ if (reason.startsWith(prefix)) {
952
+ return { nodeId: reason.slice(prefix.length), awaiting };
953
+ }
954
+ }
955
+ return null;
956
+ }
957
+ function isPause(reason) {
958
+ return decodePause(reason) !== null;
959
+ }
960
+ function pauseForHuman(ctx, awaiting, detail) {
961
+ return ctx.abort(encodePause({ nodeId: ctx.node.id, awaiting, detail }));
962
+ }
963
+
927
964
  // src/registry/subflow.ts
928
965
  var DEFAULT_MAX_DEPTH = 8;
929
966
  function subflowMode(config) {
@@ -1005,7 +1042,11 @@ var subflowExecutor = async (ctx) => {
1005
1042
  }
1006
1043
  );
1007
1044
  if (!result.ok) {
1008
- ctx.abort(`subflow "${ref}" failed: ${result.error ?? "unknown error"}`);
1045
+ const reason = result.error ?? "unknown error";
1046
+ if (decodePause(reason)) {
1047
+ ctx.abort(reason);
1048
+ }
1049
+ ctx.abort(`subflow "${ref}" failed: ${reason}`);
1009
1050
  }
1010
1051
  if (mode === "stream") {
1011
1052
  return { __port: "stream", value: result.outputs };
@@ -2850,42 +2891,6 @@ function createConnectionValidator(getNodes, options = {}) {
2850
2891
  return compatible(outPort, inPort);
2851
2892
  };
2852
2893
  }
2853
-
2854
- // src/registry/pause.ts
2855
- var PAUSE_PREFIX = "fancy-flow:pause:";
2856
- var LEGACY_PAUSE_PREFIXES = [
2857
- ["awaiting-approval:", "approval"],
2858
- ["awaiting-input:", "input"]
2859
- ];
2860
- function encodePause(signal) {
2861
- const { nodeId, awaiting, detail } = signal;
2862
- return PAUSE_PREFIX + JSON.stringify(detail === void 0 ? { nodeId, awaiting } : { nodeId, awaiting, detail });
2863
- }
2864
- function decodePause(reason) {
2865
- if (typeof reason !== "string") return null;
2866
- if (reason.startsWith(PAUSE_PREFIX)) {
2867
- const body = reason.slice(PAUSE_PREFIX.length);
2868
- try {
2869
- const parsed = JSON.parse(body);
2870
- if (typeof parsed?.nodeId !== "string" || typeof parsed?.awaiting !== "string") return null;
2871
- return "detail" in parsed ? { nodeId: parsed.nodeId, awaiting: parsed.awaiting, detail: parsed.detail } : { nodeId: parsed.nodeId, awaiting: parsed.awaiting };
2872
- } catch {
2873
- return null;
2874
- }
2875
- }
2876
- for (const [prefix, awaiting] of LEGACY_PAUSE_PREFIXES) {
2877
- if (reason.startsWith(prefix)) {
2878
- return { nodeId: reason.slice(prefix.length), awaiting };
2879
- }
2880
- }
2881
- return null;
2882
- }
2883
- function isPause(reason) {
2884
- return decodePause(reason) !== null;
2885
- }
2886
- function pauseForHuman(ctx, awaiting, detail) {
2887
- return ctx.abort(encodePause({ nodeId: ctx.node.id, awaiting, detail }));
2888
- }
2889
2894
  var adapter = null;
2890
2895
  var listeners2 = /* @__PURE__ */ new Set();
2891
2896
  function registerRichInputAdapter(next) {