@foresthubai/workflow-builder 0.4.2 → 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 (123) 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/dist/hooks/useWorkflowSerialization.d.ts.map +1 -1
  11. package/dist/hooks/useWorkflowSerialization.js +8 -11
  12. package/dist/hooks/useWorkflowSerialization.js.map +1 -1
  13. package/package.json +2 -2
  14. package/src/BuilderLayout.tsx +345 -345
  15. package/src/Canvas.tsx +261 -261
  16. package/src/CanvasEditor.tsx +142 -142
  17. package/src/CanvasTabsToolbar.tsx +176 -176
  18. package/src/RightConfigPanel.tsx +266 -266
  19. package/src/WorkflowBuilder.tsx +408 -408
  20. package/src/cn.ts +6 -6
  21. package/src/components/ui/add-button.tsx +39 -39
  22. package/src/components/ui/alert-dialog.tsx +141 -141
  23. package/src/components/ui/alert.tsx +59 -59
  24. package/src/components/ui/badge.tsx +36 -36
  25. package/src/components/ui/button.tsx +85 -85
  26. package/src/components/ui/card.tsx +79 -79
  27. package/src/components/ui/checkbox.tsx +28 -28
  28. package/src/components/ui/collapsible.tsx +9 -9
  29. package/src/components/ui/command.tsx +153 -153
  30. package/src/components/ui/delete-button.tsx +23 -23
  31. package/src/components/ui/dialog.tsx +125 -125
  32. package/src/components/ui/dropdown-menu.tsx +198 -198
  33. package/src/components/ui/input.tsx +55 -55
  34. package/src/components/ui/label.tsx +24 -24
  35. package/src/components/ui/readonly-banner.tsx +15 -15
  36. package/src/components/ui/resizable.tsx +43 -43
  37. package/src/components/ui/scroll-area.tsx +102 -102
  38. package/src/components/ui/select.tsx +160 -160
  39. package/src/components/ui/separator.tsx +29 -29
  40. package/src/components/ui/switch.tsx +27 -27
  41. package/src/components/ui/textarea.tsx +51 -51
  42. package/src/components/ui/toast.tsx +127 -127
  43. package/src/components/ui/toaster.tsx +33 -33
  44. package/src/components/ui/toggle-group.tsx +59 -59
  45. package/src/components/ui/toggle.tsx +43 -43
  46. package/src/components/ui/tooltip.tsx +32 -32
  47. package/src/dialogs/NodePickerDialog.tsx +84 -84
  48. package/src/dialogs/ValidationDialog.tsx +184 -184
  49. package/src/graph/BaseNode.tsx +557 -557
  50. package/src/graph/CustomEdge.tsx +185 -185
  51. package/src/graph/CustomNode.tsx +16 -16
  52. package/src/graph/FunctionCallNode.tsx +30 -30
  53. package/src/graph/PortHandle.tsx +189 -189
  54. package/src/graph/reactFlowRegistry.ts +26 -26
  55. package/src/hooks/use-toast.ts +125 -125
  56. package/src/hooks/useAvailableVariables.ts +20 -20
  57. package/src/hooks/useCanvasHistory.ts +22 -22
  58. package/src/hooks/useCanvasTabs.ts +168 -168
  59. package/src/hooks/useFunctionDiagnosticsSync.ts +40 -40
  60. package/src/hooks/useFunctionRegistry.ts +26 -26
  61. package/src/hooks/useFunctions.ts +44 -44
  62. package/src/hooks/useGraph.ts +161 -161
  63. package/src/hooks/useNodeDefinitions.ts +82 -82
  64. package/src/hooks/useParamErrors.ts +26 -26
  65. package/src/hooks/useResolvedTheme.ts +30 -30
  66. package/src/hooks/useResourceDiagnosticsSync.ts +58 -58
  67. package/src/hooks/useSuppressThemeTransition.ts +79 -79
  68. package/src/hooks/useWorkflowSerialization.ts +141 -144
  69. package/src/i18n/index.ts +53 -53
  70. package/src/i18n/locales/de.json +501 -501
  71. package/src/i18n/locales/en.json +557 -557
  72. package/src/index.ts +27 -27
  73. package/src/inputs/ExpressionInput.tsx +297 -297
  74. package/src/inputs/ParameterEditor.tsx +515 -515
  75. package/src/inputs/PortSection.tsx +144 -144
  76. package/src/panels/BuilderSidebar.tsx +301 -301
  77. package/src/panels/ChannelConfigPanel.tsx +49 -49
  78. package/src/panels/ChannelsPanel.tsx +28 -28
  79. package/src/panels/DebugConsolePanel.tsx +73 -73
  80. package/src/panels/DebugContextPanel.tsx +77 -77
  81. package/src/panels/DebugExternalIOPanel.tsx +180 -180
  82. package/src/panels/DiagnosticsPanel.tsx +170 -170
  83. package/src/panels/EdgeConfigPanel.tsx +104 -104
  84. package/src/panels/FunctionConfigPanel.tsx +179 -179
  85. package/src/panels/FunctionListPanel.tsx +45 -45
  86. package/src/panels/MemoryConfigPanel.tsx +55 -55
  87. package/src/panels/MemoryPanel.tsx +40 -40
  88. package/src/panels/ModelConfigPanel.tsx +41 -41
  89. package/src/panels/ModelsPanel.tsx +36 -36
  90. package/src/panels/NodeConfigPanel.tsx +630 -630
  91. package/src/panels/NodeLibrary.tsx +288 -288
  92. package/src/panels/ResourceConfigPanel.tsx +132 -132
  93. package/src/panels/ResourceListPanel.tsx +113 -113
  94. package/src/panels/VariableConfigPanel.tsx +161 -161
  95. package/src/panels/VariablesPanel.tsx +145 -145
  96. package/src/stores/canvasStore.test.ts +44 -44
  97. package/src/stores/canvasStore.ts +245 -245
  98. package/src/stores/debugStore.ts +74 -74
  99. package/src/stores/diagnosticsStore.ts +130 -130
  100. package/src/stores/editorStore.ts +190 -190
  101. package/src/styles/index.css +526 -526
  102. package/src/utils/categoryConstants.ts +26 -26
  103. package/src/utils/channelOperations.ts +86 -86
  104. package/src/utils/connectionRules.ts +137 -137
  105. package/src/utils/functionOperations.ts +179 -179
  106. package/src/utils/graphOperations.ts +550 -550
  107. package/src/utils/history.ts +207 -207
  108. package/src/utils/memoryOperations.ts +57 -57
  109. package/src/utils/migrateFunctionNodes.ts +107 -107
  110. package/src/utils/modelOperations.ts +55 -55
  111. package/src/utils/paramDisplay.ts +71 -71
  112. package/src/utils/resourceHelpers.ts +32 -32
  113. package/src/utils/translation.ts +28 -28
  114. package/src/utils/variableOperations.ts +75 -75
  115. package/tailwind-preset.ts +166 -166
  116. package/dist/lib/utils.d.ts +0 -3
  117. package/dist/lib/utils.d.ts.map +0 -1
  118. package/dist/lib/utils.js +0 -6
  119. package/dist/lib/utils.js.map +0 -1
  120. package/dist/toolbars/CanvasTabsToolbar.d.ts +0 -11
  121. package/dist/toolbars/CanvasTabsToolbar.d.ts.map +0 -1
  122. package/dist/toolbars/CanvasTabsToolbar.js +0 -101
  123. package/dist/toolbars/CanvasTabsToolbar.js.map +0 -1
