@yuku123/z-agent-frontend-component 0.1.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.
- package/README.md +66 -0
- package/dist/z-agent-frontend-component.css +1 -0
- package/dist/z-agent-frontend-component.es.js +9956 -0
- package/dist/z-agent-frontend-component.umd.js +219 -0
- package/package.json +77 -0
- package/src/api/apiRouter.js +78 -0
- package/src/api/index.js +23 -0
- package/src/api/request.js +59 -0
- package/src/api/routes.js +140 -0
- package/src/dev.jsx +80 -0
- package/src/index.js +86 -0
- package/src/pages/agent/app/index.jsx +2 -0
- package/src/pages/agent/editor/AgentAppEditor.jsx +456 -0
- package/src/pages/agent/editor/WorkflowEditor.jsx +495 -0
- package/src/pages/agent/editor/nodes/index.ts +225 -0
- package/src/pages/agent/index.jsx +1379 -0
- package/src/pages/agent/share.jsx +512 -0
- package/src/pages/ak/AkUsageDrawer.jsx +208 -0
- package/src/pages/ak/index.jsx +496 -0
- package/src/pages/llm/index.jsx +736 -0
- package/src/pages/llm/model/index.jsx +220 -0
- package/src/pages/llm/provider/index.jsx +173 -0
- package/src/pages/mcp/index.jsx +359 -0
- package/src/pages/oss/BucketList.jsx +320 -0
- package/src/pages/oss/ObjectBrowser.jsx +409 -0
- package/src/pages/product/execute.jsx +608 -0
- package/src/pages/product/index.jsx +628 -0
- package/src/pages/product/scene.jsx +746 -0
- package/src/pages/script/ApiBridgeEditor.jsx +255 -0
- package/src/pages/script/CurlImportModal.jsx +263 -0
- package/src/pages/script/FieldMappingEditor.jsx +131 -0
- package/src/pages/script/OpenApiImportModal.jsx +212 -0
- package/src/pages/script/index.jsx +532 -0
- package/src/pages/skill/index.jsx +1595 -0
- package/src/pages/trace/DebugPlayground.jsx +357 -0
- package/src/pages/trace/components/MetricsDashboard.jsx +164 -0
- package/src/pages/trace/components/RagFragments.jsx +134 -0
- package/src/pages/trace/components/Timeline.jsx +142 -0
- package/src/pages/trace/components/ToolCallTree.jsx +116 -0
- package/src/pages/trace/index.jsx +13 -0
- package/src/pages/usage/index.jsx +352 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import {CircleNode, CircleNodeModel, h, PolygonNode, PolygonNodeModel, RectNode, RectNodeModel,} from '@logicflow/core';
|
|
2
|
+
|
|
3
|
+
// ============ Node Definitions (match backend FlowNode TYPE_) ============
|
|
4
|
+
// TYPE: start | end | llm | condition | http | template | parallel | agent
|
|
5
|
+
|
|
6
|
+
// 开始节点 (CircleNode)
|
|
7
|
+
class StartNode extends CircleNode {
|
|
8
|
+
static extendKey = 'start';
|
|
9
|
+
|
|
10
|
+
getNodeStyle() {
|
|
11
|
+
const style = super.getNodeStyle();
|
|
12
|
+
style.fill = '#52c41a';
|
|
13
|
+
style.stroke = '#52c41a';
|
|
14
|
+
style.strokeWidth = 2;
|
|
15
|
+
return style;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getTextStyle() {
|
|
19
|
+
const style = super.getTextStyle();
|
|
20
|
+
style.color = '#fff';
|
|
21
|
+
style.fontSize = 14;
|
|
22
|
+
return style;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// LLM 节点 (矩形)
|
|
27
|
+
class LLMNode extends RectNode {
|
|
28
|
+
static extendKey = 'llm';
|
|
29
|
+
|
|
30
|
+
getNodeStyle() {
|
|
31
|
+
const style = super.getNodeStyle();
|
|
32
|
+
style.fill = '#e6f4ff';
|
|
33
|
+
style.stroke = '#1677ff';
|
|
34
|
+
style.strokeWidth = 2;
|
|
35
|
+
return style;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getTextStyle() {
|
|
39
|
+
const style = super.getTextStyle();
|
|
40
|
+
style.color = '#1677ff';
|
|
41
|
+
style.fontSize = 13;
|
|
42
|
+
return style;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Agent 节点 (矩形)
|
|
47
|
+
class AgentNode extends RectNode {
|
|
48
|
+
static extendKey = 'agent';
|
|
49
|
+
|
|
50
|
+
getNodeStyle() {
|
|
51
|
+
const style = super.getNodeStyle();
|
|
52
|
+
style.fill = '#f0f5ff';
|
|
53
|
+
style.stroke = '#2f54eb';
|
|
54
|
+
style.strokeWidth = 2;
|
|
55
|
+
return style;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getTextStyle() {
|
|
59
|
+
const style = super.getTextStyle();
|
|
60
|
+
style.color = '#2f54eb';
|
|
61
|
+
style.fontSize = 13;
|
|
62
|
+
return style;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 条件分支节点 (菱形)
|
|
67
|
+
class ConditionNode extends PolygonNode {
|
|
68
|
+
static extendKey = 'condition';
|
|
69
|
+
|
|
70
|
+
getNodeStyle() {
|
|
71
|
+
const style = super.getNodeStyle();
|
|
72
|
+
style.fill = '#fff7e6';
|
|
73
|
+
style.stroke = '#fa8c16';
|
|
74
|
+
style.strokeWidth = 2;
|
|
75
|
+
return style;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
getTextStyle() {
|
|
79
|
+
const style = super.getTextStyle();
|
|
80
|
+
style.color = '#d46b08';
|
|
81
|
+
style.fontSize = 12;
|
|
82
|
+
return style;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getAttributes() {
|
|
86
|
+
const attributes = super.getAttributes();
|
|
87
|
+
const width = 120;
|
|
88
|
+
const height = 80;
|
|
89
|
+
const points = [
|
|
90
|
+
[attributes.x, attributes.y - height / 2],
|
|
91
|
+
[attributes.x + width / 2, attributes.y],
|
|
92
|
+
[attributes.x, attributes.y + height / 2],
|
|
93
|
+
[attributes.x - width / 2, attributes.y],
|
|
94
|
+
];
|
|
95
|
+
return {...attributes, points, width, height};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// HTTP 节点 (矩形)
|
|
100
|
+
class HttpNode extends RectNode {
|
|
101
|
+
static extendKey = 'http';
|
|
102
|
+
|
|
103
|
+
getNodeStyle() {
|
|
104
|
+
const style = super.getNodeStyle();
|
|
105
|
+
style.fill = '#fff7e6';
|
|
106
|
+
style.stroke = '#fa8c16';
|
|
107
|
+
style.strokeWidth = 2;
|
|
108
|
+
return style;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getTextStyle() {
|
|
112
|
+
const style = super.getTextStyle();
|
|
113
|
+
style.color = '#d46b08';
|
|
114
|
+
style.fontSize = 13;
|
|
115
|
+
return style;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 模板/变量节点 (矩形)
|
|
120
|
+
class TemplateNode extends RectNode {
|
|
121
|
+
static extendKey = 'template';
|
|
122
|
+
|
|
123
|
+
getNodeStyle() {
|
|
124
|
+
const style = super.getNodeStyle();
|
|
125
|
+
style.fill = '#f6ffed';
|
|
126
|
+
style.stroke = '#13c2c2';
|
|
127
|
+
style.strokeWidth = 2;
|
|
128
|
+
return style;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
getTextStyle() {
|
|
132
|
+
const style = super.getTextStyle();
|
|
133
|
+
style.color = '#08979c';
|
|
134
|
+
style.fontSize = 13;
|
|
135
|
+
return style;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 并行节点 (六边形-ish rect)
|
|
140
|
+
class ParallelNode extends RectNode {
|
|
141
|
+
static extendKey = 'parallel';
|
|
142
|
+
|
|
143
|
+
getNodeStyle() {
|
|
144
|
+
const style = super.getNodeStyle();
|
|
145
|
+
style.fill = '#f9f0ff';
|
|
146
|
+
style.stroke = '#722ed1';
|
|
147
|
+
style.strokeWidth = 2;
|
|
148
|
+
return style;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
getTextStyle() {
|
|
152
|
+
const style = super.getTextStyle();
|
|
153
|
+
style.color = '#722ed1';
|
|
154
|
+
style.fontSize = 13;
|
|
155
|
+
return style;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
getShape() {
|
|
159
|
+
const {x, y, width, height} = this.getAttributes();
|
|
160
|
+
const w = width / 2;
|
|
161
|
+
const halfH = height / 2; // use halfH to avoid shadowing the imported `h` SVG helper
|
|
162
|
+
const offset = 12;
|
|
163
|
+
return h('polygon', {
|
|
164
|
+
points: [
|
|
165
|
+
[x - w + offset, y - halfH],
|
|
166
|
+
[x + w - offset, y - halfH],
|
|
167
|
+
[x + w, y],
|
|
168
|
+
[x + w - offset, y + halfH],
|
|
169
|
+
[x - w + offset, y + halfH],
|
|
170
|
+
[x - w, y],
|
|
171
|
+
],
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// 结束节点 (CircleNode)
|
|
177
|
+
class EndNode extends CircleNode {
|
|
178
|
+
static extendKey = 'end';
|
|
179
|
+
|
|
180
|
+
getNodeStyle() {
|
|
181
|
+
const style = super.getNodeStyle();
|
|
182
|
+
style.fill = '#ff4d4f';
|
|
183
|
+
style.stroke = '#ff4d4f';
|
|
184
|
+
style.strokeWidth = 2;
|
|
185
|
+
return style;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
getTextStyle() {
|
|
189
|
+
const style = super.getTextStyle();
|
|
190
|
+
style.color = '#fff';
|
|
191
|
+
style.fontSize = 14;
|
|
192
|
+
return style;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ============ Register All Nodes ============
|
|
197
|
+
// LogicFlow 2.x:View 与 Model 是两类,必须分别传入。
|
|
198
|
+
// 之前用 `CircleNode.model` 是错误的 —— 那是 View 类,并没有静态 model 属性,
|
|
199
|
+
// 导致 lf.render() 时报「找不到start对应的节点」。
|
|
200
|
+
export function registerAgentNodes(lf: any): void {
|
|
201
|
+
lf.register({type: 'start', view: StartNode, model: CircleNodeModel});
|
|
202
|
+
lf.register({type: 'llm', view: LLMNode, model: RectNodeModel});
|
|
203
|
+
lf.register({type: 'agent', view: AgentNode, model: RectNodeModel});
|
|
204
|
+
lf.register({type: 'condition', view: ConditionNode, model: PolygonNodeModel});
|
|
205
|
+
lf.register({type: 'http', view: HttpNode, model: RectNodeModel});
|
|
206
|
+
lf.register({type: 'template', view: TemplateNode, model: RectNodeModel});
|
|
207
|
+
lf.register({type: 'parallel', view: ParallelNode, model: RectNodeModel});
|
|
208
|
+
lf.register({type: 'end', view: EndNode, model: CircleNodeModel});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// ============ Node Palette (Draggable Types) ============
|
|
212
|
+
export const AGENT_FLOW_NODE_TYPES = [
|
|
213
|
+
{type: 'start', label: '开始', icon: 'https://cdn.jsdelivr.net/gh/LogicFlow/static@latest/docs/static/start.png'},
|
|
214
|
+
{type: 'llm', label: 'LLM 调用', icon: '🤖'},
|
|
215
|
+
{type: 'agent', label: 'Agent 节点', icon: '🤖'},
|
|
216
|
+
{
|
|
217
|
+
type: 'condition',
|
|
218
|
+
label: '条件分支',
|
|
219
|
+
icon: 'https://cdn.jsdelivr.net/gh/LogicFlow/static@latest/docs/static/condition.png'
|
|
220
|
+
},
|
|
221
|
+
{type: 'http', label: 'HTTP 请求', icon: '🔗'},
|
|
222
|
+
{type: 'template', label: '模板转换', icon: '📝'},
|
|
223
|
+
{type: 'parallel', label: '并行执行', icon: '⚡'},
|
|
224
|
+
{type: 'end', label: '结束', icon: 'https://cdn.jsdelivr.net/gh/LogicFlow/static@latest/docs/static/end.png'},
|
|
225
|
+
];
|