@agentscope-ai/flow 0.0.1 → 0.0.3
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.
- package/dist/components/base-node/index.js +5 -5
- package/dist/components/check-list-btn/index.js +12 -12
- package/dist/components/condition-item/index.d.ts +1 -1
- package/dist/components/condition-item/index.js +6 -6
- package/dist/components/custom-handle/source-handle.js +2 -1
- package/dist/components/custom-inputs-control/index.js +8 -8
- package/dist/components/flow-base-edge/index.js +11 -11
- package/dist/components/flow-panel/config-panel.js +2 -2
- package/dist/components/judge-form/index.js +4 -4
- package/dist/components/node-menu/index.js +1 -1
- package/dist/components/node-result-panel/index.js +7 -7
- package/dist/components/task-status/index.js +13 -13
- package/dist/hooks/use-edges-interaction.js +9 -9
- package/dist/hooks/use-flow-debug-interaction.js +1 -1
- package/dist/hooks/use-nodes-interaction.js +2 -2
- package/dist/hooks/use-nodes-output-params.js +5 -5
- package/dist/hooks/use-work-flow.js +2 -2
- package/dist/types/work-flow.d.ts +48 -48
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
|
@@ -106,10 +106,10 @@ function BaseNode(props) {
|
|
|
106
106
|
}
|
|
107
107
|
}, [props.id]);
|
|
108
108
|
var nodeResult = useMemo(function () {
|
|
109
|
-
var _taskStore$
|
|
109
|
+
var _taskStore$nodeResult;
|
|
110
110
|
if (!taskStore) return null;
|
|
111
|
-
return ((_taskStore$
|
|
112
|
-
return item.
|
|
111
|
+
return ((_taskStore$nodeResult = taskStore.nodeResults) === null || _taskStore$nodeResult === void 0 ? void 0 : _taskStore$nodeResult.find(function (item) {
|
|
112
|
+
return item.nodeId === props.id;
|
|
113
113
|
})) || null;
|
|
114
114
|
}, [props.id, taskStore]);
|
|
115
115
|
var actionMenus = useMemo(function () {
|
|
@@ -167,7 +167,7 @@ function BaseNode(props) {
|
|
|
167
167
|
}
|
|
168
168
|
}, /*#__PURE__*/React.createElement("div", {
|
|
169
169
|
ref: containerRef,
|
|
170
|
-
className: classNames('spark-flow-node-container', props.className, _defineProperty({}, "spark-flow-node-container-".concat(nodeResult === null || nodeResult === void 0 ? void 0 : nodeResult.
|
|
170
|
+
className: classNames('spark-flow-node-container', props.className, _defineProperty({}, "spark-flow-node-container-".concat(nodeResult === null || nodeResult === void 0 ? void 0 : nodeResult.nodeStatus), !!nodeResult && showResults))
|
|
171
171
|
}, /*#__PURE__*/React.createElement("div", {
|
|
172
172
|
className: "flex-justify-between"
|
|
173
173
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -180,7 +180,7 @@ function BaseNode(props) {
|
|
|
180
180
|
},
|
|
181
181
|
className: "spark-flow-node-label flex-1 w-1"
|
|
182
182
|
}, props.data.label)), !!nodeResult && showResults ? /*#__PURE__*/React.createElement(NodeStatusIcon, {
|
|
183
|
-
status: nodeResult.
|
|
183
|
+
status: nodeResult.nodeStatus
|
|
184
184
|
}) : props.disableAction ? null : /*#__PURE__*/React.createElement("div", {
|
|
185
185
|
onClick: function onClick(e) {
|
|
186
186
|
e.stopPropagation();
|
|
@@ -38,13 +38,13 @@ export default /*#__PURE__*/memo(function CheckListBtn() {
|
|
|
38
38
|
nodes.forEach(function (item) {
|
|
39
39
|
var nodeInfo = nodeSchemaMap[item.type];
|
|
40
40
|
if (!(nodeInfo !== null && nodeInfo !== void 0 && nodeInfo.checkValid)) return;
|
|
41
|
-
var
|
|
42
|
-
if (
|
|
41
|
+
var errorMsgs = nodeInfo.checkValid(item.data);
|
|
42
|
+
if (errorMsgs.length > 0) {
|
|
43
43
|
list.push({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
nodeId: item.id,
|
|
45
|
+
errorMsgs: errorMsgs,
|
|
46
|
+
nodeType: item.type,
|
|
47
|
+
nodeName: item.data.label
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
});
|
|
@@ -89,24 +89,24 @@ export default /*#__PURE__*/memo(function CheckListBtn() {
|
|
|
89
89
|
}, checkList.map(function (item) {
|
|
90
90
|
return /*#__PURE__*/React.createElement("div", {
|
|
91
91
|
onClick: function onClick() {
|
|
92
|
-
handleNodeClickByNodeId(item.
|
|
92
|
+
handleNodeClickByNodeId(item.nodeId);
|
|
93
93
|
setShowCheckList(false);
|
|
94
94
|
},
|
|
95
|
-
key: item.
|
|
95
|
+
key: item.nodeId,
|
|
96
96
|
className: "spark-flow-node-check-container"
|
|
97
97
|
}, /*#__PURE__*/React.createElement("div", {
|
|
98
98
|
className: "spark-flow-node-check-container-header"
|
|
99
99
|
}, /*#__PURE__*/React.createElement(FlowIcon, {
|
|
100
100
|
size: "small",
|
|
101
|
-
nodeType: item.
|
|
101
|
+
nodeType: item.nodeType
|
|
102
102
|
}), /*#__PURE__*/React.createElement(Typography.Text, {
|
|
103
103
|
ellipsis: {
|
|
104
|
-
tooltip: item.
|
|
104
|
+
tooltip: item.nodeName
|
|
105
105
|
},
|
|
106
106
|
className: "spark-flow-node-check-container-header-title"
|
|
107
|
-
}, item.
|
|
107
|
+
}, item.nodeName)), /*#__PURE__*/React.createElement("div", {
|
|
108
108
|
className: "spark-flow-node-check-container-content"
|
|
109
|
-
}, item.
|
|
109
|
+
}, item.errorMsgs.map(function (msg, index) {
|
|
110
110
|
return /*#__PURE__*/React.createElement("div", {
|
|
111
111
|
className: "spark-flow-node-check-container-content-item",
|
|
112
112
|
key: index
|
|
@@ -2,7 +2,7 @@ import { IConditionItem } from "../../types/work-flow";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { IVarTreeItem } from '../variable-tree-select';
|
|
4
4
|
import './index.less';
|
|
5
|
-
export declare const operatorLabelRender: (val: string) => "
|
|
5
|
+
export declare const operatorLabelRender: (val: string) => "=" | "≠" | ">" | "≥" | "<" | "≤" | "∋" | "∌" | undefined;
|
|
6
6
|
export interface IConditionItemProps {
|
|
7
7
|
value: IConditionItem;
|
|
8
8
|
onChange: (value: Partial<IConditionItem>) => void;
|
|
@@ -81,11 +81,11 @@ export default function ConditionItem(props) {
|
|
|
81
81
|
width: 60
|
|
82
82
|
},
|
|
83
83
|
options: VALUE_FROM_OPTIONS,
|
|
84
|
-
value: props.value.right.
|
|
84
|
+
value: props.value.right.valueFrom,
|
|
85
85
|
onChange: function onChange(val) {
|
|
86
86
|
return props.onChange({
|
|
87
87
|
right: _objectSpread(_objectSpread({}, props.value.right), {}, {
|
|
88
|
-
|
|
88
|
+
valueFrom: val,
|
|
89
89
|
value: void 0
|
|
90
90
|
})
|
|
91
91
|
});
|
|
@@ -98,7 +98,7 @@ export default function ConditionItem(props) {
|
|
|
98
98
|
}), /*#__PURE__*/React.createElement(Divider, {
|
|
99
99
|
className: "spark-flow-condition-item-divider",
|
|
100
100
|
type: "vertical"
|
|
101
|
-
}), props.value.right.
|
|
101
|
+
}), props.value.right.valueFrom === 'refer' && /*#__PURE__*/React.createElement("div", {
|
|
102
102
|
className: "flex-1"
|
|
103
103
|
}, /*#__PURE__*/React.createElement(VariableSelector, {
|
|
104
104
|
disabled: props.disabled,
|
|
@@ -111,7 +111,7 @@ export default function ConditionItem(props) {
|
|
|
111
111
|
right: _objectSpread(_objectSpread({}, props.value.right), val)
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
})), props.value.right.
|
|
114
|
+
})), props.value.right.valueFrom === 'input' && /*#__PURE__*/React.createElement("div", {
|
|
115
115
|
className: "flex-1"
|
|
116
116
|
}, /*#__PURE__*/React.createElement(VariableBaseInput, {
|
|
117
117
|
disabled: props.disabled,
|
|
@@ -126,7 +126,7 @@ export default function ConditionItem(props) {
|
|
|
126
126
|
type: props.value.right.type
|
|
127
127
|
})));
|
|
128
128
|
}
|
|
129
|
-
}, [props.value, props.disabled, props.onChange]);
|
|
129
|
+
}, [props.value, props.disabled, props.onChange, memoRightVariableListByType]);
|
|
130
130
|
return /*#__PURE__*/React.createElement("div", {
|
|
131
131
|
className: "spark-flow-condition-item"
|
|
132
132
|
}, /*#__PURE__*/React.createElement(Flex, {
|
|
@@ -143,7 +143,7 @@ export default function ConditionItem(props) {
|
|
|
143
143
|
props.onChange({
|
|
144
144
|
left: _objectSpread(_objectSpread({}, props.value.left), val),
|
|
145
145
|
right: props.value.left.type === val.type ? props.value.right : {
|
|
146
|
-
|
|
146
|
+
valueFrom: props.value.right.valueFrom,
|
|
147
147
|
value: void 0,
|
|
148
148
|
type: getRightType(val.type)
|
|
149
149
|
},
|
|
@@ -9,6 +9,7 @@ import { SparkPlusLine } from '@agentscope-ai/icons';
|
|
|
9
9
|
import { Handle, Position } from '@xyflow/react';
|
|
10
10
|
import React, { useState } from 'react';
|
|
11
11
|
import { PopoverNodeMenu } from "../node-menu";
|
|
12
|
+
import classNames from 'classnames';
|
|
12
13
|
export default function SourceHandle(props) {
|
|
13
14
|
var _useState = useState(false),
|
|
14
15
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -34,7 +35,7 @@ export default function SourceHandle(props) {
|
|
|
34
35
|
e.stopPropagation();
|
|
35
36
|
e.preventDefault();
|
|
36
37
|
},
|
|
37
|
-
className:
|
|
38
|
+
className: classNames('spark-flow-source-handle', 'flex-center', open ? 'spark-flow-source-handle-open' : '', props.className),
|
|
38
39
|
type: "source",
|
|
39
40
|
position: Position.Right,
|
|
40
41
|
id: props.handleId
|
|
@@ -35,7 +35,7 @@ export var variableLabelRender = function variableLabelRender(_ref) {
|
|
|
35
35
|
dm: '无效变量'
|
|
36
36
|
}));
|
|
37
37
|
}
|
|
38
|
-
if (value.
|
|
38
|
+
if (value.valueFrom !== 'refer' || !value.value || !nodeInfo) {
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
41
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -164,7 +164,7 @@ export var VariableSelector = /*#__PURE__*/memo(function (props) {
|
|
|
164
164
|
}));
|
|
165
165
|
});
|
|
166
166
|
export var VariableFormComp = /*#__PURE__*/memo(function (props) {
|
|
167
|
-
if (props.data.
|
|
167
|
+
if (props.data.valueFrom === 'clear') return /*#__PURE__*/React.createElement(Input, {
|
|
168
168
|
className: "flex-1",
|
|
169
169
|
disabled: true,
|
|
170
170
|
placeholder: $i18n.get({
|
|
@@ -172,7 +172,7 @@ export var VariableFormComp = /*#__PURE__*/memo(function (props) {
|
|
|
172
172
|
dm: '不需要输入值'
|
|
173
173
|
})
|
|
174
174
|
});
|
|
175
|
-
if (props.data.
|
|
175
|
+
if (props.data.valueFrom === 'refer') return /*#__PURE__*/React.createElement(VariableSelector, {
|
|
176
176
|
disabled: props.disabled,
|
|
177
177
|
value: props.data,
|
|
178
178
|
onChange: props.onChange,
|
|
@@ -180,7 +180,7 @@ export var VariableFormComp = /*#__PURE__*/memo(function (props) {
|
|
|
180
180
|
enabledTypes: props.enabledTypes,
|
|
181
181
|
disabledTypes: props.disabledTypes
|
|
182
182
|
});
|
|
183
|
-
if (props.data.
|
|
183
|
+
if (props.data.valueFrom === 'input') {
|
|
184
184
|
if (props.typeSwitchDisabled) {
|
|
185
185
|
return /*#__PURE__*/React.createElement("div", {
|
|
186
186
|
className: "flex-1"
|
|
@@ -244,7 +244,7 @@ export default /*#__PURE__*/memo(function CustomInputsControl(props) {
|
|
|
244
244
|
var changeRowValue = useCallback(function (ind, payload) {
|
|
245
245
|
var newVal = value.map(function (item, index) {
|
|
246
246
|
if (index === ind) {
|
|
247
|
-
if (payload.
|
|
247
|
+
if (payload.valueFrom === 'input' && !payload.type) {
|
|
248
248
|
payload.type = 'String';
|
|
249
249
|
}
|
|
250
250
|
return _objectSpread(_objectSpread({}, item), payload);
|
|
@@ -256,7 +256,7 @@ export default /*#__PURE__*/memo(function CustomInputsControl(props) {
|
|
|
256
256
|
var handleAddVar = useCallback(function () {
|
|
257
257
|
props.onChange([].concat(_toConsumableArray(value), [{
|
|
258
258
|
key: '',
|
|
259
|
-
|
|
259
|
+
valueFrom: 'refer',
|
|
260
260
|
type: props.defaultType || 'String'
|
|
261
261
|
}]));
|
|
262
262
|
}, [props.defaultType, props.onChange, value]);
|
|
@@ -317,10 +317,10 @@ export default /*#__PURE__*/memo(function CustomInputsControl(props) {
|
|
|
317
317
|
width: 60
|
|
318
318
|
},
|
|
319
319
|
className: "flex-shrink-0 spark-flow-variable-from-select",
|
|
320
|
-
value: item.
|
|
320
|
+
value: item.valueFrom,
|
|
321
321
|
onChange: function onChange(val) {
|
|
322
322
|
return changeRowValue(index, {
|
|
323
|
-
|
|
323
|
+
valueFrom: val,
|
|
324
324
|
value: void 0
|
|
325
325
|
});
|
|
326
326
|
},
|
|
@@ -63,8 +63,8 @@ export default /*#__PURE__*/memo(function FlowBaseEdge(_ref) {
|
|
|
63
63
|
var _getCommonConfig = getCommonConfig(),
|
|
64
64
|
antPrefix = _getCommonConfig.antPrefix;
|
|
65
65
|
var colorList = useMemo(function () {
|
|
66
|
-
if (edgeData.
|
|
67
|
-
if (edgeData.
|
|
66
|
+
if (edgeData._sourceNodeStatus && edgeData._targetNodeStatus) {
|
|
67
|
+
if (edgeData._sourceNodeStatus === 'success' && edgeData._targetNodeStatus === 'success') {
|
|
68
68
|
return [{
|
|
69
69
|
color: '#30A46C',
|
|
70
70
|
opacity: 0.5,
|
|
@@ -75,7 +75,7 @@ export default /*#__PURE__*/memo(function FlowBaseEdge(_ref) {
|
|
|
75
75
|
offset: 100
|
|
76
76
|
}];
|
|
77
77
|
}
|
|
78
|
-
if (edgeData.
|
|
78
|
+
if (edgeData._sourceNodeStatus === 'success' && edgeData._targetNodeStatus === 'fail') {
|
|
79
79
|
return [{
|
|
80
80
|
color: '#30A46C',
|
|
81
81
|
opacity: 1,
|
|
@@ -90,7 +90,7 @@ export default /*#__PURE__*/memo(function FlowBaseEdge(_ref) {
|
|
|
90
90
|
offset: 100
|
|
91
91
|
}];
|
|
92
92
|
}
|
|
93
|
-
if (edgeData.
|
|
93
|
+
if (edgeData._sourceNodeStatus === 'success' || edgeData._sourceNodeStatus === 'executing' && edgeData._targetNodeStatus === 'executing') {
|
|
94
94
|
return [{
|
|
95
95
|
color: '#30A46C',
|
|
96
96
|
opacity: 1,
|
|
@@ -135,22 +135,22 @@ export default /*#__PURE__*/memo(function FlowBaseEdge(_ref) {
|
|
|
135
135
|
}, [edgeData, selected]);
|
|
136
136
|
var isAnimated = useMemo(function () {
|
|
137
137
|
var _ref2;
|
|
138
|
-
if (edgeData.
|
|
139
|
-
return edgeData.
|
|
138
|
+
if (edgeData._sourceNodeStatus === 'executing' && edgeData._targetNodeStatus === 'executing') return true;
|
|
139
|
+
return edgeData._sourceNodeStatus === 'success' && !((_ref2 = ['fail', 'success']) !== null && _ref2 !== void 0 && _ref2.includes(edgeData._targetNodeStatus || ''));
|
|
140
140
|
}, [edgeData]);
|
|
141
141
|
var markerEndColor = useMemo(function () {
|
|
142
|
-
if (edgeData.
|
|
143
|
-
if (edgeData.
|
|
142
|
+
if (edgeData._sourceNodeStatus && edgeData._targetNodeStatus) {
|
|
143
|
+
if (edgeData._sourceNodeStatus === 'success' && edgeData._targetNodeStatus === 'success') {
|
|
144
144
|
return {
|
|
145
145
|
stroke: '#30A46C'
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
-
if (edgeData.
|
|
148
|
+
if (edgeData._sourceNodeStatus === 'success' && edgeData._targetNodeStatus === 'fail') {
|
|
149
149
|
return {
|
|
150
150
|
stroke: '#F23139'
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
|
-
if (edgeData.
|
|
153
|
+
if (edgeData._sourceNodeStatus === 'success') {
|
|
154
154
|
return {
|
|
155
155
|
stroke: '#615CED'
|
|
156
156
|
};
|
|
@@ -168,7 +168,7 @@ export default /*#__PURE__*/memo(function FlowBaseEdge(_ref) {
|
|
|
168
168
|
return {
|
|
169
169
|
stroke: "var(--".concat(antPrefix, "-color-mauve)")
|
|
170
170
|
};
|
|
171
|
-
}, [edgeData._hover, selected, getCommonConfig, edgeData.
|
|
171
|
+
}, [edgeData._hover, selected, getCommonConfig, edgeData._sourceNodeStatus, edgeData._targetNodeStatus, antPrefix]);
|
|
172
172
|
return /*#__PURE__*/React.createElement(React.Fragment, null, !animated && /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("marker", {
|
|
173
173
|
id: "".concat(id, "-arrow"),
|
|
174
174
|
markerWidth: "20",
|
|
@@ -74,14 +74,14 @@ export var ConfigPanel = /*#__PURE__*/memo(function (_ref) {
|
|
|
74
74
|
onNodeDelete(selectedNodeData.id);
|
|
75
75
|
break;
|
|
76
76
|
case 'id':
|
|
77
|
-
copy(
|
|
77
|
+
copy(selectedNodeData.id);
|
|
78
78
|
message.success($i18n.get({
|
|
79
79
|
id: 'spark-flow.components.FlowPanel.ConfigPanel.copySuccess',
|
|
80
80
|
dm: '复制成功'
|
|
81
81
|
}));
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
|
-
}, [selectedNodeData
|
|
84
|
+
}, [selectedNodeData, setState, onNodeCopy, onNodeDelete]);
|
|
85
85
|
useEffect(function () {
|
|
86
86
|
setState({
|
|
87
87
|
isEditing: false
|
|
@@ -54,12 +54,12 @@ export default /*#__PURE__*/memo(function JudgeForm(props) {
|
|
|
54
54
|
logic: 'and',
|
|
55
55
|
conditions: [{
|
|
56
56
|
left: {
|
|
57
|
-
|
|
57
|
+
valueFrom: 'refer',
|
|
58
58
|
type: 'String',
|
|
59
59
|
value: void 0
|
|
60
60
|
},
|
|
61
61
|
right: {
|
|
62
|
-
|
|
62
|
+
valueFrom: 'input',
|
|
63
63
|
type: 'String',
|
|
64
64
|
value: void 0
|
|
65
65
|
},
|
|
@@ -75,12 +75,12 @@ export default /*#__PURE__*/memo(function JudgeForm(props) {
|
|
|
75
75
|
changeBranchItem(branchId, {
|
|
76
76
|
conditions: [].concat(_toConsumableArray(targetBranch.conditions || []), [{
|
|
77
77
|
left: {
|
|
78
|
-
|
|
78
|
+
valueFrom: 'refer',
|
|
79
79
|
type: 'String',
|
|
80
80
|
value: void 0
|
|
81
81
|
},
|
|
82
82
|
right: {
|
|
83
|
-
|
|
83
|
+
valueFrom: 'input',
|
|
84
84
|
type: 'String',
|
|
85
85
|
value: void 0
|
|
86
86
|
},
|
|
@@ -171,7 +171,7 @@ export var NodeMenu = /*#__PURE__*/memo(function (props) {
|
|
|
171
171
|
parentId: parentId
|
|
172
172
|
}, props.source, props.target);
|
|
173
173
|
}
|
|
174
|
-
}, [props.parentId, props.source, props.target, props.onSelect, nodes]);
|
|
174
|
+
}, [props.parentId, props.source, props.target, props.onSelect, nodes, nodesReadOnly, onAddNewNodeWithSource]);
|
|
175
175
|
return /*#__PURE__*/React.createElement("div", {
|
|
176
176
|
className: "spark-flow-node-menu h-full flex flex-col"
|
|
177
177
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -74,7 +74,7 @@ var NodeResultPanel = function NodeResultPanel(props) {
|
|
|
74
74
|
_useState2 = _slicedToArray(_useState, 2),
|
|
75
75
|
expand = _useState2[0],
|
|
76
76
|
setExpand = _useState2[1];
|
|
77
|
-
var isBatch = props.data.
|
|
77
|
+
var isBatch = props.data.isBatch && !!props.data.batches;
|
|
78
78
|
var _useState3 = useState(1),
|
|
79
79
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
80
80
|
batchIndex = _useState4[0],
|
|
@@ -96,15 +96,15 @@ var NodeResultPanel = function NodeResultPanel(props) {
|
|
|
96
96
|
var errorInfoContent = useMemo(function () {
|
|
97
97
|
if (isBatch) {
|
|
98
98
|
var _props$data$batches3;
|
|
99
|
-
return (_props$data$batches3 = props.data.batches[batchIndex - 1]) === null || _props$data$batches3 === void 0 ? void 0 : _props$data$batches3.
|
|
99
|
+
return (_props$data$batches3 = props.data.batches[batchIndex - 1]) === null || _props$data$batches3 === void 0 ? void 0 : _props$data$batches3.errorInfo;
|
|
100
100
|
}
|
|
101
|
-
return props.data.
|
|
101
|
+
return props.data.errorInfo;
|
|
102
102
|
}, [props.data, batchIndex]);
|
|
103
103
|
return /*#__PURE__*/React.createElement("div", {
|
|
104
104
|
onClick: function onClick(e) {
|
|
105
105
|
e.stopPropagation();
|
|
106
106
|
},
|
|
107
|
-
className: classNames("spark-flow-node-result-panel nodrag spark-flow-node-result-panel-".concat(props.data.
|
|
107
|
+
className: classNames("spark-flow-node-result-panel nodrag spark-flow-node-result-panel-".concat(props.data.nodeStatus), _defineProperty({}, 'spark-flow-node-result-panel-hidden', !expand))
|
|
108
108
|
}, /*#__PURE__*/React.createElement("div", {
|
|
109
109
|
className: "spark-flow-node-result-header flex flex-col gap-[4px]",
|
|
110
110
|
onClick: function onClick(e) {
|
|
@@ -119,9 +119,9 @@ var NodeResultPanel = function NodeResultPanel(props) {
|
|
|
119
119
|
className: "flex-center gap-[8px]"
|
|
120
120
|
}, /*#__PURE__*/React.createElement("span", {
|
|
121
121
|
className: "spark-flow-node-result-status"
|
|
122
|
-
}, statusNameMap[props.data.
|
|
122
|
+
}, statusNameMap[props.data.nodeStatus]), /*#__PURE__*/React.createElement("span", {
|
|
123
123
|
className: "spark-flow-node-result-time"
|
|
124
|
-
}, props.data.
|
|
124
|
+
}, props.data.nodeExecTime)), props.data.nodeStatus !== 'skip' && /*#__PURE__*/React.createElement(SparkUpLine, {
|
|
125
125
|
className: "text-base spark-flow-node-result-expand-icon"
|
|
126
126
|
})), expand && isBatch && /*#__PURE__*/React.createElement(Pagination, {
|
|
127
127
|
current: batchIndex,
|
|
@@ -138,7 +138,7 @@ var NodeResultPanel = function NodeResultPanel(props) {
|
|
|
138
138
|
onClick: function onClick(e) {
|
|
139
139
|
return e.stopPropagation();
|
|
140
140
|
}
|
|
141
|
-
}), expand && props.data.
|
|
141
|
+
}), expand && props.data.nodeStatus === 'fail' && /*#__PURE__*/React.createElement(Typography.Text, {
|
|
142
142
|
ellipsis: {
|
|
143
143
|
tooltip: {
|
|
144
144
|
title: errorInfoContent,
|
|
@@ -52,21 +52,21 @@ function TaskStatus() {
|
|
|
52
52
|
});
|
|
53
53
|
var copyRequestId = useCallback(function () {
|
|
54
54
|
if (!taskStore) return;
|
|
55
|
-
copy(taskStore.
|
|
55
|
+
copy(taskStore.requestId);
|
|
56
56
|
message.success($i18n.get({
|
|
57
57
|
id: 'spark-flow.components.TaskStatus.index.requestIdCopied',
|
|
58
58
|
dm: 'Request ID 已复制'
|
|
59
59
|
}));
|
|
60
|
-
}, [taskStore === null || taskStore === void 0 ? void 0 : taskStore.
|
|
60
|
+
}, [taskStore === null || taskStore === void 0 ? void 0 : taskStore.requestId]);
|
|
61
61
|
var dataSource = useMemo(function () {
|
|
62
62
|
var list = [];
|
|
63
|
-
taskStore.
|
|
63
|
+
taskStore.nodeResults.forEach(function (item) {
|
|
64
64
|
var _item$usages;
|
|
65
65
|
if ((_item$usages = item.usages) !== null && _item$usages !== void 0 && _item$usages.length) {
|
|
66
66
|
var _item$usages2;
|
|
67
67
|
var tokenMap = ((_item$usages2 = item.usages) === null || _item$usages2 === void 0 ? void 0 : _item$usages2.reduce(function (acc, cur) {
|
|
68
|
-
acc.input += cur.
|
|
69
|
-
acc.output += cur.
|
|
68
|
+
acc.input += cur.promptTokens;
|
|
69
|
+
acc.output += cur.completionTokens;
|
|
70
70
|
return acc;
|
|
71
71
|
}, {
|
|
72
72
|
input: 0,
|
|
@@ -76,14 +76,14 @@ function TaskStatus() {
|
|
|
76
76
|
output: 0
|
|
77
77
|
};
|
|
78
78
|
list.push(_objectSpread({
|
|
79
|
-
id: item.
|
|
80
|
-
name: item.
|
|
81
|
-
type: item.
|
|
79
|
+
id: item.nodeId,
|
|
80
|
+
name: item.nodeName,
|
|
81
|
+
type: item.nodeType
|
|
82
82
|
}, tokenMap));
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
return list;
|
|
86
|
-
}, [taskStore.
|
|
86
|
+
}, [taskStore.nodeResults]);
|
|
87
87
|
var columns = useMemo(function () {
|
|
88
88
|
return [{
|
|
89
89
|
title: $i18n.get({
|
|
@@ -129,7 +129,7 @@ function TaskStatus() {
|
|
|
129
129
|
}];
|
|
130
130
|
}, []);
|
|
131
131
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
132
|
-
className: classNames("spark-flow-task-status flex-justify-between spark-flow-task-status-".concat(taskStore.
|
|
132
|
+
className: classNames("spark-flow-task-status flex-justify-between spark-flow-task-status-".concat(taskStore.taskStatus), {
|
|
133
133
|
'spark-flow-task-status-hidden-results': !showResults
|
|
134
134
|
})
|
|
135
135
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -137,8 +137,8 @@ function TaskStatus() {
|
|
|
137
137
|
}, /*#__PURE__*/React.createElement("div", {
|
|
138
138
|
className: "flex items-center gap-[8px]"
|
|
139
139
|
}, /*#__PURE__*/React.createElement(NodeStatusIcon, {
|
|
140
|
-
status: taskStore.
|
|
141
|
-
}), /*#__PURE__*/React.createElement("span", null, statusNameMap[taskStore.
|
|
140
|
+
status: taskStore.taskStatus
|
|
141
|
+
}), /*#__PURE__*/React.createElement("span", null, statusNameMap[taskStore.taskStatus]), /*#__PURE__*/React.createElement("span", null, taskStore.taskExecTime)), /*#__PURE__*/React.createElement("div", {
|
|
142
142
|
className: "flex items-center gap-[4px]"
|
|
143
143
|
}, /*#__PURE__*/React.createElement(Popover, {
|
|
144
144
|
placement: "bottom",
|
|
@@ -170,7 +170,7 @@ function TaskStatus() {
|
|
|
170
170
|
className: "font-medium"
|
|
171
171
|
}, "Request ID"), /*#__PURE__*/React.createElement("div", {
|
|
172
172
|
className: "flex gap-[4px] items-center"
|
|
173
|
-
}, taskStore.
|
|
173
|
+
}, taskStore.requestId, /*#__PURE__*/React.createElement(SparkCopyLine, {
|
|
174
174
|
className: "cursor-pointer",
|
|
175
175
|
onClick: copyRequestId,
|
|
176
176
|
size: 16
|
|
@@ -20,10 +20,10 @@ export var useEdgesInteraction = function useEdgesInteraction() {
|
|
|
20
20
|
var source = item.source,
|
|
21
21
|
target = item.target;
|
|
22
22
|
var sourceNodeResult = cacheNodeResult[source] || val.find(function (v) {
|
|
23
|
-
return v.
|
|
23
|
+
return v.nodeId === source;
|
|
24
24
|
});
|
|
25
25
|
var targetNodeResult = cacheNodeResult[target] || val.find(function (v) {
|
|
26
|
-
return v.
|
|
26
|
+
return v.nodeId === target;
|
|
27
27
|
});
|
|
28
28
|
if (!cacheNodeResult[source]) {
|
|
29
29
|
cacheNodeResult[source] = sourceNodeResult;
|
|
@@ -32,17 +32,17 @@ export var useEdgesInteraction = function useEdgesInteraction() {
|
|
|
32
32
|
cacheNodeResult[target] = targetNodeResult;
|
|
33
33
|
}
|
|
34
34
|
if (!!sourceNodeResult && !!targetNodeResult) return _objectSpread(_objectSpread({}, item), {}, {
|
|
35
|
-
animated: targetNodeResult.
|
|
35
|
+
animated: targetNodeResult.nodeStatus === 'executing',
|
|
36
36
|
data: _objectSpread(_objectSpread({}, item.data), {}, {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
_sourceNodeStatus: sourceNodeResult.nodeStatus,
|
|
38
|
+
_targetNodeStatus: targetNodeResult.nodeStatus
|
|
39
39
|
})
|
|
40
40
|
});
|
|
41
41
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
42
42
|
animated: false,
|
|
43
43
|
data: _objectSpread(_objectSpread({}, item.data), {}, {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
_sourceNodeStatus: undefined,
|
|
45
|
+
_targetNodeStatus: undefined
|
|
46
46
|
})
|
|
47
47
|
});
|
|
48
48
|
});
|
|
@@ -56,8 +56,8 @@ export var useEdgesInteraction = function useEdgesInteraction() {
|
|
|
56
56
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
57
57
|
animated: false,
|
|
58
58
|
data: _objectSpread(_objectSpread({}, item.data), {}, {
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
_sourceNodeStatus: undefined,
|
|
60
|
+
_targetNodeStatus: undefined
|
|
61
61
|
})
|
|
62
62
|
});
|
|
63
63
|
});
|
|
@@ -10,7 +10,7 @@ export var useFlowDebugInteraction = function useFlowDebugInteraction() {
|
|
|
10
10
|
hiddenEdgeStatus = _useEdgesInteraction.hiddenEdgeStatus;
|
|
11
11
|
var updateTaskStore = useCallback(function (val) {
|
|
12
12
|
setTaskStore(val);
|
|
13
|
-
updateEdgeByNodeResults(val.
|
|
13
|
+
updateEdgeByNodeResults(val.nodeResults);
|
|
14
14
|
}, [setTaskStore, updateEdgeByNodeResults]);
|
|
15
15
|
var clearTaskStore = useCallback(function () {
|
|
16
16
|
setTaskStore(void 0);
|
|
@@ -534,10 +534,10 @@ export var useNodesInteraction = function useNodesInteraction() {
|
|
|
534
534
|
}
|
|
535
535
|
sourceHandle = _newNode.id;
|
|
536
536
|
if (_newNode.type === 'Classifier') {
|
|
537
|
-
sourceHandle = "".concat(_newNode.id, "_").concat(_newNode.data.
|
|
537
|
+
sourceHandle = "".concat(_newNode.id, "_").concat(_newNode.data.nodeParam.conditions[0].id);
|
|
538
538
|
}
|
|
539
539
|
if (_newNode.type === 'Judge') {
|
|
540
|
-
sourceHandle = "".concat(_newNode.id, "_").concat(_newNode.data.
|
|
540
|
+
sourceHandle = "".concat(_newNode.id, "_").concat(_newNode.data.nodeParam.branches[0].id);
|
|
541
541
|
}
|
|
542
542
|
newEdges.push(generateEdge({
|
|
543
543
|
source: source.id,
|
|
@@ -181,11 +181,11 @@ export var useNodesOutputParams = function useNodesOutputParams() {
|
|
|
181
181
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
182
182
|
var outputParams = [];
|
|
183
183
|
Object.keys(nodesMap).forEach(function (nodeId) {
|
|
184
|
-
var _node$data$
|
|
184
|
+
var _node$data$outputPara;
|
|
185
185
|
var node = nodesMap[nodeId];
|
|
186
|
-
if (((_node$data$
|
|
186
|
+
if (((_node$data$outputPara = node.data.outputParams) === null || _node$data$outputPara === void 0 ? void 0 : _node$data$outputPara.length) > 0) {
|
|
187
187
|
var varItems = buildOutputParamsTree(_objectSpread({
|
|
188
|
-
outputParams: node.data.
|
|
188
|
+
outputParams: node.data.outputParams,
|
|
189
189
|
nodeId: nodeId
|
|
190
190
|
}, options));
|
|
191
191
|
if (varItems.length > 0) {
|
|
@@ -213,8 +213,8 @@ export var useNodesOutputParams = function useNodesOutputParams() {
|
|
|
213
213
|
value: '${sys.query}',
|
|
214
214
|
type: 'String'
|
|
215
215
|
}, {
|
|
216
|
-
label: '
|
|
217
|
-
value: '${sys.
|
|
216
|
+
label: 'historyList',
|
|
217
|
+
value: '${sys.historyList}',
|
|
218
218
|
type: 'Array<String>'
|
|
219
219
|
}]
|
|
220
220
|
}];
|
|
@@ -12,10 +12,10 @@ export var useNodesReadOnly = function useNodesReadOnly() {
|
|
|
12
12
|
var getNodesReadOnly = useCallback(function () {
|
|
13
13
|
var _workflowStore$getSta = workflowStore.getState(),
|
|
14
14
|
taskStore = _workflowStore$getSta.taskStore;
|
|
15
|
-
return [WorkflowRunningStatus.Running, WorkflowRunningStatus.Paused].includes((taskStore === null || taskStore === void 0 ? void 0 : taskStore.
|
|
15
|
+
return [WorkflowRunningStatus.Running, WorkflowRunningStatus.Paused].includes((taskStore === null || taskStore === void 0 ? void 0 : taskStore.taskStatus) || '') || readyOnly;
|
|
16
16
|
}, [workflowStore, readyOnly]);
|
|
17
17
|
return {
|
|
18
|
-
nodesReadOnly: [WorkflowRunningStatus.Running, WorkflowRunningStatus.Paused].includes((taskStore === null || taskStore === void 0 ? void 0 : taskStore.
|
|
18
|
+
nodesReadOnly: [WorkflowRunningStatus.Running, WorkflowRunningStatus.Paused].includes((taskStore === null || taskStore === void 0 ? void 0 : taskStore.taskStatus) || '') || readyOnly,
|
|
19
19
|
getNodesReadOnly: getNodesReadOnly
|
|
20
20
|
};
|
|
21
21
|
};
|
|
@@ -45,8 +45,8 @@ export interface IPointItem {
|
|
|
45
45
|
}
|
|
46
46
|
export interface IEdgeData {
|
|
47
47
|
_hover?: boolean;
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
_sourceNodeStatus?: IWorkFlowStatus;
|
|
49
|
+
_targetNodeStatus?: IWorkFlowStatus;
|
|
50
50
|
}
|
|
51
51
|
export interface INodeDataOutputParamItem {
|
|
52
52
|
id?: string;
|
|
@@ -54,7 +54,7 @@ export interface INodeDataOutputParamItem {
|
|
|
54
54
|
type?: IValueType;
|
|
55
55
|
desc?: string;
|
|
56
56
|
required?: boolean;
|
|
57
|
-
|
|
57
|
+
valueFrom?: 'refer' | 'input' | 'clear';
|
|
58
58
|
properties?: INodeDataOutputParamItem[];
|
|
59
59
|
}
|
|
60
60
|
export interface INodeDataInputParamItem {
|
|
@@ -62,15 +62,15 @@ export interface INodeDataInputParamItem {
|
|
|
62
62
|
key: string;
|
|
63
63
|
type?: IValueType;
|
|
64
64
|
value?: string;
|
|
65
|
-
|
|
65
|
+
valueFrom?: 'refer' | 'input' | 'clear';
|
|
66
66
|
/** Whether the parameter is required */
|
|
67
67
|
required?: boolean;
|
|
68
68
|
}
|
|
69
69
|
export type IWorkFlowNodeData<T = any> = {
|
|
70
70
|
label: string;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
inputParams: INodeDataInputParamItem[];
|
|
72
|
+
outputParams: INodeDataOutputParamItem[];
|
|
73
|
+
nodeParam: T;
|
|
74
74
|
desc?: string;
|
|
75
75
|
};
|
|
76
76
|
export interface IConditionItem {
|
|
@@ -85,10 +85,10 @@ export interface IBranchItem {
|
|
|
85
85
|
conditions?: IConditionItem[];
|
|
86
86
|
}
|
|
87
87
|
export interface ICheckListItem {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
nodeId: string;
|
|
89
|
+
nodeType: string;
|
|
90
|
+
nodeName: string;
|
|
91
|
+
errorMsgs: {
|
|
92
92
|
label: string;
|
|
93
93
|
error: string;
|
|
94
94
|
}[];
|
|
@@ -112,50 +112,50 @@ export interface IUserInputItem {
|
|
|
112
112
|
required?: boolean;
|
|
113
113
|
}
|
|
114
114
|
export interface IWorkFlowTaskResultItem {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
nodeType: string;
|
|
116
|
+
nodeName: string;
|
|
117
|
+
nodeId: string;
|
|
118
|
+
nodeContent: string | IUserInputItem[];
|
|
119
|
+
nodeStatus: IWorkFlowStatus;
|
|
120
|
+
parentNodeId?: string;
|
|
121
121
|
}
|
|
122
122
|
export interface IWorkFlowNodeResultItem {
|
|
123
|
-
|
|
123
|
+
isBatch: boolean;
|
|
124
124
|
retry?: {
|
|
125
125
|
happened: boolean;
|
|
126
|
-
|
|
126
|
+
retryTimes: number;
|
|
127
127
|
};
|
|
128
128
|
input?: string;
|
|
129
129
|
output?: string;
|
|
130
130
|
usages?: {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
promptTokens: number;
|
|
132
|
+
completionTokens: number;
|
|
133
|
+
totalTokens: number;
|
|
134
134
|
}[];
|
|
135
135
|
batches: IWorkFlowNodeResultItem[];
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
isMultiBranch: boolean;
|
|
137
|
+
multiBranchResults?: {
|
|
138
|
+
conditionId: string;
|
|
139
|
+
targetIds: string[];
|
|
140
140
|
}[];
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
nodeId: string;
|
|
142
|
+
nodeName: string;
|
|
143
|
+
nodeType: string;
|
|
144
|
+
nodeStatus: IWorkFlowStatus;
|
|
145
|
+
parentNodeId?: string;
|
|
146
|
+
outputType: 'json' | 'text';
|
|
147
|
+
nodeExecTime: string;
|
|
148
|
+
tryCatch?: {
|
|
149
149
|
happened: boolean;
|
|
150
150
|
strategy: string;
|
|
151
151
|
};
|
|
152
|
-
|
|
152
|
+
shortMemory?: {
|
|
153
153
|
round: number;
|
|
154
|
-
|
|
154
|
+
currentSelfChatMessages: {
|
|
155
155
|
role?: string;
|
|
156
156
|
content?: any;
|
|
157
157
|
name?: string;
|
|
158
|
-
|
|
158
|
+
toolCalls?: Array<{
|
|
159
159
|
id: string;
|
|
160
160
|
type: string;
|
|
161
161
|
index: number;
|
|
@@ -168,21 +168,21 @@ export interface IWorkFlowNodeResultItem {
|
|
|
168
168
|
audio?: {
|
|
169
169
|
id: string;
|
|
170
170
|
data: string;
|
|
171
|
-
|
|
171
|
+
expiresAt: number;
|
|
172
172
|
transcript: string;
|
|
173
173
|
};
|
|
174
174
|
}[];
|
|
175
175
|
};
|
|
176
|
-
|
|
176
|
+
errorInfo?: string;
|
|
177
177
|
}
|
|
178
178
|
export interface IWorkFlowTaskProcess {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
179
|
+
taskId: string;
|
|
180
|
+
conversationId?: string;
|
|
181
|
+
requestId: string;
|
|
182
|
+
taskStatus: IWorkFlowStatus;
|
|
183
|
+
taskResults: IWorkFlowTaskResultItem[];
|
|
184
|
+
errorCode?: string;
|
|
185
|
+
errorInfo?: string;
|
|
186
|
+
taskExecTime: string;
|
|
187
|
+
nodeResults: IWorkFlowNodeResultItem[];
|
|
188
188
|
}
|
package/dist/utils/index.js
CHANGED
|
@@ -205,9 +205,9 @@ export var layoutFlow = /*#__PURE__*/function () {
|
|
|
205
205
|
};
|
|
206
206
|
}();
|
|
207
207
|
export var getParentInputParams = function getParentInputParams(node) {
|
|
208
|
-
var
|
|
208
|
+
var inputParams = node.data.inputParams;
|
|
209
209
|
var list = [];
|
|
210
|
-
|
|
210
|
+
inputParams.forEach(function (item) {
|
|
211
211
|
var _item$type;
|
|
212
212
|
if ((_item$type = item.type) !== null && _item$type !== void 0 && _item$type.includes('Array') && !!item.value) {
|
|
213
213
|
var arrayType = item.type.replace(/^Array<(.+)>$/, '$1');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentscope-ai/flow",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A powerful and flexible flow canvas rendering engine designed for AI applications. Provides comprehensive workflow visualization and interaction capabilities for platforms like Bailian and AgentScope, enabling seamless creation and management of complex AI agent workflows with an intuitive drag-and-drop interface.",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|