@agentscope-ai/flow 0.0.1

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 (176) hide show
  1. package/README.zh-CN.md +67 -0
  2. package/dist/components/base-node/index.d.ts +27 -0
  3. package/dist/components/base-node/index.js +320 -0
  4. package/dist/components/base-node/index.less +258 -0
  5. package/dist/components/branch-title-header/index.d.ts +12 -0
  6. package/dist/components/branch-title-header/index.js +176 -0
  7. package/dist/components/branch-title-header/index.less +28 -0
  8. package/dist/components/check-list-btn/index.d.ts +4 -0
  9. package/dist/components/check-list-btn/index.js +144 -0
  10. package/dist/components/check-list-btn/index.less +113 -0
  11. package/dist/components/code-input/index.d.ts +24 -0
  12. package/dist/components/code-input/index.js +356 -0
  13. package/dist/components/code-input/index.less +87 -0
  14. package/dist/components/condition-item/index.d.ts +13 -0
  15. package/dist/components/condition-item/index.js +185 -0
  16. package/dist/components/condition-item/index.less +23 -0
  17. package/dist/components/custom-connection-line/index.d.ts +4 -0
  18. package/dist/components/custom-connection-line/index.js +28 -0
  19. package/dist/components/custom-handle/source-handle.d.ts +10 -0
  20. package/dist/components/custom-handle/source-handle.js +45 -0
  21. package/dist/components/custom-handle/target-handle.d.ts +6 -0
  22. package/dist/components/custom-handle/target-handle.js +21 -0
  23. package/dist/components/custom-inputs-control/index.d.ts +56 -0
  24. package/dist/components/custom-inputs-control/index.js +366 -0
  25. package/dist/components/custom-inputs-control/index.less +28 -0
  26. package/dist/components/custom-outputs-form/index.d.ts +24 -0
  27. package/dist/components/custom-outputs-form/index.js +346 -0
  28. package/dist/components/custom-outputs-form/index.less +51 -0
  29. package/dist/components/drag-panel/index.d.ts +10 -0
  30. package/dist/components/drag-panel/index.js +79 -0
  31. package/dist/components/drag-panel/index.less +23 -0
  32. package/dist/components/draggable-with-handle/index.d.ts +13 -0
  33. package/dist/components/draggable-with-handle/index.js +81 -0
  34. package/dist/components/draggable-with-handle/index.less +23 -0
  35. package/dist/components/flow-aside/index.d.ts +4 -0
  36. package/dist/components/flow-aside/index.js +62 -0
  37. package/dist/components/flow-aside/index.less +84 -0
  38. package/dist/components/flow-base-edge/index.d.ts +5 -0
  39. package/dist/components/flow-base-edge/index.js +226 -0
  40. package/dist/components/flow-base-edge/index.less +28 -0
  41. package/dist/components/flow-base-edge/linear-gradient-svg.d.ts +21 -0
  42. package/dist/components/flow-base-edge/linear-gradient-svg.js +32 -0
  43. package/dist/components/flow-icon/index.d.ts +9 -0
  44. package/dist/components/flow-icon/index.js +30 -0
  45. package/dist/components/flow-icon/index.less +20 -0
  46. package/dist/components/flow-mini-map/index.d.ts +4 -0
  47. package/dist/components/flow-mini-map/index.js +26 -0
  48. package/dist/components/flow-mini-map/index.less +22 -0
  49. package/dist/components/flow-panel/config-panel.d.ts +15 -0
  50. package/dist/components/flow-panel/config-panel.js +303 -0
  51. package/dist/components/flow-panel/index.d.ts +7 -0
  52. package/dist/components/flow-panel/index.js +7 -0
  53. package/dist/components/flow-panel/index.less +85 -0
  54. package/dist/components/flow-panel/panel-container.d.ts +12 -0
  55. package/dist/components/flow-panel/panel-container.js +25 -0
  56. package/dist/components/flow-tools/add-node-btn.d.ts +3 -0
  57. package/dist/components/flow-tools/add-node-btn.js +26 -0
  58. package/dist/components/flow-tools/history-btn.d.ts +3 -0
  59. package/dist/components/flow-tools/history-btn.js +59 -0
  60. package/dist/components/flow-tools/index.d.ts +4 -0
  61. package/dist/components/flow-tools/index.js +29 -0
  62. package/dist/components/flow-tools/index.less +82 -0
  63. package/dist/components/flow-tools/layout-btn.d.ts +3 -0
  64. package/dist/components/flow-tools/layout-btn.js +27 -0
  65. package/dist/components/flow-tools/mini-map-btn.d.ts +3 -0
  66. package/dist/components/flow-tools/mini-map-btn.js +32 -0
  67. package/dist/components/flow-tools/scale-btn.d.ts +3 -0
  68. package/dist/components/flow-tools/scale-btn.js +101 -0
  69. package/dist/components/flow-tools/short-key-btn.d.ts +3 -0
  70. package/dist/components/flow-tools/short-key-btn.js +38 -0
  71. package/dist/components/flow-tools/short-key-content.d.ts +4 -0
  72. package/dist/components/flow-tools/short-key-content.js +153 -0
  73. package/dist/components/flow-tools/short-key-content.less +38 -0
  74. package/dist/components/flow-tools/touch-mode-btn.d.ts +3 -0
  75. package/dist/components/flow-tools/touch-mode-btn.js +89 -0
  76. package/dist/components/input-text-area/index.d.ts +16 -0
  77. package/dist/components/input-text-area/index.js +74 -0
  78. package/dist/components/input-text-area/index.less +30 -0
  79. package/dist/components/judge-form/index.d.ts +13 -0
  80. package/dist/components/judge-form/index.js +182 -0
  81. package/dist/components/judge-form/index.less +11 -0
  82. package/dist/components/node-menu/index.d.ts +35 -0
  83. package/dist/components/node-menu/index.js +266 -0
  84. package/dist/components/node-menu/index.less +79 -0
  85. package/dist/components/node-resizer/index.d.ts +11 -0
  86. package/dist/components/node-resizer/index.js +46 -0
  87. package/dist/components/node-resizer/index.less +12 -0
  88. package/dist/components/node-result-panel/index.d.ts +9 -0
  89. package/dist/components/node-result-panel/index.js +155 -0
  90. package/dist/components/node-result-panel/index.less +132 -0
  91. package/dist/components/node-tree/index.d.ts +4 -0
  92. package/dist/components/node-tree/index.js +213 -0
  93. package/dist/components/node-tree/index.less +51 -0
  94. package/dist/components/output-params-tree/index.d.ts +10 -0
  95. package/dist/components/output-params-tree/index.js +34 -0
  96. package/dist/components/output-params-tree/index.less +27 -0
  97. package/dist/components/script-code-mirror/index.d.ts +14 -0
  98. package/dist/components/script-code-mirror/index.js +162 -0
  99. package/dist/components/script-code-mirror/index.less +11 -0
  100. package/dist/components/script-edit-modal/index.d.ts +30 -0
  101. package/dist/components/script-edit-modal/index.js +84 -0
  102. package/dist/components/script-edit-modal/index.less +24 -0
  103. package/dist/components/select-with-desc/index.d.ts +5 -0
  104. package/dist/components/select-with-desc/index.js +20 -0
  105. package/dist/components/select-with-desc/index.less +11 -0
  106. package/dist/components/task-status/index.d.ts +4 -0
  107. package/dist/components/task-status/index.js +209 -0
  108. package/dist/components/task-status/index.less +65 -0
  109. package/dist/components/var-input-text-area/index.d.ts +17 -0
  110. package/dist/components/var-input-text-area/index.js +211 -0
  111. package/dist/components/var-input-text-area/index.less +64 -0
  112. package/dist/components/var-type-prefix/index.d.ts +17 -0
  113. package/dist/components/var-type-prefix/index.js +21 -0
  114. package/dist/components/variable-input/index.d.ts +24 -0
  115. package/dist/components/variable-input/index.js +163 -0
  116. package/dist/components/variable-input/index.less +13 -0
  117. package/dist/components/variable-tree-select/index.d.ts +33 -0
  118. package/dist/components/variable-tree-select/index.js +160 -0
  119. package/dist/components/variable-tree-select/index.less +61 -0
  120. package/dist/constant/index.d.ts +61 -0
  121. package/dist/constant/index.js +515 -0
  122. package/dist/flow/animate.css +5 -0
  123. package/dist/flow/context.d.ts +12 -0
  124. package/dist/flow/context.js +44 -0
  125. package/dist/flow/index.d.ts +13 -0
  126. package/dist/flow/index.js +162 -0
  127. package/dist/flow/index.less +72 -0
  128. package/dist/hooks/index.d.ts +10 -0
  129. package/dist/hooks/index.js +10 -0
  130. package/dist/hooks/use-edges-interaction.d.ts +11 -0
  131. package/dist/hooks/use-edges-interaction.js +125 -0
  132. package/dist/hooks/use-flow-debug-interaction.d.ts +5 -0
  133. package/dist/hooks/use-flow-debug-interaction.js +23 -0
  134. package/dist/hooks/use-flow-interaction.d.ts +12 -0
  135. package/dist/hooks/use-flow-interaction.js +173 -0
  136. package/dist/hooks/use-flow-key-press.d.ts +1 -0
  137. package/dist/hooks/use-flow-key-press.js +32 -0
  138. package/dist/hooks/use-flow-save.d.ts +5 -0
  139. package/dist/hooks/use-flow-save.js +47 -0
  140. package/dist/hooks/use-flow-view-port.d.ts +7 -0
  141. package/dist/hooks/use-flow-view-port.js +46 -0
  142. package/dist/hooks/use-history.d.ts +21 -0
  143. package/dist/hooks/use-history.js +80 -0
  144. package/dist/hooks/use-nodes-interaction.d.ts +34 -0
  145. package/dist/hooks/use-nodes-interaction.js +777 -0
  146. package/dist/hooks/use-nodes-output-params.d.ts +31 -0
  147. package/dist/hooks/use-nodes-output-params.js +300 -0
  148. package/dist/hooks/use-nodes-update.d.ts +9 -0
  149. package/dist/hooks/use-nodes-update.js +38 -0
  150. package/dist/hooks/use-work-flow.d.ts +4 -0
  151. package/dist/hooks/use-work-flow.js +21 -0
  152. package/dist/i18n/i18n.d.ts +62 -0
  153. package/dist/i18n/i18n.js +111 -0
  154. package/dist/i18n/index.d.ts +3 -0
  155. package/dist/i18n/index.js +12 -0
  156. package/dist/i18n/locales/en-us.json +327 -0
  157. package/dist/i18n/locales/ja-jp.json +300 -0
  158. package/dist/i18n/locales/zh-cn.json +327 -0
  159. package/dist/index.css +1 -0
  160. package/dist/index.d.ts +47 -0
  161. package/dist/index.js +47 -0
  162. package/dist/index.less +1 -0
  163. package/dist/store/index.d.ts +70 -0
  164. package/dist/store/index.js +146 -0
  165. package/dist/tailwind.css +28 -0
  166. package/dist/types/work-flow.d.ts +188 -0
  167. package/dist/types/work-flow.js +1 -0
  168. package/dist/utils/default-values.d.ts +2 -0
  169. package/dist/utils/default-values.js +16 -0
  170. package/dist/utils/index.d.ts +39 -0
  171. package/dist/utils/index.js +273 -0
  172. package/dist/utils/unique-id.d.ts +2 -0
  173. package/dist/utils/unique-id.js +39 -0
  174. package/dist/utils/work-flow.d.ts +17 -0
  175. package/dist/utils/work-flow.js +44 -0
  176. package/package.json +78 -0
