vue-agent-start 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/package.json +30 -0
  2. package/pnpm-workspace.yaml +3 -0
  3. package/src/agent-flow/adapter/backend.ts +99 -0
  4. package/src/agent-flow/components/ChatIframePanel.vue +773 -0
  5. package/src/agent-flow/components/DatasetItemCard.vue +313 -0
  6. package/src/agent-flow/components/MemoryWindow.vue +104 -0
  7. package/src/agent-flow/components/PromptEditor.vue +804 -0
  8. package/src/agent-flow/components/PromptEditorTagPanel.vue +460 -0
  9. package/src/agent-flow/components/SvgIcon.vue +32 -0
  10. package/src/agent-flow/components/ToolItemCard.vue +169 -0
  11. package/src/agent-flow/components/VariableCard.vue +161 -0
  12. package/src/agent-flow/components/VariableSelector.vue +162 -0
  13. package/src/agent-flow/components/chat-iframe-types.ts +35 -0
  14. package/src/agent-flow/components/stubs/DatasetChooser.vue +70 -0
  15. package/src/agent-flow/components/stubs/Embedding.vue +22 -0
  16. package/src/agent-flow/components/stubs/ModelSelect.vue +24 -0
  17. package/src/agent-flow/components/stubs/RestfulSelectCard.vue +24 -0
  18. package/src/agent-flow/components/stubs/ToolChooser.vue +96 -0
  19. package/src/agent-flow/components/stubs/TriggersItemCard.vue +126 -0
  20. package/src/agent-flow/components/stubs/VariableModal.vue +115 -0
  21. package/src/agent-flow/index.ts +73 -0
  22. package/src/agent-flow/stores/workflow.ts +72 -0
  23. package/src/agent-flow/utils/langUtils.ts +173 -0
  24. package/src/agent-flow/workflow/Ability.vue +65 -0
  25. package/src/agent-flow/workflow/AuthorizationItem.vue +101 -0
  26. package/src/agent-flow/workflow/ConversationVar.vue +42 -0
  27. package/src/agent-flow/workflow/CustomEdge.vue +94 -0
  28. package/src/agent-flow/workflow/EnvironmentVar.vue +40 -0
  29. package/src/agent-flow/workflow/FlowDesigner.vue +2802 -0
  30. package/src/agent-flow/workflow/Icon.vue +179 -0
  31. package/src/agent-flow/workflow/NodeConfig.vue +509 -0
  32. package/src/agent-flow/workflow/NodeConfigCard.vue +460 -0
  33. package/src/agent-flow/workflow/NodeHandle.vue +147 -0
  34. package/src/agent-flow/workflow/NodeHeaderToolbar.vue +77 -0
  35. package/src/agent-flow/workflow/NodeHoverToolbar.vue +176 -0
  36. package/src/agent-flow/workflow/OutputItemCard.vue +668 -0
  37. package/src/agent-flow/workflow/ParamTableItem.vue +200 -0
  38. package/src/agent-flow/workflow/StructTable.vue +202 -0
  39. package/src/agent-flow/workflow/VarInsertField.vue +517 -0
  40. package/src/agent-flow/workflow/VarSelectField.vue +223 -0
  41. package/src/agent-flow/workflow/VariableSelectorItem.vue +48 -0
  42. package/src/agent-flow/workflow/WfField.vue +206 -0
  43. package/src/agent-flow/workflow/_config-base.css +470 -0
  44. package/src/agent-flow/workflow/composables/useNode.js +55 -0
  45. package/src/agent-flow/workflow/index.vue +53 -0
  46. package/src/agent-flow/workflow/nodeCard/AgentNodeCard.vue +180 -0
  47. package/src/agent-flow/workflow/nodeCard/AnswerNodeCard.vue +65 -0
  48. package/src/agent-flow/workflow/nodeCard/ClassifierCard.vue +152 -0
  49. package/src/agent-flow/workflow/nodeCard/CodeNodeCard.vue +139 -0
  50. package/src/agent-flow/workflow/nodeCard/ConditionNodeCard.vue +323 -0
  51. package/src/agent-flow/workflow/nodeCard/DocumentExtractorCard.vue +83 -0
  52. package/src/agent-flow/workflow/nodeCard/EndNodeCard.vue +123 -0
  53. package/src/agent-flow/workflow/nodeCard/HttpNodeCard.vue +451 -0
  54. package/src/agent-flow/workflow/nodeCard/HumanInputCard.vue +152 -0
  55. package/src/agent-flow/workflow/nodeCard/IterationCard.vue +66 -0
  56. package/src/agent-flow/workflow/nodeCard/KnowledgeRetrievalCard.vue +48 -0
  57. package/src/agent-flow/workflow/nodeCard/LLMNodeCard.vue +206 -0
  58. package/src/agent-flow/workflow/nodeCard/ListOperatorCard.vue +188 -0
  59. package/src/agent-flow/workflow/nodeCard/ParameterExtractorCard.vue +352 -0
  60. package/src/agent-flow/workflow/nodeCard/ServiceApiNodeCard.vue +188 -0
  61. package/src/agent-flow/workflow/nodeCard/StartNodeCard.vue +216 -0
  62. package/src/agent-flow/workflow/nodeCard/VariableAssignerCard.vue +125 -0
  63. package/src/agent-flow/workflow/nodeCard/VariableNodeCard.vue +121 -0
  64. package/src/agent-flow/workflow/nodes/AgentNode.vue +122 -0
  65. package/src/agent-flow/workflow/nodes/AnswerNode.vue +99 -0
  66. package/src/agent-flow/workflow/nodes/ClassifierNode.vue +199 -0
  67. package/src/agent-flow/workflow/nodes/CodeNode.vue +152 -0
  68. package/src/agent-flow/workflow/nodes/ConditionNode.vue +232 -0
  69. package/src/agent-flow/workflow/nodes/DocumentExtractorNode.vue +96 -0
  70. package/src/agent-flow/workflow/nodes/EndNode.vue +119 -0
  71. package/src/agent-flow/workflow/nodes/FileUploadNode.vue +97 -0
  72. package/src/agent-flow/workflow/nodes/HttpNode.vue +204 -0
  73. package/src/agent-flow/workflow/nodes/HumanInputNode.vue +110 -0
  74. package/src/agent-flow/workflow/nodes/IterationNode.vue +98 -0
  75. package/src/agent-flow/workflow/nodes/KnowledgeRetrievalNode.vue +253 -0
  76. package/src/agent-flow/workflow/nodes/LLMNode.vue +134 -0
  77. package/src/agent-flow/workflow/nodes/ListOperatorNode.vue +111 -0
  78. package/src/agent-flow/workflow/nodes/LoopNode.vue +94 -0
  79. package/src/agent-flow/workflow/nodes/ParameterExtractorNode.vue +147 -0
  80. package/src/agent-flow/workflow/nodes/ServiceApiNode.vue +161 -0
  81. package/src/agent-flow/workflow/nodes/StartNode.vue +199 -0
  82. package/src/agent-flow/workflow/nodes/TemplateNode.vue +103 -0
  83. package/src/agent-flow/workflow/nodes/UserInputNode.vue +92 -0
  84. package/src/agent-flow/workflow/nodes/VariableAssignerNode.vue +145 -0
  85. package/src/agent-flow/workflow/nodes/VariableNode.vue +130 -0
  86. package/src/agent-flow/workflow/nodes/_node-base.css +338 -0
  87. package/src/agent-flow/workflow/utils/node_card_form.ts +335 -0
  88. package/src/agent-flow/workflow/utils/node_config.ts +63 -0
  89. package/src/agent-flow/workflow/utils/workflow_utils.ts +151 -0
  90. package/src/agent-studio/adapters/springAgentStart.ts +390 -0
  91. package/src/agent-studio/api/index.ts +1 -0
  92. package/src/agent-studio/api/types.ts +173 -0
  93. package/src/agent-studio/components/AgentApiDocs.vue +500 -0
  94. package/src/agent-studio/components/AgentAppsPage.vue +1601 -0
  95. package/src/agent-studio/components/AgentCardGrid.vue +259 -0
  96. package/src/agent-studio/components/AgentChatPage.vue +553 -0
  97. package/src/agent-studio/components/AgentDebugPanel.vue +350 -0
  98. package/src/agent-studio/components/AgentLogsPanel.vue +391 -0
  99. package/src/agent-studio/components/AgentMonitorPanel.vue +204 -0
  100. package/src/agent-studio/components/AgentOrchestrate.vue +505 -0
  101. package/src/agent-studio/components/AgentPromptEditor.vue +237 -0
  102. package/src/agent-studio/components/AgentStudioShell.vue +227 -0
  103. package/src/agent-studio/components/AgentToolsPanel.vue +394 -0
  104. package/src/agent-studio/components/AgentVariablesPanel.vue +205 -0
  105. package/src/agent-studio/components/ApiKeyManager.vue +251 -0
  106. package/src/agent-studio/components/AppDesignDrawer.vue +3391 -0
  107. package/src/agent-studio/components/CreateAppModal.vue +737 -0
  108. package/src/agent-studio/components/SparkChart.vue +200 -0
  109. package/src/agent-studio/components/VariableEditorModal.vue +499 -0
  110. package/src/agent-studio/composables/useAgentStudio.ts +347 -0
  111. package/src/agent-studio/index.ts +60 -0
  112. package/src/agent-studio/panels/DrawerFlowDesigner.vue +203 -0
  113. package/src/agent-studio/panels/LogAnnotationPanel.vue +490 -0
  114. package/src/agent-studio/panels/MonitorPanel.vue +535 -0
  115. package/src/agent-studio/types.ts +242 -0
  116. package/src/index.ts +155 -0
  117. package/src/knowledge-hub/adapters/springAgentStart.ts +472 -0
  118. package/src/knowledge-hub/components/AddDocumentsWizard.vue +1452 -0
  119. package/src/knowledge-hub/components/CreateDatasetWizard.vue +1723 -0
  120. package/src/knowledge-hub/components/DatasetCardGrid.vue +467 -0
  121. package/src/knowledge-hub/components/DatasetDetailDrawer.vue +888 -0
  122. package/src/knowledge-hub/components/DatasetPicker.vue +65 -0
  123. package/src/knowledge-hub/components/DatasetPickerModal.vue +526 -0
  124. package/src/knowledge-hub/components/DatasetSettingsPanel.vue +908 -0
  125. package/src/knowledge-hub/components/DatasetSidebar.vue +781 -0
  126. package/src/knowledge-hub/components/DocumentChunksView.vue +802 -0
  127. package/src/knowledge-hub/components/DocumentTable.vue +552 -0
  128. package/src/knowledge-hub/components/HitTestingPanel.vue +74 -0
  129. package/src/knowledge-hub/components/KnowledgeApp.vue +66 -0
  130. package/src/knowledge-hub/components/KnowledgeHubApp.vue +504 -0
  131. package/src/knowledge-hub/components/RecallTestingPanelV2.vue +515 -0
  132. package/src/knowledge-hub/components/RetrievalConfigPopover.vue +270 -0
  133. package/src/knowledge-hub/components/RetrievalMethodPicker.vue +547 -0
  134. package/src/knowledge-hub/components/RetrievedList.vue +24 -0
  135. package/src/knowledge-hub/components/internal/KhDialog.vue +195 -0
  136. package/src/knowledge-hub/composables/useKnowledge.ts +89 -0
  137. package/src/knowledge-hub/i18n/index.ts +2 -0
  138. package/src/knowledge-hub/i18n/messages.ts +422 -0
  139. package/src/knowledge-hub/i18n/useKhI18n.ts +107 -0
  140. package/src/knowledge-hub/index.ts +46 -0
  141. package/src/knowledge-hub/styles/index.css +4 -0
  142. package/src/knowledge-hub/styles/tokens.css +138 -0
  143. package/src/knowledge-hub/types/api.ts +213 -0
  144. package/src/knowledge-hub/types/dataset.ts +88 -0
  145. package/src/knowledge-hub/types/document.ts +45 -0
  146. package/src/knowledge-hub/types/index.ts +9 -0
  147. package/src/knowledge-hub/types/retrieval.ts +46 -0
  148. package/src/provider-hub/components/CredentialForm.vue +103 -0
  149. package/src/provider-hub/components/DefaultModelsPanel.vue +270 -0
  150. package/src/provider-hub/components/GroupedModelSelect.vue +445 -0
  151. package/src/provider-hub/components/ModelCardGrid.vue +332 -0
  152. package/src/provider-hub/components/ModelParameterDrawer.vue +739 -0
  153. package/src/provider-hub/components/ModelPickerPopover.vue +1282 -0
  154. package/src/provider-hub/components/ProviderApp.vue +159 -0
  155. package/src/provider-hub/components/ProviderCredentialModal.vue +321 -0
  156. package/src/provider-hub/components/ProviderGallery.vue +131 -0
  157. package/src/provider-hub/components/ProviderHubShell.vue +1992 -0
  158. package/src/provider-hub/components/ProviderIcon.vue +130 -0
  159. package/src/provider-hub/composables/useProviderHub.ts +358 -0
  160. package/src/provider-hub/index.ts +43 -0
  161. package/src/provider-hub/svg/MiniMax.svg +1 -0
  162. package/src/provider-hub/svg/Volcengine.svg +1 -0
  163. package/src/provider-hub/svg/Zhipu.svg +1 -0
  164. package/src/provider-hub/svg/deepseek.svg +1 -0
  165. package/src/provider-hub/svg/moonshot.svg +1 -0
  166. package/src/provider-hub/svg/openai.svg +1 -0
  167. package/src/provider-hub/svg/qwen.svg +1 -0
  168. package/src/provider-hub/svg/siliconflow.svg +1 -0
  169. package/src/provider-hub/types.ts +256 -0