@@ -1,179 +1,179 @@
1
- import { useEffect, useMemo, useState } from "react";
2
- import { useTranslation } from "react-i18next";
3
- import { Button } from "../components/ui/button";
4
- import { Separator } from "../components/ui/separator";
5
- import {
6
- AlertDialog,
7
- AlertDialogAction,
8
- AlertDialogCancel,
9
- AlertDialogContent,
10
- AlertDialogDescription,
11
- AlertDialogFooter,
12
- AlertDialogHeader,
13
- AlertDialogTitle,
14
- } from "../components/ui/alert-dialog";
15
- import { ChevronRight } from "lucide-react";
16
- import type { FunctionDeclaration } from "@foresthubai/workflow-core/function";
17
- import { useEditorStore } from "../stores/editorStore";
18
- import { useDiagnosticsStore } from "../stores/diagnosticsStore";
19
- import { isReadOnly } from "../WorkflowBuilder";
20
- import { ReadOnlyBanner } from "../components/ui/readonly-banner";
21
- import { DeleteButton } from "../components/ui/delete-button";
22
- import { PortSection } from "../inputs/PortSection";
23
- import ExpressionInput from "../inputs/ExpressionInput";
24
- import { useAvailableVariables } from "../hooks/useAvailableVariables";
25
- import {
26
- renameFunction,
27
- addArgument,
28
- updateArgument,
29
- removeArgument,
30
- addOutput,
31
- updateOutput,
32
- removeOutput,
33
- setOutputExpression,
34
- deleteFunction,
35
- } from "../utils/functionOperations";
36
-
37
- interface FunctionConfigPanelProps {
38
- func: FunctionDeclaration;
39
- onClose: () => void;
40
- }
41
-
42
- /**
43
- * Right-side editor for a project-scoped function declaration, styled like the other
44
- * config panels: an editable title, then Inputs and Outputs sections (strong label +
45
- * description) whose rows are the same `bg-card` declaration cards the node Outputs
46
- * section uses. Each output bundles its declaration with the expression that produces
47
- * it; those expressions resolve against the function body's scope (the body canvas is
48
- * active, since selectFunction switched to it). Edits are non-undo-tracked.
49
- */
50
- export const FunctionConfigPanel = ({ func, onClose }: FunctionConfigPanelProps) => {
51
- const { t } = useTranslation();
52
- const readOnly = useEditorStore((s) => isReadOnly(s.builderMode));
53
- const { id, arguments: fnArgs, outputs } = func;
54
-
55
- const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
56
-
57
- // Local name state preserves cursor position; resets when a different function opens.
58
- const [localName, setLocalName] = useState(func.name);
59
- useEffect(() => {
60
- setLocalName(func.name);
61
- }, [id, func.name]);
62
-
63
- // Output expressions resolve against the function body's variable scope.
64
- const { lookup: availableVariables } = useAvailableVariables(id);
65
-
66
- // Per-output error messages come from the same byFunctionId slot that rings the
67
- // sidebar tab badge + list row, so panel, badge, and list always agree.
68
- const fnDiags = useDiagnosticsStore((s) => s.byFunctionId[id]);
69
- const outputErrors = useMemo(() => {
70
- const byUid = new Map<string, string[]>();
71
- for (const d of fnDiags ?? []) {
72
- if (!d.outputId) continue;
73
- const list = byUid.get(d.outputId);
74
- if (list) list.push(d.message);
75
- else byUid.set(d.outputId, [d.message]);
76
- }
77
- return byUid;
78
- }, [fnDiags]);
79
-
80
- return (
81
- <div className="p-4">
82
- <div className="space-y-4">
83
- <div className="flex items-center justify-between gap-2">
84
- <div className="flex-1 min-w-0">
85
- <div className="group flex items-center gap-1.5 rounded-md border border-transparent px-1.5 -mx-1.5 hover:border-input focus-within:border-input transition-colors">
86
- <input
87
- type="text"
88
- title={t("functionName")}
89
- className="font-semibold text-lg bg-transparent w-full outline-none cursor-text py-0.5 font-mono"
90
- value={localName}
91
- readOnly={readOnly}
92
- placeholder={t("functionNamePlaceholder")}
93
- onChange={(e) => {
94
- setLocalName(e.target.value);
95
- renameFunction(id, e.target.value);
96
- }}
97
- />
98
- </div>
99
- <p className="text-sm text-muted-foreground">{t("functionDefinition")}</p>
100
- </div>
101
- <Button variant="ghost" size="icon" className="shrink-0" onClick={onClose}>
102
- <ChevronRight className="h-4 w-4" />
103
- </Button>
104
- </div>
105
-
106
- {readOnly && <ReadOnlyBanner />}
107
-
108
- <div className={`space-y-4 ${readOnly ? "pointer-events-none opacity-60" : ""}`}>
109
- <Separator />
110
-
111
- <PortSection
112
- title={t("inputs")}
113
- description={t("functionInputsDesc")}
114
- addLabel={t("add")}
115
- emptyText={t("noInputs")}
116
- ports={fnArgs}
117
- onAdd={() => addArgument(id)}
118
- onUpdate={(index, patch) => updateArgument(id, index, patch)}
119
- onRemove={(index) => removeArgument(id, index)}
120
- />
121
-
122
- <Separator />
123
-
124
- <PortSection
125
- title={t("outputs")}
126
- description={t("functionOutputsDesc")}
127
- addLabel={t("add")}
128
- emptyText={t("noOutputs")}
129
- ports={outputs}
130
- onAdd={() => addOutput(id)}
131
- onUpdate={(index, patch) => updateOutput(id, index, patch)}
132
- onRemove={(index) => removeOutput(id, index)}
133
- errorsFor={(out) => outputErrors.get(out.uid) ?? []}
134
- renderExtra={(out, index) => (
135
- <ExpressionInput
136
- value={out.expression}
137
- onChange={(expr) => setOutputExpression(id, index, expr)}
138
- expressionType={out.dataType}
139
- availableVariables={availableVariables}
140
- placeholder={`${t("expressionFor")} ${out.name}...`}
141
- />
142
- )}
143
- />
144
- </div>
145
-
146
- {!readOnly && (
147
- <>
148
- <Separator />
149
- <DeleteButton onClick={() => setShowDeleteConfirm(true)}>{t("deleteFunction")}</DeleteButton>
150
- </>
151
- )}
152
- </div>
153
-
154
- {/* Functions carry a body + call sites, so deletion is confirmed (unlike the
155
- leaf resources, which delete inline). */}
156
- <AlertDialog open={showDeleteConfirm} onOpenChange={setShowDeleteConfirm}>
157
- <AlertDialogContent>
158
- <AlertDialogHeader>
159
- <AlertDialogTitle>{t("deleteFunctionTitle")}</AlertDialogTitle>
160
- <AlertDialogDescription>{t("deleteFunctionDesc")}</AlertDialogDescription>
161
- </AlertDialogHeader>
162
- <AlertDialogFooter>
163
- <AlertDialogCancel>{t("cancel")}</AlertDialogCancel>
164
- <AlertDialogAction
165
- className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
166
- onClick={() => {
167
- deleteFunction(id);
168
- setShowDeleteConfirm(false);
169
- onClose();
170
- }}
171
- >
172
- {t("delete")}
173
- </AlertDialogAction>
174
- </AlertDialogFooter>
175
- </AlertDialogContent>
176
- </AlertDialog>
177
- </div>
178
- );
179
- };
1
+ import { useEffect, useMemo, useState } from "react";
2
+ import { useTranslation } from "react-i18next";
3
+ import { Button } from "../components/ui/button";
4
+ import { Separator } from "../components/ui/separator";
5
+ import {
6
+ AlertDialog,
7
+ AlertDialogAction,
8
+ AlertDialogCancel,
9
+ AlertDialogContent,
10
+ AlertDialogDescription,
11
+ AlertDialogFooter,
12
+ AlertDialogHeader,
13
+ AlertDialogTitle,
14
+ } from "../components/ui/alert-dialog";
15
+ import { ChevronRight } from "lucide-react";
16
+ import type { FunctionDeclaration } from "@foresthubai/workflow-core/function";
17
+ import { useEditorStore } from "../stores/editorStore";
18
+ import { useDiagnosticsStore } from "../stores/diagnosticsStore";
19
+ import { isReadOnly } from "../WorkflowBuilder";
20
+ import { ReadOnlyBanner } from "../components/ui/readonly-banner";
21
+ import { DeleteButton } from "../components/ui/delete-button";
22
+ import { PortSection } from "../inputs/PortSection";
23
+ import ExpressionInput from "../inputs/ExpressionInput";
24
+ import { useAvailableVariables } from "../hooks/useAvailableVariables";
25
+ import {
26
+ renameFunction,
27
+ addArgument,
28
+ updateArgument,
29
+ removeArgument,
30
+ addOutput,
31
+ updateOutput,
32
+ removeOutput,
33
+ setOutputExpression,
34
+ deleteFunction,
35
+ } from "../utils/functionOperations";
36
+
37
+ interface FunctionConfigPanelProps {
38
+ func: FunctionDeclaration;
39
+ onClose: () => void;
40
+ }
41
+
42
+ /**
43
+ * Right-side editor for a project-scoped function declaration, styled like the other
44
+ * config panels: an editable title, then Inputs and Outputs sections (strong label +
45
+ * description) whose rows are the same `bg-card` declaration cards the node Outputs
46
+ * section uses. Each output bundles its declaration with the expression that produces
47
+ * it; those expressions resolve against the function body's scope (the body canvas is
48
+ * active, since selectFunction switched to it). Edits are non-undo-tracked.
49
+ */
50
+ export const FunctionConfigPanel = ({ func, onClose }: FunctionConfigPanelProps) => {
51
+ const { t } = useTranslation();
52
+ const readOnly = useEditorStore((s) => isReadOnly(s.builderMode));
53
+ const { id, arguments: fnArgs, outputs } = func;
54
+
55
+ const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
56
+
57
+ // Local name state preserves cursor position; resets when a different function opens.
58
+ const [localName, setLocalName] = useState(func.name);
59
+ useEffect(() => {
60
+ setLocalName(func.name);
61
+ }, [id, func.name]);
62
+
63
+ // Output expressions resolve against the function body's variable scope.
64
+ const { lookup: availableVariables } = useAvailableVariables(id);
65
+
66
+ // Per-output error messages come from the same byFunctionId slot that rings the
67
+ // sidebar tab badge + list row, so panel, badge, and list always agree.
68
+ const fnDiags = useDiagnosticsStore((s) => s.byFunctionId[id]);
69
+ const outputErrors = useMemo(() => {
70
+ const byUid = new Map<string, string[]>();
71
+ for (const d of fnDiags ?? []) {
72
+ if (!d.outputId) continue;
73
+ const list = byUid.get(d.outputId);
74
+ if (list) list.push(d.message);
75
+ else byUid.set(d.outputId, [d.message]);
76
+ }
77
+ return byUid;
78
+ }, [fnDiags]);
79
+
80
+ return (
81
+ <div className="p-4">
82
+ <div className="space-y-4">
83
+ <div className="flex items-center justify-between gap-2">
84
+ <div className="flex-1 min-w-0">
85
+ <div className="group flex items-center gap-1.5 rounded-md border border-transparent px-1.5 -mx-1.5 hover:border-input focus-within:border-input transition-colors">
86
+ <input
87
+ type="text"
88
+ title={t("functionName")}
89
+ className="font-semibold text-lg bg-transparent w-full outline-none cursor-text py-0.5 font-mono"
90
+ value={localName}
91
+ readOnly={readOnly}
92
+ placeholder={t("functionNamePlaceholder")}
93
+ onChange={(e) => {
94
+ setLocalName(e.target.value);
95
+ renameFunction(id, e.target.value);
96
+ }}
97
+ />
98
+ </div>
99
+ <p className="text-sm text-muted-foreground">{t("functionDefinition")}</p>
100
+ </div>
101
+ <Button variant="ghost" size="icon" className="shrink-0" onClick={onClose}>
102
+ <ChevronRight className="h-4 w-4" />
103
+ </Button>
104
+ </div>
105
+
106
+ {readOnly && <ReadOnlyBanner />}
107
+
108
+ <div className={`space-y-4 ${readOnly ? "pointer-events-none opacity-60" : ""}`}>
109
+ <Separator />
110
+
111
+ <PortSection
112
+ title={t("inputs")}
113
+ description={t("functionInputsDesc")}
114
+ addLabel={t("add")}
115
+ emptyText={t("noInputs")}
116
+ ports={fnArgs}
117
+ onAdd={() => addArgument(id)}
118
+ onUpdate={(index, patch) => updateArgument(id, index, patch)}
119
+ onRemove={(index) => removeArgument(id, index)}
120
+ />
121
+
122
+ <Separator />
123
+
124
+ <PortSection
125
+ title={t("outputs")}
126
+ description={t("functionOutputsDesc")}
127
+ addLabel={t("add")}
128
+ emptyText={t("noOutputs")}
129
+ ports={outputs}
130
+ onAdd={() => addOutput(id)}
131
+ onUpdate={(index, patch) => updateOutput(id, index, patch)}
132
+ onRemove={(index) => removeOutput(id, index)}
133
+ errorsFor={(out) => outputErrors.get(out.uid) ?? []}
134
+ renderExtra={(out, index) => (
135
+ <ExpressionInput
136
+ value={out.expression}
137
+ onChange={(expr) => setOutputExpression(id, index, expr)}
138
+ expressionType={out.dataType}
139
+ availableVariables={availableVariables}
140
+ placeholder={`${t("expressionFor")} ${out.name}...`}
141
+ />
142
+ )}
143
+ />
144
+ </div>
145
+
146
+ {!readOnly && (
147
+ <>
148
+ <Separator />
149
+ <DeleteButton onClick={() => setShowDeleteConfirm(true)}>{t("deleteFunction")}</DeleteButton>
150
+ </>
151
+ )}
152
+ </div>
153
+
154
+ {/* Functions carry a body + call sites, so deletion is confirmed (unlike the
155
+ leaf resources, which delete inline). */}
156
+ <AlertDialog open={showDeleteConfirm} onOpenChange={setShowDeleteConfirm}>
157
+ <AlertDialogContent>
158
+ <AlertDialogHeader>
159
+ <AlertDialogTitle>{t("deleteFunctionTitle")}</AlertDialogTitle>
160
+ <AlertDialogDescription>{t("deleteFunctionDesc")}</AlertDialogDescription>
161
+ </AlertDialogHeader>
162
+ <AlertDialogFooter>
163
+ <AlertDialogCancel>{t("cancel")}</AlertDialogCancel>
164
+ <AlertDialogAction
165
+ className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
166
+ onClick={() => {
167
+ deleteFunction(id);
168
+ setShowDeleteConfirm(false);
169
+ onClose();
170
+ }}
171
+ >
172
+ {t("delete")}
173
+ </AlertDialogAction>
174
+ </AlertDialogFooter>
175
+ </AlertDialogContent>
176
+ </AlertDialog>
177
+ </div>
178
+ );
179
+ };
@@ -1,45 +1,45 @@
1
- import { useTranslation } from "react-i18next";
2
- import { FunctionSquare, Plus } from "lucide-react";
3
- import { useDiagnosticsStore } from "../stores/diagnosticsStore";
4
- import { useEditorStore } from "../stores/editorStore";
5
- import { ResourceListPanel } from "./ResourceListPanel";
6
-
7
- interface FunctionListPanelProps {
8
- /** Open + select an existing function (switches to its canvas). */
9
- onOpenFunction: (id: string) => void;
10
- /** Create a new function and open it. */
11
- onCreateFunction: () => string;
12
- }
13
-
14
- /**
15
- * Always-present sidebar list of project-scoped functions, mirroring the
16
- * channels/memory/models panels. Selecting a row opens the function (its canvas +
17
- * the definition config on the right); the badge shows the in→out port counts.
18
- */
19
- export const FunctionListPanel = ({ onOpenFunction, onCreateFunction }: FunctionListPanelProps) => {
20
- const { t } = useTranslation();
21
- const functions = useEditorStore((s) => s.functions);
22
- const selection = useEditorStore((s) => s.selection);
23
- const byFunctionId = useDiagnosticsStore((s) => s.byFunctionId);
24
-
25
- const items = Object.values(functions).map((f) => ({
26
- id: f.id,
27
- label: f.name,
28
- inputs: f.arguments.length,
29
- outputs: f.outputs.length,
30
- }));
31
-
32
- return (
33
- <ResourceListPanel
34
- items={items}
35
- selectedId={selection.kind === "function" ? selection.id : null}
36
- onSelect={onOpenFunction}
37
- diagnosticsSlot={byFunctionId}
38
- badge={(f) => `${f.inputs}→${f.outputs}`}
39
- emptyIcon={FunctionSquare}
40
- emptyText={t("noFunctions")}
41
- emptyHint={t("addFunctionHint")}
42
- addActions={[{ label: t("addFunction"), icon: Plus, onAdd: () => onCreateFunction() }]}
43
- />
44
- );
45
- };
1
+ import { useTranslation } from "react-i18next";
2
+ import { FunctionSquare, Plus } from "lucide-react";
3
+ import { useDiagnosticsStore } from "../stores/diagnosticsStore";
4
+ import { useEditorStore } from "../stores/editorStore";
5
+ import { ResourceListPanel } from "./ResourceListPanel";
6
+
7
+ interface FunctionListPanelProps {
8
+ /** Open + select an existing function (switches to its canvas). */
9
+ onOpenFunction: (id: string) => void;
10
+ /** Create a new function and open it. */
11
+ onCreateFunction: () => string;
12
+ }
13
+
14
+ /**
15
+ * Always-present sidebar list of project-scoped functions, mirroring the
16
+ * channels/memory/models panels. Selecting a row opens the function (its canvas +
17
+ * the definition config on the right); the badge shows the in→out port counts.
18
+ */
19
+ export const FunctionListPanel = ({ onOpenFunction, onCreateFunction }: FunctionListPanelProps) => {
20
+ const { t } = useTranslation();
21
+ const functions = useEditorStore((s) => s.functions);
22
+ const selection = useEditorStore((s) => s.selection);
23
+ const byFunctionId = useDiagnosticsStore((s) => s.byFunctionId);
24
+
25
+ const items = Object.values(functions).map((f) => ({
26
+ id: f.id,
27
+ label: f.name,
28
+ inputs: f.arguments.length,
29
+ outputs: f.outputs.length,
30
+ }));
31
+
32
+ return (
33
+ <ResourceListPanel
34
+ items={items}
35
+ selectedId={selection.kind === "function" ? selection.id : null}
36
+ onSelect={onOpenFunction}
37
+ diagnosticsSlot={byFunctionId}
38
+ badge={(f) => `${f.inputs}→${f.outputs}`}
39
+ emptyIcon={FunctionSquare}
40
+ emptyText={t("noFunctions")}
41
+ emptyHint={t("addFunctionHint")}
42
+ addActions={[{ label: t("addFunction"), icon: Plus, onAdd: () => onCreateFunction() }]}
43
+ />
44
+ );
45
+ };
@@ -1,55 +1,55 @@
1
- import { useTranslation } from "react-i18next";
2
- import { MemoryRegistry, type Memory } from "@foresthubai/workflow-core/memory";
3
- import { useEditorStore } from "../stores/editorStore";
4
- import { useDiagnosticsStore } from "../stores/diagnosticsStore";
5
- import { deleteMemory, updateMemory } from "../utils/memoryOperations";
6
- import { ResourceConfigPanel } from "./ResourceConfigPanel";
7
-
8
- interface MemoryConfigPanelProps {
9
- memory: Memory;
10
- onClose: () => void;
11
- }
12
-
13
- export const MemoryConfigPanel = ({ memory, onClose }: MemoryConfigPanelProps) => {
14
- const { t } = useTranslation();
15
- const allMemory = useEditorStore((s) => s.memory);
16
- const def = MemoryRegistry.getByType(memory.type);
17
- const memoryDiags = useDiagnosticsStore((s) => s.byMemoryId[memory.id]);
18
-
19
- // Label doubles as the LLM tool identifier for memory files and must be unique
20
- // per agent. Surfaced inline below the title (mirrors the old name check).
21
- const isDuplicateLabel =
22
- memory.type === "MemoryFile" &&
23
- memory.label.trim() !== "" &&
24
- Object.values(allMemory).some((m) => m.id !== memory.id && m.type === "MemoryFile" && m.label === memory.label);
25
- const isEmptyLabel = memory.label.trim() === "";
26
-
27
- const belowLabel = (
28
- <>
29
- {isEmptyLabel && <p className="text-xs text-destructive mt-1">{t("memoryLabelRequired", "Label is required")}</p>}
30
- {isDuplicateLabel && (
31
- <p className="text-xs text-destructive mt-1">{t("memoryLabelDuplicate", "Label must be unique per agent")}</p>
32
- )}
33
- </>
34
- );
35
-
36
- return (
37
- <ResourceConfigPanel
38
- resetKey={memory.id}
39
- label={memory.label}
40
- labelTitle={t("memoryLabel", "Memory label")}
41
- onLabelChange={(label) => updateMemory(memory.id, { label })}
42
- description={def?.description ?? ""}
43
- belowLabel={belowLabel}
44
- parameters={def?.parameters ?? []}
45
- getValue={(p) => memory.arguments[p.id]}
46
- allArguments={{ ...memory.arguments }}
47
- onParamChange={(paramId, value) => updateMemory(memory.id, { arguments: { [paramId]: value } })}
48
- diagnostics={memoryDiags}
49
- translationPrefix="memory"
50
- deleteLabel={t("deleteMemory", "Delete memory")}
51
- onDelete={() => deleteMemory(memory.id)}
52
- onClose={onClose}
53
- />
54
- );
55
- };
1
+ import { useTranslation } from "react-i18next";
2
+ import { MemoryRegistry, type Memory } from "@foresthubai/workflow-core/memory";
3
+ import { useEditorStore } from "../stores/editorStore";
4
+ import { useDiagnosticsStore } from "../stores/diagnosticsStore";
5
+ import { deleteMemory, updateMemory } from "../utils/memoryOperations";
6
+ import { ResourceConfigPanel } from "./ResourceConfigPanel";
7
+
8
+ interface MemoryConfigPanelProps {
9
+ memory: Memory;
10
+ onClose: () => void;
11
+ }
12
+
13
+ export const MemoryConfigPanel = ({ memory, onClose }: MemoryConfigPanelProps) => {
14
+ const { t } = useTranslation();
15
+ const allMemory = useEditorStore((s) => s.memory);
16
+ const def = MemoryRegistry.getByType(memory.type);
17
+ const memoryDiags = useDiagnosticsStore((s) => s.byMemoryId[memory.id]);
18
+
19
+ // Label doubles as the LLM tool identifier for memory files and must be unique
20
+ // per agent. Surfaced inline below the title (mirrors the old name check).
21
+ const isDuplicateLabel =
22
+ memory.type === "MemoryFile" &&
23
+ memory.label.trim() !== "" &&
24
+ Object.values(allMemory).some((m) => m.id !== memory.id && m.type === "MemoryFile" && m.label === memory.label);
25
+ const isEmptyLabel = memory.label.trim() === "";
26
+
27
+ const belowLabel = (
28
+ <>
29
+ {isEmptyLabel && <p className="text-xs text-destructive mt-1">{t("memoryLabelRequired", "Label is required")}</p>}
30
+ {isDuplicateLabel && (
31
+ <p className="text-xs text-destructive mt-1">{t("memoryLabelDuplicate", "Label must be unique per agent")}</p>
32
+ )}
33
+ </>
34
+ );
35
+
36
+ return (
37
+ <ResourceConfigPanel
38
+ resetKey={memory.id}
39
+ label={memory.label}
40
+ labelTitle={t("memoryLabel", "Memory label")}
41
+ onLabelChange={(label) => updateMemory(memory.id, { label })}
42
+ description={def?.description ?? ""}
43
+ belowLabel={belowLabel}
44
+ parameters={def?.parameters ?? []}
45
+ getValue={(p) => memory.arguments[p.id]}
46
+ allArguments={{ ...memory.arguments }}
47
+ onParamChange={(paramId, value) => updateMemory(memory.id, { arguments: { [paramId]: value } })}
48
+ diagnostics={memoryDiags}
49
+ translationPrefix="memory"
50
+ deleteLabel={t("deleteMemory", "Delete memory")}
51
+ onDelete={() => deleteMemory(memory.id)}
52
+ onClose={onClose}
53
+ />
54
+ );
55
+ };
@@ -1,40 +1,40 @@
1
- import { useTranslation } from "react-i18next";
2
- import { Database, FileText } from "lucide-react";
3
- import type { MemoryType } from "@foresthubai/workflow-core/memory";
4
- import { useDiagnosticsStore } from "../stores/diagnosticsStore";
5
- import { useEditorStore } from "../stores/editorStore";
6
- import { addMemory } from "../utils/memoryOperations";
7
- import { ResourceListPanel } from "./ResourceListPanel";
8
-
9
- /** Short, friendly badge label per memory type (the raw type names are long). */
10
- const TYPE_BADGE: Record<MemoryType, string> = {
11
- MemoryFile: "File",
12
- VectorDatabase: "Vector",
13
- };
14
-
15
- export const MemoryPanel = () => {
16
- const { t } = useTranslation();
17
- const memory = useEditorStore((s) => s.memory);
18
- const selection = useEditorStore((s) => s.selection);
19
- const selectMemory = useEditorStore((s) => s.selectMemory);
20
- const byMemoryId = useDiagnosticsStore((s) => s.byMemoryId);
21
-
22
- const add = (type: MemoryType) => selectMemory(addMemory(type).id);
23
-
24
- return (
25
- <ResourceListPanel
26
- items={Object.values(memory)}
27
- selectedId={selection.kind === "memory" ? selection.id : null}
28
- onSelect={selectMemory}
29
- diagnosticsSlot={byMemoryId}
30
- badge={(m) => TYPE_BADGE[m.type]}
31
- emptyIcon={Database}
32
- emptyText={t("noMemory", "No memory declared yet")}
33
- emptyHint={t("noMemoryHint", "Declare memory files for agents and vector databases for RAG")}
34
- addActions={[
35
- { label: t("addMemoryFile", "Add Memory File"), icon: FileText, onAdd: () => add("MemoryFile") },
36
- { label: t("addVectorDatabase", "Add Vector Database"), icon: Database, onAdd: () => add("VectorDatabase") },
37
- ]}
38
- />
39
- );
40
- };
1
+ import { useTranslation } from "react-i18next";
2
+ import { Database, FileText } from "lucide-react";
3
+ import type { MemoryType } from "@foresthubai/workflow-core/memory";
4
+ import { useDiagnosticsStore } from "../stores/diagnosticsStore";
5
+ import { useEditorStore } from "../stores/editorStore";
6
+ import { addMemory } from "../utils/memoryOperations";
7
+ import { ResourceListPanel } from "./ResourceListPanel";
8
+
9
+ /** Short, friendly badge label per memory type (the raw type names are long). */
10
+ const TYPE_BADGE: Record<MemoryType, string> = {
11
+ MemoryFile: "File",
12
+ VectorDatabase: "Vector",
13
+ };
14
+
15
+ export const MemoryPanel = () => {
16
+ const { t } = useTranslation();
17
+ const memory = useEditorStore((s) => s.memory);
18
+ const selection = useEditorStore((s) => s.selection);
19
+ const selectMemory = useEditorStore((s) => s.selectMemory);
20
+ const byMemoryId = useDiagnosticsStore((s) => s.byMemoryId);
21
+
22
+ const add = (type: MemoryType) => selectMemory(addMemory(type).id);
23
+
24
+ return (
25
+ <ResourceListPanel
26
+ items={Object.values(memory)}
27
+ selectedId={selection.kind === "memory" ? selection.id : null}
28
+ onSelect={selectMemory}
29
+ diagnosticsSlot={byMemoryId}
30
+ badge={(m) => TYPE_BADGE[m.type]}
31
+ emptyIcon={Database}
32
+ emptyText={t("noMemory", "No memory declared yet")}
33
+ emptyHint={t("noMemoryHint", "Declare memory files for agents and vector databases for RAG")}
34
+ addActions={[
35
+ { label: t("addMemoryFile", "Add Memory File"), icon: FileText, onAdd: () => add("MemoryFile") },
36
+ { label: t("addVectorDatabase", "Add Vector Database"), icon: Database, onAdd: () => add("VectorDatabase") },
37
+ ]}
38
+ />
39
+ );
40
+ };