@@ -0,0 +1,162 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ import { autocompletion } from '@codemirror/autocomplete';
9
+ import { javascript } from '@codemirror/lang-javascript';
10
+ import { python } from '@codemirror/lang-python';
11
+ import { StateEffect, StateField } from '@codemirror/state';
12
+ import { EditorView } from '@codemirror/view';
13
+ import { vscodeDark, vscodeLight } from '@uiw/codemirror-theme-vscode';
14
+ import ReactCodeMirror from '@uiw/react-codemirror';
15
+ import React, { memo, useMemo } from 'react';
16
+ import "./index.less";
17
+ // 创建一个 StateEffect 来更新 IME 状态
18
+ var setIMEComposing = StateEffect.define();
19
+
20
+ // 创建一个 StateField 来存储 IME 是否正在输入
21
+ var imeComposingField = StateField.define({
22
+ create: function create() {
23
+ return false;
24
+ },
25
+ update: function update(value, tr) {
26
+ var _iterator = _createForOfIteratorHelper(tr.effects),
27
+ _step;
28
+ try {
29
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
30
+ var effect = _step.value;
31
+ if (effect.is(setIMEComposing)) {
32
+ return effect.value;
33
+ }
34
+ }
35
+ } catch (err) {
36
+ _iterator.e(err);
37
+ } finally {
38
+ _iterator.f();
39
+ }
40
+ return value;
41
+ }
42
+ });
43
+ var generateTypeDefinitions = function generateTypeDefinitions(inputParams, language) {
44
+ if (language === 'javascript') {
45
+ // generate input parameter type
46
+ var inputTypeDef = inputParams.map(function (param) {
47
+ return "".concat(param.key, ": ").concat(param.type);
48
+ }).join(',\n ');
49
+ return "type InputParams = {\n ".concat(inputTypeDef, "\n};\n\nfunction process(params: InputParams): void {\n const input = params;\n \n // Write your code here\n return output;\n}");
50
+ } else {
51
+ var _inputTypeDef = inputParams.map(function (param) {
52
+ return "".concat(param.key, ": ").concat(param.type);
53
+ }).join('\n ');
54
+ return "from typing import TypedDict, Dict, Any\n\nclass InputParams(TypedDict):\n ".concat(_inputTypeDef, "\n\ndef process(params: InputParams):\n input = params\n \n # Write your code here\n return output");
55
+ }
56
+ };
57
+ var createCompletionSource = function createCompletionSource(inputParams) {
58
+ return function (context) {
59
+ // 检查 IME 是否正在输入
60
+ var isComposing = context.state.field(imeComposingField, false);
61
+ if (isComposing) {
62
+ console.log('IME composing, blocking autocomplete');
63
+ return null;
64
+ }
65
+
66
+ // 恢复原来的匹配逻辑:匹配任意单词字符
67
+ var word = context.matchBefore(/\w*/);
68
+ if (!word) return null;
69
+ var completions = _toConsumableArray(inputParams.map(function (param) {
70
+ return {
71
+ label: "params.".concat(param.key),
72
+ type: 'variable',
73
+ info: "Params parameter: ".concat(param.key, " (").concat(param.type, ")")
74
+ };
75
+ }));
76
+ return {
77
+ from: word.from,
78
+ options: completions
79
+ };
80
+ };
81
+ };
82
+
83
+ // 创建 IME 事件监听扩展
84
+ var createIMEExtension = function createIMEExtension() {
85
+ var compositionEndTimer = null;
86
+ return EditorView.domEventHandlers({
87
+ compositionstart: function compositionstart(event, view) {
88
+ console.log('compositionstart');
89
+ // 清除之前的定时器
90
+ if (compositionEndTimer) {
91
+ clearTimeout(compositionEndTimer);
92
+ compositionEndTimer = null;
93
+ }
94
+ // 设置 IME 正在输入
95
+ view.dispatch({
96
+ effects: setIMEComposing.of(true)
97
+ });
98
+ },
99
+ compositionend: function compositionend(event, view) {
100
+ console.log('compositionend');
101
+ // compositionend 后延迟一段时间再允许自动补全
102
+ // 这样可以避免输入法上屏的瞬间触发自动补全
103
+ compositionEndTimer = setTimeout(function () {
104
+ view.dispatch({
105
+ effects: setIMEComposing.of(false)
106
+ });
107
+ compositionEndTimer = null;
108
+ }, 150);
109
+ }
110
+ });
111
+ };
112
+
113
+ // create an extension to hide type definitions
114
+ var createHiddenTypeDefinitions = function createHiddenTypeDefinitions(typeDefinitions, onChange) {
115
+ return EditorView.updateListener.of(function (update) {
116
+ if (update.docChanged) {
117
+ var _content$split$pop;
118
+ // get the current document content
119
+ var content = update.state.doc.toString();
120
+ // remove the type definition part, only keep the user code
121
+ var userCode = ((_content$split$pop = content.split('// Write your code here').pop()) === null || _content$split$pop === void 0 ? void 0 : _content$split$pop.trim()) || '';
122
+ onChange(userCode);
123
+ }
124
+ });
125
+ };
126
+ export default /*#__PURE__*/memo(function ScriptCodeMirror(props) {
127
+ var _props$theme = props.theme,
128
+ theme = _props$theme === void 0 ? 'dark' : _props$theme,
129
+ inputParams = props.inputParams,
130
+ outputParams = props.outputParams,
131
+ language = props.language;
132
+ var typeDefinitions = useMemo(function () {
133
+ return generateTypeDefinitions(inputParams, language);
134
+ }, [inputParams, language]);
135
+ var extensions = useMemo(function () {
136
+ var baseExtensions = [imeComposingField,
137
+ // IME 输入状态字段
138
+ createIMEExtension(),
139
+ // IME 事件监听
140
+ autocompletion({
141
+ override: [createCompletionSource(inputParams)],
142
+ activateOnTyping: true // 保持自动触发
143
+ }), createHiddenTypeDefinitions(typeDefinitions, props.onChange)];
144
+ switch (language) {
145
+ case 'javascript':
146
+ return [].concat(baseExtensions, [javascript({
147
+ typescript: true
148
+ })]);
149
+ case 'python':
150
+ return [].concat(baseExtensions, [python()]);
151
+ }
152
+ }, [language, inputParams, outputParams, typeDefinitions, props.onChange]);
153
+ return /*#__PURE__*/React.createElement(ReactCodeMirror, {
154
+ className: "script-code-mirror",
155
+ value: props.value,
156
+ onChange: props.onChange,
157
+ lang: language,
158
+ extensions: extensions,
159
+ readOnly: props.disabled,
160
+ theme: theme === 'dark' ? vscodeDark : vscodeLight
161
+ });
162
+ });
@@ -0,0 +1,11 @@
1
+ .script-code-mirror {
2
+ border-radius: 6px;
3
+
4
+ .cm-editor {
5
+ border-radius: 6px;
6
+ }
7
+
8
+ .cm-gutters {
9
+ border-radius: 6px 0 0 6px;
10
+ }
11
+ }
@@ -0,0 +1,30 @@
1
+ import { INodeDataInputParamItem, INodeDataOutputParamItem } from "../../types/work-flow";
2
+ import React from 'react';
3
+ import './index.less';
4
+ export declare const SCRIPT_TYPE_OPTIONS: {
5
+ label: string;
6
+ value: string;
7
+ }[];
8
+ export declare const CODE_DEMO_MAP: {
9
+ python: string;
10
+ javascript: string;
11
+ };
12
+ export interface IScriptEditModalProps {
13
+ language: 'python' | 'javascript';
14
+ value: string;
15
+ inputParams: INodeDataInputParamItem[];
16
+ outputParams: INodeDataOutputParamItem[];
17
+ onClose: () => void;
18
+ onOk: (val: {
19
+ language: IScriptEditModalProps['language'];
20
+ value: IScriptEditModalProps['value'];
21
+ }) => void;
22
+ disabled?: boolean;
23
+ codeDemoMap?: Record<string, string>;
24
+ scriptTypeOptions?: {
25
+ label: string;
26
+ value: string;
27
+ }[];
28
+ zIndex?: number;
29
+ }
30
+ export default function ScriptEditModal(props: IScriptEditModalProps): React.JSX.Element;
@@ -0,0 +1,84 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import $i18n from "../../i18n";
8
+ import { Modal } from '@agentscope-ai/design';
9
+ import { useSetState } from 'ahooks';
10
+ import { Segmented } from 'antd';
11
+ import React from 'react';
12
+ import ScriptCodeMirror from "../script-code-mirror";
13
+ import "./index.less";
14
+ export var SCRIPT_TYPE_OPTIONS = [{
15
+ label: 'Python',
16
+ value: 'python'
17
+ }, {
18
+ label: 'JavaScript',
19
+ value: 'javascript'
20
+ }];
21
+ export var CODE_DEMO_MAP = {
22
+ python: "def main():\n ret = {\n \"output\": params['input1'] + params['input2'] \n }\n return ret",
23
+ javascript: "function main() {\n const ret = {\n \"output\": params.input1 + params.input2\n };\n return ret;\n}"
24
+ };
25
+ export default function ScriptEditModal(props) {
26
+ var _props$codeDemoMap = props.codeDemoMap,
27
+ codeDemoMap = _props$codeDemoMap === void 0 ? CODE_DEMO_MAP : _props$codeDemoMap,
28
+ _props$scriptTypeOpti = props.scriptTypeOptions,
29
+ scriptTypeOptions = _props$scriptTypeOpti === void 0 ? SCRIPT_TYPE_OPTIONS : _props$scriptTypeOpti;
30
+ var _useSetState = useSetState({
31
+ language: props.language,
32
+ value: props.value
33
+ }),
34
+ _useSetState2 = _slicedToArray(_useSetState, 2),
35
+ state = _useSetState2[0],
36
+ setState = _useSetState2[1];
37
+ var handleChangeLanguage = function handleChangeLanguage(val) {
38
+ setState({
39
+ language: val,
40
+ value: codeDemoMap[val]
41
+ });
42
+ };
43
+ return /*#__PURE__*/React.createElement(Modal, {
44
+ open: true,
45
+ width: 'calc(100vw - 16px)',
46
+ height: 'calc(100vh - 16px)',
47
+ className: "spark-flow-script-edit-modal",
48
+ onOk: function onOk() {
49
+ return props.onOk({
50
+ language: state.language,
51
+ value: state.value
52
+ });
53
+ },
54
+ onCancel: props.onClose,
55
+ okButtonProps: {
56
+ disabled: props.disabled
57
+ },
58
+ title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, $i18n.get({
59
+ id: 'spark-flow.ScriptEditModal.index.scriptConversionCodeEditor',
60
+ dm: '脚本转换:代码编辑'
61
+ })), /*#__PURE__*/React.createElement(Segmented, {
62
+ disabled: props.disabled,
63
+ value: state.language,
64
+ options: scriptTypeOptions,
65
+ onChange: function onChange(val) {
66
+ return handleChangeLanguage(val);
67
+ }
68
+ })),
69
+ zIndex: props.zIndex
70
+ }, /*#__PURE__*/React.createElement("div", {
71
+ className: "spark-flow-script-edit-modal-editor"
72
+ }, /*#__PURE__*/React.createElement(ScriptCodeMirror, {
73
+ disabled: props.disabled,
74
+ inputParams: props.inputParams,
75
+ outputParams: props.outputParams,
76
+ value: state.value,
77
+ onChange: function onChange(val) {
78
+ return setState({
79
+ value: val
80
+ });
81
+ },
82
+ language: state.language
83
+ })));
84
+ }
@@ -0,0 +1,24 @@
1
+ @import '../../index.less';
2
+
3
+ .spark-flow-script-edit-modal {
4
+ margin: 8px!important;
5
+ max-width: 100vw!important;
6
+ top: 0px!important;
7
+ .@{ant-prefix}-modal-header {
8
+ position: relative;
9
+
10
+ .@{ant-prefix}-segmented {
11
+ position: absolute;
12
+ top: 50%;
13
+ left: 50%;
14
+ transform: translate(-50%, -50%);
15
+ }
16
+ }
17
+
18
+ &-editor {
19
+ .cm-theme, .cm-editor {
20
+ height: calc(100vh - 20px - 20px - 65px - 65px - 16px);
21
+ min-width: 400px;
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,5 @@
1
+ import { SelectProps } from '@agentscope-ai/design';
2
+ import React from 'react';
3
+ import './index.less';
4
+ declare const _default: React.NamedExoticComponent<SelectProps<any, import("antd/es/select").DefaultOptionType>>;
5
+ export default _default;
@@ -0,0 +1,20 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ import { Select } from '@agentscope-ai/design';
3
+ import { Typography } from 'antd';
4
+ import React, { memo } from 'react';
5
+ import "./index.less";
6
+ export default /*#__PURE__*/memo(function SelectWithDesc(props) {
7
+ return /*#__PURE__*/React.createElement(Select, _extends({}, props, {
8
+ optionRender: function optionRender(item) {
9
+ return /*#__PURE__*/React.createElement("div", {
10
+ className: 'spark-flow-select-with-desc-item'
11
+ }, /*#__PURE__*/React.createElement("div", null, item.label), !!item.data.desc && /*#__PURE__*/React.createElement(Typography.Paragraph, {
12
+ ellipsis: {
13
+ rows: 2,
14
+ tooltip: item.data.desc
15
+ },
16
+ className: 'spark-flow-select-with-desc-item-desc'
17
+ }, item.data.desc));
18
+ }
19
+ }));
20
+ });
@@ -0,0 +1,11 @@
1
+ @import '../../index.less';
2
+
3
+ .spark-flow-select-with-desc-item {
4
+ .spark-flow-select-with-desc-item-desc {
5
+ color: e('var(--@{ant-prefix}-color-text-secondary)');
6
+ font-size: 12px;
7
+ line-height: 18px;
8
+ white-space: wrap;
9
+ margin: 0;
10
+ }
11
+ }
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ declare const _default: React.MemoExoticComponent<() => React.JSX.Element | null>;
4
+ export default _default;
@@ -0,0 +1,209 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { useStore } from "../../flow/context";
8
+ import $i18n from "../../i18n";
9
+ import { Button, copy, Popover, Tag } from '@agentscope-ai/design';
10
+ import { SparkCode01Line, SparkCopyLine, SparkHideLine, SparkTokenLine } from '@agentscope-ai/icons';
11
+ import { Flex, message, Table, Typography } from 'antd';
12
+ import classNames from 'classnames';
13
+ import React, { memo, useCallback, useMemo } from 'react';
14
+ import { NodeStatusIcon } from "../base-node";
15
+ import FlowIcon from "../flow-icon";
16
+ import "./index.less";
17
+ var statusNameMap = {
18
+ success: $i18n.get({
19
+ id: 'spark-flow.components.TaskStatus.index.runSuccess',
20
+ dm: '运行成功'
21
+ }),
22
+ executing: $i18n.get({
23
+ id: 'spark-flow.components.TaskStatus.index.running',
24
+ dm: '运行中'
25
+ }),
26
+ skip: $i18n.get({
27
+ id: 'spark-flow.components.TaskStatus.index.skipped',
28
+ dm: '跳过'
29
+ }),
30
+ fail: $i18n.get({
31
+ id: 'spark-flow.components.TaskStatus.index.runFailed',
32
+ dm: '运行失败'
33
+ }),
34
+ stop: $i18n.get({
35
+ id: 'spark-flow.components.TaskStatus.index.stopped',
36
+ dm: '已停止'
37
+ }),
38
+ wait: $i18n.get({
39
+ id: 'spark-flow.components.TaskStatus.index.paused',
40
+ dm: '已暂停'
41
+ })
42
+ };
43
+ function TaskStatus() {
44
+ var taskStore = useStore(function (state) {
45
+ return state.taskStore;
46
+ });
47
+ var showResults = useStore(function (state) {
48
+ return state.showResults;
49
+ });
50
+ var setShowResults = useStore(function (state) {
51
+ return state.setShowResults;
52
+ });
53
+ var copyRequestId = useCallback(function () {
54
+ if (!taskStore) return;
55
+ copy(taskStore.request_id);
56
+ message.success($i18n.get({
57
+ id: 'spark-flow.components.TaskStatus.index.requestIdCopied',
58
+ dm: 'Request ID 已复制'
59
+ }));
60
+ }, [taskStore === null || taskStore === void 0 ? void 0 : taskStore.request_id]);
61
+ var dataSource = useMemo(function () {
62
+ var list = [];
63
+ taskStore.node_results.forEach(function (item) {
64
+ var _item$usages;
65
+ if ((_item$usages = item.usages) !== null && _item$usages !== void 0 && _item$usages.length) {
66
+ var _item$usages2;
67
+ var tokenMap = ((_item$usages2 = item.usages) === null || _item$usages2 === void 0 ? void 0 : _item$usages2.reduce(function (acc, cur) {
68
+ acc.input += cur.prompt_tokens;
69
+ acc.output += cur.completion_tokens;
70
+ return acc;
71
+ }, {
72
+ input: 0,
73
+ output: 0
74
+ })) || {
75
+ input: 0,
76
+ output: 0
77
+ };
78
+ list.push(_objectSpread({
79
+ id: item.node_id,
80
+ name: item.node_name,
81
+ type: item.node_type
82
+ }, tokenMap));
83
+ }
84
+ });
85
+ return list;
86
+ }, [taskStore.node_results]);
87
+ var columns = useMemo(function () {
88
+ return [{
89
+ title: $i18n.get({
90
+ id: 'spark-flow.components.TaskStatus.index.nodeId',
91
+ dm: '节点ID'
92
+ }),
93
+ dataIndex: 'id'
94
+ }, {
95
+ title: $i18n.get({
96
+ id: 'spark-flow.components.TaskStatus.index.nodeType',
97
+ dm: '节点类型'
98
+ }),
99
+ dataIndex: 'type',
100
+ render: function render(_, record) {
101
+ return /*#__PURE__*/React.createElement(Flex, {
102
+ gap: 8,
103
+ align: "center"
104
+ }, /*#__PURE__*/React.createElement("span", {
105
+ className: "flex-shrink-0"
106
+ }, /*#__PURE__*/React.createElement(FlowIcon, {
107
+ nodeType: record.type
108
+ })), /*#__PURE__*/React.createElement(Typography.Text, {
109
+ ellipsis: {
110
+ tooltip: true
111
+ },
112
+ style: {
113
+ maxWidth: 120
114
+ }
115
+ }, record.name));
116
+ }
117
+ }, {
118
+ title: $i18n.get({
119
+ id: 'spark-flow.components.TaskStatus.index.inputTokens',
120
+ dm: '输入Tokens'
121
+ }),
122
+ dataIndex: 'input'
123
+ }, {
124
+ title: $i18n.get({
125
+ id: 'spark-flow.components.TaskStatus.index.outputTokens',
126
+ dm: '输出Tokens'
127
+ }),
128
+ dataIndex: 'output'
129
+ }];
130
+ }, []);
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.task_status), {
133
+ 'spark-flow-task-status-hidden-results': !showResults
134
+ })
135
+ }, /*#__PURE__*/React.createElement("div", {
136
+ className: "gap-[16px] flex items-center"
137
+ }, /*#__PURE__*/React.createElement("div", {
138
+ className: "flex items-center gap-[8px]"
139
+ }, /*#__PURE__*/React.createElement(NodeStatusIcon, {
140
+ status: taskStore.task_status
141
+ }), /*#__PURE__*/React.createElement("span", null, statusNameMap[taskStore.task_status]), /*#__PURE__*/React.createElement("span", null, taskStore.task_exec_time)), /*#__PURE__*/React.createElement("div", {
142
+ className: "flex items-center gap-[4px]"
143
+ }, /*#__PURE__*/React.createElement(Popover, {
144
+ placement: "bottom",
145
+ rootClassName: "spark-flow-task-token-popover",
146
+ getPopupContainer: function getPopupContainer(ele) {
147
+ return ele;
148
+ },
149
+ content: /*#__PURE__*/React.createElement(Table, {
150
+ pagination: {
151
+ pageSize: dataSource.length,
152
+ hideOnSinglePage: true
153
+ },
154
+ dataSource: dataSource,
155
+ columns: columns
156
+ }),
157
+ destroyTooltipOnHide: true
158
+ }, /*#__PURE__*/React.createElement(Tag, {
159
+ icon: /*#__PURE__*/React.createElement(SparkTokenLine, {
160
+ size: 16
161
+ }),
162
+ className: "spark-flow-task-status-tag",
163
+ color: "mauve",
164
+ bordered: true
165
+ }, $i18n.get({
166
+ id: 'spark-flow.components.TaskStatus.index.tokenDetails',
167
+ dm: 'Token 详情'
168
+ }))), /*#__PURE__*/React.createElement(Popover, {
169
+ content: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
170
+ className: "font-medium"
171
+ }, "Request ID"), /*#__PURE__*/React.createElement("div", {
172
+ className: "flex gap-[4px] items-center"
173
+ }, taskStore.request_id, /*#__PURE__*/React.createElement(SparkCopyLine, {
174
+ className: "cursor-pointer",
175
+ onClick: copyRequestId,
176
+ size: 16
177
+ })))
178
+ }, /*#__PURE__*/React.createElement(Tag, {
179
+ icon: /*#__PURE__*/React.createElement(SparkCode01Line, {
180
+ size: 16
181
+ }),
182
+ className: "spark-flow-task-status-tag",
183
+ color: "mauve",
184
+ bordered: true
185
+ }, "Request ID")))), /*#__PURE__*/React.createElement(Button, {
186
+ onClick: function onClick() {
187
+ return setShowResults(!showResults);
188
+ },
189
+ className: "spark-flow-task-status-button",
190
+ type: "text",
191
+ icon: /*#__PURE__*/React.createElement(SparkHideLine, {
192
+ size: 16
193
+ })
194
+ }, showResults ? $i18n.get({
195
+ id: 'spark-flow.components.TaskStatus.index.hideTestResult',
196
+ dm: '隐藏测试结果'
197
+ }) : $i18n.get({
198
+ id: 'spark-flow.components.TaskStatus.index.showTestResult',
199
+ dm: '显示测试结果'
200
+ }))));
201
+ }
202
+ var TaskStatusWrap = function TaskStatusWrap() {
203
+ var taskStore = useStore(function (state) {
204
+ return state.taskStore;
205
+ });
206
+ if (!taskStore) return null;
207
+ return /*#__PURE__*/React.createElement(TaskStatus, null);
208
+ };
209
+ export default /*#__PURE__*/memo(TaskStatusWrap);
@@ -0,0 +1,65 @@
1
+ @import '../../index.less';
2
+
3
+ .spark-flow-task-status {
4
+ border-bottom: 1px solid e('var(--@{ant-prefix}-color-border-secondary)');
5
+ height: 40px;
6
+ padding: 0 24px;
7
+ font-weight: 500;
8
+ background: e('var(--@{ant-prefix}-color-info-bg)');
9
+
10
+ &-fail {
11
+ background: e('var(--@{ant-prefix}-color-error-bg)');
12
+ color: e('var(--@{ant-prefix}-color-error)');
13
+ }
14
+
15
+ &-success {
16
+ background: e('var(--@{ant-prefix}-color-success-bg)');
17
+ color: e('var(--@{ant-prefix}-color-success)');
18
+ }
19
+
20
+ &-tag {
21
+ color: e('var(--@{ant-prefix}-color-text-secondary)') !important;
22
+ background: e('var(--@{ant-prefix}-color-bg-base)') !important;
23
+ display: inline-flex !important;
24
+ align-items: center;
25
+ gap: 2px;
26
+ > span {
27
+ margin-inline-start: 0 !important;
28
+ }
29
+ }
30
+
31
+ &.spark-flow-task-status-hidden-results {
32
+ display: none;
33
+ }
34
+ }
35
+
36
+ .spark-flow-task-status-button {
37
+ padding: 0 !important;
38
+ color: e('var(--@{ant-prefix}-color-text-secondary)');
39
+ font-weight: normal;
40
+ }
41
+
42
+ .spark-flow-task-token-popover {
43
+ .@{ant-prefix}-popover-content .@{ant-prefix}-popover-inner {
44
+ padding: 0;
45
+ max-width: initial;
46
+ }
47
+
48
+ .@{ant-prefix}-table {
49
+ border-radius: e("var(--@{ant-prefix}-table-header-border-radius)");
50
+ }
51
+
52
+ .@{ant-prefix}-table-wrapper .@{ant-prefix}-table-container table > thead > tr:first-child {
53
+ > *:first-child {
54
+ border-start-start-radius: e("var(--@{ant-prefix}-table-header-border-radius)");
55
+ }
56
+
57
+ > *:last-child {
58
+ border-start-end-radius: e("var(--@{ant-prefix}-table-header-border-radius)");
59
+ }
60
+ }
61
+
62
+ .@{ant-prefix}-table-wrapper .@{ant-prefix}-table-tbody >tr >td {
63
+ border: none;
64
+ }
65
+ }
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { IVarTreeItem } from '../variable-tree-select';
3
+ import './index.less';
4
+ export interface IVariableInputReferProps {
5
+ setEditorValue: (value: string) => void;
6
+ }
7
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<{
8
+ variableList: IVarTreeItem[];
9
+ value?: string | undefined;
10
+ maxLength?: number | undefined;
11
+ onChange?: ((value?: string) => void) | undefined;
12
+ disabled?: boolean | undefined;
13
+ placeholder?: string | undefined;
14
+ className?: string | undefined;
15
+ style?: React.CSSProperties | undefined;
16
+ } & React.RefAttributes<IVariableInputReferProps>>>;
17
+ export default _default;