@@ -0,0 +1,335 @@
1
+ /**
2
+ * Per-node default `data` shape, keyed by the SAME identifier the FlowDesigner
3
+ * registers its `#node-XXX` slot under and stores on `node.type`. Aligned with
4
+ * the backend `NodeType` enum (UPPER_SNAKE) so a saved graph round-trips
5
+ * cleanly — no adapter translation needed between the designer and the engine.
6
+ *
7
+ * Designer-only entries with no backend {@code NodeType} equivalent
8
+ * ({@code USER_INPUT}, {@code FILE_UPLOAD}, {@code HUMAN_INPUT}, {@code LOOP})
9
+ * still use the UPPER_SNAKE convention for consistency; the backend's
10
+ * {@code NodeType.fromJson} maps them onto the closest engine node at run
11
+ * time (USER_INPUT/FILE_UPLOAD/HUMAN_INPUT → START, LOOP → ITERATION).
12
+ */
13
+ const nodeCardForm: any = {
14
+ START: {
15
+ variables: [],
16
+ sysVariables: [
17
+ { name: 'query', type: 'String', required: true },
18
+ { name: 'files', type: 'Array[File]' },
19
+ { name: 'dialogue_count', type: 'Number' },
20
+ { name: 'conversation_id', type: 'String' },
21
+ { name: 'user_id', type: 'String' },
22
+ { name: 'app_id', type: 'String' },
23
+ { name: 'workflow_id', type: 'String' },
24
+ { name: 'workflow_run_id', type: 'String' },
25
+ ],
26
+ triggers: {},
27
+ triggersEnabled: false,
28
+ structOutput: {
29
+ schema: {},
30
+ data: [
31
+ {
32
+ id: '0',
33
+ type: 'object',
34
+ name: 'triggers',
35
+ value: '',
36
+ description: '触发器输出',
37
+ hidden: true,
38
+ children: [],
39
+ },
40
+ ],
41
+ },
42
+ output: [{ type: 'string', name: 'query', value: '', label: '用户查询' }],
43
+ },
44
+ ANSWER: {
45
+ answer: '',
46
+ },
47
+ AGENT: {
48
+ modelId: '',
49
+ context: '',
50
+ system: '',
51
+ selectOptions: [],
52
+ required: false,
53
+ memory: {
54
+ window: {
55
+ enabled: true,
56
+ size: 10,
57
+ user: '0',
58
+ assistant: '0',
59
+ },
60
+ },
61
+ model: {
62
+ completionParams: {},
63
+ modelId: 'chat',
64
+ },
65
+ systemPrompt: {
66
+ id: 'prompt_template',
67
+ role: 'system',
68
+ text: '',
69
+ },
70
+ userPrompt: {
71
+ id: 'user_prompt_template',
72
+ role: 'user',
73
+ text: '用户查询:{{#var.query#}}',
74
+ },
75
+ tools: [],
76
+ agentParameters: {},
77
+ output: [
78
+ { type: 'string', name: 'text', value: '', label: '生成内容' },
79
+ { type: 'file', name: 'file', value: null, label: '生成文件' },
80
+ { type: 'object', name: 'json', value: {}, label: '生成Json' },
81
+ ],
82
+ },
83
+ LLM: {
84
+ temperature: 0.7,
85
+ max_tokens: 1000,
86
+ prompt: '',
87
+ model: {
88
+ completionParams: {},
89
+ modeId: '',
90
+ mode: 'chat',
91
+ },
92
+ systemPrompt: {
93
+ id: 'prompt_template',
94
+ role: 'system',
95
+ text: '',
96
+ },
97
+ userPrompt: {
98
+ id: 'user_prompt_template',
99
+ role: 'user',
100
+ text: '用户查询:{{#var.query#}}',
101
+ },
102
+ memory: {
103
+ query_prompt_template: '{{#sys.query#}}',
104
+ role_prefix: {
105
+ assistant: '',
106
+ user: '',
107
+ },
108
+ window: {
109
+ enabled: true,
110
+ size: 10,
111
+ user: '0',
112
+ assistant: '0',
113
+ },
114
+ },
115
+ structOutputEnabled: false,
116
+ structOutput: {
117
+ schema: {},
118
+ data: [
119
+ {
120
+ id: '0',
121
+ type: 'object',
122
+ name: 'struct',
123
+ value: '',
124
+ description: '结构化内容',
125
+ hidden: true,
126
+ children: [],
127
+ },
128
+ ],
129
+ },
130
+ output: [{ type: 'string', name: 'text', value: '', label: '生成内容' }],
131
+ },
132
+ QUESTION_CLASSIFIER: {
133
+ categories: ['正面', '负面', '中性'],
134
+ model: {
135
+ completionParams: {},
136
+ modeId: '',
137
+ mode: 'chat',
138
+ },
139
+ classes: [
140
+ {
141
+ id: 1,
142
+ name: '',
143
+ },
144
+ ],
145
+ },
146
+ IF_ELSE: {
147
+ cases: [],
148
+ output: {},
149
+ },
150
+
151
+ CODE: {
152
+ modelId: '',
153
+ context: '',
154
+ system: '',
155
+ variables: [],
156
+ selectOptions: [],
157
+ required: false,
158
+ memory: { windows: 1 },
159
+ code_language: 'python',
160
+ code: '\ndef main(arg1: str, arg2: str) -> dict:\n return {\n "result": arg1 + arg2,\n }\n',
161
+ },
162
+ KNOWLEDGE_RETRIEVAL: {
163
+ label: '知识检索',
164
+ description: '知识库检索节点',
165
+ queryVariableSelector: [],
166
+ required: false,
167
+ memory: { windows: 1 },
168
+ metadataFilter: 'disabled',
169
+ metadataConditions: [{ name: '', value: '', operator: 'IS' }],
170
+ dataset: {
171
+ useAnnotation: false,
172
+ dynamic: false,
173
+ dynamicVariableSelector: [],
174
+ datasets: [],
175
+ },
176
+ output: [
177
+ {
178
+ type: 'Array[Object]',
179
+ name: 'result[]',
180
+ value: '',
181
+ label: '召回分段',
182
+ children: [
183
+ {
184
+ type: 'string',
185
+ name: 'text',
186
+ value: '',
187
+ label: '分段内容',
188
+ },
189
+ {
190
+ type: 'object',
191
+ name: 'metadata',
192
+ value: '',
193
+ label: '元数据',
194
+ },
195
+ ],
196
+ },
197
+ ],
198
+ },
199
+ USER_INPUT: {
200
+ variable: '',
201
+ required: true,
202
+ },
203
+ FILE_UPLOAD: {
204
+ allowedTypes: ['pdf', 'txt', 'doc'],
205
+ maxSize: 10,
206
+ },
207
+ LOOP: {
208
+ maxIterations: 10,
209
+ condition: '',
210
+ },
211
+ VARIABLE_AGGREGATOR: {
212
+ variables: [],
213
+ operation: 'combine',
214
+ output: [
215
+ {
216
+ type: 'Object',
217
+ name: 'result',
218
+ value: '',
219
+ label: '聚合变量',
220
+ children: [],
221
+ },
222
+ ],
223
+ },
224
+ HTTP_REQUEST: {
225
+ method: 'GET',
226
+ url: '',
227
+ timeoutSeconds: 30,
228
+ maxRetries: 0,
229
+ authorization: {
230
+ auth_type: 'none',
231
+ api_key_header: 'Authorization',
232
+ api_key_header_prefix: 'bearer',
233
+ api_key_value: '',
234
+ },
235
+ headers: [{ name: '', value: '' }],
236
+ parameters: [{ name: '', value: '' }],
237
+ bodyType: 'NONE',
238
+ body: {
239
+ NONE: null,
240
+ BINARY: '',
241
+ FORM_DATA: [{ name: '', value: '', type: 'TEXT' }],
242
+ X_WWW_FORM_URLENCODED: [{ name: '', value: '' }],
243
+ JSON: '',
244
+ RAW: '',
245
+ },
246
+ output: [
247
+ { type: 'number', name: 'status', value: 0, label: '响应状态码' },
248
+ { type: 'string', name: 'body', value: '', label: '响应体' },
249
+ { type: 'object', name: 'headers', value: {}, label: '响应头' },
250
+ ],
251
+ },
252
+ SERVICE_API: {
253
+ method: 'GET',
254
+ url: '',
255
+ timeoutSeconds: 30,
256
+ headers: [{ name: '', value: '' }],
257
+ parameters: [{ name: '', value: '' }],
258
+ output: [
259
+ { type: 'number', name: 'status', value: 0, label: '响应状态码' },
260
+ { type: 'string', name: 'body', value: '', label: '响应体' },
261
+ ],
262
+ },
263
+ TEMPLATE_TRANSFORM: {
264
+ template: '',
265
+ variables: [],
266
+ },
267
+ END: {
268
+ output: [],
269
+ },
270
+ ITERATION: {
271
+ iteratorVariableSelector: [],
272
+ outputVariableSelector: [],
273
+ childrenNodes: [],
274
+ parallelSize: 1,
275
+ errorMode: 'terminate',
276
+ output: [
277
+ { type: 'array', name: 'result', value: [], label: '迭代结果' },
278
+ ],
279
+ },
280
+ PARAMETER_EXTRACTOR: {
281
+ parameters: [
282
+ { name: 'param1', type: 'string', description: '', required: false },
283
+ ],
284
+ model: { modelId: '', modelName: '', mode: 'chat', completionParams: {} },
285
+ reasoning_mode: 'function_call',
286
+ inputVariableSelector: [],
287
+ systemPrompt: {
288
+ id: 'prompt_template',
289
+ role: 'system',
290
+ text: '',
291
+ },
292
+ output: [
293
+ { type: 'object', name: 'result', value: {}, label: '抽取结果' },
294
+ ],
295
+ },
296
+ LIST_OPERATOR: {
297
+ inputVariableSelector: [],
298
+ operation: 'filter',
299
+ filterConditions: [],
300
+ mapExpression: '',
301
+ offset: 0,
302
+ limit: 100,
303
+ sortField: '',
304
+ sortOrder: 'asc',
305
+ output: [
306
+ { type: 'array', name: 'result', value: [], label: '结果列表' },
307
+ ],
308
+ },
309
+ DOCUMENT_EXTRACTOR: {
310
+ variableSelector: [],
311
+ extractMode: 'text',
312
+ splitMode: 'none',
313
+ chunkSize: 1000,
314
+ output: [
315
+ { type: 'string', name: 'text', value: '', label: '提取文本' },
316
+ ],
317
+ },
318
+ HUMAN_INPUT: {
319
+ approvalType: 'approve',
320
+ prompt: '请审批以下内容',
321
+ formFields: [],
322
+ timeout: 3600,
323
+ output: [
324
+ { type: 'string', name: 'response', value: '', label: '人工响应' },
325
+ { type: 'boolean', name: 'approved', value: false, label: '是否批准' },
326
+ ],
327
+ },
328
+ VARIABLE_ASSIGNER: {
329
+ assignments: [
330
+ { target: '', source: [], writeMode: 'overwrite' },
331
+ ],
332
+ output: [],
333
+ },
334
+ };
335
+ export default nodeCardForm;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * 节点元数据目录 —— 内置节点的清单
3
+ *
4
+ * 对外通过默认导出。宿主项目可以:
5
+ * - 直接读取本清单渲染扩展面板
6
+ * - 通过 `.concat(...)` 追加自己的节点条目
7
+ *
8
+ * {@link NodeCatalogItem.type} 与 backend `spring-agent-workflow` 的
9
+ * {@code NodeType} 枚举一致(UPPER_SNAKE),也是 FlowDesigner 里
10
+ * `<template #node-{type}>` 注册的 slot 名 —— 单一标识贯穿画布、持久化、
11
+ * 引擎执行三层。设计器独有的类型(USER_INPUT / FILE_UPLOAD / HUMAN_INPUT /
12
+ * LOOP)没有严格对应的 backend NodeType,backend 的
13
+ * {@code NodeType.fromJson} 会把它们映射到最接近的引擎节点(前三者 → START,
14
+ * LOOP → ITERATION),使得设计器保存的图仍能跑起来。
15
+ */
16
+
17
+ export interface NodeCatalogItem {
18
+ /**
19
+ * 唯一标识 —— 同时是 VueFlow slot 名和 backend `NodeType` 枚举名,
20
+ * 保证画布 / 存储 / 引擎三处对齐。
21
+ */
22
+ type: string;
23
+ name: string;
24
+ icon: string;
25
+ category: '输入' | 'AI 模型' | '逻辑' | '工具' | '输出' | '其他';
26
+ description?: string;
27
+ }
28
+
29
+ const nodeItems: NodeCatalogItem[] = [
30
+ // 输入
31
+ { type: 'START', name: '开始', icon: 'start', category: '输入' },
32
+ { type: 'USER_INPUT', name: '用户输入', icon: 'user', category: '输入' },
33
+ { type: 'FILE_UPLOAD', name: '文件上传', icon: 'file', category: '输入' },
34
+
35
+ // AI 模型
36
+ { type: 'LLM', name: 'LLM', icon: 'llm', category: 'AI 模型' },
37
+ { type: 'AGENT', name: 'Agent', icon: 'agent', category: 'AI 模型' },
38
+ { type: 'KNOWLEDGE_RETRIEVAL', name: '知识检索', icon: 'knowledge', category: 'AI 模型' },
39
+ { type: 'QUESTION_CLASSIFIER', name: '问题分类', icon: 'classifier', category: 'AI 模型' },
40
+
41
+ // 逻辑
42
+ { type: 'IF_ELSE', name: '条件分支', icon: 'condition', category: '逻辑' },
43
+ { type: 'LOOP', name: '循环', icon: 'loop', category: '逻辑' },
44
+ { type: 'ITERATION', name: '迭代', icon: 'loop', category: '逻辑' },
45
+ { type: 'LIST_OPERATOR', name: '列表操作', icon: 'variable', category: '逻辑' },
46
+ { type: 'VARIABLE_AGGREGATOR', name: '变量聚合', icon: 'variable', category: '逻辑' },
47
+ { type: 'VARIABLE_ASSIGNER', name: '变量赋值', icon: 'variable', category: '逻辑' },
48
+ { type: 'PARAMETER_EXTRACTOR', name: '参数提取', icon: 'variable', category: '逻辑' },
49
+ { type: 'HUMAN_INPUT', name: '人工介入', icon: 'user', category: '逻辑' },
50
+
51
+ // 工具
52
+ { type: 'HTTP_REQUEST', name: 'HTTP 请求', icon: 'http', category: '工具' },
53
+ { type: 'SERVICE_API', name: '服务接口', icon: 'service', category: '工具' },
54
+ { type: 'CODE', name: '代码执行', icon: 'code', category: '工具' },
55
+ { type: 'TEMPLATE_TRANSFORM', name: '模板转换', icon: 'template', category: '工具' },
56
+ { type: 'DOCUMENT_EXTRACTOR', name: '文档提取', icon: 'file', category: '工具' },
57
+
58
+ // 输出
59
+ { type: 'ANSWER', name: '直接回复', icon: 'answer', category: '输出' },
60
+ { type: 'END', name: '结束', icon: 'end', category: '输出' },
61
+ ];
62
+
63
+ export default nodeItems;
@@ -0,0 +1,151 @@
1
+ import { useWorkflowStore } from '@/stores/workflow';
2
+ import langUtils from '@/utils/langUtils';
3
+ import nodeCardForm from '@/workflow/utils/node_card_form';
4
+
5
+ const workflowStore = useWorkflowStore();
6
+ export default {
7
+ conditionOperators: [
8
+ { value: 'CONTAINS', label: '包含' },
9
+ { value: 'NOT_CONTAINS', label: '不包含' },
10
+ { value: 'STARTS_WITH', label: '开始是' },
11
+ { value: 'ENDS_WITH', label: '结束是' },
12
+ { value: 'IS', label: '是' },
13
+ { value: 'IS_NOT', label: '不是' },
14
+ { value: 'IS_EMPTY', label: '为空' },
15
+ { value: 'IS_NOT_EMPTY', label: '不为空' },
16
+ ],
17
+ agentStrategy: [
18
+ { value: 'AGENT_REACT', label: 'Agent React' },
19
+ { value: 'AGENT_FUNCTION_CALLING', label: 'Agent Function Calling' },
20
+ { value: 'MCP_FUNCTION_CALLING', label: 'Mcp Function Calling' },
21
+ ],
22
+ getOperator(value: string) {
23
+ for (const it of this.conditionOperators) {
24
+ if (it.value === value) {
25
+ return it.label;
26
+ }
27
+ }
28
+ },
29
+ initNodeDefaultData: (nodes: any) => {
30
+ function deepMerge(obj1: any, obj2: any) {
31
+ const result = { ...obj1 };
32
+
33
+ for (const key in obj2) {
34
+ if (Object.prototype.hasOwnProperty.call(obj2, key)) {
35
+ result[key] =
36
+ typeof obj2[key] === 'object' &&
37
+ obj2[key] !== null &&
38
+ !Array.isArray(obj2[key])
39
+ ? deepMerge(obj1[key] || {}, obj2[key])
40
+ : obj2[key];
41
+ }
42
+ }
43
+
44
+ return result;
45
+ }
46
+
47
+ if (nodes && nodes.length > 0) {
48
+ for (const node of nodes) {
49
+ const configFormData = nodeCardForm[node.type];
50
+ const nodeData = node.data;
51
+ const configData = langUtils.clone(configFormData);
52
+ nodeData.id = node.id;
53
+ // nodeData.structOutput = undefined;
54
+ nodeData.headers = undefined;
55
+ const newData = deepMerge(configData, nodeData);
56
+ Object.assign(node.data, newData);
57
+ }
58
+ }
59
+ },
60
+ getOutputItem(data: any, name: string) {
61
+ const outputList = this.getOutputList(data);
62
+ const findRecursively = (items: any[]): any => {
63
+ if (!items) {
64
+ return [];
65
+ }
66
+ for (const item of items) {
67
+ if (item.name === name) {
68
+ return item;
69
+ }
70
+ if (item.children && Array.isArray(item.children)) {
71
+ const found = findRecursively(item.children);
72
+ if (found) return found;
73
+ }
74
+ }
75
+ return undefined;
76
+ };
77
+
78
+ return findRecursively(outputList);
79
+ },
80
+ getOutputList: (data: any) => {
81
+ const outputList = [];
82
+ if (!data) {
83
+ return [];
84
+ }
85
+
86
+ if (data.structOutput && data.structOutputEnabled) {
87
+ outputList.push(...data.structOutput?.data);
88
+ } else if (data.output && Array.isArray(data.output)) {
89
+ outputList.push(...data.output);
90
+ }
91
+ if (data.triggersEnabled) {
92
+ outputList.push(...data.structOutput?.data);
93
+ }
94
+ if (data.id === '1') {
95
+ outputList.push(...data.variables);
96
+ }
97
+ return outputList;
98
+ },
99
+ getVariableLabel(variableSelector: any[]) {
100
+ if (!variableSelector || variableSelector.length === 0) {
101
+ return '';
102
+ }
103
+ const list = variableSelector;
104
+ const node = workflowStore.getNodeById(list[0]);
105
+ const labels = [];
106
+ if (node && node.data) {
107
+ labels.push(node.data.label);
108
+ }
109
+ for (let i = 1; i < list.length; i++) {
110
+ const v = list[i];
111
+ const item = this.getOutputItem(node.data, v);
112
+ if (item) {
113
+ labels.push(item.label || item.description);
114
+ }
115
+ }
116
+ return labels.join('.');
117
+ },
118
+ splitExpressions(input: string) {
119
+ const result: any[] = [];
120
+ if (!input) {
121
+ return result;
122
+ }
123
+
124
+ // 定义匹配 {{#...#}} 格式的正则表达式
125
+ const pattern = /\{\{#.*?#\}\}/g;
126
+ let lastEnd = 0;
127
+ let match;
128
+
129
+ while ((match = pattern.exec(input)) !== null) {
130
+ // 添加表达式左侧的文本
131
+ const left = input.substring(lastEnd, match.index);
132
+ if (left) {
133
+ result.push(left);
134
+ }
135
+
136
+ // 添加表达式本身
137
+ const expression = match[0];
138
+ result.push(expression);
139
+
140
+ lastEnd = pattern.lastIndex;
141
+ }
142
+
143
+ // 添加最后一个表达式右侧的剩余文本
144
+ const right = input.slice(Math.max(0, lastEnd));
145
+ if (right) {
146
+ result.push(right);
147
+ }
148
+
149
+ return result;
150
+ },
151
+ };