@foresthubai/workflow-builder 0.4.3 → 0.4.4

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 (120) hide show
  1. package/LICENSE +661 -661
  2. package/NOTICE +16 -16
  3. package/README.md +110 -110
  4. package/dist/components/ui/command.d.ts +2 -2
  5. package/dist/components/ui/input.d.ts +1 -1
  6. package/dist/components/ui/resizable.d.ts +1 -1
  7. package/dist/components/ui/textarea.d.ts +1 -1
  8. package/dist/graph/BaseNode.js +10 -10
  9. package/dist/graph/reactFlowRegistry.d.ts.map +1 -1
  10. package/package.json +2 -2
  11. package/src/BuilderLayout.tsx +345 -345
  12. package/src/Canvas.tsx +261 -261
  13. package/src/CanvasEditor.tsx +142 -142
  14. package/src/CanvasTabsToolbar.tsx +176 -176
  15. package/src/RightConfigPanel.tsx +266 -266
  16. package/src/WorkflowBuilder.tsx +408 -408
  17. package/src/cn.ts +6 -6
  18. package/src/components/ui/add-button.tsx +39 -39
  19. package/src/components/ui/alert-dialog.tsx +141 -141
  20. package/src/components/ui/alert.tsx +59 -59
  21. package/src/components/ui/badge.tsx +36 -36
  22. package/src/components/ui/button.tsx +85 -85
  23. package/src/components/ui/card.tsx +79 -79
  24. package/src/components/ui/checkbox.tsx +28 -28
  25. package/src/components/ui/collapsible.tsx +9 -9
  26. package/src/components/ui/command.tsx +153 -153
  27. package/src/components/ui/delete-button.tsx +23 -23
  28. package/src/components/ui/dialog.tsx +125 -125
  29. package/src/components/ui/dropdown-menu.tsx +198 -198
  30. package/src/components/ui/input.tsx +55 -55
  31. package/src/components/ui/label.tsx +24 -24
  32. package/src/components/ui/readonly-banner.tsx +15 -15
  33. package/src/components/ui/resizable.tsx +43 -43
  34. package/src/components/ui/scroll-area.tsx +102 -102
  35. package/src/components/ui/select.tsx +160 -160
  36. package/src/components/ui/separator.tsx +29 -29
  37. package/src/components/ui/switch.tsx +27 -27
  38. package/src/components/ui/textarea.tsx +51 -51
  39. package/src/components/ui/toast.tsx +127 -127
  40. package/src/components/ui/toaster.tsx +33 -33
  41. package/src/components/ui/toggle-group.tsx +59 -59
  42. package/src/components/ui/toggle.tsx +43 -43
  43. package/src/components/ui/tooltip.tsx +32 -32
  44. package/src/dialogs/NodePickerDialog.tsx +84 -84
  45. package/src/dialogs/ValidationDialog.tsx +184 -184
  46. package/src/graph/BaseNode.tsx +557 -557
  47. package/src/graph/CustomEdge.tsx +185 -185
  48. package/src/graph/CustomNode.tsx +16 -16
  49. package/src/graph/FunctionCallNode.tsx +30 -30
  50. package/src/graph/PortHandle.tsx +189 -189
  51. package/src/graph/reactFlowRegistry.ts +26 -26
  52. package/src/hooks/use-toast.ts +125 -125
  53. package/src/hooks/useAvailableVariables.ts +20 -20
  54. package/src/hooks/useCanvasHistory.ts +22 -22
  55. package/src/hooks/useCanvasTabs.ts +168 -168
  56. package/src/hooks/useFunctionDiagnosticsSync.ts +40 -40
  57. package/src/hooks/useFunctionRegistry.ts +26 -26
  58. package/src/hooks/useFunctions.ts +44 -44
  59. package/src/hooks/useGraph.ts +161 -161
  60. package/src/hooks/useNodeDefinitions.ts +82 -82
  61. package/src/hooks/useParamErrors.ts +26 -26
  62. package/src/hooks/useResolvedTheme.ts +30 -30
  63. package/src/hooks/useResourceDiagnosticsSync.ts +58 -58
  64. package/src/hooks/useSuppressThemeTransition.ts +79 -79
  65. package/src/hooks/useWorkflowSerialization.ts +141 -141
  66. package/src/i18n/index.ts +53 -53
  67. package/src/i18n/locales/de.json +501 -501
  68. package/src/i18n/locales/en.json +557 -557
  69. package/src/index.ts +27 -27
  70. package/src/inputs/ExpressionInput.tsx +297 -297
  71. package/src/inputs/ParameterEditor.tsx +515 -515
  72. package/src/inputs/PortSection.tsx +144 -144
  73. package/src/panels/BuilderSidebar.tsx +301 -301
  74. package/src/panels/ChannelConfigPanel.tsx +49 -49
  75. package/src/panels/ChannelsPanel.tsx +28 -28
  76. package/src/panels/DebugConsolePanel.tsx +73 -73
  77. package/src/panels/DebugContextPanel.tsx +77 -77
  78. package/src/panels/DebugExternalIOPanel.tsx +180 -180
  79. package/src/panels/DiagnosticsPanel.tsx +170 -170
  80. package/src/panels/EdgeConfigPanel.tsx +104 -104
  81. package/src/panels/FunctionConfigPanel.tsx +179 -179
  82. package/src/panels/FunctionListPanel.tsx +45 -45
  83. package/src/panels/MemoryConfigPanel.tsx +55 -55
  84. package/src/panels/MemoryPanel.tsx +40 -40
  85. package/src/panels/ModelConfigPanel.tsx +41 -41
  86. package/src/panels/ModelsPanel.tsx +36 -36
  87. package/src/panels/NodeConfigPanel.tsx +630 -630
  88. package/src/panels/NodeLibrary.tsx +288 -288
  89. package/src/panels/ResourceConfigPanel.tsx +132 -132
  90. package/src/panels/ResourceListPanel.tsx +113 -113
  91. package/src/panels/VariableConfigPanel.tsx +161 -161
  92. package/src/panels/VariablesPanel.tsx +145 -145
  93. package/src/stores/canvasStore.test.ts +44 -44
  94. package/src/stores/canvasStore.ts +245 -245
  95. package/src/stores/debugStore.ts +74 -74
  96. package/src/stores/diagnosticsStore.ts +130 -130
  97. package/src/stores/editorStore.ts +190 -190
  98. package/src/styles/index.css +526 -526
  99. package/src/utils/categoryConstants.ts +26 -26
  100. package/src/utils/channelOperations.ts +86 -86
  101. package/src/utils/connectionRules.ts +137 -137
  102. package/src/utils/functionOperations.ts +179 -179
  103. package/src/utils/graphOperations.ts +550 -550
  104. package/src/utils/history.ts +207 -207
  105. package/src/utils/memoryOperations.ts +57 -57
  106. package/src/utils/migrateFunctionNodes.ts +107 -107
  107. package/src/utils/modelOperations.ts +55 -55
  108. package/src/utils/paramDisplay.ts +71 -71
  109. package/src/utils/resourceHelpers.ts +32 -32
  110. package/src/utils/translation.ts +28 -28
  111. package/src/utils/variableOperations.ts +75 -75
  112. package/tailwind-preset.ts +166 -166
  113. package/dist/lib/utils.d.ts +0 -3
  114. package/dist/lib/utils.d.ts.map +0 -1
  115. package/dist/lib/utils.js +0 -6
  116. package/dist/lib/utils.js.map +0 -1
  117. package/dist/toolbars/CanvasTabsToolbar.d.ts +0 -11
  118. package/dist/toolbars/CanvasTabsToolbar.d.ts.map +0 -1
  119. package/dist/toolbars/CanvasTabsToolbar.js +0 -101
  120. package/dist/toolbars/CanvasTabsToolbar.js.map +0 -1
@@ -1,189 +1,189 @@
1
- import React from "react";
2
- import { Handle, Position } from "@xyflow/react";
3
- import { Plus } from "lucide-react";
4
- import type { EdgeType } from "@foresthubai/workflow-core/edge";
5
-
6
- export interface PortActionDetail {
7
- nodeId: string;
8
- handleId: string;
9
- portType: EdgeType;
10
- }
11
-
12
- export interface PortHandleProps {
13
- id: string;
14
- nodeId?: string;
15
- type: "source" | "target";
16
- position: Position;
17
- portType: EdgeType;
18
- label?: string;
19
- style?: React.CSSProperties;
20
- disabled?: boolean;
21
- showPlus?: boolean;
22
- }
23
-
24
- export const PortHandle = ({
25
- id,
26
- nodeId,
27
- type,
28
- position,
29
- portType,
30
- label,
31
- style,
32
- disabled,
33
- showPlus,
34
- }: PortHandleProps) => {
35
- const getHandleStyle = () => {
36
- const baseStyle: React.CSSProperties = {
37
- width: "12px",
38
- height: "12px",
39
- // Outline matches the canonical graph-line color (same as edges + node borders).
40
- border: "2px solid hsl(var(--edge-default))",
41
- };
42
-
43
- if (disabled) {
44
- return {
45
- ...baseStyle,
46
- backgroundColor: "hsl(var(--muted-foreground) / 0.3)",
47
- border: "2px solid hsl(var(--muted-foreground) / 0.4)",
48
- borderRadius: portType === "control" ? "2px" : portType === "tool" ? "2px" : "50%",
49
- opacity: 0.8,
50
- cursor: "not-allowed",
51
- ...(portType === "tool" ? { clipPath: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)" } : {}),
52
- };
53
- }
54
-
55
- switch (portType) {
56
- case "control":
57
- // Square shape for execution/control ports. Fill matches the node body
58
- // (--card) so the port reads as a recessed hole outlined in the graph color.
59
- return {
60
- ...baseStyle,
61
- backgroundColor: "hsl(var(--card))",
62
- borderRadius: "2px",
63
- };
64
- case "tool":
65
- // Diamond via clip-path so the handle stays anchored on the node edge
66
- // (rotating it would override React Flow's centering transform). A
67
- // clip-path can't show a border, so the handle background is the outline
68
- // color and an inset inner diamond (rendered as a child below) paints the
69
- // canonical tool fill (--node-tool), leaving a 2px edge-default outline.
70
- return {
71
- ...baseStyle,
72
- backgroundColor: "hsl(var(--edge-default))",
73
- border: "none",
74
- borderRadius: "0",
75
- clipPath: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)",
76
- };
77
- default:
78
- // Circle shape as fallback
79
- return {
80
- ...baseStyle,
81
- backgroundColor: "white",
82
- borderRadius: "50%",
83
- };
84
- }
85
- };
86
-
87
- const getLabelPositionClass = () => {
88
- switch (position) {
89
- case Position.Left:
90
- return "right-full mr-3 text-right";
91
- case Position.Right:
92
- return "left-full ml-3 text-left";
93
- case Position.Top:
94
- return "bottom-full mb-2 text-center left-1/2 -translate-x-1/2";
95
- case Position.Bottom:
96
- return "top-full mt-2 text-center left-1/2 -translate-x-1/2";
97
- default:
98
- return "left-full ml-3 text-left";
99
- }
100
- };
101
-
102
- const getLabelStyle = (): React.CSSProperties => {
103
- if (position === Position.Left || position === Position.Right) {
104
- return {
105
- top: "50%",
106
- transform: "translateY(calc(-50% + 12px))",
107
- };
108
- }
109
- return {};
110
- };
111
-
112
- const getPlusPositionClass = () => {
113
- // Center with a negative margin (button is w-4 h-4 = 16px, so -8px = -2),
114
- // NOT a translate. The hover effect uses `transform: scale()`, and reusing
115
- // transform for centering too makes the translate drop out mid-animation,
116
- // which both off-centers the plus and makes it jump on hover.
117
- switch (position) {
118
- case Position.Bottom:
119
- return "top-[15px] left-1/2 -ml-2";
120
- default:
121
- return "left-[15px] top-1/2 -mt-2";
122
- }
123
- };
124
-
125
- // Nudge the *visible* dot 1px toward the node interior so it sits on the
126
- // outline centerline (the SVG border is strokeW=2). The offset is on a child,
127
- // NOT the Handle — React Flow anchors edges to the Handle's measured box, so
128
- // keeping that on the node edge means edges still connect flush instead of
129
- // stopping 1px short.
130
- const dotOffset =
131
- position === Position.Top
132
- ? "translateY(1px)"
133
- : position === Position.Bottom
134
- ? "translateY(-1px)"
135
- : position === Position.Left
136
- ? "translateX(1px)"
137
- : "translateX(-1px)";
138
-
139
- return (
140
- <div className="absolute z-20" style={style}>
141
- <Handle
142
- id={id}
143
- type={type}
144
- position={position}
145
- isConnectable={!disabled}
146
- style={{ width: "12px", height: "12px", background: "transparent", border: "none", minWidth: 0, minHeight: 0 }}
147
- >
148
- <div
149
- style={{ ...getHandleStyle(), position: "absolute", inset: 0, transform: dotOffset, pointerEvents: "none" }}
150
- >
151
- {portType === "tool" && !disabled && (
152
- <div
153
- style={{
154
- position: "absolute",
155
- inset: "2px",
156
- backgroundColor: "hsl(var(--node-tool))",
157
- clipPath: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)",
158
- }}
159
- />
160
- )}
161
- </div>
162
- </Handle>
163
- {label && !disabled && (
164
- <div
165
- className={`absolute text-xs text-muted-foreground pointer-events-none select-none whitespace-nowrap ${getLabelPositionClass()}`}
166
- style={getLabelStyle()}
167
- >
168
- {label}
169
- </div>
170
- )}
171
- {showPlus && !disabled && nodeId && (
172
- <button
173
- type="button"
174
- title="Add port"
175
- className={`nodrag absolute flex items-center justify-center w-4 h-4 rounded-full bg-muted-foreground/60 text-card hover:bg-primary hover:scale-110 transition-all cursor-pointer ${getPlusPositionClass()}`}
176
- onClick={(e) => {
177
- e.stopPropagation();
178
- e.preventDefault();
179
- const detail: PortActionDetail = { nodeId, handleId: id, portType };
180
- e.currentTarget.dispatchEvent(new CustomEvent("port-plus-click", { detail, bubbles: true }));
181
- }}
182
- onPointerDown={(e) => e.stopPropagation()}
183
- >
184
- <Plus className="w-2.5 h-2.5" strokeWidth={3} />
185
- </button>
186
- )}
187
- </div>
188
- );
189
- };
1
+ import React from "react";
2
+ import { Handle, Position } from "@xyflow/react";
3
+ import { Plus } from "lucide-react";
4
+ import type { EdgeType } from "@foresthubai/workflow-core/edge";
5
+
6
+ export interface PortActionDetail {
7
+ nodeId: string;
8
+ handleId: string;
9
+ portType: EdgeType;
10
+ }
11
+
12
+ export interface PortHandleProps {
13
+ id: string;
14
+ nodeId?: string;
15
+ type: "source" | "target";
16
+ position: Position;
17
+ portType: EdgeType;
18
+ label?: string;
19
+ style?: React.CSSProperties;
20
+ disabled?: boolean;
21
+ showPlus?: boolean;
22
+ }
23
+
24
+ export const PortHandle = ({
25
+ id,
26
+ nodeId,
27
+ type,
28
+ position,
29
+ portType,
30
+ label,
31
+ style,
32
+ disabled,
33
+ showPlus,
34
+ }: PortHandleProps) => {
35
+ const getHandleStyle = () => {
36
+ const baseStyle: React.CSSProperties = {
37
+ width: "12px",
38
+ height: "12px",
39
+ // Outline matches the canonical graph-line color (same as edges + node borders).
40
+ border: "2px solid hsl(var(--edge-default))",
41
+ };
42
+
43
+ if (disabled) {
44
+ return {
45
+ ...baseStyle,
46
+ backgroundColor: "hsl(var(--muted-foreground) / 0.3)",
47
+ border: "2px solid hsl(var(--muted-foreground) / 0.4)",
48
+ borderRadius: portType === "control" ? "2px" : portType === "tool" ? "2px" : "50%",
49
+ opacity: 0.8,
50
+ cursor: "not-allowed",
51
+ ...(portType === "tool" ? { clipPath: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)" } : {}),
52
+ };
53
+ }
54
+
55
+ switch (portType) {
56
+ case "control":
57
+ // Square shape for execution/control ports. Fill matches the node body
58
+ // (--card) so the port reads as a recessed hole outlined in the graph color.
59
+ return {
60
+ ...baseStyle,
61
+ backgroundColor: "hsl(var(--card))",
62
+ borderRadius: "2px",
63
+ };
64
+ case "tool":
65
+ // Diamond via clip-path so the handle stays anchored on the node edge
66
+ // (rotating it would override React Flow's centering transform). A
67
+ // clip-path can't show a border, so the handle background is the outline
68
+ // color and an inset inner diamond (rendered as a child below) paints the
69
+ // canonical tool fill (--node-tool), leaving a 2px edge-default outline.
70
+ return {
71
+ ...baseStyle,
72
+ backgroundColor: "hsl(var(--edge-default))",
73
+ border: "none",
74
+ borderRadius: "0",
75
+ clipPath: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)",
76
+ };
77
+ default:
78
+ // Circle shape as fallback
79
+ return {
80
+ ...baseStyle,
81
+ backgroundColor: "white",
82
+ borderRadius: "50%",
83
+ };
84
+ }
85
+ };
86
+
87
+ const getLabelPositionClass = () => {
88
+ switch (position) {
89
+ case Position.Left:
90
+ return "right-full mr-3 text-right";
91
+ case Position.Right:
92
+ return "left-full ml-3 text-left";
93
+ case Position.Top:
94
+ return "bottom-full mb-2 text-center left-1/2 -translate-x-1/2";
95
+ case Position.Bottom:
96
+ return "top-full mt-2 text-center left-1/2 -translate-x-1/2";
97
+ default:
98
+ return "left-full ml-3 text-left";
99
+ }
100
+ };
101
+
102
+ const getLabelStyle = (): React.CSSProperties => {
103
+ if (position === Position.Left || position === Position.Right) {
104
+ return {
105
+ top: "50%",
106
+ transform: "translateY(calc(-50% + 12px))",
107
+ };
108
+ }
109
+ return {};
110
+ };
111
+
112
+ const getPlusPositionClass = () => {
113
+ // Center with a negative margin (button is w-4 h-4 = 16px, so -8px = -2),
114
+ // NOT a translate. The hover effect uses `transform: scale()`, and reusing
115
+ // transform for centering too makes the translate drop out mid-animation,
116
+ // which both off-centers the plus and makes it jump on hover.
117
+ switch (position) {
118
+ case Position.Bottom:
119
+ return "top-[15px] left-1/2 -ml-2";
120
+ default:
121
+ return "left-[15px] top-1/2 -mt-2";
122
+ }
123
+ };
124
+
125
+ // Nudge the *visible* dot 1px toward the node interior so it sits on the
126
+ // outline centerline (the SVG border is strokeW=2). The offset is on a child,
127
+ // NOT the Handle — React Flow anchors edges to the Handle's measured box, so
128
+ // keeping that on the node edge means edges still connect flush instead of
129
+ // stopping 1px short.
130
+ const dotOffset =
131
+ position === Position.Top
132
+ ? "translateY(1px)"
133
+ : position === Position.Bottom
134
+ ? "translateY(-1px)"
135
+ : position === Position.Left
136
+ ? "translateX(1px)"
137
+ : "translateX(-1px)";
138
+
139
+ return (
140
+ <div className="absolute z-20" style={style}>
141
+ <Handle
142
+ id={id}
143
+ type={type}
144
+ position={position}
145
+ isConnectable={!disabled}
146
+ style={{ width: "12px", height: "12px", background: "transparent", border: "none", minWidth: 0, minHeight: 0 }}
147
+ >
148
+ <div
149
+ style={{ ...getHandleStyle(), position: "absolute", inset: 0, transform: dotOffset, pointerEvents: "none" }}
150
+ >
151
+ {portType === "tool" && !disabled && (
152
+ <div
153
+ style={{
154
+ position: "absolute",
155
+ inset: "2px",
156
+ backgroundColor: "hsl(var(--node-tool))",
157
+ clipPath: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)",
158
+ }}
159
+ />
160
+ )}
161
+ </div>
162
+ </Handle>
163
+ {label && !disabled && (
164
+ <div
165
+ className={`absolute text-xs text-muted-foreground pointer-events-none select-none whitespace-nowrap ${getLabelPositionClass()}`}
166
+ style={getLabelStyle()}
167
+ >
168
+ {label}
169
+ </div>
170
+ )}
171
+ {showPlus && !disabled && nodeId && (
172
+ <button
173
+ type="button"
174
+ title="Add port"
175
+ className={`nodrag absolute flex items-center justify-center w-4 h-4 rounded-full bg-muted-foreground/60 text-card hover:bg-primary hover:scale-110 transition-all cursor-pointer ${getPlusPositionClass()}`}
176
+ onClick={(e) => {
177
+ e.stopPropagation();
178
+ e.preventDefault();
179
+ const detail: PortActionDetail = { nodeId, handleId: id, portType };
180
+ e.currentTarget.dispatchEvent(new CustomEvent("port-plus-click", { detail, bubbles: true }));
181
+ }}
182
+ onPointerDown={(e) => e.stopPropagation()}
183
+ >
184
+ <Plus className="w-2.5 h-2.5" strokeWidth={3} />
185
+ </button>
186
+ )}
187
+ </div>
188
+ );
189
+ };
@@ -1,26 +1,26 @@
1
- // ReactFlow node/edge type registries
2
- // Maps ReactFlow type strings to the React components that render them.
3
- // Shared between CanvasArea (editor) and VersionPreviewCanvas (read-only preview).
4
- // Lives in graph/ because it references sibling components, but is only consumed
5
- // by higher-level composing components — no graph/ component imports this file.
6
-
7
- import { NodeCategory } from "@foresthubai/workflow-core/node";
8
- import { CustomNode } from "./CustomNode";
9
- import { FunctionCallNode } from "./FunctionCallNode";
10
- import CustomEdge from "./CustomEdge";
11
-
12
- export const nodeTypes = {
13
- Standard: CustomNode,
14
- FunctionCall: FunctionCallNode,
15
- [NodeCategory.Trigger]: CustomNode,
16
- [NodeCategory.Tool]: CustomNode,
17
- [NodeCategory.AI]: CustomNode,
18
- };
19
-
20
- export const edgeTypes = {
21
- control: CustomEdge,
22
- tool: CustomEdge,
23
- agentTask: CustomEdge,
24
- agentChoice: CustomEdge,
25
- agentDelegate: CustomEdge,
26
- };
1
+ // ReactFlow node/edge type registries
2
+ // Maps ReactFlow type strings to the React components that render them.
3
+ // Shared between CanvasArea (editor) and VersionPreviewCanvas (read-only preview).
4
+ // Lives in graph/ because it references sibling components, but is only consumed
5
+ // by higher-level composing components — no graph/ component imports this file.
6
+
7
+ import { NodeCategory } from "@foresthubai/workflow-core/node";
8
+ import { CustomNode } from "./CustomNode";
9
+ import { FunctionCallNode } from "./FunctionCallNode";
10
+ import CustomEdge from "./CustomEdge";
11
+
12
+ export const nodeTypes = {
13
+ Standard: CustomNode,
14
+ FunctionCall: FunctionCallNode,
15
+ [NodeCategory.Trigger]: CustomNode,
16
+ [NodeCategory.Tool]: CustomNode,
17
+ [NodeCategory.AI]: CustomNode,
18
+ };
19
+
20
+ export const edgeTypes = {
21
+ control: CustomEdge,
22
+ tool: CustomEdge,
23
+ agentTask: CustomEdge,
24
+ agentChoice: CustomEdge,
25
+ agentDelegate: CustomEdge,
26
+ };